Electionpublic class FastLeaderElection extends java.lang.Object implements Election
| Modifier and Type | Class | 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.
|
| Constructor | Description |
|---|---|
FastLeaderElection(QuorumPeer self,
QuorumCnxManager manager) |
Constructor of FastLeaderElection.
|
| Modifier and Type | Method | Description |
|---|---|---|
protected boolean |
checkLeader(java.util.HashMap<java.lang.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 vlue of the logical clock counter
|
Vote |
lookForLeader() |
Starts a new round of leader election.
|
protected boolean |
ooePredicate(java.util.HashMap<java.lang.Long,Vote> recv,
java.util.HashMap<java.lang.Long,Vote> ooe,
FastLeaderElection.Notification n) |
This predicate checks that a leader has been elected.
|
void |
shutdown() |
|
protected boolean |
termPredicate(java.util.HashMap<java.lang.Long,Vote> votes,
Vote vote) |
Termination predicate.
|
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 FastLeaderElection(QuorumPeer self, QuorumCnxManager manager)
self - QuorumPeer that created this objectmanager - Connection managerpublic long getLogicalClock()
public QuorumCnxManager getCnxManager()
protected boolean totalOrderPredicate(long newId,
long newZxid,
long newEpoch,
long curId,
long curZxid,
long curEpoch)
id - Server identifierzxid - Last zxid observed by the issuer of this voteprotected boolean termPredicate(java.util.HashMap<java.lang.Long,Vote> votes, Vote vote)
votes - Set of votesl - Identifier of the vote received lastzxid - zxid of the the vote received lastprotected boolean checkLeader(java.util.HashMap<java.lang.Long,Vote> votes, long leader, long electionEpoch)
votes - set of votesleader - leader idelectionEpoch - epoch idprotected boolean ooePredicate(java.util.HashMap<java.lang.Long,Vote> recv, java.util.HashMap<java.lang.Long,Vote> ooe, FastLeaderElection.Notification n)
recv - map of received votesooe - map containing out of election votes (LEADING or FOLLOWING)n - Notificationpublic Vote lookForLeader() throws java.lang.InterruptedException
lookForLeader in interface Electionjava.lang.InterruptedExceptionCopyright © 2018 The Apache Software Foundation