Observer (Apache ZooKeeper - Server 3.7.0 API)
Date: 2021-03-17

org.apache.zookeeper.server.quorum

## 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 and Description
    --- | ---
    `static 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.
    `static 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.

    - ### 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 and Description
    --- | ---
    `QuorumPeer.QuorumServer` | `getCurrentLearnerMaster()`
    `long` | `getLearnerMasterId()`
    `static long` | `getObserverElectionDelayMs()`
    `protected void` | `processPacket(QuorumPacket qp)` Controls the response of an observer to the receipt of a quorumpacket
    `boolean` | `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.
    `String` | `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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 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

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### 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.

    - #### getCurrentLearnerMaster

          public QuorumPeer.QuorumServer getCurrentLearnerMaster()

    - #### getObserverElectionDelayMs

          public static long getObserverElectionDelayMs()

    - #### setObserverElectionDelayMs

          public static void setObserverElectionDelayMs(long electionDelayMs)

Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.