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[12], shmid[12];
98 for (int i = 0; i < maxnodes; i++) {
99 snprintf(idname, sizeof(idname), "%2.2d", idbase + i);
100 snprintf(shmid, sizeof(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, const_cast<char*>(ringbuf.c_str()), portchar, const_cast<char*>(shmname.c_str()),
107 shmid);
108 printf("Running sender to %d\n", port);
109 fflush(stdout);
110 m_nnodes++;
111 }
112 }
113
114
115 m_nrecv = 0;
116 int maxrecv = m_conf->getconfi("distributor", "receiver", "nnodes");
117 int ridbase = m_conf->getconfi("distributor", "receiver", "idbase");
118 const char* rhostbase = m_conf->getconf("distributor", "receiver", "hostbase");
119 char* rbadlist = m_conf->getconf("distributor", "receiver", "badlist");
120 char* port = m_conf->getconf("distributor", "receiver", "port");
121 char* receiver = m_conf->getconf("distributor", "receiver", "script");
122
123
124 for (int i = 0; i < maxrecv; i++) {
125 sprintf(hostname, "%s%2.2d", rhostbase, ridbase + i);
126 snprintf(idname, sizeof(idname), "%2.2d", ridbase + i);
127 snprintf(shmid, sizeof(shmid), "%2.2d", i + 20);
128 if (rbadlist == NULL ||
129 strstr(rbadlist, hostname) == 0) {
130 printf("Running receiver for %s\n", hostname);
131 fflush(stdout);
132 m_pid_recv[m_nrecv] = m_proc->Execute(receiver, const_cast<char*>(ringbuf.c_str()), hostname, port,
133 const_cast<char*>(shmname.c_str()), shmid);
134 m_nrecv++;
135 }
136 }
137
138 printf("ERecoDistributor : Configure done\n");
139 return 0;
140}