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 <stdio.h>
0035 #include <stdlib.h>
0036 #include <string.h>
0037 #include <errno.h>
0038 #include <regex.h>
0039 #include <utlist.h>
0040 #include <unistd.h>
0041 #include <signal.h>
0042
0043 #include <ndebug.h>
0044 #include <atmi.h>
0045 #include <atmi_int.h>
0046 #include <typed_buf.h>
0047 #include <ndrstandard.h>
0048 #include <ubf.h>
0049 #include <Exfields.h>
0050 #include <Excompat.h>
0051 #include <ubfutil.h>
0052 #include <sys_unix.h>
0053 #include <atmi_shm.h>
0054
0055 #include "tpadmsv.h"
0056 #include "expr.h"
0057
0058
0059
0060
0061
0062
0063
0064
0065 typedef struct
0066 {
0067 char domainid[MAXTIDENT+1];
0068 char state[3+1];
0069 long curqueues;
0070 long curservers;
0071 long curservices;
0072
0073 } ndrx_adm_domain_t;
0074
0075
0076
0077
0078 expublic ndrx_adm_elmap_t ndrx_G_domain_map[] =
0079 {
0080
0081 {TA_DOMAINID, TPADM_EL(ndrx_adm_domain_t, domainid)}
0082 ,{TA_STATE, TPADM_EL(ndrx_adm_domain_t, state)}
0083 ,{TA_CURQUEUES, TPADM_EL(ndrx_adm_domain_t, curqueues)}
0084 ,{TA_CURSERVERS, TPADM_EL(ndrx_adm_domain_t, curservers)}
0085 ,{TA_CURSERVICES, TPADM_EL(ndrx_adm_domain_t, curservices)}
0086 ,{BBADFLDID}
0087 };
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 expublic int ndrx_adm_domain_get(char *clazz, ndrx_adm_cursors_t *cursnew, long flags)
0100 {
0101 int ret = EXSUCCEED;
0102 ndrx_adm_domain_t dom;
0103 string_list_t* qlist = NULL;
0104 string_list_t* elt = NULL;
0105 int typ;
0106
0107
0108 cursnew->map = ndrx_G_domain_map;
0109
0110 memset(&dom, 0, sizeof(dom));
0111
0112 ndrx_growlist_init(&cursnew->list, 100, sizeof(ndrx_adm_domain_t));
0113
0114 snprintf(dom.domainid, sizeof(dom.domainid), "%ld", tpgetnodeid());
0115 NDRX_STRCPY_SAFE(dom.state, "ACT");
0116
0117
0118 qlist = ndrx_sys_mqueue_list_make(G_atmi_env.qpath, &ret);
0119
0120 if (EXSUCCEED!=ret)
0121 {
0122 NDRX_LOG(log_error, "posix queue listing failed!");
0123 EXFAIL_OUT(ret);
0124 }
0125
0126
0127 LL_FOREACH(qlist,elt)
0128 {
0129
0130 if (0!=strncmp(elt->qname,
0131 G_atmi_env.qprefix_match, G_atmi_env.qprefix_match_len))
0132 {
0133 continue;
0134 }
0135 dom.curqueues++;
0136
0137
0138 typ = ndrx_q_type_get(elt->qname);
0139
0140 if (NDRX_QTYPE_SRVADM==typ)
0141 {
0142 dom.curservers++;
0143 }
0144 }
0145
0146
0147 dom.curservices = ndrx_shm_get_svc_count();
0148
0149
0150 if (EXSUCCEED!=ndrx_growlist_add(&cursnew->list, (void *)&dom, 0))
0151 {
0152 NDRX_LOG(log_error, "Growlist failed for domain - out of memory?");
0153 EXFAIL_OUT(ret);
0154 }
0155
0156 out:
0157
0158 if (NULL!=qlist)
0159 {
0160 ndrx_string_list_free(qlist);
0161 }
0162
0163 if (EXSUCCEED!=ret)
0164 {
0165 ndrx_growlist_free(&cursnew->list);
0166 }
0167
0168 return ret;
0169 }
0170
0171