Class LearnerHandler
java.lang.Object
java.lang.Thread
org.apache.zookeeper.server.ZooKeeperThread
org.apache.zookeeper.server.quorum.LearnerHandler
- All Implemented Interfaces:
Runnable
There will be an instance of this class created by the Leader for each
learner. All communication with a learner is handled by this
class.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
protected final Date
static final String
For testing purpose, force learnerMaster to use snapshot to sync with followersprotected long
static final String
protected final MessageTracker
protected final AtomicLong
protected final AtomicLong
protected final AtomicLong
protected long
ZooKeeper server identifier of this learnerprotected final Socket
protected int
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Method Summary
Modifier and TypeMethodDescriptionlong
For testing, return packet queuestatic String
void
ping()
ping calls from the learnerMaster to the peersprotected long
queueCommittedProposals
(Iterator<Leader.Proposal> itr, long peerLastZxid, Long maxZxid, Long lastCommittedZxid) Queue committed proposals into packet queue.void
void
run()
This thread will receive packets from the peer and process them and also listen to new connections from new peers.protected void
setBufferedOutput
(BufferedOutputStream bufferedOutput) void
setFirstPacket
(boolean value) For testing, we need to reset this valueprotected void
protected boolean
Tests need not send marker packets as they are only needed to log quorum packet delaysvoid
shutdown()
protected void
Start thread that will forward any packet in the queue to the followerboolean
synced()
long
toString()
Methods inherited from class org.apache.zookeeper.server.ZooKeeperThread
handleException
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, yield
-
Field Details
-
LEADER_CLOSE_SOCKET_ASYNC
- See Also:
-
closeSocketAsync
public static final boolean closeSocketAsync -
sock
-
sid
protected long sidZooKeeper server identifier of this learner -
version
protected int version -
packetsReceived
-
packetsSent
-
requestsReceived
-
lastZxid
protected volatile long lastZxid -
established
-
messageTracker
-
FORCE_SNAP_SYNC
For testing purpose, force learnerMaster to use snapshot to sync with followers- See Also:
-
-
Method Details
-
getSocket
-
getLastZxid
public long getLastZxid() -
getEstablished
-
setOutputArchive
-
setBufferedOutput
-
toString
-
getLearnerType
-
packetToString
-
run
public void run()This thread will receive packets from the peer and process them and also listen to new connections from new peers. -
startSendingPackets
protected void startSendingPackets()Start thread that will forward any packet in the queue to the follower -
shouldSendMarkerPacketForLogging
protected boolean shouldSendMarkerPacketForLogging()Tests need not send marker packets as they are only needed to log quorum packet delays -
queueCommittedProposals
protected long queueCommittedProposals(Iterator<Leader.Proposal> itr, long peerLastZxid, Long maxZxid, Long lastCommittedZxid) Queue committed proposals into packet queue. The range of packets which is going to be queued are (peerLaxtZxid, maxZxid]- Parameters:
itr
- iterator point to the proposalspeerLastZxid
- last zxid seen by the followermaxZxid
- max zxid of the proposal to queue, null if no limitlastCommittedZxid
- when sending diff, we need to send lastCommittedZxid on the leader to follow Zab 1.0 protocol.- Returns:
- last zxid of the queued proposal
-
shutdown
public void shutdown() -
tickOfNextAckDeadline
public long tickOfNextAckDeadline() -
ping
public void ping()ping calls from the learnerMaster to the peers -
synced
public boolean synced() -
getLearnerHandlerInfo
-
resetObserverConnectionStats
public void resetObserverConnectionStats() -
getQueuedPackets
For testing, return packet queue -
setFirstPacket
public void setFirstPacket(boolean value) For testing, we need to reset this value
-