76{
77
78
79 string ringbuf = string(m_conf->getconf("system", "unitname")) + ":" +
80 string(m_conf->getconf("distributor", "ringbuffer"));
81
82
83 string shmname = string(m_conf->getconf("system", "unitname")) + ":" +
84 string(m_conf->getconf("distributor", "nodename"));
85
86
87 m_nnodes = 0;
88 int maxnodes = m_conf->getconfi("processor", "nnodes");
89 int idbase = m_conf->getconfi("processor", "idbase");
90
91 char* badlist = m_conf->getconf("processor", "badlist");
92
93 char* sender = m_conf->getconf("distributor", "sender", "script");
94 int portbase = m_conf->getconfi("distributor", "sender", "portbase");
95
96
97 char hostname[512], idname[3], shmid[3];
98 for (int i = 0; i < maxnodes; i++) {
99 sprintf(idname, "%2.2d", idbase + i);
100 sprintf(shmid, "%2.2d", i);
101 if (badlist == NULL ||
102 strstr(badlist, idname) == 0) {
103 int port = (idbase + i) + portbase;
104 char portchar[256];
105 sprintf(portchar, "%d", port);
106 m_pid_sender[m_nnodes] = m_proc->
Execute(sender, (
char*)ringbuf.c_str(), portchar, (
char*)shmname.c_str(), shmid);
107 printf("Running sender to %d\n", port);
108 fflush(stdout);
109 m_nnodes++;
110 }
111 }
112
113
114 m_nrecv = 0;
115 int maxrecv = m_conf->getconfi("distributor", "receiver", "nnodes");
116 int ridbase = m_conf->getconfi("distributor", "receiver", "idbase");
117 char* rhostbase = m_conf->getconf("distributor", "receiver", "hostbase");
118 char* rbadlist = m_conf->getconf("distributor", "receiver", "badlist");
119 char* port = m_conf->getconf("distributor", "receiver", "port");
120 char* receiver = m_conf->getconf("distributor", "receiver", "script");
121
122
123 for (int i = 0; i < maxrecv; i++) {
124 sprintf(hostname, "%s%2.2d", rhostbase, ridbase + i);
125 sprintf(idname, "%2.2d", ridbase + i);
126 sprintf(shmid, "%2.2d", i + 20);
127 if (rbadlist == NULL ||
128 strstr(rbadlist, hostname) == 0) {
129 printf("Running receiver for %s\n", hostname);
130 fflush(stdout);
131 m_pid_recv[m_nrecv] = m_proc->
Execute(receiver, (
char*)ringbuf.c_str(), hostname, port, (
char*)shmname.c_str(), shmid);
132 m_nrecv++;
133 }
134 }
135
136 printf("ERecoDistributor : Configure done\n");
137 return 0;
138}
int Execute(char *script, int nargs, char **args)