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