Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
etl::WriterState Class Reference

Implementation of WriterStateInterface that manages ETL writer state. More...

#include <WriterState.hpp>

Inheritance diagram for etl::WriterState:
Collaboration diagram for etl::WriterState:

Public Member Functions

 WriterState (std::shared_ptr< SystemState > state, data::LedgerCacheInterface const &cache)
 Construct a WriterState with the given system state and cache.
bool isReadOnly () const override
 Check if the ETL process is in strict read-only mode.
bool isWriting () const override
 Check if the ETL process is currently writing to the database.
void startWriting () override
 Request to start writing to the database.
void giveUpWriting () override
 Request to stop writing to the database.
void setWriterDecidingFallback () override
 Switch the cluster to the fallback writer decision mechanism.
bool isFallback () const override
 Check if the cluster is using the fallback writer decision mechanism.
bool isFallbackRecovery () const override
 Check if this node is in fallback recovery mode.
void setFallbackRecovery (bool newValue) override
 Set or clear the fallback recovery flag.
bool isEtlStarted () const override
 Whether the ETL monitor has started and the node is ready to become a writer.
bool isCacheFull () const override
 Whether the ledger cache is fully loaded.
std::unique_ptr< WriterStateInterfaceclone () const override
 Create a clone of this writer state.

Detailed Description

Implementation of WriterStateInterface that manages ETL writer state.

This class coordinates with SystemState to manage whether the ETL process is actively writing to the database. It provides methods to query the current writing state and request transitions between writing and non-writing states.

Constructor & Destructor Documentation

◆ WriterState()

etl::WriterState::WriterState ( std::shared_ptr< SystemState > state,
data::LedgerCacheInterface const & cache )

Construct a WriterState with the given system state and cache.

Parameters
stateShared pointer to the system state for coordination
cacheThe ledger cache used to report cache fullness

Member Function Documentation

◆ clone()

std::unique_ptr< WriterStateInterface > etl::WriterState::clone ( ) const
overridevirtual

Create a clone of this writer state.

Creates a new WriterState instance sharing the same system state.

Returns
A unique pointer to the cloned writer state.

Implements etl::WriterStateInterface.

◆ giveUpWriting()

void etl::WriterState::giveUpWriting ( )
overridevirtual

Request to stop writing to the database.

If not currently writing, this method does nothing. Otherwise, it sets the shouldGiveUpWriter flag in the system state to signal the request.

Implements etl::WriterStateInterface.

◆ isCacheFull()

bool etl::WriterState::isCacheFull ( ) const
overridevirtual

Whether the ledger cache is fully loaded.

Returns
true if the cache is full, false otherwise.

Implements etl::WriterStateInterface.

◆ isEtlStarted()

bool etl::WriterState::isEtlStarted ( ) const
overridevirtual

Whether the ETL monitor has started and the node is ready to become a writer.

Returns
true if ETL has started the monitor loop, false otherwise.

Implements etl::WriterStateInterface.

◆ isFallback()

bool etl::WriterState::isFallback ( ) const
overridevirtual

Check if the cluster is using the fallback writer decision mechanism.

Returns
true if the cluster has switched to fallback mode, false otherwise

Implements etl::WriterStateInterface.

◆ isFallbackRecovery()

bool etl::WriterState::isFallbackRecovery ( ) const
overridevirtual

Check if this node is in fallback recovery mode.

Fallback recovery is an intermediate state entered when the node has been in fallback mode long enough to attempt returning to election-based writer selection. In this state the node continues participating in the fallback write-race while coordinating with other nodes to exit fallback together.

Returns
true if the node is in fallback recovery mode, false otherwise

Implements etl::WriterStateInterface.

◆ isReadOnly()

bool etl::WriterState::isReadOnly ( ) const
overridevirtual

Check if the ETL process is in strict read-only mode.

Returns
true if the process is in strict read-only mode, false otherwise

Implements etl::WriterStateInterface.

◆ isWriting()

bool etl::WriterState::isWriting ( ) const
overridevirtual

Check if the ETL process is currently writing to the database.

Returns
true if the process is writing, false otherwise

Implements etl::WriterStateInterface.

◆ setFallbackRecovery()

void etl::WriterState::setFallbackRecovery ( bool newValue)
overridevirtual

Set or clear the fallback recovery flag.

When newValue is true, the node enters fallback recovery mode:

  • isFallbackRecovery returns true
  • The plain fallback flag (isFallback) is cleared so the node no longer publishes DbRole::Fallback; it publishes DbRole::FallbackRecovery instead.

When newValue is false, the recovery flag is cleared without touching the plain fallback flag. This is used when the recovery coordination completes and the node transitions back to election mode.

Parameters
newValuetrue to enter recovery mode, false to leave it

Implements etl::WriterStateInterface.

◆ setWriterDecidingFallback()

void etl::WriterState::setWriterDecidingFallback ( )
overridevirtual

Switch the cluster to the fallback writer decision mechanism.

Sets the isWriterDecidingFallback flag in the system state, which will be propagated to other nodes in the cluster through the ClioNode DbRole::Fallback state.

Implements etl::WriterStateInterface.

◆ startWriting()

void etl::WriterState::startWriting ( )
overridevirtual

Request to start writing to the database.

If already writing, this method does nothing. Otherwise, it sets the shouldTakeoverWriting flag in the system state to signal the request.

Implements etl::WriterStateInterface.


The documentation for this class was generated from the following files:
  • /__w/clio/clio/src/etl/WriterState.hpp
  • /__w/clio/clio/src/etl/WriterState.cpp