OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::raft::state_manager Class Reference

Implementation of nuraft::state_mgr using a file. More...

#include <state_manager.hpp>

Inheritance diagram for cbdc::raft::state_manager:
Collaboration diagram for cbdc::raft::state_manager:

Public Member Functions

 state_manager (int32_t srv_id, std::string log_dir, std::string config_file, std::string state_file, std::vector< network::endpoint_t > raft_endpoints)
 Constructor.
 
 ~state_manager () override=default
 
 state_manager (const state_manager &other)=delete
 
auto operator= (const state_manager &other) -> state_manager &=delete
 
 state_manager (state_manager &&other) noexcept
 
auto operator= (state_manager &&other) noexcept -> state_manager &
 
auto load_config () -> nuraft::ptr< nuraft::cluster_config > override
 Read and deserialize the cluster configuration.
 
void save_config (const nuraft::cluster_config &config) override
 Serialize and write the given cluster configuration.
 
void save_state (const nuraft::srv_state &state) override
 Serialize and write the given server state.
 
auto read_state () -> nuraft::ptr< nuraft::srv_state > override
 Read and deserialize the server state.
 
auto load_log_store () -> nuraft::ptr< nuraft::log_store > override
 Load and return the log store.
 
auto server_id () -> int32_t override
 Return the server ID.
 
void system_exit (int exit_code) override
 Terminate the application with the given exit code.
 

Detailed Description

Implementation of nuraft::state_mgr using a file.

Definition at line 16 of file state_manager.hpp.

Constructor & Destructor Documentation

◆ state_manager() [1/3]

cbdc::raft::state_manager::state_manager ( int32_t srv_id,
std::string log_dir,
std::string config_file,
std::string state_file,
std::vector< network::endpoint_t > raft_endpoints )

Constructor.

Parameters
srv_idID of the raft node.
log_dirdirectory for the raft log.
config_filefile for the cluster configuration.
state_filefile for the server state.
raft_endpointslist of initial node endpoints in the cluster.

Definition at line 16 of file state_manager.cpp.

◆ ~state_manager()

cbdc::raft::state_manager::~state_manager ( )
overridedefault

◆ state_manager() [2/3]

cbdc::raft::state_manager::state_manager ( const state_manager & other)
delete

◆ state_manager() [3/3]

cbdc::raft::state_manager::state_manager ( state_manager && other)
noexcept

Member Function Documentation

◆ load_config()

auto cbdc::raft::state_manager::load_config ( ) -> nuraft::ptr<nuraft::cluster_config>
override

Read and deserialize the cluster configuration.

Returns
cluster configuration, or nullptr if the file is empty.

Definition at line 66 of file state_manager.cpp.

References cbdc::raft::load_object().

Here is the call graph for this function:

◆ load_log_store()

auto cbdc::raft::state_manager::load_log_store ( ) -> nuraft::ptr<nuraft::log_store>
override

Load and return the log store.

Returns
log store instance, or nullptr if loading failed.

Definition at line 101 of file state_manager.cpp.

◆ operator=() [1/2]

auto cbdc::raft::state_manager::operator= ( const state_manager & other) -> state_manager &=delete
delete

◆ operator=() [2/2]

auto cbdc::raft::state_manager::operator= ( state_manager && other) -> state_manager &
noexcept

◆ read_state()

auto cbdc::raft::state_manager::read_state ( ) -> nuraft::ptr<nuraft::srv_state>
override

Read and deserialize the server state.

Returns
server state, or nullptr if the file is empty.

Definition at line 96 of file state_manager.cpp.

References cbdc::raft::load_object().

Here is the call graph for this function:

◆ save_config()

void cbdc::raft::state_manager::save_config ( const nuraft::cluster_config & config)
override

Serialize and write the given cluster configuration.

Parameters
configcluster configuration.

Definition at line 88 of file state_manager.cpp.

References cbdc::raft::save_object().

Here is the call graph for this function:

◆ save_state()

void cbdc::raft::state_manager::save_state ( const nuraft::srv_state & state)
override

Serialize and write the given server state.

Parameters
stateserver state.

Definition at line 92 of file state_manager.cpp.

References cbdc::raft::save_object().

Here is the call graph for this function:

◆ server_id()

auto cbdc::raft::state_manager::server_id ( ) -> int32_t
override

Return the server ID.

Returns
server ID.

Definition at line 110 of file state_manager.cpp.

◆ system_exit()

void cbdc::raft::state_manager::system_exit ( int exit_code)
override

Terminate the application with the given exit code.

Parameters
exit_codeapplication return code.

Definition at line 114 of file state_manager.cpp.


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