Leosac  0.8.0
Open Source Access Control
Leosac::Module::Replication::ReplicationModule Class Reference

Main class for the replication module. More...

#include <ReplicationModule.hpp>

+ Inheritance diagram for Leosac::Module::Replication::ReplicationModule:
+ Collaboration diagram for Leosac::Module::Replication::ReplicationModule:

Public Member Functions

 ReplicationModule (zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
 
 ReplicationModule (const ReplicationModule &)=delete
 
 ReplicationModule (ReplicationModule &&)=delete
 
ReplicationModuleoperator= (const ReplicationModule &)=delete
 
ReplicationModuleoperator= (ReplicationModule &&)=delete
 
virtual void run () override
 This is the main loop of the module. More...
 
- Public Member Functions inherited from Leosac::Module::BaseModule
 BaseModule (zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
 Constructor of BaseModule. More...
 
virtual ~BaseModule ()=default
 

Private Types

using TimePoint = std::chrono::system_clock::time_point
 

Private Member Functions

void process_config ()
 
void replicate ()
 Start the replication process. More...
 
void start_sync ()
 Launch the tasks so that the synchronisation may take place. More...
 
bool fetch_local_version (uint64_t &local)
 Fetch the local configuration version by running a task in the main thread. More...
 
bool fetch_remote_version (uint64_t &remote)
 Fetch the remote configuration version by running a task in a pool, and sending the CONFIG_VERSION message. More...
 

Private Attributes

int delay_
 Delay between 2 replications attempt. More...
 
std::string endpoint_
 Target master server. More...
 
std::string pubkey_
 Master server's public key. More...
 
TimePoint last_sync_
 

Additional Inherited Members

- Protected Member Functions inherited from Leosac::Module::BaseModule
virtual void handle_pipe ()
 The base class register the pipe_ socket to its reactor_ so that this function is called when the pipe_ is available from reading. More...
 
virtual void handle_control ()
 Handle called when a message on the module's control socket arrives. More...
 
virtual void dump_additional_config (zmqpp::message *out) const
 Dump additional configuration (for example module specific config file). More...
 
void dump_config (ConfigManager::ConfigFormat fmt, zmqpp::message *out_msg) const
 Fills a message with the module's configuration information. More...
 
void config_check (const std::string &obj_name, Leosac::Hardware::DeviceClass type)
 An helper that checks configuration the existence of some objects. More...
 
void config_check (const std::string &obj_name)
 An helper that checks configuration the existence of some objects. More...
 
- Protected Attributes inherited from Leosac::Module::BaseModule
zmqpp::context & ctx_
 A reference to the ZeroMQ context in case you need it to create additional socket. More...
 
zmqpp::socket & pipe_
 A reference to the pair socket that link back to the module manager. More...
 
boost::property_tree::ptree config_
 The configuration tree passed to the start_module function. More...
 
CoreUtilsPtr utils_
 Pointer to the core utils, which gives access to scheduler and others. More...
 
bool is_running_
 Boolean indicating whether the main loop should run or not. More...
 
zmqpp::socket control_
 Control REP socket. More...
 
zmqpp::reactor reactor_
 The reactor object we poll() on in the main loop. More...
 
std::string name_
 

Detailed Description

Main class for the replication module.

Definition at line 40 of file ReplicationModule.hpp.

Member Typedef Documentation

◆ TimePoint

using Leosac::Module::Replication::ReplicationModule::TimePoint = std::chrono::system_clock::time_point
private

Definition at line 54 of file ReplicationModule.hpp.

Constructor & Destructor Documentation

◆ ReplicationModule() [1/3]

ReplicationModule::ReplicationModule ( zmqpp::context &  ctx,
zmqpp::socket *  pipe,
const boost::property_tree::ptree &  cfg,
CoreUtilsPtr  utils 
)

Definition at line 31 of file ReplicationModule.cpp.

◆ ReplicationModule() [2/3]

Leosac::Module::Replication::ReplicationModule::ReplicationModule ( const ReplicationModule )
delete

◆ ReplicationModule() [3/3]

Leosac::Module::Replication::ReplicationModule::ReplicationModule ( ReplicationModule &&  )
delete

Member Function Documentation

◆ fetch_local_version()

bool ReplicationModule::fetch_local_version ( uint64_t &  local)
private

Fetch the local configuration version by running a task in the main thread.

Definition at line 92 of file ReplicationModule.cpp.

◆ fetch_remote_version()

bool ReplicationModule::fetch_remote_version ( uint64_t &  remote)
private

Fetch the remote configuration version by running a task in a pool, and sending the CONFIG_VERSION message.

Definition at line 103 of file ReplicationModule.cpp.

◆ operator=() [1/2]

ReplicationModule& Leosac::Module::Replication::ReplicationModule::operator= ( const ReplicationModule )
delete

◆ operator=() [2/2]

ReplicationModule& Leosac::Module::Replication::ReplicationModule::operator= ( ReplicationModule &&  )
delete

◆ process_config()

void ReplicationModule::process_config ( )
private

Definition at line 56 of file ReplicationModule.cpp.

◆ replicate()

void ReplicationModule::replicate ( )
private

Start the replication process.

It first checks if it needs to sync, and if it doesn't, it stops here.

Definition at line 63 of file ReplicationModule.cpp.

◆ run()

void ReplicationModule::run ( )
overridevirtual

This is the main loop of the module.

It should only exit when receiving signal::stop on its pipe_ socket. This is completely handled by this base class. In case you override this, make sure you watch the pipe_ socket.

Reimplemented from Leosac::Module::BaseModule.

Definition at line 40 of file ReplicationModule.cpp.

◆ start_sync()

void ReplicationModule::start_sync ( )
private

Launch the tasks so that the synchronisation may take place.

Definition at line 129 of file ReplicationModule.cpp.

Member Data Documentation

◆ delay_

int Leosac::Module::Replication::ReplicationModule::delay_
private

Delay between 2 replications attempt.

Definition at line 85 of file ReplicationModule.hpp.

◆ endpoint_

std::string Leosac::Module::Replication::ReplicationModule::endpoint_
private

Target master server.

Definition at line 90 of file ReplicationModule.hpp.

◆ last_sync_

TimePoint Leosac::Module::Replication::ReplicationModule::last_sync_
private

Definition at line 97 of file ReplicationModule.hpp.

◆ pubkey_

std::string Leosac::Module::Replication::ReplicationModule::pubkey_
private

Master server's public key.

Definition at line 95 of file ReplicationModule.hpp.


The documentation for this class was generated from the following files: