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 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
Modifier and TypeFieldDescriptionstatic final int
static final long
-
Constructor Summary
ConstructorDescriptionCachedResourceZkStateListener
(VeniceResource resource) CachedResourceZkStateListener
(VeniceResource resource, int retryLoadAttempts, long retryLoadIntervalInMs) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
handleStateChanged
(org.apache.zookeeper.Watcher.Event.KeeperState state) Once the state of zk connection is changed, this function will be called.protected boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.helix.zookeeper.zkclient.IZkStateListener
handleStateChanged
-
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
-
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 interfaceorg.apache.helix.zookeeper.zkclient.IZkStateListener
- Throws:
Exception
-
handleNewSession
- Specified by:
handleNewSession
in interfaceorg.apache.helix.zookeeper.zkclient.IZkStateListener
- Throws:
Exception
-
handleSessionEstablishmentError
- Specified by:
handleSessionEstablishmentError
in interfaceorg.apache.helix.zookeeper.zkclient.IZkStateListener
- Throws:
Exception
-
isDisconnected
protected boolean isDisconnected()
-