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

Holds the LogCabin daemon's top-level objects. More...

#include <Globals.h>

List of all members.

Classes

class  ExitHandler
 Exits from the event loop upon receiving a UNIX signal. More...
class  LogRotateHandler
 Re-opens the log file upon receiving a UNIX signal. More...

Public Member Functions

 Globals ()
 Constructor.
 ~Globals ()
 Destructor.
void init ()
 Finish initializing this object.
void leaveSignalsBlocked ()
 Leave the signals blocked when this object is destroyed.
void run ()
 Run the event loop until SIGINT, SIGTERM, or someone calls Event::Loop::exit().
void unblockAllSignals ()
 Enable asynchronous signal delivery for all signals that this class is in charge of.

Public Attributes

Core::Config config
 Global configuration options.
Server::ServerStats serverStats
 Statistics and information about the server's current state.
Event::Loop eventLoop
 The event loop that runs the RPC system.
Client::SessionManager::ClusterUUID clusterUUID
 A unique ID for the cluster that this server may connect to.
uint64_t serverId
 Unique ID for this server.
std::shared_ptr
< Server::RaftConsensus
raft
 Consensus module.
std::shared_ptr
< Server::StateMachine
stateMachine
 State machine used to process client requests.

Private Member Functions

 Globals (const Globals &)
Globalsoperator= (const Globals &)

Private Attributes

Event::Signal::Blocker sigIntBlocker
 Block SIGINT, which is handled by sigIntHandler.
Event::Signal::Blocker sigTermBlocker
 Block SIGTERM, which is handled by sigTermHandler.
Event::Signal::Blocker sigUsr1Blocker
 Block SIGUSR1, which is handled by serverStats.
Event::Signal::Blocker sigUsr2Blocker
 Block SIGUSR2, which is handled by sigUsr2Handler.
ExitHandler sigIntHandler
 Exits the event loop upon receiving SIGINT (keyboard interrupt).
Event::Signal::Monitor sigIntMonitor
 Registers sigIntHandler with the event loop.
ExitHandler sigTermHandler
 Exits the event loop upon receiving SIGTERM (kill).
Event::Signal::Monitor sigTermMonitor
 Registers sigTermHandler with the event loop.
LogRotateHandler sigUsr2Handler
 Re-opens log files upon receiving SIGUSR2 (user-defined signal).
Event::Signal::Monitor sigUsr2Monitor
 Registers sigUsr2Handler with the event loop.
std::shared_ptr
< Server::ControlService
controlService
 Service used by logcabinctl to query and change a server's internal state.
std::shared_ptr
< Server::RaftService
raftService
 Service used to communicate between servers.
std::shared_ptr
< Server::ClientService
clientService
 The application-facing facing RPC service.
std::unique_ptr< RPC::ServerrpcServer
 Listens for inbound RPCs and passes them off to the services.

Detailed Description

Holds the LogCabin daemon's top-level objects.

The purpose of main() is to create and run a Globals object. Other classes may refer to this object if they need access to other top-level objects.

Definition at line 51 of file Globals.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 73 of file Globals.cc.

Destructor.

Definition at line 98 of file Globals.cc.


Member Function Documentation

Finish initializing this object.

This should be called after config has been filled in.

Definition at line 104 of file Globals.cc.

Leave the signals blocked when this object is destroyed.

This is used in Server/Main.cc for the long-running daemon; it's not used in unit tests.

This was added to work around a specific problem: when running the servers under valgrind through cluster.py, the servers would receive SIGTERM, start to shut down, then the instant the SIGTERM signal was unmasked, the server would appear to exit with a 0 status, yet it wouldn't finish the shutdown process. I couldn't reproduce this outside of cluster.py. As there's no reason to unblock the signals before exiting the daemon, this seems like the safer bet for now. -Diego 2015-04-29

Definition at line 186 of file Globals.cc.

Run the event loop until SIGINT, SIGTERM, or someone calls Event::Loop::exit().

Definition at line 195 of file Globals.cc.

Enable asynchronous signal delivery for all signals that this class is in charge of.

This should be called in a child process after invoking fork(), as the StateMachine does.

Definition at line 201 of file Globals.cc.

Globals& LogCabin::Server::Globals::operator= ( const Globals ) [private]

Member Data Documentation

Global configuration options.

Definition at line 119 of file Globals.h.

Statistics and information about the server's current state.

Useful for diagnostics.

Definition at line 125 of file Globals.h.

The event loop that runs the RPC system.

Definition at line 130 of file Globals.h.

Block SIGINT, which is handled by sigIntHandler.

Signals are blocked early on in the startup process so that newly spawned threads also have them blocked.

Definition at line 138 of file Globals.h.

Block SIGTERM, which is handled by sigTermHandler.

Definition at line 143 of file Globals.h.

Block SIGUSR1, which is handled by serverStats.

Definition at line 148 of file Globals.h.

Block SIGUSR2, which is handled by sigUsr2Handler.

Definition at line 153 of file Globals.h.

Exits the event loop upon receiving SIGINT (keyboard interrupt).

Definition at line 158 of file Globals.h.

Registers sigIntHandler with the event loop.

Definition at line 163 of file Globals.h.

Exits the event loop upon receiving SIGTERM (kill).

Definition at line 168 of file Globals.h.

Registers sigTermHandler with the event loop.

Definition at line 173 of file Globals.h.

Re-opens log files upon receiving SIGUSR2 (user-defined signal).

This should normally be invoked by tools like logrotate.

Definition at line 179 of file Globals.h.

Registers sigUsr2Handler with the event loop.

Definition at line 184 of file Globals.h.

A unique ID for the cluster that this server may connect to.

This is initialized to a value from the config file. If it's not set then, it may be set later as a result of learning a UUID from some other server.

Definition at line 192 of file Globals.h.

Unique ID for this server.

Set from config file.

Definition at line 197 of file Globals.h.

Consensus module.

Definition at line 202 of file Globals.h.

State machine used to process client requests.

Definition at line 207 of file Globals.h.

Service used by logcabinctl to query and change a server's internal state.

Definition at line 215 of file Globals.h.

Service used to communicate between servers.

Definition at line 220 of file Globals.h.

The application-facing facing RPC service.

Definition at line 225 of file Globals.h.

Listens for inbound RPCs and passes them off to the services.

Definition at line 230 of file Globals.h.


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