Class FederationPolicyUtils
java.lang.Object
org.apache.hadoop.yarn.server.federation.policies.FederationPolicyUtils
Utility class for Federation policy.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetWeightedRandom(ArrayList<Float> weights) Select a random bin according to the weight array for the bins.static FederationPolicyManagerinstantiatePolicyManager(String newType) A utilize method to instantiate a policy manager class given the type (class name) fromSubClusterPolicyConfiguration.static FederationAMRMProxyPolicyloadAMRMPolicy(String queue, FederationAMRMProxyPolicy oldPolicy, org.apache.hadoop.conf.Configuration conf, FederationStateStoreFacade federationFacade, SubClusterId homeSubClusterId) Get AMRMProxy policy from state store, using default queue and configuration as fallback.loadPolicyConfiguration(String queue, org.apache.hadoop.conf.Configuration conf, FederationStateStoreFacade federationFacade) Get Federation policy configuration from state store, using default queue and configuration as fallback.static voidsetRand(long seed) static voidvalidateSubClusterAvailability(Collection<SubClusterId> activeSubClusters, Collection<SubClusterId> blackListSubClusters) Validate if there is any active subcluster that is not blacklisted, it will throw an exception if there are no usable subclusters.
-
Field Details
-
NO_ACTIVE_SUBCLUSTER_AVAILABLE
- See Also:
-
-
Method Details
-
instantiatePolicyManager
public static FederationPolicyManager instantiatePolicyManager(String newType) throws FederationPolicyInitializationException A utilize method to instantiate a policy manager class given the type (class name) fromSubClusterPolicyConfiguration.- Parameters:
newType- class name of the policy manager to create- Returns:
- Policy manager
- Throws:
FederationPolicyInitializationException- if fails
-
loadPolicyConfiguration
public static SubClusterPolicyConfiguration loadPolicyConfiguration(String queue, org.apache.hadoop.conf.Configuration conf, FederationStateStoreFacade federationFacade) Get Federation policy configuration from state store, using default queue and configuration as fallback.- Parameters:
queue- the queue of the applicationconf- the YARN configurationfederationFacade- state store facade- Returns:
- SubClusterPolicyConfiguration recreated
-
loadAMRMPolicy
public static FederationAMRMProxyPolicy loadAMRMPolicy(String queue, FederationAMRMProxyPolicy oldPolicy, org.apache.hadoop.conf.Configuration conf, FederationStateStoreFacade federationFacade, SubClusterId homeSubClusterId) throws FederationPolicyInitializationException Get AMRMProxy policy from state store, using default queue and configuration as fallback.- Parameters:
queue- the queue of the applicationoldPolicy- the previous policy instance (can be null)conf- the YARN configurationfederationFacade- state store facadehomeSubClusterId- home sub-cluster id- Returns:
- FederationAMRMProxyPolicy recreated
- Throws:
FederationPolicyInitializationException- if fails
-
validateSubClusterAvailability
public static void validateSubClusterAvailability(Collection<SubClusterId> activeSubClusters, Collection<SubClusterId> blackListSubClusters) throws FederationPolicyException Validate if there is any active subcluster that is not blacklisted, it will throw an exception if there are no usable subclusters.- Parameters:
activeSubClusters- the list of subClusters as identified bySubClusterIdcurrently active.blackListSubClusters- the list of subClusters as identified bySubClusterIdto blackList from the selection of the home subCluster.- Throws:
FederationPolicyException- if there are no usable subclusters.
-
getWeightedRandom
Select a random bin according to the weight array for the bins. Only bins with positive weights will be considered. If no positive weight found, return -1.- Parameters:
weights- the weight array- Returns:
- the index of the sample in the array
-
setRand
@VisibleForTesting public static void setRand(long seed)
-