Class ELECTION2

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 process which executes the pre-voting mechanism sends a 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

    Fields
    Modifier and Type
    Field
    Description
    protected static final short
     

    Fields inherited from class org.jgroups.protocols.raft.election.BaseElection

    num_voting_rounds, PRE_VOTE_REQ, PRE_VOTE_RSP, raft, view, VOTE_REQ, vote_timeout

    Fields 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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    handleMessage(org.jgroups.Message msg, RaftHeader hdr)
     
    protected void
    handleView(org.jgroups.View v)
     
    boolean
     

    Methods 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, voteTimeout

    Methods 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • ELECTION2

      public ELECTION2()
  • Method Details

    • isPreVoteThreadRunning

      public boolean isPreVoteThreadRunning()
    • handleView

      protected void handleView(org.jgroups.View v)
      Specified by:
      handleView in class org.jgroups.protocols.raft.election.BaseElection
    • handleMessage

      protected void handleMessage(org.jgroups.Message msg, RaftHeader hdr)
      Overrides:
      handleMessage in class org.jgroups.protocols.raft.election.BaseElection