Belle II Software  release-05-01-25
RCNodeDaemon.cc
1 #include "daq/slc/runcontrol/RCNodeDaemon.h"
2 
3 #include <daq/slc/system/LogFile.h>
4 
5 #include <daq/slc/base/ConfigFile.h>
6 
7 using namespace Belle2;
8 
9 RCNodeDaemon::RCNodeDaemon(ConfigFile& config,
10  RCCallback* callback,
11  RCCallback* callback2,
12  DBInterface* db)
13 {
14  std::string host = config.get("nsm.host");
15  if (host.size() == 0) {
16  LogFile::error("nsm.host is empty");
17  exit(1);
18  }
19  int port = config.getInt("nsm.port");
20  if (port < 0) {
21  LogFile::error("nsm.port is not a positive integer");
22  exit(1);
23  }
24  std::string name = config.get("nsm.nodename");
25  if (name.size() == 0) {
26  LogFile::error("nsm.nodename is empty");
27  exit(1);
28  }
29  callback->setNode(NSMNode(name));
30  std::string rcconfig = config.get("rcconfig");
31  callback->setRunTypeRecord(config.get("runtype.record"));
32  if (rcconfig.size() > 0) {
33  callback->setRCConfig(rcconfig);
34  } else {
35  LogFile::notice("rcconfig is empty");
36  }
37  int timeout = config.getInt("timeout");
38  if (timeout > 0) {
39  callback->setTimeout(timeout);
40  }
41  callback->setCategory(config.get("log.category"));
42  std::string file = config.get("file");
43  std::string dbtable = config.get("dbtable");
44  if (file.size() > 0) {
45  LogFile::info("read file %s", file.c_str());
46  callback->setDBFile(file);
47  }
48  if (dbtable.size() > 0) {
49  LogFile::debug("database.use=%s", config.getBool("database.use") ? "TRUE" : "FALSE");
50  if (config.getBool("database.use") && db != NULL) {
51  callback->setDB(db, dbtable);
52  } else {
53  callback->setDBTable(dbtable);
54  callback->setProvider(config.get("provider.host"),
55  config.getInt("provider.port"));
56  }
57  } else if (file.size() > 0) {
58 
59  } else {
60  LogFile::notice("dbtable is empty");
61  }
62  m_daemon.add(callback, host, port);
63  host = config.get("nsm.global.host");
64  port = config.getInt("nsm.global.port");
65  if (callback2 != NULL && host.size() > 0 && port > 0) {
66  callback2->setNode(NSMNode(name));
67  m_daemon.add(callback2, host, port);
68  }
69 }
70 
71 void RCNodeDaemon::run()
72 {
73  m_daemon.run();
74 }
Belle2::NSMNode
Definition: NSMNode.h:14
Belle2::RCCallback
Definition: RCCallback.h:18
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::DBInterface
Definition: DBInterface.h:19
Belle2::ConfigFile
Definition: ConfigFile.h:15