LogCabin
|
Holds the LogCabin daemon's top-level objects. More...
#include <Globals.h>
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 &) | |
Globals & | operator= (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::Server > | rpcServer |
Listens for inbound RPCs and passes them off to the services. |
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.
Constructor.
Definition at line 73 of file Globals.cc.
Destructor.
Definition at line 98 of file Globals.cc.
LogCabin::Server::Globals::Globals | ( | const Globals & | ) | [private] |
void LogCabin::Server::Globals::init | ( | ) |
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.
void LogCabin::Server::Globals::run | ( | ) |
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.
uint64_t LogCabin::Server::Globals::serverId |
std::shared_ptr<Server::RaftConsensus> LogCabin::Server::Globals::raft |
std::shared_ptr<Server::StateMachine> LogCabin::Server::Globals::stateMachine |
std::shared_ptr<Server::ControlService> LogCabin::Server::Globals::controlService [private] |
std::shared_ptr<Server::RaftService> LogCabin::Server::Globals::raftService [private] |
std::shared_ptr<Server::ClientService> LogCabin::Server::Globals::clientService [private] |
std::unique_ptr<RPC::Server> LogCabin::Server::Globals::rpcServer [private] |