rippled
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | Static Private Attributes | List of all members
xrpl::NetworkOPsImp::StateAccounting Class Reference

State accounting records two attributes for each possible server state: 1) Amount of time spent in each state (in microseconds). More...

Collaboration diagram for xrpl::NetworkOPsImp::StateAccounting:
Collaboration graph
[legend]

Classes

struct  CounterData
 
struct  Counters
 

Public Member Functions

 StateAccounting ()
 
void mode (OperatingMode om)
 Record state transition.
 
void json (Json::Value &obj) const
 Output state counters in JSON format.
 
CounterData getCounterData () const
 

Private Attributes

OperatingMode mode_ = OperatingMode::DISCONNECTED
 
std::array< Counters, 5 > counters_
 
std::mutex mutex_
 
std::chrono::steady_clock::time_point start_
 
std::chrono::steady_clock::time_point const processStart_ = start_
 
std::uint64_t initialSyncUs_ {0}
 

Static Private Attributes

static std::array< Json::StaticString const, 5 > const states_
 

Detailed Description

State accounting records two attributes for each possible server state: 1) Amount of time spent in each state (in microseconds).

This value is updated upon each state transition. 2) Number of transitions to each state.

This data can be polled through server_info and represented by monitoring systems similarly to how bandwidth, CPU, and other counter-based metrics are managed.

State accounting is more accurate than periodic sampling of server state. With periodic sampling, it is very likely that state transitions are missed, and accuracy of time spent in each state is very rough.

Definition at line 124 of file NetworkOPs.cpp.

Constructor & Destructor Documentation

◆ StateAccounting()

xrpl::NetworkOPsImp::StateAccounting::StateAccounting ( )
explicit

Definition at line 144 of file NetworkOPs.cpp.

Member Function Documentation

◆ mode()

void xrpl::NetworkOPsImp::StateAccounting::mode ( OperatingMode  om)

Record state transition.

Update duration spent in previous state.

Parameters
omNew state.

Definition at line 4823 of file NetworkOPs.cpp.

◆ json()

void xrpl::NetworkOPsImp::StateAccounting::json ( Json::Value obj) const

Output state counters in JSON format.

@obj Json object to which to add state accounting data.

Definition at line 4844 of file NetworkOPs.cpp.

◆ getCounterData()

CounterData xrpl::NetworkOPsImp::StateAccounting::getCounterData ( ) const

Definition at line 176 of file NetworkOPs.cpp.

Member Data Documentation

◆ mode_

OperatingMode xrpl::NetworkOPsImp::StateAccounting::mode_ = OperatingMode::DISCONNECTED
private

Definition at line 134 of file NetworkOPs.cpp.

◆ counters_

std::array<Counters, 5> xrpl::NetworkOPsImp::StateAccounting::counters_
private

Definition at line 135 of file NetworkOPs.cpp.

◆ mutex_

std::mutex xrpl::NetworkOPsImp::StateAccounting::mutex_
mutableprivate

Definition at line 136 of file NetworkOPs.cpp.

◆ start_

std::chrono::steady_clock::time_point xrpl::NetworkOPsImp::StateAccounting::start_
private
Initial value:

Definition at line 137 of file NetworkOPs.cpp.

◆ processStart_

std::chrono::steady_clock::time_point const xrpl::NetworkOPsImp::StateAccounting::processStart_ = start_
private

Definition at line 139 of file NetworkOPs.cpp.

◆ initialSyncUs_

std::uint64_t xrpl::NetworkOPsImp::StateAccounting::initialSyncUs_ {0}
private

Definition at line 140 of file NetworkOPs.cpp.

◆ states_

std::array< Json::StaticString const, 5 > const xrpl::NetworkOPsImp::StateAccounting::states_
staticprivate
Initial value:
= {
Lightweight wrapper to tag static string.
Definition json_value.h:45
static std::array< char const *, 5 > const stateNames

Definition at line 141 of file NetworkOPs.cpp.