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
ConstructorDescriptionHelixLiveInstanceMonitor
(org.apache.helix.zookeeper.impl.client.ZkClient zkClient, String clusterName) -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
void
handleChildChange
(String parentPath, List<String> currentChildren) boolean
isInstanceAlive
(Instance instance) Check whether current instance is alive or not.void
refresh()
Must be run during service start else it wont subscribe to state changes.void
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.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:
refresh
in interfaceVeniceResource
-
clear
public void clear()- Specified by:
clear
in interfaceVeniceResource
-
handleChildChange
- Specified by:
handleChildChange
in interfaceorg.apache.helix.zookeeper.zkclient.IZkChildListener
- Throws:
Exception
-
isInstanceAlive
Description copied from interface:LiveInstanceMonitor
Check whether current instance is alive or not.- Specified by:
isInstanceAlive
in interfaceLiveInstanceMonitor
- Returns:
-
getAllLiveInstances
- Specified by:
getAllLiveInstances
in interfaceLiveInstanceMonitor
-
registerLiveInstanceChangedListener
- Specified by:
registerLiveInstanceChangedListener
in interfaceLiveInstanceMonitor
-