public class FastLeaderElection extends Object implements Election
Modifier and Type | Class and Description |
---|---|
protected class |
FastLeaderElection.Messenger
Multi-threaded implementation of message handler.
|
static class |
FastLeaderElection.Notification
Notifications are messages that let other peers know that
a given peer has changed its vote, either because it has
joined leader election or because it learned of another
peer with higher zxid or same zxid and higher server id
|
static class |
FastLeaderElection.ToSend
Messages that a peer wants to send to other peers.
|
Modifier and Type | Field and Description |
---|---|
static String |
MAX_NOTIFICATION_INTERVAL
Maximum notification interval, default is 60s
|
static String |
MIN_NOTIFICATION_INTERVAL
Minimum notification interval, default is equal to finalizeWait
|
Constructor and Description |
---|
FastLeaderElection(QuorumPeer self,
QuorumCnxManager manager)
Constructor of FastLeaderElection.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkLeader(Map<Long,Vote> votes,
long leader,
long electionEpoch)
In the case there is a leader elected, and a quorum supporting
this leader, we have to check if the leader has voted and acked
that it is leading.
|
QuorumCnxManager |
getCnxManager() |
long |
getLogicalClock()
Returns the current value of the logical clock counter
|
Vote |
getVote() |
protected SyncedLearnerTracker |
getVoteTracker(Map<Long,Vote> votes,
Vote vote)
Given a set of votes, return the SyncedLearnerTracker which is used to
determines if have sufficient to declare the end of the election round.
|
Vote |
lookForLeader()
Starts a new round of leader election.
|
void |
shutdown() |
void |
start()
This method starts the sender and receiver threads.
|
protected boolean |
totalOrderPredicate(long newId,
long newZxid,
long newEpoch,
long curId,
long curZxid,
long curEpoch)
Check if a pair (server id, zxid) succeeds our
current vote.
|
public static final String MIN_NOTIFICATION_INTERVAL
public static final String MAX_NOTIFICATION_INTERVAL
public FastLeaderElection(QuorumPeer self, QuorumCnxManager manager)
self
- QuorumPeer that created this objectmanager
- Connection managerpublic long getLogicalClock()
public void start()
public QuorumCnxManager getCnxManager()
protected boolean totalOrderPredicate(long newId, long newZxid, long newEpoch, long curId, long curZxid, long curEpoch)
protected SyncedLearnerTracker getVoteTracker(Map<Long,Vote> votes, Vote vote)
votes
- Set of votesvote
- Identifier of the vote received lastprotected boolean checkLeader(Map<Long,Vote> votes, long leader, long electionEpoch)
votes
- set of votesleader
- leader idelectionEpoch
- epoch idpublic Vote getVote()
public Vote lookForLeader() throws InterruptedException
lookForLeader
in interface Election
InterruptedException
Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.