Clio
develop
The XRP Ledger API server.
Theme:
Default
Round
Robot
Toggle main menu visibility
Loading...
Searching...
No Matches
WriterDecider.hpp
1
#pragma once
2
3
#include "cluster/Backend.hpp"
4
#include "cluster/ClioNode.hpp"
5
#include "cluster/impl/FallbackRecoveryTimer.hpp"
6
#include "etl/WriterState.hpp"
7
8
#include <boost/asio/thread_pool.hpp>
9
10
#include <chrono>
11
#include <memory>
12
13
namespace
cluster
{
14
64
class
WriterDecider
{
65
public
:
69
static
constexpr
std::chrono::steady_clock::duration
kRecoveryTime
= std::chrono::hours{1};
70
71
private
:
75
boost::asio::thread_pool& ctx_;
76
80
std::unique_ptr<etl::WriterStateInterface> writerState_;
81
91
impl::FallbackRecoveryTimer
fallbackRecoveryTimer_;
92
93
public
:
102
WriterDecider
(
103
boost::asio::thread_pool& ctx,
104
std::unique_ptr<etl::WriterStateInterface> writerState,
105
std::chrono::steady_clock::duration recoveryTime =
kRecoveryTime
106
);
107
133
void
134
onNewState
(
ClioNode::CUuid
selfId, std::shared_ptr<Backend::ClusterData const> clusterData);
135
};
136
137
}
// namespace cluster
cluster::WriterDecider::WriterDecider
WriterDecider(boost::asio::thread_pool &ctx, std::unique_ptr< etl::WriterStateInterface > writerState, std::chrono::steady_clock::duration recoveryTime=kRecoveryTime)
Constructs a WriterDecider.
Definition
WriterDecider.cpp:41
cluster::WriterDecider::onNewState
void onNewState(ClioNode::CUuid selfId, std::shared_ptr< Backend::ClusterData const > clusterData)
Handles cluster state changes and decides whether this node should be the writer.
Definition
WriterDecider.cpp:51
cluster::WriterDecider::kRecoveryTime
static constexpr std::chrono::steady_clock::duration kRecoveryTime
Default time spent in Fallback before attempting to recover to election mode.
Definition
WriterDecider.hpp:69
cluster::impl::FallbackRecoveryTimer
One-shot timer for fallback recovery, with internal thread-safety.
Definition
FallbackRecoveryTimer.hpp:24
cluster
This namespace implements cluster coordination between Clio nodes.
Definition
Backend.cpp:24
cluster::ClioNode::CUuid
std::shared_ptr< boost::uuids::uuid const > CUuid
Shared read-only node UUID.
Definition
ClioNode.hpp:50
src
cluster
WriterDecider.hpp
Generated by
1.17.0