Class AbstractRouterPolicy
java.lang.Object
org.apache.hadoop.yarn.server.federation.policies.AbstractConfigurableFederationPolicy
org.apache.hadoop.yarn.server.federation.policies.router.AbstractRouterPolicy
- All Implemented Interfaces:
ConfigurableFederationPolicy,FederationRouterPolicy
- Direct Known Subclasses:
HashBasedRouterPolicy,LoadBasedRouterPolicy,PriorityRouterPolicy,RejectRouterPolicy,UniformRandomRouterPolicy,WeightedRandomRouterPolicy
public abstract class AbstractRouterPolicy
extends AbstractConfigurableFederationPolicy
implements FederationRouterPolicy
Base abstract class for
FederationRouterPolicy implementations, that
provides common validation for reinitialization.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract SubClusterIdchooseSubCluster(String queue, Map<SubClusterId, SubClusterInfo> preSelectSubClusters) This method is implemented by the specific policy, and it is used to route both reservations, and applications among a given set of sub-clusters.getHomeSubcluster(org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext appContext, List<SubClusterId> blackLists) Simply picks from alphabetically-sorted active subclusters based on the hash of query name.getReservationHomeSubcluster(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest request) This method provides a wrapper of all policy functionalities for routing a reservation.protected Map<SubClusterId,SubClusterInfo> prefilterSubClusters(org.apache.hadoop.yarn.api.records.ReservationId reservationId, Map<SubClusterId, SubClusterInfo> activeSubClusters) Filter chosen SubCluster based on reservationId.voidvalidate(org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext appSubmissionContext) voidvalidate(WeightedPolicyInfo newPolicyInfo) Overridable validation step for the policy configuration.Methods inherited from class org.apache.hadoop.yarn.server.federation.policies.AbstractConfigurableFederationPolicy
getActiveSubclusters, getIsDirty, getPolicyContext, getPolicyInfo, reinitialize, setPolicyContext, setPolicyInfoMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.yarn.server.federation.policies.ConfigurableFederationPolicy
reinitialize
-
Constructor Details
-
AbstractRouterPolicy
public AbstractRouterPolicy()
-
-
Method Details
-
validate
public void validate(WeightedPolicyInfo newPolicyInfo) throws FederationPolicyInitializationException Description copied from class:AbstractConfigurableFederationPolicyOverridable validation step for the policy configuration.- Overrides:
validatein classAbstractConfigurableFederationPolicy- Parameters:
newPolicyInfo- the configuration to test.- Throws:
FederationPolicyInitializationException- if the configuration is not valid.
-
validate
public void validate(org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext appSubmissionContext) throws FederationPolicyException - Throws:
FederationPolicyException
-
chooseSubCluster
protected abstract SubClusterId chooseSubCluster(String queue, Map<SubClusterId, SubClusterInfo> preSelectSubClusters) throws org.apache.hadoop.yarn.exceptions.YarnExceptionThis method is implemented by the specific policy, and it is used to route both reservations, and applications among a given set of sub-clusters.- Parameters:
queue- the queue for this application/reservationpreSelectSubClusters- a pre-filter set of sub-clusters- Returns:
- the chosen sub-cluster
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- if the policy fails to choose a sub-cluster
-
prefilterSubClusters
protected Map<SubClusterId,SubClusterInfo> prefilterSubClusters(org.apache.hadoop.yarn.api.records.ReservationId reservationId, Map<SubClusterId, SubClusterInfo> activeSubClusters) throws org.apache.hadoop.yarn.exceptions.YarnExceptionFilter chosen SubCluster based on reservationId.- Parameters:
reservationId- the globally unique identifier for a reservation.activeSubClusters- the map of ids to info for all active subclusters.- Returns:
- the chosen sub-cluster
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- if the policy fails to choose a sub-cluster
-
getHomeSubcluster
public SubClusterId getHomeSubcluster(org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext appContext, List<SubClusterId> blackLists) throws org.apache.hadoop.yarn.exceptions.YarnException Simply picks from alphabetically-sorted active subclusters based on the hash of query name. Jobs of the same queue will all be routed to the same sub-cluster, as far as the number of active sub-cluster and their names remain the same.- Specified by:
getHomeSubclusterin interfaceFederationRouterPolicy- Parameters:
appContext- theApplicationSubmissionContextthat has to be routed to an appropriate subCluster for execution.blackLists- the list of subClusters as identified bySubClusterIdto blackList from the selection of the home subCluster.- Returns:
- a hash-based chosen
SubClusterIdthat will be the "home" for this application. - Throws:
org.apache.hadoop.yarn.exceptions.YarnException- if there are no active subclusters.
-
getReservationHomeSubcluster
public SubClusterId getReservationHomeSubcluster(org.apache.hadoop.yarn.api.protocolrecords.ReservationSubmissionRequest request) throws org.apache.hadoop.yarn.exceptions.YarnException This method provides a wrapper of all policy functionalities for routing a reservation. Internally it manages configuration changes, and policy init/reinit.- Specified by:
getReservationHomeSubclusterin interfaceFederationRouterPolicy- Parameters:
request- the reservation to route.- Returns:
- the id of the subcluster that will be the "home" for this reservation.
- Throws:
org.apache.hadoop.yarn.exceptions.YarnException- if there are issues initializing policies, or no valid sub-cluster id could be found for this reservation.
-