Class CachedResourceZkStateListener

  • All Implemented Interfaces:
    org.apache.helix.zookeeper.zkclient.IZkStateListener

    public class CachedResourceZkStateListener
    extends java.lang.Object
    implements org.apache.helix.zookeeper.zkclient.IZkStateListener
    Listener used to monitor zk connection state change and refresh venice resource once zk connection is reconnected.

    ZK does not guarantee the delivery of notifications. After ZK client disconnect from one ZK server, it will try to connect to another server. After client is connected again, ZK client will register all of watcher again to the new server. But all of events happen during disconnecting are unknown in client's view. So venice should refresh some resources to sync up local cache with ZK.

    • Field Detail

      • DEFAULT_RETRY_LOAD_ATTEMPTS

        public static final int DEFAULT_RETRY_LOAD_ATTEMPTS
        See Also:
        Constant Field Values
      • DEFAULT_RETRY_LOAD_INTERVAL_IN_MS

        public static final long DEFAULT_RETRY_LOAD_INTERVAL_IN_MS
    • Constructor Detail

      • CachedResourceZkStateListener

        public CachedResourceZkStateListener​(VeniceResource resource)
      • CachedResourceZkStateListener

        public CachedResourceZkStateListener​(VeniceResource resource,
                                             int retryLoadAttempts,
                                             long retryLoadIntervalInMs)
    • Method Detail

      • handleStateChanged

        public void handleStateChanged​(org.apache.zookeeper.Watcher.Event.KeeperState state)
                                throws java.lang.Exception
        Once the state of zk connection is changed, this function will be called. So it could not be called twice for the same state change.
        Specified by:
        handleStateChanged in interface org.apache.helix.zookeeper.zkclient.IZkStateListener
        Throws:
        java.lang.Exception
      • handleNewSession

        public void handleNewSession​(java.lang.String s)
                              throws java.lang.Exception
        Specified by:
        handleNewSession in interface org.apache.helix.zookeeper.zkclient.IZkStateListener
        Throws:
        java.lang.Exception
      • handleSessionEstablishmentError

        public void handleSessionEstablishmentError​(java.lang.Throwable error)
                                             throws java.lang.Exception
        Specified by:
        handleSessionEstablishmentError in interface org.apache.helix.zookeeper.zkclient.IZkStateListener
        Throws:
        java.lang.Exception
      • isDisconnected

        protected boolean isDisconnected()