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.
|
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 vlue of the logical clock counter
|
Vote |
getVote() |
Vote |
lookForLeader()
Starts a new round of leader election.
|
void |
shutdown() |
void |
start()
This method starts the sender and receiver threads.
|
protected boolean |
termPredicate(Map<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 void start()
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(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–2019 The Apache Software Foundation. All rights reserved.