- All Implemented Interfaces:
org.jgroups.Lifecycle
Performs leader election. This implementation takes full advantage of JGroup's membership events with View.
When the current node is the view coordinator, it starts a voting thread to ask all members to send their information.
The voting thread stops when a new leader is elected.
The process that starts the voting thread is not trying to elect itself. The process running the voting process
increases its term and asks all nodes about their term and log index information to select the new leader, in the
form of VoteResponse. For safety reasons, only the nodes with the most
up-to-date log can be elected a leader. With a response from the majority processes, the leader with the higher term
and log index is elected. The oldest process (view coordinator) in the system has a priority. Once decided, the
process sends a message reliably to everyone identifying the new leader, with the
LeaderElected message.
After a leader is elected, a new election round starts on view changes only if the leader left the cluster. In case of losing a majority, the leader steps down.
This implementation is more robust than building with heartbeats, leading to fewer disruptions in the cluster with unnecessary (competing) election rounds. This also means the leader is capable of stepping down. Referred to in ยง6.2 of Ongaro's dissertation to prevent stale leadership information.
More information is available in the design docs.
- Since:
- 0.1
- Author:
- Bela Ban
- See Also:
-
Field Summary
FieldsFields inherited from class org.jgroups.protocols.raft.election.BaseElection
num_voting_rounds, PRE_VOTE_REQ, PRE_VOTE_RSP, raft, view, VOTE_REQ, vote_timeoutFields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, local_addr, log, policies, stack, stats, up_prot -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.jgroups.protocols.raft.election.BaseElection
determineLeader, down, getVotes, handleMessage, init, isMajorityAvailable, isViewCoordinator, isVotingThreadRunning, raft, raft, resetStats, runVotingProcess, runVotingThread, sendLeaderElectedMessage, sendVoteRequest, sendVoteResponse, startVotingThread, stop, stopVotingThread, up, up, up, voteTimeout, voteTimeoutMethods inherited from class org.jgroups.stack.Protocol
accept, addPolicy, addr, addr, afterCreationHook, destroy, down, down, enableStats, getAddress, getComponents, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getPolicies, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, policies, providedDownServices, providedUpServices, removePolicy, requiredDownServices, requiredUpServices, resetStatistics, setAddress, setDownProtocol, setErgonomics, setId, setLevel, setPolicies, setProtocolStack, setSocketFactory, setUpProtocol, setValue, start, statsEnabled, toString
-
Field Details
-
ELECTION_ID
protected static final short ELECTION_ID- See Also:
-
-
Constructor Details
-
ELECTION
public ELECTION()
-
-
Method Details
-
handleView
protected void handleView(org.jgroups.View v) - Specified by:
handleViewin classorg.jgroups.protocols.raft.election.BaseElection
-