6#ifndef OPENCBDC_TX_SRC_RAFT_STATE_MANAGER_H_
7#define OPENCBDC_TX_SRC_RAFT_STATE_MANAGER_H_
12#include <libnuraft/nuraft.hxx>
26 std::string config_file,
27 std::string state_file,
28 std::vector<network::endpoint_t> raft_endpoints);
39 auto load_config() -> nuraft::ptr<nuraft::cluster_config>
override;
43 void save_config(
const nuraft::cluster_config& config)
override;
47 void save_state(
const nuraft::srv_state& state)
override;
51 auto read_state() -> nuraft::ptr<nuraft::srv_state>
override;
67 std::string m_config_file;
68 std::string m_state_file;
69 std::string m_log_dir;
70 std::vector<network::endpoint_t> m_raft_endpoints;
Implementation of nuraft::state_mgr using a file.
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.
void save_state(const nuraft::srv_state &state) override
Serialize and write the given server state.
auto operator=(state_manager &&other) noexcept -> state_manager &
void save_config(const nuraft::cluster_config &config) override
Serialize and write the given cluster configuration.
auto read_state() -> nuraft::ptr< nuraft::srv_state > override
Read and deserialize the server state.
auto operator=(const state_manager &other) -> state_manager &=delete
auto load_config() -> nuraft::ptr< nuraft::cluster_config > override
Read and deserialize the cluster configuration.
auto load_log_store() -> nuraft::ptr< nuraft::log_store > override
Load and return the log store.
state_manager(const state_manager &other)=delete
state_manager(state_manager &&other) noexcept
~state_manager() override=default
void system_exit(int exit_code) override
Terminate the application with the given exit code.
auto server_id() -> int32_t override
Return the server ID.