Class CachedResourceZkStateListener

java.lang.Object
com.linkedin.venice.helix.CachedResourceZkStateListener
All Implemented Interfaces:
org.apache.helix.zookeeper.zkclient.IZkStateListener

public class CachedResourceZkStateListener extends 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 Details

    • DEFAULT_RETRY_LOAD_ATTEMPTS

      public static final int DEFAULT_RETRY_LOAD_ATTEMPTS
      See Also:
    • DEFAULT_RETRY_LOAD_INTERVAL_IN_MS

      public static final long DEFAULT_RETRY_LOAD_INTERVAL_IN_MS
  • Constructor Details

    • CachedResourceZkStateListener

      public CachedResourceZkStateListener(VeniceResource resource)
    • CachedResourceZkStateListener

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

    • handleStateChanged

      public void handleStateChanged(org.apache.zookeeper.Watcher.Event.KeeperState state) throws 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:
      Exception
    • handleNewSession

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

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

      protected boolean isDisconnected()