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

A base class for known servers in the cluster, including this process (see LocalServer) and others (see Peer). More...

#include <RaftConsensus.h>

Inheritance diagram for LogCabin::Server::RaftConsensusInternal::Server:
LogCabin::Server::RaftConsensusInternal::LocalServer LogCabin::Server::RaftConsensusInternal::Peer

List of all members.

Public Member Functions

 Server (uint64_t serverId)
 Constructor.
virtual ~Server ()
 Destructor.
virtual void beginRequestVote ()=0
 Begin requesting the Server's vote in the current election.
virtual void beginLeadership ()=0
 Begin replicating to the Server in the current term.
virtual void exit ()=0
 Inform any threads belonging to this Server to exit.
virtual uint64_t getLastAckEpoch () const =0
 Return the latest time this Server acknowledged our current term.
virtual uint64_t getMatchIndex () const =0
 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.
virtual bool haveVote () const =0
 Return true if this Server has awarded us its vote for this term.
virtual void interrupt ()=0
 Cancel any outstanding RPCs to this Server.
virtual bool isCaughtUp () const =0
 Return true once this Server is ready to be added to the cluster.
virtual void scheduleHeartbeat ()=0
 Make the next heartbeat RPC happen soon.
virtual void updatePeerStats (Protocol::ServerStats::Raft::Peer &peerStats, Core::Time::SteadyTimeConverter &time) const =0
 Write this Server's state into the given structure.
virtual std::ostream & dumpToStream (std::ostream &os) const =0
 Virtual method for operator<<.

Public Attributes

const uint64_t serverId
 The ID of this server.
std::string addresses
 The network addresses at which this server may be available (comma-delimited)
bool haveStateMachineSupportedVersions
 If true, minStateMachineVersion and maxStateMachineVersion are set (although they may be stale).
uint16_t minStateMachineVersion
 If haveStateMachineSupportedVersions is true, the smallest version of the state machine commands/behavior that the server can support.
uint16_t maxStateMachineVersion
 If haveStateMachineSupportedVersions is true, the largest version of the state machine commands/behavior that the server can support.
bool gcFlag
 Used internally by Configuration for garbage collection.

Friends

std::ostream & operator<< (std::ostream &os, const Server &server)
 Print out a Server for debugging purposes.

Detailed Description

A base class for known servers in the cluster, including this process (see LocalServer) and others (see Peer).

This tracks various bits of state for each server, which is used when we are a candidate or leader. This class does not do any internal locking; it should be accessed only while holding the RaftConsensus lock.

Definition at line 106 of file RaftConsensus.h.


Constructor & Destructor Documentation

Constructor.

Definition at line 55 of file RaftConsensus.cc.

Destructor.

Definition at line 65 of file RaftConsensus.cc.


Member Function Documentation

Begin requesting the Server's vote in the current election.

Return immediately. The condition variable in RaftConsensus will be notified separately.

Implemented in LogCabin::Server::RaftConsensusInternal::Peer, and LogCabin::Server::RaftConsensusInternal::LocalServer.

Begin replicating to the Server in the current term.

Return immediately. The condition variable in RaftConsensus will be notified separately.

Implemented in LogCabin::Server::RaftConsensusInternal::Peer, and LogCabin::Server::RaftConsensusInternal::LocalServer.

Inform any threads belonging to this Server to exit.

Return immediately. The condition variable in RaftConsensus will be notified separately.

Implemented in LogCabin::Server::RaftConsensusInternal::Peer, and LogCabin::Server::RaftConsensusInternal::LocalServer.

virtual uint64_t LogCabin::Server::RaftConsensusInternal::Server::getLastAckEpoch ( ) const [pure virtual]

Return the latest time this Server acknowledged our current term.

Implemented in LogCabin::Server::RaftConsensusInternal::Peer, and LogCabin::Server::RaftConsensusInternal::LocalServer.

virtual uint64_t LogCabin::Server::RaftConsensusInternal::Server::getMatchIndex ( ) const [pure 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.

Warning:
Only valid when we're leader.

Implemented in LogCabin::Server::RaftConsensusInternal::Peer, and LogCabin::Server::RaftConsensusInternal::LocalServer.

virtual bool LogCabin::Server::RaftConsensusInternal::Server::haveVote ( ) const [pure virtual]

Return true if this Server has awarded us its vote for this term.

Implemented in LogCabin::Server::RaftConsensusInternal::Peer, and LogCabin::Server::RaftConsensusInternal::LocalServer.

Cancel any outstanding RPCs to this Server.

The condition variable in RaftConsensus will be notified separately.

Implemented in LogCabin::Server::RaftConsensusInternal::Peer, and LogCabin::Server::RaftConsensusInternal::LocalServer.

virtual bool LogCabin::Server::RaftConsensusInternal::Server::isCaughtUp ( ) const [pure 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.

Implemented in LogCabin::Server::RaftConsensusInternal::Peer, and LogCabin::Server::RaftConsensusInternal::LocalServer.

Make the next heartbeat RPC happen soon.

Return immediately. The condition variable in RaftConsensus will be notified separately.

Implemented in LogCabin::Server::RaftConsensusInternal::Peer, and LogCabin::Server::RaftConsensusInternal::LocalServer.

virtual void LogCabin::Server::RaftConsensusInternal::Server::updatePeerStats ( Protocol::ServerStats::Raft::Peer &  peerStats,
Core::Time::SteadyTimeConverter time 
) const [pure virtual]

Write this Server's state into the given structure.

Used for diagnostics.

Implemented in LogCabin::Server::RaftConsensusInternal::Peer, and LogCabin::Server::RaftConsensusInternal::LocalServer.

virtual std::ostream& LogCabin::Server::RaftConsensusInternal::Server::dumpToStream ( std::ostream &  os) const [pure virtual]

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const Server server 
) [friend]

Print out a Server for debugging purposes.

Definition at line 70 of file RaftConsensus.cc.


Member Data Documentation

The ID of this server.

Definition at line 189 of file RaftConsensus.h.

The network addresses at which this server may be available (comma-delimited)

Definition at line 194 of file RaftConsensus.h.

If true, minStateMachineVersion and maxStateMachineVersion are set (although they may be stale).

Definition at line 200 of file RaftConsensus.h.

If haveStateMachineSupportedVersions is true, the smallest version of the state machine commands/behavior that the server can support.

Definition at line 205 of file RaftConsensus.h.

If haveStateMachineSupportedVersions is true, the largest version of the state machine commands/behavior that the server can support.

Definition at line 210 of file RaftConsensus.h.

Used internally by Configuration for garbage collection.

Definition at line 215 of file RaftConsensus.h.


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