9#include "daq/expreco/ERecoMaster.h"
11#include "daq/rfarm/manager/RFNSM.h"
13#include <nsm2/belle2nsm.h>
28ERecoMaster::ERecoMaster(
string conffile)
31 m_conf =
new RFConf(conffile.c_str());
32 char* nodename = m_conf->getconf(
"master",
"nodename");
40 string execdir = string(m_conf->getconf(
"system",
"execdir_base")) +
"/master";
42 mkdir(execdir.c_str(), 0755);
43 chdir(execdir.c_str());
46 m_log =
new RFLogManager(nodename, m_conf->getconf(
"system",
"lognode"));
49 FILE* f = fopen(
"pid.data",
"w");
50 fprintf(f,
"%d", getpid());
56ERecoMaster::~ERecoMaster()
63void ERecoMaster::Hook_Message_Handlers()
66 if (b2nsm_callback(
"LOG", Log_Handler) < 0) {
67 fprintf(stderr,
"ERecoMaster : hooking INFO handler failed, %s\n",
70 printf(
"ERecoMaster: Message Handlers - Ready\n");
91 char* dqmserver = m_conf->getconf(
"dqmserver",
"nodename");
92 RFNSM_Status::Instance().set_flag(0);
94 b2nsm_sendreq(dqmserver,
"RC_LOAD", 0, pars);
95 while (RFNSM_Status::Instance().get_flag() == 0) b2nsm_wait(1);
96 printf(
"ERecoMaster:: dqmserver configured\n");
100 char* distributor = m_conf->getconf(
"distributor",
"nodename");
101 RFNSM_Status::Instance().set_flag(0);
103 b2nsm_sendreq(distributor,
"RC_LOAD", 0, pars);
104 while (RFNSM_Status::Instance().get_flag() == 0) b2nsm_wait(1);
105 printf(
"ERecoMaster:: distributor configured\n");
110 int maxnodes = m_conf->getconfi(
"processor",
"nnodes");
111 int idbase = m_conf->getconfi(
"processor",
"idbase");
112 char* hostbase = m_conf->getconf(
"processor",
"nodebase");
113 char* badlist = m_conf->getconf(
"processor",
"badlist");
115 char hostnode[512], idname[3];
117 RFNSM_Status::Instance().set_flag(0);
118 for (
int i = 0; i < maxnodes; i++) {
119 sprintf(idname,
"%2.2d", idbase + i);
120 if (badlist == NULL ||
121 strstr(badlist, idname) == 0) {
122 sprintf(hostnode,
"evp_%s%2.2d", hostbase, idbase + i);
124 b2nsm_sendreq(hostnode,
"RC_LOAD", 0, pars);
128 while (RFNSM_Status::Instance().get_flag() != nnodes) b2nsm_wait(1);
133 char* sampler = m_conf->getconf(
"eventsampler",
"nodename");
134 RFNSM_Status::Instance().set_flag(0);
136 b2nsm_sendreq(sampler,
"RC_LOAD", 0, pars);
137 while (RFNSM_Status::Instance().get_flag() == 0) b2nsm_wait(1);
138 printf(
"ERecoMaster:: sampler configured\n");
143 printf(
"ERecoMaster:: event processors configured\n");
153 char* sampler = m_conf->getconf(
"eventsampler",
"nodename");
154 RFNSM_Status::Instance().set_flag(0);
156 b2nsm_sendreq(sampler,
"RC_ABORT", 0, pars);
157 while (RFNSM_Status::Instance().get_flag() == 0) b2nsm_wait(1);
158 printf(
"ErecoMaster: sampler unconfigured.\n");
161 int maxnodes = m_conf->getconfi(
"processor",
"nnodes");
162 int idbase = m_conf->getconfi(
"processor",
"idbase");
163 char* hostbase = m_conf->getconf(
"processor",
"nodebase");
164 char* badlist = m_conf->getconf(
"processor",
"badlist");
166 char hostnode[512], idname[3];
167 RFNSM_Status::Instance().set_flag(0);
169 for (
int i = 0; i < maxnodes; i++) {
170 sprintf(idname,
"%2.2d", idbase + i);
171 if (badlist == NULL ||
172 strstr(badlist, idname) == 0) {
173 sprintf(hostnode,
"evp_%s%2.2d", hostbase, idbase + i);
175 b2nsm_sendreq(hostnode,
"RC_ABORT", 0, pars);
182 while (RFNSM_Status::Instance().get_flag() != nnodes) b2nsm_wait(1);
184 printf(
"ERecoMaster: eventprocessors unconfigured.\n");
187 char* distributor = m_conf->getconf(
"distributor",
"nodename");
188 RFNSM_Status::Instance().set_flag(0);
190 b2nsm_sendreq(distributor,
"RC_ABORT", 0, pars);
191 while (RFNSM_Status::Instance().get_flag() == 0) b2nsm_wait(1);
192 printf(
"ErecoMaster: distributor unconfigured.\n");
195 char* dqmserver = m_conf->getconf(
"dqmserver",
"nodename");
196 RFNSM_Status::Instance().set_flag(0);
198 b2nsm_sendreq(dqmserver,
"RC_ABORT", 0, pars);
201 printf(
"ErecoMaster: dqmserver unconfigured.\n");
215 pars[0] = msg->pars[0];
216 pars[1] = msg->pars[1];
220 int maxnodes = m_conf->getconfi(
"processor",
"nnodes");
221 int idbase = m_conf->getconfi(
"processor",
"idbase");
222 char* hostbase = m_conf->getconf(
"processor",
"nodebase");
223 char* badlist = m_conf->getconf(
"processor",
"badlist");
225 char hostnode[512], idname[3];
226 RFNSM_Status::Instance().set_flag(0);
228 for (
int i = 0; i < maxnodes; i++) {
229 sprintf(idname,
"%2.2d", idbase + i);
230 if (badlist == NULL ||
231 strstr(badlist, idname) == 0) {
232 sprintf(hostnode,
"evp_%s%2.2d", hostbase, idbase + i);
234 b2nsm_sendreq(hostnode,
"RC_STOP", 0, pars);
241 while (RFNSM_Status::Instance().get_flag() != nnodes) b2nsm_wait(1);
246 char* dqmserver = m_conf->getconf(
"dqmserver",
"nodename");
247 RFNSM_Status::Instance().set_flag(0);
249 b2nsm_sendreq(dqmserver,
"RC_STOP", 0, pars);
250 while (RFNSM_Status::Instance().get_flag() == 0) b2nsm_wait(1);
261 char* dqmserver = m_conf->getconf(
"dqmserver",
"nodename");
263 b2nsm_sendreq(dqmserver,
"RC_RECOVER", 0, pars);
267 char* distributor = m_conf->getconf(
"distributor",
"nodename");
269 b2nsm_sendreq(distributor,
"RC_RECOVER", 0, pars);
273 int maxnodes = m_conf->getconfi(
"processor",
"nnodes");
274 int idbase = m_conf->getconfi(
"processor",
"idbase");
275 char* hostbase = m_conf->getconf(
"processor",
"hostbase");
276 char* badlist = m_conf->getconf(
"processor",
"badlist");
278 char hostnode[512], idname[3];
279 for (
int i = 0; i < maxnodes; i++) {
280 sprintf(idname,
"%2.2d", idbase + i);
281 if (badlist == NULL ||
282 strstr(badlist, idname) == 0) {
283 sprintf(hostnode,
"evp_%s%2.2d", hostbase, idbase + i);
285 b2nsm_sendreq(hostnode,
"RC_RECOVER", 0, pars);
295void ERecoMaster::monitor_loop()
Abstract base class for different kinds of events.