![]() |
|
PhoenixSwarm
3.5.0
Library to ease communication between daemons
|
Daemon which help communication between processes and thread. More...
#include <BaseDaemon.h>
Inheritance diagram for BaseDaemon:
Collaboration diagram for BaseDaemon:Public Member Functions | |
| template<typename _Callable> | |
| bool | addCallableMethod (_Callable &&function, const PString &name) |
| Add a callable method of the Daemon. | |
| virtual void | addCallMethod () |
| Do the addCallableMethod here. | |
| template<typename _Class, typename _Data> | |
| bool | addDataCallableMethod (PUncastableBool(&function)(_Class &, const _Data &), _Class &persistentData, size_t nbBin, float histLowerBound, float histUpperBound) |
| Add a callable method of the Daemon. | |
| template<typename _Data> | |
| bool | addDataCallableMethod (PUncastableBool(&function)(const _Data &), size_t nbBin, float histLowerBound, float histUpperBound) |
| Add a callable method of the Daemon. | |
| void | addMessageToConfirm (const Message &message) |
| Add a message to confirm. | |
| BaseDaemon () | |
| Default constructor of BaseDaemon. | |
| bool | callMethod (Data &result, const PString &name, const Data ¶meter) |
| Call an added callable method by name. | |
| void | checkMessageTimeout (time_t currentTime) |
| Check if a message has reached the timeout. | |
| void | clearCallableMethod () |
| Clear the map of callable methods. | |
| void | clearStat () |
| Clear all the statistics of the daemon. | |
| StatAccumulator | createNewStat (size_t nbBin, float histLowerBound, float histUpperBound) |
| Create a new clear computing statistic. | |
| virtual bool | extraLoad (const ConfigNode *config) |
| Extra call on load for the current Daemon. | |
| DaemonConfig & | getConfig () |
| Get the configuration of the current BaseDaemon. | |
| AbstractDataFunction * | getDataFunction (const Data &data) |
| Get the data function associated with the given data. | |
| PLog & | getLog () |
| Get the log of the current BaseDaemon. | |
| PLog & | getLogger () |
| Get the logger of the current BaseDaemon. | |
| DaemonMainConfig & | getMainConfig () |
| Get the main configuration of the swarm. | |
| MapDaemonConfig & | getMapDaemonConfig () |
| Get the map of all Daemon configurations. | |
| const std::map< size_t, Message > & | getMapMessageToBeConfirmed () const |
| Get the map of message to be confirmed. | |
| size_t | getMessageId () |
| Get current message id. | |
| bool | getMessageToConfirm (Message &message, size_t id) const |
| Get a message to confirm by id if it exists. | |
| OptionParser & | getOptionParser () |
| Return the OptionParser of the current BaseDaemon. | |
| bool | isDaemonExist (const PString &name) const |
| Say if a neighbour Daemon does exist. | |
| bool | load (const PPath &fileName, const PString &daemonName) |
| Load the Toml configuration which define all BaseDaemons of the Swarm. | |
| bool | load (const PString &configFileContent, const PString &daemonName, ConfigFormat::ConfigFormat format) |
| Load the Json configuration which define all BaseDaemons of the Swarm. | |
| void | loadConfigFromNode (const ConfigNode &dico, const PString &daemonName) |
| Load configuration form a node of ConfigNode. | |
| bool | parseArgument (int argc, char **argv) |
| Parse arguments given to the BaseDaemon with command line. | |
| void | processConfirmedMessage (size_t id, time_t currentTime) |
| Process confirmed message. | |
| bool | processData (const Data &data) |
| Process given data with the proper method. | |
| void | stop () |
| Stops the BaseDaemon. | |
| void | updateStatAccumulator (StatAccumulator &stat, float value) |
| Update a computing statistic with a new value. | |
| virtual | ~BaseDaemon () |
| Destructor of BaseDaemon. | |
Protected Member Functions | |
| void | fillDaemonStat (DaemonStat &stat, time_t startTimestamp, time_t endTimestamp) |
| Fill the DaemonStat with the current statistics of the daemon. | |
| VecStat | fillVecStat (const StatAccumulator &accumulator, time_t startTimestamp, time_t endTimestamp) |
| Fill a VecStat from a StatAccumulator to send to the DamonStat. | |
Protected Attributes | |
| DaemonConfig | p_config |
| Configuration of the curent Daemon. | |
| bool | p_isFullMock |
| True if the daemon has to be executed in mock mode for socket and clock. | |
| bool | p_isFullMockRecord |
| True if the daemon has to be executed in mock record mode for socket and clock. | |
| bool | p_isRun |
| True if the current BaseDaemon is running. | |
| PLog | p_log |
| Logger of the current Daemon. | |
| DaemonMainConfig | p_mainConfig |
| Main configuration of the Daemon. | |
| MapDaemonConfig | p_mapDaemon |
| Map of the other Daemon of the Swarm. | |
Private Member Functions | |
| std::map< PString, StatAccumulator > | createNewCommunicationStatMap (const PString &dataType, size_t nbBin, float histLowerBound, float histUpperBound) |
| Create a new map of communication statistic. | |
| void | getCommunicationStat (const PString &destName, const PString &dataType, float latency, size_t nbBin, float histLowerBound, float histUpperBound) |
| Add a communication statistic. | |
| void | initialisationBaseDaemon () |
| Initialisation function of the class BaseDaemon. | |
Private Attributes | |
| std::map< PString, AbstractFunction * > | p_mapCallableMethod |
| Map of callable method of the Daemon. | |
| std::map< PString, AbstractDataFunction * > | p_mapDataFunction |
| Map of methods which have to be called when receiving data. | |
| std::map< size_t, Message > | p_mapMessageToBeConfirmed |
| Map of messages which have to be confirmed by destination Daemon. | |
| size_t | p_messageId |
| Id counter of the message of the current Daemon. | |
| OptionParser | p_optionParser |
| Option parser of the Daemon. | |
Daemon which help communication between processes and thread.
Definition at line 54 of file BaseDaemon.h.
| BaseDaemon::BaseDaemon | ( | ) |
Default constructor of BaseDaemon.
Definition at line 12 of file BaseDaemon.cpp.
References initialisationBaseDaemon(), and p_optionParser.
Referenced by Daemon< _TBackend >::Daemon().
Here is the call graph for this function:
Here is the caller graph for this function:
|
virtual |
Destructor of BaseDaemon.
Definition at line 19 of file BaseDaemon.cpp.
References clearCallableMethod().
Here is the call graph for this function:
|
inline |
Add a callable method of the Daemon.
| function | : method to be added |
| name | : name of the method which can be called |
Definition at line 73 of file BaseDaemon.h.
References getLog(), and p_mapCallableMethod.
Here is the call graph for this function:
|
virtual |
Do the addCallableMethod here.
Reimplemented in StatDaemonManager< _TBackend >.
Definition at line 107 of file BaseDaemon.cpp.
References p_log.
Referenced by loadConfigFromNode().
Here is the caller graph for this function:
|
inline |
Add a callable method of the Daemon.
| function | : method to be added |
| persistentData | : data used each time the method is called |
| nbBin | : number of bin in the histogram |
| histLowerBound | : lower bound of the histogram |
| histUpperBound | : upper bound of the histogram |
Definition at line 128 of file BaseDaemon.h.
References createNewStat(), getLog(), p_config, and p_mapDataFunction.
Here is the call graph for this function:
|
inline |
Add a callable method of the Daemon.
| function | : method to be added |
| nbBin | : number of bin in the histogram |
| histLowerBound | : lower bound of the histogram |
| histUpperBound | : upper bound of the histogram |
Definition at line 105 of file BaseDaemon.h.
References createNewStat(), getLog(), p_config, and p_mapDataFunction.
Referenced by StatDaemonManager< _TBackend >::addCallMethod().
Here is the call graph for this function:
Here is the caller graph for this function:| void BaseDaemon::addMessageToConfirm | ( | const Message & | message | ) |
Add a message to confirm.
| message | : message to be added |
Definition at line 180 of file BaseDaemon.cpp.
References Message::getId(), and p_mapMessageToBeConfirmed.
Referenced by Daemon< _TBackend >::sendMessage().
Here is the call graph for this function:
Here is the caller graph for this function:Call an added callable method by name.
| [out] | result | : result of the call |
| name | : name of the method | |
| parameter | : parameters of the call |
Definition at line 121 of file BaseDaemon.cpp.
References getLog(), p_log, and p_mapCallableMethod.
Here is the call graph for this function:| void BaseDaemon::checkMessageTimeout | ( | time_t | currentTime | ) |
Check if a message has reached the timeout.
| currentTime | : current time |
Definition at line 223 of file BaseDaemon.cpp.
References getLog(), Message::getSendTime(), Message::getVecRecver(), p_config, and p_mapMessageToBeConfirmed.
Referenced by Daemon< _TBackend >::run().
Here is the call graph for this function:
Here is the caller graph for this function:| void BaseDaemon::clearCallableMethod | ( | ) |
Clear the map of callable methods.
Definition at line 131 of file BaseDaemon.cpp.
References p_mapCallableMethod.
Referenced by ~BaseDaemon().
Here is the caller graph for this function:| void BaseDaemon::clearStat | ( | ) |
Clear all the statistics of the daemon.
Definition at line 349 of file BaseDaemon.cpp.
References p_config.
Referenced by Daemon< _TBackend >::sendStatToStatDaemon().
Here is the caller graph for this function:
|
private |
Create a new map of communication statistic.
| dataType | : type of data which where pushed |
| nbBin | : number of bin of the histogram |
| histLowerBound | : lower bound of the histogram |
| histUpperBound | : upper bound of the histogram |
Definition at line 411 of file BaseDaemon.cpp.
References createNewStat().
Referenced by getCommunicationStat().
Here is the call graph for this function:
Here is the caller graph for this function:| StatAccumulator BaseDaemon::createNewStat | ( | size_t | nbBin, |
| float | histLowerBound, | ||
| float | histUpperBound ) |
Create a new clear computing statistic.
| nbBin | : number of bin of the histogram |
| histLowerBound | : lower bound of the histogram |
| histUpperBound | : upper bound of the histogram |
Definition at line 326 of file BaseDaemon.cpp.
References StatAccumulator::setHistLowerBound(), StatAccumulator::setHistUpperBound(), StatAccumulator::setMax(), StatAccumulator::setMin(), StatAccumulator::setNbEvent(), StatAccumulator::setNbEventAboveUpperBound(), StatAccumulator::setNbEventBelowLowerBound(), StatAccumulator::setSum(), and StatAccumulator::setVecHistogram().
Referenced by addDataCallableMethod(), addDataCallableMethod(), createNewCommunicationStatMap(), and getCommunicationStat().
Here is the call graph for this function:
Here is the caller graph for this function:
|
virtual |
Extra call on load for the current Daemon.
| config | : configuration for the current Daemon |
Definition at line 102 of file BaseDaemon.cpp.
|
protected |
Fill the DaemonStat with the current statistics of the daemon.
| stat | DaemonStat to be filled |
| startTimestamp | time at which the statistic started to be filled |
| endTimestamp | time at which the statistic stopped to be filled |
Definition at line 476 of file BaseDaemon.cpp.
References fillVecStat(), DaemonStat::getMapStatCommunication(), DaemonStat::getMapStatComputing(), and p_config.
Referenced by Daemon< _TBackend >::sendStatToStatDaemon().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
Fill a VecStat from a StatAccumulator to send to the DamonStat.
| accumulator | StatAccumulator to be converted |
| startTimestamp | time at which the statistic started to be filled |
| endTimestamp | time at which the statistic stopped to be filled |
Definition at line 446 of file BaseDaemon.cpp.
References VecStat::getAverage(), VecStat::getEndTimestamp(), StatAccumulator::getMax(), VecStat::getMax(), StatAccumulator::getMin(), VecStat::getMin(), StatAccumulator::getNbEvent(), VecStat::getNbEvent(), StatAccumulator::getNbEventAboveUpperBound(), StatAccumulator::getNbEventBelowLowerBound(), VecStat::getRate(), VecStat::getRateEventAboveUpperBound(), VecStat::getRateEventBelowLowerBound(), VecStat::getStartTimestamp(), StatAccumulator::getSum(), StatAccumulator::getVecHistogram(), and VecStat::getVecRateQuantile().
Referenced by fillDaemonStat().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Add a communication statistic.
| destName | : name of the destination Daemon from which data where pushed |
| dataType | : type of data which where pushed |
| latency | : latency between the send of the data and the receiving of the confirmation by the daemon destName |
| nbBin | : number of bin of the histogram |
| histLowerBound | : lower bound of the histogram |
| histUpperBound | : upper bound of the histogram |
Definition at line 425 of file BaseDaemon.cpp.
References createNewCommunicationStatMap(), createNewStat(), p_config, and updateStatAccumulator().
Referenced by processConfirmedMessage().
Here is the call graph for this function:
Here is the caller graph for this function:| DaemonConfig & BaseDaemon::getConfig | ( | ) |
Get the configuration of the current BaseDaemon.
Definition at line 365 of file BaseDaemon.cpp.
References p_config.
Referenced by StatDaemonManager< _TBackend >::addCallMethod().
Here is the caller graph for this function:| AbstractDataFunction * BaseDaemon::getDataFunction | ( | const Data & | data | ) |
Get the data function associated with the given data.
| data | The data for which to retrieve the associated function |
Definition at line 262 of file BaseDaemon.cpp.
References getLog(), Data::getType(), and p_mapDataFunction.
Referenced by processData(), and Daemon< _TBackend >::processInputMessage().
Here is the call graph for this function:
Here is the caller graph for this function:| PLog & BaseDaemon::getLog | ( | ) |
Get the log of the current BaseDaemon.
Definition at line 154 of file BaseDaemon.cpp.
References p_log.
Referenced by addCallableMethod(), StatDaemonManager< _TBackend >::addCallMethod(), addDataCallableMethod(), addDataCallableMethod(), callMethod(), checkMessageTimeout(), getDataFunction(), Daemon< _TBackend >::initialisationDaemonSocket(), processConfirmedMessage(), processData(), Daemon< _TBackend >::processInputMessage(), Daemon< _TBackend >::sendStatToStatDaemon(), and updateStatAccumulator().
Here is the caller graph for this function:| PLog & BaseDaemon::getLogger | ( | ) |
Get the logger of the current BaseDaemon.
Definition at line 386 of file BaseDaemon.cpp.
References p_log.
| DaemonMainConfig & BaseDaemon::getMainConfig | ( | ) |
Get the main configuration of the swarm.
Definition at line 379 of file BaseDaemon.cpp.
References p_mainConfig.
| MapDaemonConfig & BaseDaemon::getMapDaemonConfig | ( | ) |
Get the map of all Daemon configurations.
Definition at line 372 of file BaseDaemon.cpp.
References p_mapDaemon.
| const std::map< size_t, Message > & BaseDaemon::getMapMessageToBeConfirmed | ( | ) | const |
Get the map of message to be confirmed.
Definition at line 343 of file BaseDaemon.cpp.
References p_mapMessageToBeConfirmed.
| size_t BaseDaemon::getMessageId | ( | ) |
Get current message id.
Definition at line 253 of file BaseDaemon.cpp.
References p_messageId.
Referenced by Daemon< _TBackend >::sendData().
Here is the caller graph for this function:| bool BaseDaemon::getMessageToConfirm | ( | Message & | message, |
| size_t | id ) const |
Get a message to confirm by id if it exists.
| [out] | message | : message which has the id id |
| id | : id of the message to be searched |
Definition at line 189 of file BaseDaemon.cpp.
References p_mapMessageToBeConfirmed.
| OptionParser & BaseDaemon::getOptionParser | ( | ) |
Return the OptionParser of the current BaseDaemon.
Definition at line 147 of file BaseDaemon.cpp.
References p_optionParser.
|
private |
Initialisation function of the class BaseDaemon.
Definition at line 391 of file BaseDaemon.cpp.
References p_isFullMock, p_isFullMockRecord, p_isRun, p_messageId, and p_optionParser.
Referenced by BaseDaemon().
Here is the caller graph for this function:| bool BaseDaemon::isDaemonExist | ( | const PString & | name | ) | const |
Say if a neighbour Daemon does exist.
| name | : name of the Daemon to be searched |
Definition at line 162 of file BaseDaemon.cpp.
References p_config, and p_mapDaemon.
Referenced by loadConfigFromNode().
Here is the caller graph for this function:| bool BaseDaemon::load | ( | const PPath & | fileName, |
| const PString & | daemonName ) |
Load the Toml configuration which define all BaseDaemons of the Swarm.
| fileName | : name of the configuration file of all the BaseDaemons of the Swarm in toml format |
| daemonName | : name of the current BaseDaemon in the given file |
Definition at line 91 of file BaseDaemon.cpp.
References daemon_load_config(), loadConfigFromNode(), and p_log.
Here is the call graph for this function:| bool BaseDaemon::load | ( | const PString & | configFileContent, |
| const PString & | daemonName, | ||
| ConfigFormat::ConfigFormat | format ) |
Load the Json configuration which define all BaseDaemons of the Swarm.
| configFileContent | : name of the configuration file of all the BaseDaemons of the Swarm in json format |
| daemonName | : name of the current BaseDaemon in the given file |
| format | : format of the configuration file |
Definition at line 79 of file BaseDaemon.cpp.
References daemon_load_config(), loadConfigFromNode(), and p_log.
Referenced by parseArgument().
Here is the call graph for this function:
Here is the caller graph for this function:| void BaseDaemon::loadConfigFromNode | ( | const ConfigNode & | dico, |
| const PString & | daemonName ) |
Load configuration form a node of ConfigNode.
| [out] | dico | : loaded configuration |
| daemonName | : name of the current Daemon in the configuration |
Definition at line 45 of file BaseDaemon.cpp.
References addCallMethod(), daemon_loadString(), daemon_read_configNode(), isDaemonExist(), p_config, p_log, p_mainConfig, and p_mapDaemon.
Referenced by load(), and load().
Here is the call graph for this function:
Here is the caller graph for this function:| bool BaseDaemon::parseArgument | ( | int | argc, |
| char ** | argv ) |
Parse arguments given to the BaseDaemon with command line.
| argc | : number of arguments given to the program |
| argv | : list of arguments given to the program |
Definition at line 28 of file BaseDaemon.cpp.
References load(), p_isFullMock, p_isFullMockRecord, and p_optionParser.
Here is the call graph for this function:| void BaseDaemon::processConfirmedMessage | ( | size_t | id, |
| time_t | currentTime ) |
Process confirmed message.
| id | : id of the message to be removed |
| currentTime | : time when the confirmation was received |
Definition at line 202 of file BaseDaemon.cpp.
References getCommunicationStat(), Message::getData(), getLog(), Message::getSendTime(), Data::getType(), Message::getVecRecver(), p_config, and p_mapMessageToBeConfirmed.
Referenced by Daemon< _TBackend >::processInputMessage().
Here is the call graph for this function:
Here is the caller graph for this function:| bool BaseDaemon::processData | ( | const Data & | data | ) |
Process given data with the proper method.
| data | : data to be processed |
Definition at line 276 of file BaseDaemon.cpp.
References AbstractDataFunction::call(), getDataFunction(), getLog(), Data::getType(), and p_log.
Here is the call graph for this function:| void BaseDaemon::stop | ( | ) |
Stops the BaseDaemon.
Definition at line 139 of file BaseDaemon.cpp.
References p_config, p_isRun, and p_log.
Referenced by Daemon< _TBackend >::processInputMessage().
Here is the caller graph for this function:| void BaseDaemon::updateStatAccumulator | ( | StatAccumulator & | stat, |
| float | value ) |
Update a computing statistic with a new value.
| stat | : statistic to be updated |
| value | : new value to be added to the statistic |
Definition at line 290 of file BaseDaemon.cpp.
References StatAccumulator::getHistLowerBound(), StatAccumulator::getHistUpperBound(), getLog(), StatAccumulator::getMax(), StatAccumulator::getMin(), StatAccumulator::getNbEvent(), StatAccumulator::getNbEventAboveUpperBound(), StatAccumulator::getNbEventBelowLowerBound(), StatAccumulator::getSum(), StatAccumulator::getVecHistogram(), StatAccumulator::setMax(), StatAccumulator::setMin(), StatAccumulator::setNbEvent(), StatAccumulator::setNbEventAboveUpperBound(), StatAccumulator::setNbEventBelowLowerBound(), and StatAccumulator::setSum().
Referenced by getCommunicationStat(), and Daemon< _TBackend >::processInputMessage().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protected |
Configuration of the curent Daemon.
Definition at line 162 of file BaseDaemon.h.
Referenced by addDataCallableMethod(), addDataCallableMethod(), checkMessageTimeout(), clearStat(), fillDaemonStat(), getCommunicationStat(), getConfig(), Daemon< _TBackend >::initialisationDaemonSocket(), isDaemonExist(), loadConfigFromNode(), processConfirmedMessage(), Daemon< _TBackend >::processInputMessage(), Daemon< _TBackend >::run(), Daemon< _TBackend >::sendData(), Daemon< _TBackend >::sendStatToStatDaemon(), and stop().
|
protected |
True if the daemon has to be executed in mock mode for socket and clock.
Definition at line 170 of file BaseDaemon.h.
Referenced by initialisationBaseDaemon(), Daemon< _TBackend >::initialisationDaemonSocket(), parseArgument(), Daemon< _TBackend >::setClockMode(), and Daemon< _TBackend >::setSocketMode().
|
protected |
True if the daemon has to be executed in mock record mode for socket and clock.
Definition at line 172 of file BaseDaemon.h.
Referenced by initialisationBaseDaemon(), Daemon< _TBackend >::initialisationDaemonSocket(), parseArgument(), Daemon< _TBackend >::setClockMode(), and Daemon< _TBackend >::setSocketMode().
|
protected |
True if the current BaseDaemon is running.
Definition at line 168 of file BaseDaemon.h.
Referenced by initialisationBaseDaemon(), Daemon< _TBackend >::run(), and stop().
|
protected |
Logger of the current Daemon.
Definition at line 166 of file BaseDaemon.h.
Referenced by addCallMethod(), callMethod(), Daemon< _TBackend >::checkRecvStatus(), Daemon< _TBackend >::checkSendStatus(), getLog(), getLogger(), load(), load(), loadConfigFromNode(), processData(), Daemon< _TBackend >::processInputMessage(), and stop().
|
protected |
Main configuration of the Daemon.
Definition at line 160 of file BaseDaemon.h.
Referenced by getMainConfig(), loadConfigFromNode(), Daemon< _TBackend >::run(), and Daemon< _TBackend >::sendMessage().
|
private |
Map of callable method of the Daemon.
Definition at line 182 of file BaseDaemon.h.
Referenced by addCallableMethod(), callMethod(), and clearCallableMethod().
|
protected |
Map of the other Daemon of the Swarm.
Definition at line 164 of file BaseDaemon.h.
Referenced by getMapDaemonConfig(), Daemon< _TBackend >::initialisationDaemonSocket(), isDaemonExist(), and loadConfigFromNode().
|
private |
Map of methods which have to be called when receiving data.
Definition at line 189 of file BaseDaemon.h.
Referenced by addDataCallableMethod(), addDataCallableMethod(), and getDataFunction().
|
private |
Map of messages which have to be confirmed by destination Daemon.
Definition at line 184 of file BaseDaemon.h.
Referenced by addMessageToConfirm(), checkMessageTimeout(), getMapMessageToBeConfirmed(), getMessageToConfirm(), and processConfirmedMessage().
|
private |
Id counter of the message of the current Daemon.
Definition at line 186 of file BaseDaemon.h.
Referenced by getMessageId(), and initialisationBaseDaemon().
|
private |
Option parser of the Daemon.
Definition at line 180 of file BaseDaemon.h.
Referenced by BaseDaemon(), getOptionParser(), initialisationBaseDaemon(), and parseArgument().