Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
cluster::CacheLoaderDecider Class Reference

Decides which node in the cluster should load the ledger cache. More...

#include <CacheLoaderDecider.hpp>

Public Member Functions

 CacheLoaderDecider (boost::asio::thread_pool &ctx, std::unique_ptr< data::LedgerCacheLoadingStateInterface > cacheLoadingState)
 Constructs a CacheLoaderDecider.
void onNewState (ClioNode::CUuid selfId, std::shared_ptr< Backend::ClusterData const > clusterData)
 Handles cluster state changes and decides whether this node should load the cache.

Detailed Description

Decides which node in the cluster should load the ledger cache.

This class monitors cluster state changes and determines whether the current node should begin loading the ledger cache from the backend. The decision is made by:

  1. Doing nothing if this node's cache is already full
  2. Doing nothing if any node in the cluster is currently loading the cache
  3. Sorting all nodes whose cache is not yet full by UUID for deterministic ordering
  4. Permitting loading on this node if it is the first in the sorted list

This ensures at most one node in the cluster loads the cache at a time.

Constructor & Destructor Documentation

◆ CacheLoaderDecider()

cluster::CacheLoaderDecider::CacheLoaderDecider ( boost::asio::thread_pool & ctx,
std::unique_ptr< data::LedgerCacheLoadingStateInterface > cacheLoadingState )

Constructs a CacheLoaderDecider.

Parameters
ctxThread pool for executing asynchronous operations
cacheLoadingStateCache loading state interface for permitting cache load

Member Function Documentation

◆ onNewState()

void cluster::CacheLoaderDecider::onNewState ( ClioNode::CUuid selfId,
std::shared_ptr< Backend::ClusterData const > clusterData )

Handles cluster state changes and decides whether this node should load the cache.

This method is called when cluster state changes. It asynchronously:

  • Does nothing if this node's cache is already full
  • Does nothing if any node in the cluster is currently loading the cache
  • Sorts all not-yet-full nodes by UUID to establish a deterministic order
  • Permits cache loading on this node if it is first in the sorted list
Parameters
selfIdThe UUID of the current node
clusterDataShared pointer to current cluster data; may be empty if communication failed

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