Package com.linkedin.venice.helix
Class HelixLiveInstanceMonitor
java.lang.Object
com.linkedin.venice.helix.HelixLiveInstanceMonitor
- All Implemented Interfaces:
LiveInstanceMonitor,VeniceResource,org.apache.helix.zookeeper.zkclient.IZkChildListener
public class HelixLiveInstanceMonitor
extends Object
implements org.apache.helix.zookeeper.zkclient.IZkChildListener, VeniceResource, LiveInstanceMonitor
This class is used to monitor the current live instances(Helix participators).
Here, it is not using
HelixManager because HelixManager is using the same
ZkClient being used for all the Helix related ZK Watches/data operations.
When there are a lot of state transitions during node starts/stops, it will take a very long time to let
HelixManager to report the instance list change since those state transition notifications could happen
earlier than node stop/start event. Under this circumstance, HelixManager won't report node list change
in time. Using a separate ZkClient will allow node list change notification happen in a separate
channel, so that node list change can be captured in time.
This way is a little hacky since this class is reading from Helix ZK directory directly.-
Constructor Summary
ConstructorsConstructorDescriptionHelixLiveInstanceMonitor(org.apache.helix.zookeeper.impl.client.ZkClient zkClient, String clusterName) -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()voidhandleChildChange(String parentPath, List<String> currentChildren) booleanisInstanceAlive(Instance instance) Check whether current instance is alive or not.voidrefresh()Must be run during service start else it wont subscribe to state changes.voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.helix.zookeeper.zkclient.IZkChildListener
handleChildChange
-
Constructor Details
-
HelixLiveInstanceMonitor
public HelixLiveInstanceMonitor(org.apache.helix.zookeeper.impl.client.ZkClient zkClient, String clusterName)
-
-
Method Details
-
refresh
public void refresh()Must be run during service start else it wont subscribe to state changes.- Specified by:
refreshin interfaceVeniceResource
-
clear
public void clear()- Specified by:
clearin interfaceVeniceResource
-
handleChildChange
- Specified by:
handleChildChangein interfaceorg.apache.helix.zookeeper.zkclient.IZkChildListener- Throws:
Exception
-
isInstanceAlive
Description copied from interface:LiveInstanceMonitorCheck whether current instance is alive or not.- Specified by:
isInstanceAlivein interfaceLiveInstanceMonitor- Returns:
-
getAllLiveInstances
- Specified by:
getAllLiveInstancesin interfaceLiveInstanceMonitor
-
registerLiveInstanceChangedListener
- Specified by:
registerLiveInstanceChangedListenerin interfaceLiveInstanceMonitor
-