java.lang.Object
org.jgroups.stack.Protocol
org.jgroups.protocols.raft.election.BaseElection
org.jgroups.protocols.raft.ELECTION2
- All Implemented Interfaces:
org.jgroups.Lifecycle
public class ELECTION2
extends org.jgroups.protocols.raft.election.BaseElection
A leader election protocol.
This implementation extends ELECTION with a pre-vote mechanism. The pre-vote always runs before starting the
voting thread to define the leader. The pre-vote increases the delay in electing the leader but, in turn, covers more
edge cases. As a rule of thumb, if deploying in an unstable network with frequent partitions, this protocol should
give a more stable mechanism, avoid leader disruptions, and avoid possible liveness issues. Otherwise,
ELECTION is the default choice.
Pre-Voting phase:
This extension includes the pre-voting mechanism proposed in Ongaro's dissertation (§9.6). In the current implementation, a pre-voting phase starts in case the current node is the new view coordinator and:- The view coordinator changes and the computed update is
Utils.Majority.no_change; - The computed view update is
Utils.Majority.reachedorUtils.Majority.leader_lost
PreVoteRequest to all processes in the view. The
recipients reply with a PreVoteResponse identifying the node they see as leader. Once the initiator receives
the reply from all nodes in the view, it can start the voting process, resuming the work the same as ELECTION.- Since:
- 1.0.12
- Author:
- José Bolina
- 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
Modifier and TypeMethodDescriptionprotected voidhandleMessage(org.jgroups.Message msg, RaftHeader hdr) protected voidhandleView(org.jgroups.View v) booleanMethods inherited from class org.jgroups.protocols.raft.election.BaseElection
determineLeader, down, getVotes, 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
-
ELECTION2
public ELECTION2()
-
-
Method Details
-
isPreVoteThreadRunning
public boolean isPreVoteThreadRunning() -
handleView
protected void handleView(org.jgroups.View v) - Specified by:
handleViewin classorg.jgroups.protocols.raft.election.BaseElection
-
handleMessage
- Overrides:
handleMessagein classorg.jgroups.protocols.raft.election.BaseElection
-