OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
cbdc::coordinator::state_machine Class Referencefinal

Raft state machine for managing a replicated coordinator. More...

#include <state_machine.hpp>

Inheritance diagram for cbdc::coordinator::state_machine:
Collaboration diagram for cbdc::coordinator::state_machine:

Data Structures

struct  coordinator_state
 Used to store dtxs, which phase they are in and relevant data require for recovery. More...
 

Public Types

enum class  command : uint8_t {
  prepare = 0 , commit = 1 , discard = 2 , done = 3 ,
  get = 4
}
 Types of command the state machine can process. More...
 

Public Member Functions

 state_machine (std::shared_ptr< logging::log > logger)
 Constructor.
 
auto commit (uint64_t log_idx, nuraft::buffer &data) -> nuraft::ptr< nuraft::buffer > override
 Commits a state machine command.
 
void commit_config (nuraft::ulong log_idx, nuraft::ptr< nuraft::cluster_config > &) override
 Handler for the raft cluster configuration changes.
 
auto apply_snapshot (nuraft::snapshot &) -> bool override
 Not implemented for coordinators.
 
auto last_snapshot () -> nuraft::ptr< nuraft::snapshot > override
 Not implemented for coordinators.
 
auto last_commit_index () -> uint64_t override
 Returns the index of the last-committed command.
 
void create_snapshot (nuraft::snapshot &, nuraft::async_result< bool >::handler_type &when_done) override
 Not implemented for coordinators.
 

Detailed Description

Raft state machine for managing a replicated coordinator.

Contains a coordinator_state and the last-committed index. Accepts requests to manage and query distributed transactions.

Definition at line 21 of file uhs/twophase/coordinator/state_machine.hpp.

Member Enumeration Documentation

◆ command

enum class cbdc::coordinator::state_machine::command : uint8_t
strong

Types of command the state machine can process.

Enumerator
prepare 

Stores a dtx in the prepare phase.

commit 

Moves a dtx from prepare to commit.

discard 

Moves a dtx from commit to discard.

done 

Clears the dtx from the coordinator state.

get 

Retrieves all active dtxs.

Definition at line 30 of file uhs/twophase/coordinator/state_machine.hpp.

Constructor & Destructor Documentation

◆ state_machine()

cbdc::coordinator::state_machine::state_machine ( std::shared_ptr< logging::log > logger)
explicit

Constructor.

Constructs a new coordinator state machine.

Parameters
loggerpointer to logger instance.

Definition at line 122 of file uhs/twophase/coordinator/state_machine.cpp.

Member Function Documentation

◆ apply_snapshot()

auto cbdc::coordinator::state_machine::apply_snapshot ( nuraft::snapshot & ) -> bool
override

Not implemented for coordinators.

Returns
false (unconditionally).

Definition at line 101 of file uhs/twophase/coordinator/state_machine.cpp.

◆ commit()

auto cbdc::coordinator::state_machine::commit ( uint64_t log_idx,
nuraft::buffer & data ) -> nuraft::ptr<nuraft::buffer>
override

Commits a state machine command.

Parameters
log_idxindex of raft entry.
datathe buffer containing the command to commit.
Returns
pointer to a buffer with the serialized execution result or nullptr.

Definition at line 14 of file uhs/twophase/coordinator/state_machine.cpp.

References cbdc::serialized_size(), and cbdc::to_string().

Here is the call graph for this function:

◆ commit_config()

void cbdc::coordinator::state_machine::commit_config ( nuraft::ulong log_idx,
nuraft::ptr< nuraft::cluster_config > &  )
override

Handler for the raft cluster configuration changes.

Parameters
log_idxRaft log number of the configuration change.

Definition at line 94 of file uhs/twophase/coordinator/state_machine.cpp.

◆ create_snapshot()

void cbdc::coordinator::state_machine::create_snapshot ( nuraft::snapshot & ,
nuraft::async_result< bool >::handler_type & when_done )
override

Not implemented for coordinators.

Definition at line 114 of file uhs/twophase/coordinator/state_machine.cpp.

◆ last_commit_index()

auto cbdc::coordinator::state_machine::last_commit_index ( ) -> uint64_t
override

Returns the index of the last-committed command.

Definition at line 110 of file uhs/twophase/coordinator/state_machine.cpp.

◆ last_snapshot()

auto cbdc::coordinator::state_machine::last_snapshot ( ) -> nuraft::ptr<nuraft::snapshot>
override

Not implemented for coordinators.

Returns
nullptr (unconditionally).

Definition at line 106 of file uhs/twophase/coordinator/state_machine.cpp.


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