ifw-sup
3.0.0-pre3
|
#include <dataContext.hpp>
Public Member Functions | |
DataContext (Config &config, bool with_publisher=true, bool with_oldb=true) | |
virtual | ~DataContext () |
void | ReloadConfig () |
void | UpdateDb () |
Config & | GetConfig () |
State::StateEnum | GetState () |
Get server actual state. More... | |
void | SetState (const State::StateEnum state) |
Set server actual state. More... | |
void | SetState (const std::string &state) |
Set server actual state. More... | |
State::SubstateEnum | GetSubstate () |
Get server actual substate. More... | |
void | SetSubstate (const State::SubstateEnum state) |
Set server actual substate. More... | |
void | SetSubstate (const std::string &state) |
Set server actual substate. More... | |
State::StateEnum | GetEstimatedState () |
Get actual estimated state. More... | |
std::string | GetEstimatedStateStr () |
Set actual estimated state as string. More... | |
void | SetEstimatedState (const State::StateEnum state) |
Set actual estimated state. More... | |
std::string | GetEstimatedSubstateStr () |
Get actual estimated substate as string. More... | |
State::SubstateEnum | GetEstimatedSubstate () |
Get actual estimated substate. More... | |
void | SetEstimatedSubstate (const State::SubstateEnum state) |
Set actual estimated substate. More... | |
void | UpdateSubsysStates (const std::string &name, const std::string &state, const std::string &substate) |
void | PublishStates () |
Publish actual states. More... | |
This class provide access to the application run-time data including the in-memory DB. This class also takes care of publishing the status information
This class write the supervisor configuration and runtime data into the OLDB. The DB structure used is the following:
<prefix>/<server_id>: | |–cfg | – server_id – ... |–states | |– state |– substate |–subsystems | – subsys1 | | – states | |– state |– substate
The publishing of the status is the estimated state/substate of the supervisor and it follows the following convention.
<endpoint>/std/status
The topic is used is the one defined in the standard interface which is a string with the following format: <state>;<substate>
sup::syssup::common::DataContext::DataContext | ( | Config & | config, |
bool | with_publisher = true , |
||
bool | with_oldb = true |
||
) |
This constructor uses the application configuration to initialize the adapter object to the in-memory DB. The DB adapter is then used to initialize the DB interface object that can be used to access the DB key-value pairs.
[in] | config | Reference to the application configuration. |
[in] | with_publisher | Flag to enable/disable the publishing used in unit tests. |
[in] | with_oldb | Flag to enable/disable the DB writes used in unit tests. |
|
virtual |
Destructor
State::StateEnum sup::syssup::common::DataContext::GetEstimatedState | ( | ) |
Get actual estimated state.
std::string sup::syssup::common::DataContext::GetEstimatedStateStr | ( | ) |
Set actual estimated state as string.
State::SubstateEnum sup::syssup::common::DataContext::GetEstimatedSubstate | ( | ) |
Get actual estimated substate.
std::string sup::syssup::common::DataContext::GetEstimatedSubstateStr | ( | ) |
Get actual estimated substate as string.
State::StateEnum sup::syssup::common::DataContext::GetState | ( | ) |
Get server actual state.
State::SubstateEnum sup::syssup::common::DataContext::GetSubstate | ( | ) |
Get server actual substate.
void sup::syssup::common::DataContext::PublishStates | ( | ) |
Publish actual states.
It updates the OLDB and publish status via CII pub/sub.
void sup::syssup::common::DataContext::ReloadConfig | ( | ) |
Reload the configuration from file and reconnect to the in-memory DB.
void sup::syssup::common::DataContext::SetEstimatedState | ( | const State::StateEnum | state | ) |
Set actual estimated state.
state | new state as string |
void sup::syssup::common::DataContext::SetEstimatedSubstate | ( | const State::SubstateEnum | state | ) |
Set actual estimated substate.
state | new substate as string |
void sup::syssup::common::DataContext::SetState | ( | const State::StateEnum | state | ) |
Set server actual state.
state | new state as enumeration |
void sup::syssup::common::DataContext::SetState | ( | const std::string & | state | ) |
Set server actual state.
state | new state as string |
void sup::syssup::common::DataContext::SetSubstate | ( | const State::SubstateEnum | state | ) |
Set server actual substate.
state | new substate as enumeration |
void sup::syssup::common::DataContext::SetSubstate | ( | const std::string & | state | ) |
Set server actual substate.
state | new substate as string |
void sup::syssup::common::DataContext::UpdateDb | ( | ) |
Try to connect to the DB and update the application configuration.
void sup::syssup::common::DataContext::UpdateSubsysStates | ( | const std::string & | name, |
const std::string & | state, | ||
const std::string & | substate | ||
) |