Package com.linkedin.venice.helix
Class ZkRoutersClusterManager
java.lang.Object
com.linkedin.venice.helix.ZkRoutersClusterManager
- All Implemented Interfaces:
RoutersClusterManager,VeniceResource,org.apache.helix.zookeeper.zkclient.IZkChildListener,org.apache.helix.zookeeper.zkclient.IZkDataListener,org.apache.helix.zookeeper.zkclient.IZkStateListener
public class ZkRoutersClusterManager
extends Object
implements RoutersClusterManager, org.apache.helix.zookeeper.zkclient.IZkChildListener, org.apache.helix.zookeeper.zkclient.IZkDataListener, VeniceResource, org.apache.helix.zookeeper.zkclient.IZkStateListener
Manage live routers through Zookeeper. Help each router to create a ZNode which reflects whether that router is
connected to ZK cluster or not and monitor all routers' ZNodes to get how many routers live right now.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.linkedin.venice.meta.RoutersClusterManager
RoutersClusterManager.RouterCountChangedListener -
Constructor Summary
ConstructorsConstructorDescriptionZkRoutersClusterManager(org.apache.helix.zookeeper.impl.client.ZkClient zkClient, HelixAdapterSerializer adapter, String clusterName, int refreshAttemptsForZkReconnect, long refreshIntervalForZkReconnectInMs) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidchangeLiveRouterCount(int newRouterCount) voidclear()voidvoidenableMaxCapacityProtection(boolean enable) Enable or disable max read capacity protection feature on router.voidenableThrottling(boolean enable) Enable or disable read throttling feature on router.intGet the expected number of routers in the cluster.intGet how many routers live right now.protected final StringvoidhandleChildChange(String parentPath, List<String> currentChildren) Once a router instance is added/remove from cluster, its ephemeral zk node will be added/removed, then this handler will be executed to process the event.voidhandleDataChange(String dataPath, Object data) Once router cluster config is changed(Both cluster level or router level config is changed), its persistent zk node's data will be changed, then this handler will be executed to process the event.voidhandleDataDeleted(String dataPath) voidvoidhandleSessionEstablishmentError(Throwable throwable) voidhandleStateChanged(org.apache.zookeeper.Watcher.Event.KeeperState keeperState) booleanbooleanvoidrefresh()voidregisterRouter(String instanceId) Create a ephemeral ZNode for the give router.voidListen on the router count, get the notification once it's changed.protected voidtriggerRouterCountChangedEvent(int newRouterCount) voidunregisterRouter(String instanceId) Unregister the given router instance from the cluster.voidupdateExpectedRouterCount(int expectedNumber) Update the expected number of routers in the cluster.Methods 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
handleChildChangeMethods inherited from interface org.apache.helix.zookeeper.zkclient.IZkDataListener
handleDataChangeMethods inherited from interface org.apache.helix.zookeeper.zkclient.IZkStateListener
handleStateChanged
-
Constructor Details
-
ZkRoutersClusterManager
public ZkRoutersClusterManager(org.apache.helix.zookeeper.impl.client.ZkClient zkClient, HelixAdapterSerializer adapter, String clusterName, int refreshAttemptsForZkReconnect, long refreshIntervalForZkReconnectInMs)
-
-
Method Details
-
refresh
public void refresh()- Specified by:
refreshin interfaceVeniceResource
-
clear
public void clear()- Specified by:
clearin interfaceVeniceResource
-
getLiveRouterInstances
- Specified by:
getLiveRouterInstancesin interfaceRoutersClusterManager
-
registerRouter
Create a ephemeral ZNode for the give router. If parent path does not exist, it will help to create that as well.- Specified by:
registerRouterin interfaceRoutersClusterManager
-
unregisterRouter
Description copied from interface:RoutersClusterManagerUnregister the given router instance from the cluster.- Specified by:
unregisterRouterin interfaceRoutersClusterManager
-
getLiveRoutersCount
public int getLiveRoutersCount()Get how many routers live right now. It could be a delay because the number will only be update once the manger received the zk notification.- Specified by:
getLiveRoutersCountin interfaceRoutersClusterManager
-
getExpectedRoutersCount
public int getExpectedRoutersCount()Description copied from interface:RoutersClusterManagerGet the expected number of routers in the cluster.- Specified by:
getExpectedRoutersCountin interfaceRoutersClusterManager
-
updateExpectedRouterCount
public void updateExpectedRouterCount(int expectedNumber) Description copied from interface:RoutersClusterManagerUpdate the expected number of routers in the cluster.- Specified by:
updateExpectedRouterCountin interfaceRoutersClusterManager
-
subscribeRouterCountChangedEvent
public void subscribeRouterCountChangedEvent(RoutersClusterManager.RouterCountChangedListener listener) Description copied from interface:RoutersClusterManagerListen on the router count, get the notification once it's changed.- Specified by:
subscribeRouterCountChangedEventin interfaceRoutersClusterManager
-
isThrottlingEnabled
public boolean isThrottlingEnabled()- Specified by:
isThrottlingEnabledin interfaceRoutersClusterManager
-
isMaxCapacityProtectionEnabled
public boolean isMaxCapacityProtectionEnabled()- Specified by:
isMaxCapacityProtectionEnabledin interfaceRoutersClusterManager
-
enableThrottling
public void enableThrottling(boolean enable) Description copied from interface:RoutersClusterManagerEnable or disable read throttling feature on router. If this feature is disable, router will accept all read request regardless of store's quota.- Specified by:
enableThrottlingin interfaceRoutersClusterManager
-
enableMaxCapacityProtection
public void enableMaxCapacityProtection(boolean enable) Description copied from interface:RoutersClusterManagerEnable or disable max read capacity protection feature on router. If this feature is disabled, router will not protected by pre-defined max read capacity which means the total quota one router assigned might exceed the max capacity that router could serve.- Specified by:
enableMaxCapacityProtectionin interfaceRoutersClusterManager
-
createRouterClusterConfig
public void createRouterClusterConfig()- Specified by:
createRouterClusterConfigin interfaceRoutersClusterManager
-
getRoutersClusterConfig
-
changeLiveRouterCount
protected void changeLiveRouterCount(int newRouterCount) -
triggerRouterCountChangedEvent
protected void triggerRouterCountChangedEvent(int newRouterCount) -
handleChildChange
Once a router instance is added/remove from cluster, its ephemeral zk node will be added/removed, then this handler will be executed to process the event.- Specified by:
handleChildChangein interfaceorg.apache.helix.zookeeper.zkclient.IZkChildListener- Throws:
Exception
-
handleDataChange
Once router cluster config is changed(Both cluster level or router level config is changed), its persistent zk node's data will be changed, then this handler will be executed to process the event.Make this method synchronized to avoid the conflict modification of routersClusterConfig.
- Specified by:
handleDataChangein interfaceorg.apache.helix.zookeeper.zkclient.IZkDataListener- Throws:
Exception
-
handleDataDeleted
- Specified by:
handleDataDeletedin interfaceorg.apache.helix.zookeeper.zkclient.IZkDataListener- Throws:
Exception
-
getRouterRootPath
-
handleStateChanged
public void handleStateChanged(org.apache.zookeeper.Watcher.Event.KeeperState keeperState) - Specified by:
handleStateChangedin interfaceorg.apache.helix.zookeeper.zkclient.IZkStateListener
-
handleNewSession
- Specified by:
handleNewSessionin interfaceorg.apache.helix.zookeeper.zkclient.IZkStateListener- Throws:
Exception
-
handleSessionEstablishmentError
- Specified by:
handleSessionEstablishmentErrorin interfaceorg.apache.helix.zookeeper.zkclient.IZkStateListener- Throws:
Exception
-