Class SchedulingPolicy
java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.SchedulingPolicy
- Direct Known Subclasses:
DominantResourceFairnessPolicy,FairSharePolicy,FifoPolicy
The SchedulingPolicy is used by the fair scheduler mainly to determine
what a queue's fair share and steady fair share should be as well as
calculating available headroom. This determines how resources can be
shared between running applications within a queue.
Every queue has a policy, including parents and children. If a child
queue doesn't specify one, it inherits the parent's policy.
The policy for a child queue must be compatible with the policy of
the parent queue; there are some combinations that aren't allowed.
See isChildPolicyAllowed(SchedulingPolicy).
The policy for a queue is specified by setting property
schedulingPolicy in the fair scheduler configuration file.
The default policy is FairSharePolicy if not specified.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleancheckIfUsageOverFairShare(org.apache.hadoop.yarn.api.records.Resource usage, org.apache.hadoop.yarn.api.records.Resource fairShare) Check if the resource usage is over the fair share under this policy.abstract voidcomputeShares(Collection<? extends Schedulable> schedulables, org.apache.hadoop.yarn.api.records.Resource totalResources) Computes and updates the shares ofSchedulables as per theSchedulingPolicy, to be used later for scheduling decisions.abstract voidcomputeSteadyShares(Collection<? extends FSQueue> queues, org.apache.hadoop.yarn.api.records.Resource totalResources) Computes and updates the steady shares ofFSQueues as per theSchedulingPolicy.abstract Comparator<Schedulable>The comparator returned by this method is to be used for sorting theSchedulables in that queue.abstract org.apache.hadoop.yarn.api.records.ResourcegetHeadroom(org.apache.hadoop.yarn.api.records.Resource queueFairShare, org.apache.hadoop.yarn.api.records.Resource queueUsage, org.apache.hadoop.yarn.api.records.Resource maxAvailable) Get headroom by calculating the min ofclusterAvailableand (queueFairShare-queueUsage) resources that are applicable to this policy.static SchedulingPolicygetInstance(Class<? extends SchedulingPolicy> clazz) Returns aSchedulingPolicyinstance corresponding to the passed clazz.abstract StringgetName()abstract org.apache.hadoop.yarn.util.resource.ResourceCalculatorTheResourceCalculatorreturned by this method should be used for any calculations involving resources.voidinitialize(org.apache.hadoop.yarn.api.records.Resource clusterCapacity) Deprecated.voidinitialize(FSContext fsContext) Initialize the scheduling policy with aFSContextobject, which has a pointer to the cluster resources among other information.booleanisChildPolicyAllowed(SchedulingPolicy childPolicy) Check whether the policy of a child queue is allowed.static SchedulingPolicyReturnsSchedulingPolicyinstance corresponding to theSchedulingPolicypassed as a string.
-
Field Details
-
DEFAULT_POLICY
-
-
Constructor Details
-
SchedulingPolicy
public SchedulingPolicy()
-
-
Method Details
-
getInstance
Returns aSchedulingPolicyinstance corresponding to the passed clazz.- Parameters:
clazz- a class that extendsSchedulingPolicy- Returns:
- a
SchedulingPolicyinstance
-
parse
ReturnsSchedulingPolicyinstance corresponding to theSchedulingPolicypassed as a string. The policy can be "fair" for FairSharePolicy, "fifo" for FifoPolicy, or "drf" for DominantResourceFairnessPolicy. For a customSchedulingPolicys in the RM classpath, the policy should be canonical class name of theSchedulingPolicy.- Parameters:
policy- canonical class name or "drf" or "fair" or "fifo"- Returns:
- a
SchedulingPolicyinstance parsed from given policy - Throws:
AllocationConfigurationException- for any errors.
-
initialize
Deprecated.Since it doesn't track cluster resource changes, replaced byinitialize(FSContext).Initialize the scheduling policy with cluster resources.- Parameters:
clusterCapacity- cluster resources
-
initialize
Initialize the scheduling policy with aFSContextobject, which has a pointer to the cluster resources among other information.- Parameters:
fsContext- aFSContextobject which has a pointer to the cluster resources
-
getResourceCalculator
public abstract org.apache.hadoop.yarn.util.resource.ResourceCalculator getResourceCalculator()TheResourceCalculatorreturned by this method should be used for any calculations involving resources.- Returns:
- ResourceCalculator instance to use
-
getName
- Returns:
- returns the name of
SchedulingPolicy
-
getComparator
The comparator returned by this method is to be used for sorting theSchedulables in that queue.- Returns:
- the comparator to sort by
-
getHeadroom
public abstract org.apache.hadoop.yarn.api.records.Resource getHeadroom(org.apache.hadoop.yarn.api.records.Resource queueFairShare, org.apache.hadoop.yarn.api.records.Resource queueUsage, org.apache.hadoop.yarn.api.records.Resource maxAvailable) Get headroom by calculating the min ofclusterAvailableand (queueFairShare-queueUsage) resources that are applicable to this policy. For eg if only memory then leave other resources such as CPU to same asclusterAvailable.- Parameters:
queueFairShare- fairshare in the queuequeueUsage- resources used in the queuemaxAvailable- available resource in cluster for this queue- Returns:
- calculated headroom
-
isChildPolicyAllowed
Check whether the policy of a child queue is allowed.- Parameters:
childPolicy- the policy of child queue- Returns:
- true if the child policy is allowed; false otherwise
-
initialize(FSContext).