LogCabin
|
A type of Server for the local process. More...
#include <RaftConsensus.h>
Public Member Functions | |
LocalServer (uint64_t serverId, RaftConsensus &consensus) | |
~LocalServer () | |
void | exit () |
Inform any threads belonging to this Server to exit. | |
void | beginRequestVote () |
Begin requesting the Server's vote in the current election. | |
void | beginLeadership () |
Begin replicating to the Server in the current term. | |
uint64_t | getMatchIndex () const |
Return the largest entry ID for which this Server is known to share the same entries up to and including this entry with our log. | |
bool | haveVote () const |
Return true if this Server has awarded us its vote for this term. | |
uint64_t | getLastAckEpoch () const |
Return the latest time this Server acknowledged our current term. | |
void | interrupt () |
Cancel any outstanding RPCs to this Server. | |
bool | isCaughtUp () const |
Return true once this Server is ready to be added to the cluster. | |
void | scheduleHeartbeat () |
Make the next heartbeat RPC happen soon. | |
std::ostream & | dumpToStream (std::ostream &os) const |
Virtual method for operator<<. | |
void | updatePeerStats (Protocol::ServerStats::Raft::Peer &peerStats, Core::Time::SteadyTimeConverter &time) const |
Write this Server's state into the given structure. | |
Public Attributes | |
RaftConsensus & | consensus |
uint64_t | lastSyncedIndex |
The index of the last log entry that has been flushed to disk. |
A type of Server for the local process.
There will only be one instance of this class. Most of these methods don't do much, but they are needed to satisfy the Server interface.
Definition at line 224 of file RaftConsensus.h.
LogCabin::Server::RaftConsensusInternal::LocalServer::LocalServer | ( | uint64_t | serverId, |
RaftConsensus & | consensus | ||
) |
Definition at line 77 of file RaftConsensus.cc.
Definition at line 84 of file RaftConsensus.cc.
void LogCabin::Server::RaftConsensusInternal::LocalServer::exit | ( | ) | [virtual] |
Inform any threads belonging to this Server to exit.
Return immediately. The condition variable in RaftConsensus will be notified separately.
Implements LogCabin::Server::RaftConsensusInternal::Server.
Definition at line 100 of file RaftConsensus.cc.
void LogCabin::Server::RaftConsensusInternal::LocalServer::beginRequestVote | ( | ) | [virtual] |
Begin requesting the Server's vote in the current election.
Return immediately. The condition variable in RaftConsensus will be notified separately.
Implements LogCabin::Server::RaftConsensusInternal::Server.
Definition at line 89 of file RaftConsensus.cc.
void LogCabin::Server::RaftConsensusInternal::LocalServer::beginLeadership | ( | ) | [virtual] |
Begin replicating to the Server in the current term.
Return immediately. The condition variable in RaftConsensus will be notified separately.
Implements LogCabin::Server::RaftConsensusInternal::Server.
Definition at line 94 of file RaftConsensus.cc.
uint64_t LogCabin::Server::RaftConsensusInternal::LocalServer::getMatchIndex | ( | ) | const [virtual] |
Return the largest entry ID for which this Server is known to share the same entries up to and including this entry with our log.
This is used for advancing the leader's commitIndex. Monotonically increases within a term.
Implements LogCabin::Server::RaftConsensusInternal::Server.
Definition at line 111 of file RaftConsensus.cc.
bool LogCabin::Server::RaftConsensusInternal::LocalServer::haveVote | ( | ) | const [virtual] |
Return true if this Server has awarded us its vote for this term.
Implements LogCabin::Server::RaftConsensusInternal::Server.
Definition at line 117 of file RaftConsensus.cc.
uint64_t LogCabin::Server::RaftConsensusInternal::LocalServer::getLastAckEpoch | ( | ) | const [virtual] |
Return the latest time this Server acknowledged our current term.
Implements LogCabin::Server::RaftConsensusInternal::Server.
Definition at line 105 of file RaftConsensus.cc.
void LogCabin::Server::RaftConsensusInternal::LocalServer::interrupt | ( | ) | [virtual] |
Cancel any outstanding RPCs to this Server.
The condition variable in RaftConsensus will be notified separately.
Implements LogCabin::Server::RaftConsensusInternal::Server.
Definition at line 123 of file RaftConsensus.cc.
bool LogCabin::Server::RaftConsensusInternal::LocalServer::isCaughtUp | ( | ) | const [virtual] |
Return true once this Server is ready to be added to the cluster.
This means it has received enough of our log to where it is not expected to cause an availability problem when added to the cluster configuration. Should monotonically change from false to true.
Implements LogCabin::Server::RaftConsensusInternal::Server.
Definition at line 128 of file RaftConsensus.cc.
void LogCabin::Server::RaftConsensusInternal::LocalServer::scheduleHeartbeat | ( | ) | [virtual] |
Make the next heartbeat RPC happen soon.
Return immediately. The condition variable in RaftConsensus will be notified separately.
Implements LogCabin::Server::RaftConsensusInternal::Server.
Definition at line 134 of file RaftConsensus.cc.
std::ostream & LogCabin::Server::RaftConsensusInternal::LocalServer::dumpToStream | ( | std::ostream & | os | ) | const [virtual] |
Virtual method for operator<<.
Implements LogCabin::Server::RaftConsensusInternal::Server.
Definition at line 139 of file RaftConsensus.cc.
void LogCabin::Server::RaftConsensusInternal::LocalServer::updatePeerStats | ( | Protocol::ServerStats::Raft::Peer & | peerStats, |
Core::Time::SteadyTimeConverter & | time | ||
) | const [virtual] |
Write this Server's state into the given structure.
Used for diagnostics.
Implements LogCabin::Server::RaftConsensusInternal::Server.
Definition at line 146 of file RaftConsensus.cc.
Definition at line 240 of file RaftConsensus.h.
The index of the last log entry that has been flushed to disk.
Valid for leaders only. Returned by getMatchIndex() and used to advance the leader's commitIndex.
Definition at line 246 of file RaftConsensus.h.