Package com.linkedin.venice.utils
Class HelixUtils
java.lang.Object
com.linkedin.venice.utils.HelixUtils
Helper functions for Helix.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intRetry 9 times for each helix operation in case of getting the error by default. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckClusterSetup(org.apache.helix.HelixAdmin admin, String cluster, int maxAttempts) Before this participant/spectator joining the Helix cluster, we need to make sure the cluster has been setup by controller.static <T> voidcompareAndUpdate(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, int maxAttempts, org.apache.helix.zookeeper.zkclient.DataUpdater<T> dataUpdater) static <T> voidcompareAndUpdate(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, org.apache.helix.zookeeper.zkclient.DataUpdater<T> dataUpdater) static voidconnectHelixManager(SafeHelixManager manager, int maxAttempts) Try to connect Helix Manager.static <T> voidstatic <T> voidcreate(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, T data, int maxAttempts) static <T> booleanstatic <T> List<T>getChildren(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, int maxAttempts) static org.apache.helix.model.CloudConfiggetCloudConfig(org.apache.helix.cloud.constants.CloudProvider cloudProvider, String cloudId, List<String> cloudInfoSources, String cloudInfoProcessorPackage, String cloudInfoProcessorName) static org.apache.helix.model.MaintenanceSignalgetClusterMaintenanceSignal(String clusterName, SafeHelixManager manager) If a cluster is in maintenance mode it returns all the signals associated with it regarding the reason and other details for creating the maintenance mode.static StringgetHelixClusterZkPath(String clusterName) static org.apache.helix.model.IdealStategetIdealState(String clusterName, String resourceName, SafeHelixManager manager) static InstancegetInstanceFromHelixInstanceName(String helixInstanceName) static intgetPartitionId(String helixPartitionName) static StringgetPartitionName(String resourceName, int partitionId) static StringgetResourceName(String helixPartitionName) static StringinstanceIdToUrl(String instanceId) Convert a replica's instance ID to its URL.static booleanisLiveInstance(String clusterName, String instanceId, SafeHelixManager manager) listPathContents(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path) static <T> voidstatic <T> voidremove(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, int maxAttempts) static voidsetupCustomizedStateConfig(org.apache.helix.HelixAdmin admin, String clusterName) This method tells helix what properties to aggregate for customized view.static <T> voidstatic <T> voidupdate(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, T data, int maxAttempts) static <T> voidupdateChildren(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, List<String> paths, List<T> data) static <T> voidupdateChildren(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, List<String> paths, List<T> data, int maxAttempts)
-
Field Details
-
DEFAULT_HELIX_OP_RETRY_COUNT
public static final int DEFAULT_HELIX_OP_RETRY_COUNTRetry 9 times for each helix operation in case of getting the error by default.- See Also:
-
-
Method Details
-
getHelixClusterZkPath
-
getPartitionId
-
getPartitionName
-
getResourceName
-
getInstanceFromHelixInstanceName
- Parameters:
helixInstanceName- of form host_port.- Returns:
- Instance object with correct host and port.
-
getChildren
public static <T> List<T> getChildren(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, int maxAttempts) - Parameters:
dataAccessor- ZK data accessorpath- parent pathmaxAttempts- maximum number of retry attempts- Returns:
- a list of objects that are under parent path. It will return an empty list of objects if parent path is not existing
- Throws:
VeniceException- if data inconsistency persists after all retry attempts
-
listPathContents
-
create
public static <T> void create(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, T data) -
create
public static <T> void create(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, T data, int maxAttempts) -
update
public static <T> void update(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, T data) -
update
public static <T> void update(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, T data, int maxAttempts) -
updateChildren
-
updateChildren
-
exists
public static <T> boolean exists(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path) -
remove
public static <T> void remove(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path) -
remove
public static <T> void remove(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, int maxAttempts) -
compareAndUpdate
public static <T> void compareAndUpdate(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, org.apache.helix.zookeeper.zkclient.DataUpdater<T> dataUpdater) -
compareAndUpdate
public static <T> void compareAndUpdate(org.apache.helix.manager.zk.ZkBaseDataAccessor<T> dataAccessor, String path, int maxAttempts, org.apache.helix.zookeeper.zkclient.DataUpdater<T> dataUpdater) -
connectHelixManager
Try to connect Helix Manager. If failed, waits for certain time and retry. If Helix Manager can not be connected after certain number of retry, throws exception. This method is most likely being used asynchronously since it is going to block and wait if connection fails.- Parameters:
manager- HelixManager instancemaxAttempts- maximum number of attempts to retry on failure- Throws:
VeniceException- if connection keeps failing after certain number of retry
-
checkClusterSetup
public static void checkClusterSetup(org.apache.helix.HelixAdmin admin, String cluster, int maxAttempts) Before this participant/spectator joining the Helix cluster, we need to make sure the cluster has been setup by controller. Otherwise, the following operations issued by participant/spectator would fail. -
isLiveInstance
public static boolean isLiveInstance(String clusterName, String instanceId, SafeHelixManager manager) -
getIdealState
public static org.apache.helix.model.IdealState getIdealState(String clusterName, String resourceName, SafeHelixManager manager) -
getClusterMaintenanceSignal
public static org.apache.helix.model.MaintenanceSignal getClusterMaintenanceSignal(String clusterName, SafeHelixManager manager) If a cluster is in maintenance mode it returns all the signals associated with it regarding the reason and other details for creating the maintenance mode.- Parameters:
clusterName-manager-- Returns:
- the maintenance mode signal if the cluster is in maintenance mode, otherwise returns null.
-
setupCustomizedStateConfig
public static void setupCustomizedStateConfig(org.apache.helix.HelixAdmin admin, String clusterName) This method tells helix what properties to aggregate for customized view. How customized view works in steps: 1. Venice SN reports its instance level states e.g. ingestion progress / hybrid store quota for each partition. 2. Helix aggregates the per instance level states to store version level. This method tells Helix what states to aggregate. So far we need to aggregate two propertiesHelixPartitionState.OFFLINE_PUSHandHelixPartitionState.HYBRID_STORE_QUOTA. 3. Other components e.g. Venice routers listen to the store version level states to serve traffic.- Parameters:
admin-clusterName-
-
instanceIdToUrl
Convert a replica's instance ID to its URL. An example is "localhost_port" to "https://localhost:port".- Parameters:
instanceId-- Returns:
- replica URL
-
getCloudConfig
-