public class Leader extends LearnerMaster
| Modifier and Type | Class and Description |
|---|---|
static class |
Leader.Proposal |
static class |
Leader.XidRolloverException |
| Modifier and Type | Field and Description |
|---|---|
static int |
ACKEPOCH
This message is used by the follow to ack a proposed epoch.
|
protected Set<Long> |
connectingFollowers |
protected Set<Long> |
electingFollowers |
protected boolean |
electionFinished |
static int |
LEADERINFO
This message is the first that a follower receives from the leader.
|
static String |
MAX_TIME_TO_WAIT_FOR_EPOCH |
protected Leader.Proposal |
newLeaderProposal |
static int |
PROPOSAL
This message type is sent by a leader to propose a mutation.
|
protected boolean |
quorumFormed |
| Constructor and Description |
|---|
Leader(QuorumPeer self,
LeaderZooKeeperServer zk) |
| Modifier and Type | Method and Description |
|---|---|
void |
addLearnerHandler(LearnerHandler learner)
Adds peer to the leader.
|
static QuorumPacket |
buildInformAndActivePacket(long zxid,
long designatedLeader,
byte[] proposalData) |
void |
commit(long zxid)
Create a commit packet and send it to all the members of the quorum
|
void |
commitAndActivate(long zxid,
long designatedLeader) |
static int |
getAckLoggingFrequency() |
long |
getAndDecrementFollowerCounter()
decrement follower count
|
int |
getCurrentTick()
the current tick
|
long |
getEpoch()
Returns the current epoch of the leader.
|
long |
getEpochToPropose(long sid,
long lastAcceptedEpoch)
get the first zxid of the next epoch
|
List<LearnerHandler> |
getForwardingFollowers()
Returns a copy of the current forwarding follower snapshot
|
long |
getLastProposed()
last proposed zxid
|
List<LearnerHandler> |
getLearners()
Returns a copy of the current learner snapshot
|
List<LearnerHandler> |
getNonVotingFollowers() |
int |
getNumPendingSyncs() |
List<LearnerHandler> |
getObservingLearners()
Returns a copy of the current observer snapshot
|
Iterable<Map<String,Object>> |
getObservingLearnersInfo() |
static String |
getPacketType(int packetType)
Get string representation of a given packet type
|
String |
getPeerInfo(long sid) |
BufferStats |
getProposalStats() |
QuorumAuthServer |
getQuorumAuthServer() |
byte[] |
getQuorumVerifierBytes()
identifier of current quorum verifier for new leader
|
long |
getQuorumVerifierVersion()
version of current quorum verifier
|
int |
getTickOfInitialAckDeadline()
next deadline tick marking observer sync (steady state)
|
int |
getTickOfNextAckDeadline()
deadline tick marking observer sync (initial)
|
long |
getUptime() |
ZKDatabase |
getZKDatabase()
ZKDatabase
|
void |
inform(Leader.Proposal proposal)
Create an inform packet and send it to all observers.
|
void |
informAndActivate(Leader.Proposal proposal,
long designatedLeader)
Create an inform and activate packet and send it to all observers.
|
boolean |
isQuorumSynced(QuorumVerifier qv)
Returns true if a quorum in qv is connected and synced with the leader
and false otherwise
|
void |
processAck(long sid,
long zxid,
SocketAddress followerAddr)
Keep a count of acks that are received by the leader for a particular
proposal
|
void |
processSync(LearnerSyncRequest r)
Process sync requests
|
Leader.Proposal |
propose(Request request)
create a proposal and send it out to all the members
|
void |
registerLearnerHandlerBean(LearnerHandler learnerHandler,
Socket socket)
registers the handler's bean
|
void |
removeLearnerHandler(LearnerHandler peer)
Remove the learner from the learner list
|
void |
reportLookingSid(long sid) |
void |
resetObserverConnectionStats() |
void |
revalidateSession(QuorumPacket qp,
LearnerHandler learnerHandler)
handle revalidate packet
|
void |
sendSync(LearnerSyncRequest r)
Sends a sync message to the appropriate server
|
static void |
setAckLoggingFrequency(int frequency) |
void |
setLeadingVoteSet(SyncedLearnerTracker voteSet) |
static void |
setMaxTimeToWaitForEpoch(int maxTimeToWaitForEpoch) |
long |
startForwarding(LearnerHandler handler,
long lastSeenZxid)
lets the leader know that a follower is capable of following and is done
syncing
|
void |
submitLearnerRequest(Request si)
proxy request from learner to server
|
int |
syncTimeout()
time allowed for sync response
|
void |
touch(long sess,
int to)
mark session as alive
|
boolean |
tryToCommit(Leader.Proposal p,
long zxid,
SocketAddress followerAddr) |
void |
unregisterLearnerHandlerBean(LearnerHandler learnerHandler)
unregisters the handler's bean
|
void |
waitForEpochAck(long id,
StateSummary ss)
wait for the leader of the new epoch to be confirmed by followers
|
void |
waitForNewLeaderAck(long sid,
long zxid)
Process NEWLEADER ack of a given sid and wait until the leader receives
sufficient acks.
|
void |
waitForStartup()
wait for server to start
|
getLearnerDiffSyncThrottler, getLearnerSnapSyncThrottler, getMaxConcurrentDiffSyncs, getMaxConcurrentSnapSyncs, setMaxConcurrentDiffSyncs, setMaxConcurrentSnapSyncsprotected boolean quorumFormed
public static final int LEADERINFO
public static final int ACKEPOCH
public static final int PROPOSAL
protected final Leader.Proposal newLeaderProposal
public static final String MAX_TIME_TO_WAIT_FOR_EPOCH
protected boolean electionFinished
public Leader(QuorumPeer self, LeaderZooKeeperServer zk) throws IOException
IOExceptionpublic static void setAckLoggingFrequency(int frequency)
public static int getAckLoggingFrequency()
public BufferStats getProposalStats()
public List<LearnerHandler> getLearners()
public List<LearnerHandler> getForwardingFollowers()
public List<LearnerHandler> getNonVotingFollowers()
public List<LearnerHandler> getObservingLearners()
public void resetObserverConnectionStats()
public int getNumPendingSyncs()
public void addLearnerHandler(LearnerHandler learner)
learner - instance of learner handlepublic void removeLearnerHandler(LearnerHandler peer)
peer - public boolean isQuorumSynced(QuorumVerifier qv)
qv, - a QuorumVerifierpublic long getUptime()
public boolean tryToCommit(Leader.Proposal p, long zxid, SocketAddress followerAddr)
public void processAck(long sid,
long zxid,
SocketAddress followerAddr)
zxid, - the zxid of the proposal sent outsid, - the id of the server that sent the ackfollowerAddr - public void commit(long zxid)
zxid - public void commitAndActivate(long zxid,
long designatedLeader)
public void inform(Leader.Proposal proposal)
public static QuorumPacket buildInformAndActivePacket(long zxid, long designatedLeader, byte[] proposalData)
public void informAndActivate(Leader.Proposal proposal, long designatedLeader)
public long getLastProposed()
LearnerMasterpublic long getEpoch()
public Leader.Proposal propose(Request request) throws Leader.XidRolloverException
request - Leader.XidRolloverExceptionpublic void processSync(LearnerSyncRequest r)
r - the requestpublic void sendSync(LearnerSyncRequest r)
public long startForwarding(LearnerHandler handler, long lastSeenZxid)
handler - handler of the followerlastSeenZxid - zxid of learnerpublic void waitForStartup()
throws InterruptedException
LearnerMasterInterruptedExceptionpublic static void setMaxTimeToWaitForEpoch(int maxTimeToWaitForEpoch)
public void setLeadingVoteSet(SyncedLearnerTracker voteSet)
public void reportLookingSid(long sid)
public long getEpochToPropose(long sid,
long lastAcceptedEpoch)
throws InterruptedException,
IOException
LearnerMastersid - learner idInterruptedExceptionIOExceptionpublic ZKDatabase getZKDatabase()
LearnerMasterpublic void waitForEpochAck(long id,
StateSummary ss)
throws IOException,
InterruptedException
LearnerMasterid - learner idIOExceptionInterruptedExceptionpublic void waitForNewLeaderAck(long sid,
long zxid)
throws InterruptedException
sid - zxid - zxid at learnerInterruptedExceptionpublic static String getPacketType(int packetType)
packetType - public int getCurrentTick()
LearnerMasterpublic int syncTimeout()
LearnerMasterpublic int getTickOfNextAckDeadline()
LearnerMasterpublic int getTickOfInitialAckDeadline()
LearnerMasterpublic long getAndDecrementFollowerCounter()
LearnerMasterpublic void touch(long sess,
int to)
LearnerMastersess - session idto - timeoutpublic void submitLearnerRequest(Request si)
LearnerMastersi - requestpublic long getQuorumVerifierVersion()
LearnerMasterpublic String getPeerInfo(long sid)
sid - server idpublic byte[] getQuorumVerifierBytes()
LearnerMasterpublic QuorumAuthServer getQuorumAuthServer()
public void revalidateSession(QuorumPacket qp, LearnerHandler learnerHandler) throws IOException
LearnerMasterqp - session packetlearnerHandler - learnerIOExceptionpublic void registerLearnerHandlerBean(LearnerHandler learnerHandler, Socket socket)
LearnerMasterlearnerHandler - handlersocket - connection to learnerpublic void unregisterLearnerHandlerBean(LearnerHandler learnerHandler)
LearnerMasterlearnerHandler - handlerCopyright © 2008–2021 The Apache Software Foundation. All rights reserved.