Class Observer
- java.lang.Object
-
- org.apache.zookeeper.server.quorum.Learner
-
- org.apache.zookeeper.server.quorum.Observer
-
public class Observer extends Learner
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
Fields Modifier and Type Field Description static StringOBSERVER_ELECTION_DELAY_MSDelay 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 StringOBSERVER_RECONNECT_DELAY_MSWhen 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description QuorumPeer.QuorumServergetCurrentLearnerMaster()longgetLearnerMasterId()static longgetObserverElectionDelayMs()protected voidprocessPacket(QuorumPacket qp)Controls the response of an observer to the receipt of a quorumpacketbooleansetLearnerMaster(String learnerMaster)Prompts the Observer to disconnect from its current learner master and reconnect to the specified server.static voidsetObserverElectionDelayMs(long electionDelayMs)voidshutdown()Shutdown the Observer.StringtoString()-
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 Detail
-
OBSERVER_RECONNECT_DELAY_MS
public static final String 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:
- Constant Field Values
-
OBSERVER_ELECTION_DELAY_MS
public static final String 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:
- Constant Field Values
-
-
Method Detail
-
processPacket
protected void processPacket(QuorumPacket qp) throws Exception
Controls the response of an observer to the receipt of a quorumpacket- Parameters:
qp-- Throws:
Exception
-
getLearnerMasterId
public long getLearnerMasterId()
-
setLearnerMaster
public boolean setLearnerMaster(String learnerMaster)
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
public QuorumPeer.QuorumServer getCurrentLearnerMaster()
-
getObserverElectionDelayMs
public static long getObserverElectionDelayMs()
-
setObserverElectionDelayMs
public static void setObserverElectionDelayMs(long electionDelayMs)
-
-