rippled
Classes | Public Member Functions | Private Attributes | Static Private Attributes | List of all members
ripple::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 ripple::NetworkOPsImp::StateAccounting:
Collaboration graph
[legend]

Classes

struct  CounterData
 
struct  Counters
 

Public Member Functions

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

Private Attributes

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

Static Private Attributes

static const std::array< Json::StaticString const, 5 > 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 131 of file NetworkOPs.cpp.

Constructor & Destructor Documentation

◆ StateAccounting()

ripple::NetworkOPsImp::StateAccounting::StateAccounting ( )
explicit

Definition at line 151 of file NetworkOPs.cpp.

Member Function Documentation

◆ mode()

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

Record state transition.

Update duration spent in previous state.

Parameters
omNew state.

Definition at line 4533 of file NetworkOPs.cpp.

◆ json()

void ripple::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 4554 of file NetworkOPs.cpp.

◆ getCounterData()

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

Definition at line 183 of file NetworkOPs.cpp.

Member Data Documentation

◆ mode_

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

Definition at line 141 of file NetworkOPs.cpp.

◆ counters_

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

Definition at line 142 of file NetworkOPs.cpp.

◆ mutex_

std::mutex ripple::NetworkOPsImp::StateAccounting::mutex_
mutableprivate

Definition at line 143 of file NetworkOPs.cpp.

◆ start_

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

Definition at line 144 of file NetworkOPs.cpp.

◆ processStart_

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

Definition at line 146 of file NetworkOPs.cpp.

◆ initialSyncUs_

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

Definition at line 147 of file NetworkOPs.cpp.

◆ states_

const std::array< Json::StaticString const, 5 > ripple::NetworkOPsImp::StateAccounting::states_
staticprivate
Json::StaticString
Lightweight wrapper to tag static string.
Definition: json_value.h:60
ripple::stateNames
static const std::array< char const *, 5 > stateNames
Definition: NetworkOPs.cpp:839
std::chrono::steady_clock::now
T now(T... args)