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 TypeMethodDescriptionvoid
addLearnerHandler
(LearnerHandler learnerHandler) long
int
long
getEpochToPropose
(long sid, long lastAcceptedEpoch) long
getPeerInfo
(long sid) byte[]
long
int
int
void
processAck
(long sid, long zxid, SocketAddress localSocketAddress) void
registerLearnerHandlerBean
(LearnerHandler learnerHandler, Socket socket) void
removeLearnerHandler
(LearnerHandler learnerHandler) void
void
revalidateSession
(QuorumPacket qp, LearnerHandler learnerHandler) void
run()
void
start()
long
startForwarding
(LearnerHandler learnerHandler, long lastSeenZxid) void
stop()
void
int
void
touch
(long sess, int to) void
unregisterLearnerHandlerBean
(LearnerHandler learnerHandler) void
waitForEpochAck
(long sid, StateSummary ss) void
waitForNewLeaderAck
(long sid, long zxid) void
Methods 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:
IOException
InterruptedException
-
waitForStartup
- Throws:
InterruptedException
-
getLastProposed
public long getLastProposed() -
getEpochToPropose
public long getEpochToPropose(long sid, long lastAcceptedEpoch) throws InterruptedException, IOException - Throws:
InterruptedException
IOException
-
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
-