0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include <string.h>
0035 #include <stdio.h>
0036 #include <stdlib.h>
0037 #include <memory.h>
0038 #include <sys/param.h>
0039
0040 #include <ndrstandard.h>
0041 #include <ndebug.h>
0042 #include <nstdutil.h>
0043
0044 #include <ndrxdcmn.h>
0045 #include <atmi_int.h>
0046 #include <gencall.h>
0047 #include <utlist.h>
0048 #include <Exfields.h>
0049
0050 #include "xa_cmn.h"
0051 #include <ndrx.h>
0052 #include <qcommon.h>
0053 #include <nclopt.h>
0054
0055
0056
0057
0058
0059
0060 exprivate char M_qspace[XATMI_SERVICE_NAME_LENGTH+1] = "";
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 expublic int cmd_mqch(cmd_mapping_t *p_cmd_map, int argc, char **argv, int *p_have_next)
0071 {
0072 int ret = EXSUCCEED;
0073 char qconf[512];
0074 short srvid, nodeid;
0075 UBFH *p_ub = NULL;
0076 char cmd = TMQ_CMD_MQCH;
0077 char qspacesvc[XATMI_SERVICE_NAME_LENGTH+1];
0078 long rsplen;
0079
0080 ncloptmap_t clopt[] =
0081 {
0082 {'n', BFLD_SHORT, (char *)&nodeid, 0,
0083 NCLOPT_MAND|NCLOPT_HAVE_VALUE, "Cluster node id"},
0084 {'i', BFLD_SHORT, (char *)&srvid, 0,
0085 NCLOPT_MAND|NCLOPT_HAVE_VALUE, "Server ID"},
0086 {'q', BFLD_STRING, qconf, sizeof(qconf),
0087 NCLOPT_MAND|NCLOPT_HAVE_VALUE, "Queue config string"},
0088 {0}
0089 };
0090
0091
0092 if (nstd_parse_clopt(clopt, EXTRUE, argc, argv, EXFALSE))
0093 {
0094 fprintf(stderr, XADMIN_INVALID_OPTIONS_MSG);
0095 EXFAIL_OUT(ret);
0096 }
0097
0098
0099 if (EXSUCCEED!=tpinit(NULL))
0100 {
0101 fprintf(stderr, "Failed to tpinit(): %s", tpstrerror(tperrno));
0102 NDRX_LOG(log_error, "Failed to tpinit(): %s", tpstrerror(tperrno));
0103 EXFAIL_OUT(ret);
0104 }
0105
0106
0107 p_ub = (UBFH *)tpalloc("UBF", "", 1024);
0108
0109 if (NULL==p_ub)
0110 {
0111 fprintf(stderr, "Failed to alloc call buffer%s", tpstrerror(tperrno));
0112 NDRX_LOG(log_error,"Failed to alloc call buffer%s", tpstrerror(tperrno));
0113 EXFAIL_OUT(ret);
0114 }
0115
0116 if (EXSUCCEED!=Bchg(p_ub, EX_QCMD, 0, &cmd, 0L))
0117 {
0118 fprintf(stderr, "Failed to set command: %s", Bstrerror(Berror));
0119 NDRX_LOG(log_error,"Failed to set command: %s", Bstrerror(Berror));
0120 EXFAIL_OUT(ret);
0121 }
0122
0123 if (EXSUCCEED!=CBchg(p_ub, EX_DATA, 0, qconf, 0L, BFLD_STRING))
0124 {
0125 fprintf(stderr, "Failed to set data: %s", Bstrerror(Berror));
0126 NDRX_LOG(log_error,"Failed to set data: %s", Bstrerror(Berror));
0127 EXFAIL_OUT(ret);
0128 }
0129
0130 snprintf(qspacesvc, sizeof(qspacesvc), NDRX_SVC_TMQ, (long)nodeid, (int)srvid);
0131
0132 NDRX_LOG(log_info, "Calling: %s", qspacesvc);
0133
0134 if (EXSUCCEED!=tpcall(qspacesvc, (char *)p_ub, 0L,
0135 (char **)&p_ub, &rsplen, TPNOTRAN))
0136 {
0137 NDRX_LOG(log_error,"Failed: %s", tpstrerror(tperrno));
0138
0139 printf("Failed: %s\n", tpstrerror(tperrno));
0140 }
0141 else
0142 {
0143 printf("OK\n");
0144 }
0145
0146 out:
0147 return ret;
0148 }
0149
0150