hce-node application
1.4.3
HCE Hierarchical Cluster Engine node application
Main Page
Namespaces
Classes
Files
File List
File Members
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
//-----------------------------------------------------------------------------
14
DataNodeOptions::DataNodeOptions
(
HandlerProperties
& handlerProperties)
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
{
31
if
(!properties.
isExist
(
HCE::handlers::properties::HEARTBEAT_DELAY
))
32
setHeartbeatDelay
(pConf->getInt(
HCE::handlers::properties::HEARTBEAT_DELAY
)*1000);
33
34
if
(!properties.
isExist
(
HCE::handlers::properties::HEARTBEAT_TIMEOUT
))
35
setHeartbeatTimeout
(pConf->getInt(
HCE::handlers::properties::HEARTBEAT_TIMEOUT
)*1000);
36
37
if
(!properties.
isExist
(
HCE::handlers::properties::HEARTBEAT_MODE
))
38
setHeartbeatMode
(pConf->getInt(
HCE::handlers::properties::HEARTBEAT_MODE
));
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
}
52
if
(!properties.
isExist
(
HCE::handlers::properties::HEARTBEAT_DELAY
))
53
setHeartbeatDelay
(
HCE::handlers::HEARTBEAT_DELAY
);
54
55
if
(!properties.
isExist
(
HCE::handlers::properties::HEARTBEAT_TIMEOUT
))
56
setHeartbeatTimeout
(
HCE::handlers::HEARTBEAT_TIMEOUT
);
57
58
if
(!properties.
isExist
(
HCE::handlers::properties::HEARTBEAT_MODE
))
59
setHeartbeatMode
(
HCE::handlers::HEARBEAT_MODE_DEFAULT
);
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
//-----------------------------------------------------------------------------
73
unsigned
int
DataNodeOptions::getHeartbeatDelay
(
void
)
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
//-----------------------------------------------------------------------------
84
unsigned
int
DataNodeOptions::getHeartbeatTimeout
(
void
)
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
//-----------------------------------------------------------------------------
95
unsigned
int
DataNodeOptions::getHeartbeatMode
(
void
)
96
{
97
return
properties.
get
<
unsigned
int
>(
HCE::handlers::properties::HEARTBEAT_MODE
);
98
}
99
//-----------------------------------------------------------------------------
100
//-----------------------------------------------------------------------------
101
}
// end namespace drce
102
}
// end namespace HCE
sources
src
DataNodeOptions.cpp
Generated on Tue Jun 30 2015 19:42:08 for hce-node application by
1.8.1.2