Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
ClioNode.hpp
1#pragma once
2
3#include "data/LedgerCacheLoadingState.hpp"
4#include "etl/WriterState.hpp"
5
6#include <boost/json/conversion.hpp>
7#include <boost/json/value.hpp>
8#include <boost/uuid/uuid.hpp>
9
10#include <chrono>
11#include <memory>
12
13namespace cluster {
14
18struct ClioNode {
22 static constexpr char const* kTimeFormat = "%Y-%m-%dT%H:%M:%SZ";
23
40 enum class DbRole {
43 Writer = 2,
46 Max = 4,
47 };
48
49 using Uuid = std::shared_ptr<boost::uuids::uuid>;
50 using CUuid = std::shared_ptr<boost::uuids::uuid const>;
51
53 std::chrono::system_clock::time_point
59
68 static ClioNode
69 from(
70 Uuid uuid,
71 etl::WriterStateInterface const& writerState,
72 data::LedgerCacheLoadingStateInterface const& cacheLoadingState
73 );
74};
75
84void
85tag_invoke(boost::json::value_from_tag, boost::json::value& jv, ClioNode const& node);
86
99tag_invoke(boost::json::value_to_tag<ClioNode>, boost::json::value const& jv);
100
101} // namespace cluster
Interface for coordinating cache loading permissions across a cluster.
Definition LedgerCacheLoadingState.hpp:18
Interface for managing writer state in the ETL subsystem.
Definition WriterState.hpp:21
This namespace implements cluster coordination between Clio nodes.
Definition Backend.cpp:24
void tag_invoke(boost::json::value_from_tag, boost::json::value &jv, ClioNode const &node)
Convert a ClioNode to a JSON object.
Definition ClioNode.cpp:66
Represents a node in the cluster.
Definition ClioNode.hpp:18
bool etlStarted
Whether the ETL monitor has started on this node.
Definition ClioNode.hpp:56
bool cacheIsCurrentlyLoading
Whether this node is currently loading the ledger cache.
Definition ClioNode.hpp:58
bool cacheIsFull
Whether the ledger cache is fully loaded on this node.
Definition ClioNode.hpp:57
Uuid uuid
The UUID of the node.
Definition ClioNode.hpp:52
DbRole dbRole
The database role of the node.
Definition ClioNode.hpp:55
static constexpr char const * kTimeFormat
The format of the time to store in the database.
Definition ClioNode.hpp:22
std::shared_ptr< boost::uuids::uuid > Uuid
Shared node UUID.
Definition ClioNode.hpp:49
std::chrono::system_clock::time_point updateTime
The time the data about the node was last updated.
Definition ClioNode.hpp:54
DbRole
Database role of a node in the cluster.
Definition ClioNode.hpp:40
@ ReadOnly
Node never writes to the database.
Definition ClioNode.hpp:41
@ FallbackRecovery
Node is coordinating a return from fallback to election mode.
Definition ClioNode.hpp:45
@ Max
Highest valid role value; used for validation.
Definition ClioNode.hpp:46
@ Fallback
Node uses the database-based fallback writer decision.
Definition ClioNode.hpp:44
@ NotWriter
Node can write but is not the designated writer.
Definition ClioNode.hpp:42
@ Writer
Node is actively writing to the database.
Definition ClioNode.hpp:43
static ClioNode from(Uuid uuid, etl::WriterStateInterface const &writerState, data::LedgerCacheLoadingStateInterface const &cacheLoadingState)
Create a ClioNode from writer state and cache loading state.
Definition ClioNode.cpp:35
std::shared_ptr< boost::uuids::uuid const > CUuid
Shared read-only node UUID.
Definition ClioNode.hpp:50