Class 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 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
      • shutdown

        public void shutdown()
        Shutdown the Observer.
        Overrides:
        shutdown in class Learner
      • 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.
      • getObserverElectionDelayMs

        public static long getObserverElectionDelayMs()
      • setObserverElectionDelayMs

        public static void setObserverElectionDelayMs​(long electionDelayMs)