Class ObserverMaster
java.lang.Object
org.apache.zookeeper.server.quorum.LearnerMaster
org.apache.zookeeper.server.quorum.ObserverMaster
- All Implemented Interfaces:
Runnable
Used by Followers to host Observers. This reduces the network load on the Leader process by pushing
the responsibility for keeping Observers in sync off the leading peer.
It is expected that Observers will continue to perform the initial vetting of clients and requests.
Observers send the request to the follower where it is received by an ObserverMaster.
The ObserverMaster forwards a copy of the request to the ensemble Leader and inserts it into its own
request processor pipeline where it can be matched with the response comes back. All commits received
from the Leader will be forwarded along to every Learner connected to the ObserverMaster.
New Learners connecting to a Follower will receive a LearnerHandler object and be party to its syncing logic
to be brought up to date.
The logic is quite a bit simpler than the corresponding logic in Leader because it only hosts observers.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddLearnerHandler(LearnerHandler learnerHandler) longintlonggetEpochToPropose(long sid, long lastAcceptedEpoch) longgetPeerInfo(long sid) byte[]longintintvoidprocessAck(long sid, long zxid, SocketAddress localSocketAddress) voidregisterLearnerHandlerBean(LearnerHandler learnerHandler, Socket socket) voidremoveLearnerHandler(LearnerHandler learnerHandler) voidvoidrevalidateSession(QuorumPacket qp, LearnerHandler learnerHandler) voidrun()voidstart()longstartForwarding(LearnerHandler learnerHandler, long lastSeenZxid) voidstop()voidintvoidtouch(long sess, int to) voidunregisterLearnerHandlerBean(LearnerHandler learnerHandler) voidwaitForEpochAck(long sid, StateSummary ss) voidwaitForNewLeaderAck(long sid, long zxid) voidMethods inherited from class org.apache.zookeeper.server.quorum.LearnerMaster
getLearnerDiffSyncThrottler, getLearnerSnapSyncThrottler, getMaxConcurrentDiffSyncs, getMaxConcurrentSnapSyncs, setMaxConcurrentDiffSyncs, setMaxConcurrentSnapSyncs
-
Method Details
-
addLearnerHandler
-
removeLearnerHandler
-
syncTimeout
public int syncTimeout() -
getTickOfNextAckDeadline
public int getTickOfNextAckDeadline() -
getTickOfInitialAckDeadline
public int getTickOfInitialAckDeadline() -
getAndDecrementFollowerCounter
public long getAndDecrementFollowerCounter() -
waitForEpochAck
- Throws:
IOExceptionInterruptedException
-
waitForStartup
- Throws:
InterruptedException
-
getLastProposed
public long getLastProposed() -
getEpochToPropose
public long getEpochToPropose(long sid, long lastAcceptedEpoch) throws InterruptedException, IOException - Throws:
InterruptedExceptionIOException
-
getZKDatabase
-
waitForNewLeaderAck
- Throws:
InterruptedException
-
getCurrentTick
public int getCurrentTick() -
processAck
-
touch
public void touch(long sess, int to) -
revalidateSession
- Throws:
IOException
-
submitLearnerRequest
-
startForwarding
-
getQuorumVerifierVersion
public long getQuorumVerifierVersion() -
getPeerInfo
-
getQuorumVerifierBytes
public byte[] getQuorumVerifierBytes() -
getQuorumAuthServer
-
start
- Throws:
IOException
-
run
public void run() -
stop
public void stop() -
getActiveObservers
-
resetObserverConnectionStats
public void resetObserverConnectionStats() -
registerLearnerHandlerBean
-
unregisterLearnerHandlerBean
-