Package com.linkedin.venice.helix
Class CachedResourceZkStateListener
- java.lang.Object
-
- com.linkedin.venice.helix.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 Summary
Fields Modifier and Type Field Description static int
DEFAULT_RETRY_LOAD_ATTEMPTS
static long
DEFAULT_RETRY_LOAD_INTERVAL_IN_MS
-
Constructor Summary
Constructors Constructor Description CachedResourceZkStateListener(VeniceResource resource)
CachedResourceZkStateListener(VeniceResource resource, int retryLoadAttempts, long retryLoadIntervalInMs)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
handleNewSession(java.lang.String s)
void
handleSessionEstablishmentError(java.lang.Throwable error)
void
handleStateChanged(org.apache.zookeeper.Watcher.Event.KeeperState state)
Once the state of zk connection is changed, this function will be called.protected boolean
isDisconnected()
-
-
-
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 interfaceorg.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 interfaceorg.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 interfaceorg.apache.helix.zookeeper.zkclient.IZkStateListener
- Throws:
java.lang.Exception
-
isDisconnected
protected boolean isDisconnected()
-
-