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 java.lang.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 usingHelixManager
because HelixManager is using the sameZkClient
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 separateZkClient
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
Constructors Constructor Description HelixLiveInstanceMonitor(org.apache.helix.zookeeper.impl.client.ZkClient zkClient, java.lang.String clusterName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
java.util.Set<Instance>
getAllLiveInstances()
void
handleChildChange(java.lang.String parentPath, java.util.List<java.lang.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
registerLiveInstanceChangedListener(LiveInstanceChangedListener listener)
-
-
-
Method Detail
-
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
public void handleChildChange(java.lang.String parentPath, java.util.List<java.lang.String> currentChildren) throws java.lang.Exception
- Specified by:
handleChildChange
in interfaceorg.apache.helix.zookeeper.zkclient.IZkChildListener
- Throws:
java.lang.Exception
-
isInstanceAlive
public boolean isInstanceAlive(Instance instance)
Description copied from interface:LiveInstanceMonitor
Check whether current instance is alive or not.- Specified by:
isInstanceAlive
in interfaceLiveInstanceMonitor
- Returns:
-
getAllLiveInstances
public java.util.Set<Instance> getAllLiveInstances()
- Specified by:
getAllLiveInstances
in interfaceLiveInstanceMonitor
-
registerLiveInstanceChangedListener
public void registerLiveInstanceChangedListener(LiveInstanceChangedListener listener)
- Specified by:
registerLiveInstanceChangedListener
in interfaceLiveInstanceMonitor
-
-