Class ProportionalCapacityPreemptionPolicy
java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.monitor.capacity.ProportionalCapacityPreemptionPolicy
- All Implemented Interfaces:
CapacitySchedulerPreemptionContext,SchedulingEditPolicy
public class ProportionalCapacityPreemptionPolicy
extends Object
implements SchedulingEditPolicy, CapacitySchedulerPreemptionContext
This class implement a
SchedulingEditPolicy that is designed to be
paired with the CapacityScheduler. At every invocation of
editSchedule() it computes the ideal amount of resources assigned to each
queue (for each queue in the hierarchy), and determines whether preemption
is needed. Overcapacity is distributed among queues in a weighted fair manner,
where the weight is the amount of guaranteed capacity for the queue.
Based on this ideal assignment it determines whether preemption is required
and select a set of containers from each application that would be killed if
the corresponding amount of resources is not freed up by the application.
If not in observeOnly mode, it triggers preemption requests via a
ContainerPreemptEvent that the ResourceManager will ensure
to deliver to the application (or to execute).
If the deficit of resources is persistent over a long enough period of time
this policy will trigger forced termination of containers (again by generating
ContainerPreemptEvent).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumIntraQueuePreemptionOrder will be used to define various priority orders which could be configured by admin. -
Constructor Summary
ConstructorsConstructorDescriptionProportionalCapacityPreemptionPolicy(RMContext context, CapacityScheduler scheduler, org.apache.hadoop.yarn.util.Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPartitionToUnderServedQueues(String queueName, String partition) voidThis method is invoked at regular intervals.intbooleanlongbooleanSet<org.apache.hadoop.yarn.api.records.ContainerId>floatdoublefloatlongdoubleorg.apache.hadoop.yarn.api.records.ResourcegetPartitionResource(String partition) getQueueByPartition(String queueName, String partition) Get queue partition by given queueName and partitionNamegetQueuePartitions(String queueName) Get all queue partitions by given queueNameorg.apache.hadoop.yarn.util.resource.ResourceCalculatorgetUnderServedQueuesPerPartition(String partition) voidinit(org.apache.hadoop.conf.Configuration config, RMContext context, ResourceScheduler sched) boolean
-
Constructor Details
-
ProportionalCapacityPreemptionPolicy
public ProportionalCapacityPreemptionPolicy() -
ProportionalCapacityPreemptionPolicy
@VisibleForTesting public ProportionalCapacityPreemptionPolicy(RMContext context, CapacityScheduler scheduler, org.apache.hadoop.yarn.util.Clock clock)
-
-
Method Details
-
init
public void init(org.apache.hadoop.conf.Configuration config, RMContext context, ResourceScheduler sched) - Specified by:
initin interfaceSchedulingEditPolicy
-
getResourceCalculator
public org.apache.hadoop.yarn.util.resource.ResourceCalculator getResourceCalculator()- Specified by:
getResourceCalculatorin interfaceCapacitySchedulerPreemptionContext
-
editSchedule
public void editSchedule()Description copied from interface:SchedulingEditPolicyThis method is invoked at regular intervals. Internally the policy is allowed to track containers and affect the scheduler. The "actions" performed are passed back through an EventHandler.- Specified by:
editSchedulein interfaceSchedulingEditPolicy
-
getMonitoringInterval
public long getMonitoringInterval()- Specified by:
getMonitoringIntervalin interfaceSchedulingEditPolicy
-
getPolicyName
- Specified by:
getPolicyNamein interfaceSchedulingEditPolicy
-
getToPreemptContainers
-
getQueueByPartition
Get queue partition by given queueName and partitionName- Specified by:
getQueueByPartitionin interfaceCapacitySchedulerPreemptionContext
-
getQueuePartitions
Get all queue partitions by given queueName- Specified by:
getQueuePartitionsin interfaceCapacitySchedulerPreemptionContext
-
getScheduler
- Specified by:
getSchedulerin interfaceCapacitySchedulerPreemptionContext
-
getRMContext
- Specified by:
getRMContextin interfaceCapacitySchedulerPreemptionContext
-
isObserveOnly
public boolean isObserveOnly()- Specified by:
isObserveOnlyin interfaceCapacitySchedulerPreemptionContext
-
getKillableContainers
- Specified by:
getKillableContainersin interfaceCapacitySchedulerPreemptionContext
-
getMaxIgnoreOverCapacity
public double getMaxIgnoreOverCapacity()- Specified by:
getMaxIgnoreOverCapacityin interfaceCapacitySchedulerPreemptionContext
-
getNaturalTerminationFactor
public double getNaturalTerminationFactor()- Specified by:
getNaturalTerminationFactorin interfaceCapacitySchedulerPreemptionContext
-
getLeafQueueNames
- Specified by:
getLeafQueueNamesin interfaceCapacitySchedulerPreemptionContext
-
getAllPartitions
- Specified by:
getAllPartitionsin interfaceCapacitySchedulerPreemptionContext
-
getClusterMaxApplicationPriority
public int getClusterMaxApplicationPriority()- Specified by:
getClusterMaxApplicationPriorityin interfaceCapacitySchedulerPreemptionContext
-
getMaxAllowableLimitForIntraQueuePreemption
public float getMaxAllowableLimitForIntraQueuePreemption()- Specified by:
getMaxAllowableLimitForIntraQueuePreemptionin interfaceCapacitySchedulerPreemptionContext
-
getMinimumThresholdForIntraQueuePreemption
public float getMinimumThresholdForIntraQueuePreemption()- Specified by:
getMinimumThresholdForIntraQueuePreemptionin interfaceCapacitySchedulerPreemptionContext
-
getPartitionResource
- Specified by:
getPartitionResourcein interfaceCapacitySchedulerPreemptionContext
-
getUnderServedQueuesPerPartition
- Specified by:
getUnderServedQueuesPerPartitionin interfaceCapacitySchedulerPreemptionContext
-
addPartitionToUnderServedQueues
- Specified by:
addPartitionToUnderServedQueuesin interfaceCapacitySchedulerPreemptionContext
-
getIntraQueuePreemptionOrderPolicy
public ProportionalCapacityPreemptionPolicy.IntraQueuePreemptionOrderPolicy getIntraQueuePreemptionOrderPolicy()- Specified by:
getIntraQueuePreemptionOrderPolicyin interfaceCapacitySchedulerPreemptionContext
-
getCrossQueuePreemptionConservativeDRF
public boolean getCrossQueuePreemptionConservativeDRF()- Specified by:
getCrossQueuePreemptionConservativeDRFin interfaceCapacitySchedulerPreemptionContext
-
getInQueuePreemptionConservativeDRF
public boolean getInQueuePreemptionConservativeDRF()- Specified by:
getInQueuePreemptionConservativeDRFin interfaceCapacitySchedulerPreemptionContext
-
getDefaultMaximumKillWaitTimeout
public long getDefaultMaximumKillWaitTimeout()- Specified by:
getDefaultMaximumKillWaitTimeoutin interfaceCapacitySchedulerPreemptionContext
-