Class ObserverMaster

  • All Implemented Interfaces:
    java.lang.Runnable

    public class ObserverMaster
    extends LearnerMaster
    implements java.lang.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 Detail

      • addLearnerHandler

        public void addLearnerHandler​(LearnerHandler learnerHandler)
      • removeLearnerHandler

        public void removeLearnerHandler​(LearnerHandler learnerHandler)
      • syncTimeout

        public int syncTimeout()
      • getTickOfNextAckDeadline

        public int getTickOfNextAckDeadline()
      • getTickOfInitialAckDeadline

        public int getTickOfInitialAckDeadline()
      • getAndDecrementFollowerCounter

        public long getAndDecrementFollowerCounter()
      • waitForEpochAck

        public void waitForEpochAck​(long sid,
                                    StateSummary ss)
                             throws java.io.IOException,
                                    java.lang.InterruptedException
        Throws:
        java.io.IOException
        java.lang.InterruptedException
      • waitForStartup

        public void waitForStartup()
                            throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • getLastProposed

        public long getLastProposed()
      • getEpochToPropose

        public long getEpochToPropose​(long sid,
                                      long lastAcceptedEpoch)
                               throws java.lang.InterruptedException,
                                      java.io.IOException
        Throws:
        java.lang.InterruptedException
        java.io.IOException
      • getZKDatabase

        public ZKDatabase getZKDatabase()
      • waitForNewLeaderAck

        public void waitForNewLeaderAck​(long sid,
                                        long zxid)
                                 throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • getCurrentTick

        public int getCurrentTick()
      • processAck

        public void processAck​(long sid,
                               long zxid,
                               java.net.SocketAddress localSocketAddress)
      • touch

        public void touch​(long sess,
                          int to)
      • revalidateSession

        public void revalidateSession​(QuorumPacket qp,
                                      LearnerHandler learnerHandler)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • submitLearnerRequest

        public void submitLearnerRequest​(Request si)
      • startForwarding

        public long startForwarding​(LearnerHandler learnerHandler,
                                    long lastSeenZxid)
      • getQuorumVerifierVersion

        public long getQuorumVerifierVersion()
      • getPeerInfo

        public java.lang.String getPeerInfo​(long sid)
      • getQuorumVerifierBytes

        public byte[] getQuorumVerifierBytes()
      • start

        public void start()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
      • stop

        public void stop()
      • getActiveObservers

        public java.lang.Iterable<java.util.Map<java.lang.String,​java.lang.Object>> getActiveObservers()
      • resetObserverConnectionStats

        public void resetObserverConnectionStats()
      • registerLearnerHandlerBean

        public void registerLearnerHandlerBean​(LearnerHandler learnerHandler,
                                               java.net.Socket socket)
      • unregisterLearnerHandlerBean

        public void unregisterLearnerHandlerBean​(LearnerHandler learnerHandler)