Class Observer
java.lang.Object
org.apache.zookeeper.server.quorum.Learner
org.apache.zookeeper.server.quorum.Observer
Observers are peers that do not take part in the atomic broadcast protocol.
Instead, they are informed of successful proposals by the Leader. Observers
therefore naturally act as a relay point for publishing the proposal stream
and can relieve Followers of some of the connection load. Observers may
submit proposals, but do not vote in their acceptance.
See ZOOKEEPER-368 for a discussion of this feature.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Delay the Observer's participation in a leader election upon disconnect so as to prevent unexpected additional load on the voting peers during the process.static final String
When observer lost its connection with the leader, it waits for 0 to the specified value before trying to reconnect with the leader.Fields inherited from class org.apache.zookeeper.server.quorum.Learner
bufferedOutput, closeSocketAsync, leaderAddr, leaderIs, leaderOs, leaderProtocolVersion, LEARNER_ASYNC_SENDING, LEARNER_CLOSE_SOCKET_ASYNC, messageTracker, sock, sockBeingClosed
-
Method Summary
Modifier and TypeMethodDescriptionlong
static long
protected void
Controls the response of an observer to the receipt of a quorumpacketboolean
setLearnerMaster
(String learnerMaster) Prompts the Observer to disconnect from its current learner master and reconnect to the specified server.static void
setObserverElectionDelayMs
(long electionDelayMs) void
shutdown()
Shutdown the Observer.toString()
Methods inherited from class org.apache.zookeeper.server.quorum.Learner
connectToLeader, createSocket, findLeader, getAsyncSending, getPendingRevalidationsCount, getSocket, nanoTime, ping, registerWithLeader, revalidate, setAsyncSending, sockConnect, startSendingThread, syncWithLeader
-
Field Details
-
OBSERVER_RECONNECT_DELAY_MS
When observer lost its connection with the leader, it waits for 0 to the specified value before trying to reconnect with the leader. So that the entire observer fleet won't try to run leader election and reconnect to the leader at once. Default value is zero.- See Also:
-
OBSERVER_ELECTION_DELAY_MS
Delay the Observer's participation in a leader election upon disconnect so as to prevent unexpected additional load on the voting peers during the process. Default value is 200.- See Also:
-
-
Method Details
-
toString
-
processPacket
Controls the response of an observer to the receipt of a quorumpacket- Parameters:
qp
-- Throws:
Exception
-
shutdown
public void shutdown()Shutdown the Observer. -
getLearnerMasterId
public long getLearnerMasterId() -
setLearnerMaster
Prompts the Observer to disconnect from its current learner master and reconnect to the specified server. If that connection attempt fails, the Observer will fail over to the next available learner master. -
getCurrentLearnerMaster
-
getObserverElectionDelayMs
public static long getObserverElectionDelayMs() -
setObserverElectionDelayMs
public static void setObserverElectionDelayMs(long electionDelayMs)
-