OpenCBDC Transaction Processor
|
Replicated coordinator node. More...
#include <controller.hpp>
Data Structures | |
struct | coordinator_state |
Current state of distributed transactions managed by a coordinator. More... | |
struct | sm_command |
A full command for the state machine to process. More... | |
struct | sm_command_header |
Metadata of a command for the state machine. More... | |
Public Types | |
using | send_fn_t |
using | prepare_tx = std::vector<transaction::compact_tx> |
List of compact transactions associated with a distributed transaction in the prepare phase. | |
using | prepare_txs |
Map from distributed transaction IDs in the prepare phase to the associated compact transactions. | |
using | commit_tx = std::pair<std::vector<bool>, std::vector<std::vector<uint64_t>>> |
Aggregated responses and metadata from the prepare phase. | |
using | commit_txs |
Map from distributed transaction IDs in the commit phase to the associated responses and metadata from the prepare phase. | |
using | discard_txs = std::unordered_set<hash_t, hashing::const_sip_hash<hash_t>> |
Set of distributed transaction IDs in the discard phase. | |
![]() | |
using | callback_type = std::function<void(std::optional<bool>)> |
Signature of callback function for a transaction execution result. | |
Public Member Functions | |
controller (size_t node_id, size_t coordinator_id, cbdc::config::options opts, std::shared_ptr< logging::log > logger) | |
Constructs a new replicated coordinator node. | |
controller ()=delete | |
controller (const controller &)=delete | |
auto | operator= (const controller &) -> controller &=delete |
controller (controller &&)=delete | |
auto | operator= (controller &&) -> controller &=delete |
~controller () override | |
auto | init () -> bool |
Starts the replicated coordinator and associated raft server. | |
void | quit () |
Terminates the replicated coordinator instance. | |
auto | execute_transaction (transaction::compact_tx tx, callback_type result_callback) -> bool override |
Coordinates a transaction among locking shards. | |
![]() | |
virtual | ~interface ()=default |
interface ()=default | |
interface (const interface &)=delete | |
auto | operator= (const interface &) -> interface &=delete |
interface (interface &&)=delete | |
auto | operator= (interface &&) -> interface &=delete |
Replicated coordinator node.
Participates in a raft cluster with other replicated coordinators. When acting as the leader, listens on a specified endpoint and handles new transaction requests from sentinels. Recovers failed dtxs as part of its leadership transition.
Definition at line 27 of file uhs/twophase/coordinator/controller.hpp.
using cbdc::coordinator::controller::commit_tx = std::pair<std::vector<bool>, std::vector<std::vector<uint64_t>>> |
Aggregated responses and metadata from the prepare phase.
First is a vector of bools, true if the transaction at the same index in the batch should be completed, false if it should be aborted. Second is a vector, one element for each shard ID, specifying which transaction indexes in the batch are revelant to the shard.
Definition at line 72 of file uhs/twophase/coordinator/controller.hpp.
Map from distributed transaction IDs in the commit phase to the associated responses and metadata from the prepare phase.
Definition at line 76 of file uhs/twophase/coordinator/controller.hpp.
using cbdc::coordinator::controller::discard_txs = std::unordered_set<hash_t, hashing::const_sip_hash<hash_t>> |
Set of distributed transaction IDs in the discard phase.
Definition at line 80 of file uhs/twophase/coordinator/controller.hpp.
using cbdc::coordinator::controller::prepare_tx = std::vector<transaction::compact_tx> |
List of compact transactions associated with a distributed transaction in the prepare phase.
Definition at line 60 of file uhs/twophase/coordinator/controller.hpp.
Map from distributed transaction IDs in the prepare phase to the associated compact transactions.
Definition at line 64 of file uhs/twophase/coordinator/controller.hpp.
Definition at line 29 of file uhs/twophase/coordinator/controller.hpp.
cbdc::coordinator::controller::controller | ( | size_t | node_id, |
size_t | coordinator_id, | ||
cbdc::config::options | opts, | ||
std::shared_ptr< logging::log > | logger ) |
Constructs a new replicated coordinator node.
node_id | raft node ID in the coordinator cluster. |
coordinator_id | ID to determine which coordinator cluster this node is part of. |
opts | configuration options. |
logger | pointer to shared logger. |
Definition at line 18 of file uhs/twophase/coordinator/controller.cpp.
References cbdc::config::options::m_election_timeout_lower, cbdc::config::options::m_election_timeout_upper, cbdc::config::options::m_heartbeat, and cbdc::config::options::m_raft_max_batch.
|
delete |
|
delete |
|
delete |
|
override |
Definition at line 42 of file uhs/twophase/coordinator/controller.cpp.
References quit().
|
overridevirtual |
Coordinates a transaction among locking shards.
Adds a transaction to the current batch. Registers a callback function to return the transaction execution result once the shards completely process the batch.
tx | transaction to execute. |
result_callback | function to call with the result once execution is complete. |
Implements cbdc::coordinator::interface.
Definition at line 684 of file uhs/twophase/coordinator/controller.cpp.
References cbdc::transaction::validation::check_attestations(), and cbdc::to_string().
auto cbdc::coordinator::controller::init | ( | ) | -> bool |
Starts the replicated coordinator and associated raft server.
Definition at line 46 of file uhs/twophase/coordinator/controller.cpp.
|
delete |
|
delete |
void cbdc::coordinator::controller::quit | ( | ) |
Terminates the replicated coordinator instance.
Definition at line 656 of file uhs/twophase/coordinator/controller.cpp.
Referenced by ~controller().