hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
DataNodeOptions.cpp
Go to the documentation of this file.
1 #include <Poco/AutoPtr.h>
2 #include <Poco/Configurable.h>
3 #include <Poco/Util/IniFileConfiguration.h>
4 #include <Poco/String.h>
5 
6 #include "HandlerTypes.hpp"
7 #include "DataNodeOptions.hpp"
8 
9 namespace HCE
10 {
11 namespace handlers
12 {
13 //-----------------------------------------------------------------------------
15 : properties(handlerProperties)
16 {
17 }
18 //-----------------------------------------------------------------------------
19 void DataNodeOptions::initNode(const std::string& iniFile, LoggerStream& logger)
20 {
21  if (!iniFile.empty())
22  {
23  logger.log(NODE_LOG_MODE_INFORMATION) << "load node settings from '" << iniFile << "' file" << flush;
24 
26  try
27  {
28  Poco::AutoPtr<Poco::Util::IniFileConfiguration> pConf(new Poco::Util::IniFileConfiguration(iniFile));
29  try
30  {
33 
36 
39  }
40  catch(Poco::SyntaxException& e)
41  {
43  logger.log(NODE_LOG_MODE_ERROR) << "nodeInit() - data node options ini file processing error: '" << e.displayText() << "'" << flush;
44  }
45  }
46  catch(Poco::Exception& e)
47  {
49  logger.log(NODE_LOG_MODE_ERROR) << "nodeInit() - data node options ini file access error: '" << e.displayText() << "'" << flush;
50  }
54 
57 
60 
61  logger.log(NODE_LOG_MODE_INFORMATION) << "hb_delay = " << getHeartbeatDelay() << flush;
62  logger.log(NODE_LOG_MODE_INFORMATION) << "hb_timeout = " << getHeartbeatTimeout() << flush;
63  logger.log(NODE_LOG_MODE_INFORMATION) << "hb_mode = " << getHeartbeatMode() << flush;
64  }
65 }
66 //-----------------------------------------------------------------------------
67 void DataNodeOptions::setHeartbeatDelay(unsigned int heartbeatDelay)
68 {
69  if (heartbeatDelay >= MIN_ALLOWED_HEARTBEAT_DELAY)
70  properties.set(HCE::handlers::properties::HEARTBEAT_DELAY, heartbeatDelay);
71 }
72 //-----------------------------------------------------------------------------
74 {
75  return properties.get<unsigned int>(HCE::handlers::properties::HEARTBEAT_DELAY);
76 }
77 //-----------------------------------------------------------------------------
78 void DataNodeOptions::setHeartbeatTimeout(unsigned int heartbeatTimeout)
79 {
80  if (heartbeatTimeout >= MIN_ALLOWED_HEARTBEAT_TIMEOUT)
81  properties.set(HCE::handlers::properties::HEARTBEAT_TIMEOUT, heartbeatTimeout);
82 }
83 //-----------------------------------------------------------------------------
85 {
86  return properties.get<unsigned int>(HCE::handlers::properties::HEARTBEAT_TIMEOUT);
87 }
88 //-----------------------------------------------------------------------------
89 void DataNodeOptions::setHeartbeatMode(unsigned int heartbeatMode)
90 {
91  if (heartbeatMode <= HEARBEAT_MODE_MAX_NUMBER && heartbeatMode >= HEARBEAT_MODE_DEFAULT)
92  properties.set(HCE::handlers::properties::HEARTBEAT_MODE, heartbeatMode);
93 }
94 //-----------------------------------------------------------------------------
96 {
97  return properties.get<unsigned int>(HCE::handlers::properties::HEARTBEAT_MODE);
98 }
99 //-----------------------------------------------------------------------------
100 //-----------------------------------------------------------------------------
101 } // end namespace drce
102 } // end namespace HCE