LogCabin
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
LogCabin::Server::ServerStats Class Reference

Manages creation of server statistics, which are used for diagnostics. More...

#include <ServerStats.h>

List of all members.

Classes

struct  Deferred
 Members that are constructed later, during enable(). More...
class  Lock
 Provides read/write access to stats, protected against concurrent access. More...
class  SignalHandler
 Asks statsDumper thread to dumps stats to the debug log (NOTICE level) on SIGUSR1 signal. More...

Public Member Functions

 ServerStats (Globals &globals)
 Constructor.
 ~ServerStats ()
 Destructor.
void enable ()
 Called after Globals are initialized to finish setting up this class.
void exit ()
 Prepare for shutdown.
void dumpToDebugLog () const
 Write the current stats to the debug log (NOTICE level).
Protocol::ServerStats getCurrent () const
 Calculate and return the current server stats.

Private Types

typedef Core::Time::SteadyClock SteadyClock
 Used to dump stats periodically.
typedef Core::Time::SystemClock SystemClock
 Used to include wall time in stats.

Private Member Functions

void dumpToDebugLog (std::unique_lock< Core::Mutex > &lockGuard) const
 See public dumpToDebugLog() above.
Protocol::ServerStats getCurrent (std::unique_lock< Core::Mutex > &lockGuard) const
 See public getCurrent() above.
void statsDumperMain ()

Private Attributes

Globalsglobals
 Server-wide objects.
Core::Mutex mutex
 Protects all of the following members of this class.
Core::ConditionVariable statsDumpRequested
 Notified when isStatsDumpRequested is set and when exiting is set.
bool exiting
 Set to true when statsDumper should exit.
bool isStatsDumpRequested
 Set to true when statsDumper should write the entire stats to the debug log.
Core::Time::SteadyClock::time_point lastDumped
 The last time when the stats were written to the debug log.
Protocol::ServerStats stats
 Partially filled-in structure that is copied as the basis of all calls to getCurrent().
std::unique_ptr< Deferreddeferred
 See Deferred.

Detailed Description

Manages creation of server statistics, which are used for diagnostics.

Server statistics are gathered in two ways. First, this object maintains a stats structure that modules can fill in by acquiring a Lock and modifying directly. This stats structure is copied every time stats are requested. Second, when stats are requested, getCurrent() will ask certain modules (such as RaftConsensus) to fill in the current information into a copy of the stats structure.

Definition at line 45 of file ServerStats.h.


Member Typedef Documentation

Used to dump stats periodically.

Definition at line 104 of file ServerStats.h.

Used to include wall time in stats.

Definition at line 109 of file ServerStats.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 86 of file ServerStats.cc.

Destructor.

Definition at line 98 of file ServerStats.cc.


Member Function Documentation

Called after Globals are initialized to finish setting up this class.

Attaches signal handler and starts stats dumper thread. Starts calling other modules for their state in getCurrent().

Definition at line 103 of file ServerStats.cc.

Prepare for shutdown.

Waits for the statsDumper thread to exit, and destroys the deferred object (the opposite of enable()).

Definition at line 114 of file ServerStats.cc.

Write the current stats to the debug log (NOTICE level).

This is preferred over calling getCurrent() followed by NOTICE(), since it will arrange for the next periodic stats dump to be delayed (there's not much sense in a periodic stats dump immediately following a manual stats dump).

Definition at line 127 of file ServerStats.cc.

Protocol::ServerStats LogCabin::Server::ServerStats::getCurrent ( ) const

Calculate and return the current server stats.

Definition at line 134 of file ServerStats.cc.

void LogCabin::Server::ServerStats::dumpToDebugLog ( std::unique_lock< Core::Mutex > &  lockGuard) const [private]

See public dumpToDebugLog() above.

Internally releases and reacquires the lock for concurrency and to avoid deadlock.

Definition at line 143 of file ServerStats.cc.

Protocol::ServerStats LogCabin::Server::ServerStats::getCurrent ( std::unique_lock< Core::Mutex > &  lockGuard) const [private]

See public getCurrent() above.

Internally releases and reacquires the lock for concurrency and to avoid deadlock.

Definition at line 155 of file ServerStats.cc.

Definition at line 173 of file ServerStats.cc.


Member Data Documentation

Server-wide objects.

Definition at line 186 of file ServerStats.h.

Protects all of the following members of this class.

Definition at line 191 of file ServerStats.h.

Notified when isStatsDumpRequested is set and when exiting is set.

statsDumper waits on this.

Definition at line 197 of file ServerStats.h.

Set to true when statsDumper should exit.

Definition at line 202 of file ServerStats.h.

Set to true when statsDumper should write the entire stats to the debug log.

Mutable so that it can be reset to false in const methods such as dumpToDebugLog().

Definition at line 209 of file ServerStats.h.

The last time when the stats were written to the debug log.

Monotonically increases.

Definition at line 215 of file ServerStats.h.

Protocol::ServerStats LogCabin::Server::ServerStats::stats [private]

Partially filled-in structure that is copied as the basis of all calls to getCurrent().

Definition at line 221 of file ServerStats.h.

See Deferred.

If non-NULL, enabled() has already been called, and other modules should be queried for stats during getCurrent().

Definition at line 227 of file ServerStats.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines