Class AbstractSchedulerPlanFollower
java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.reservation.AbstractSchedulerPlanFollower
- All Implemented Interfaces:
Runnable,PlanFollower
- Direct Known Subclasses:
CapacitySchedulerPlanFollower,FairSchedulerPlanFollower
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.hadoop.yarn.util.Clockprotected Collection<Plan>protected YarnScheduler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidaddReservationQueue(String planQueueName, Queue queue, String currResId) Add a new reservation queue for reservation currResId for this planQueue.protected voidcleanupExpiredQueues(String planQueueName, boolean shouldMove, Set<String> toRemove, String defReservationQueue) First sets entitlement of queues to zero to prevent new app submission.protected abstract voidcreateDefaultReservationQueue(String planQueueName, Queue queue, String defReservationQueue) Creates the default reservation queue for use when no reservation is used for applications submitted to this planQueue.getChildReservationQueues(Queue planQueue) Get a list of reservation queues for this planQueue.protected abstract QueuegetPlanQueue(String planQueueName) Get queue associated with reservable queue named.protected abstract org.apache.hadoop.yarn.api.records.ResourcegetPlanResources(Plan plan, Queue queue, org.apache.hadoop.yarn.api.records.Resource clusterResources) Get plan resources for this planQueue.protected StringgetReservationIdFromQueueName(String resQueueName) protected StringgetReservationQueueName(String planQueueName, String reservationId) protected abstract org.apache.hadoop.yarn.api.records.ResourcegetReservationQueueResourceIfExists(Plan plan, org.apache.hadoop.yarn.api.records.ReservationId reservationId) Get reservation queue resources if it exists otherwise return null.protected intgetReservedResources(long now, Set<ReservationAllocation> currentReservations, Set<String> curReservationNames, org.apache.hadoop.yarn.api.records.Resource reservedResources) voidinit(org.apache.hadoop.yarn.util.Clock clock, ResourceScheduler sched, Collection<Plan> plans) Init function that configures the PlanFollower, by providing:voidrun()voidsetPlans(Collection<Plan> plans) Setter for the list of plans.protected voidsetQueueEntitlement(String planQueueName, String currResId, float targetCapacity, float maxCapacity) protected List<ReservationAllocation>sortByDelta(List<ReservationAllocation> currentReservations, long now, Plan plan) Sort in the order from the least new amount of resources asked (likely negative) to the highest.voidsynchronizePlan(Plan plan, boolean shouldReplan) The function performing the actual synchronization operation for a given Plan.
-
Field Details
-
plans
-
scheduler
-
clock
protected org.apache.hadoop.yarn.util.Clock clock
-
-
Constructor Details
-
AbstractSchedulerPlanFollower
public AbstractSchedulerPlanFollower()
-
-
Method Details
-
init
public void init(org.apache.hadoop.yarn.util.Clock clock, ResourceScheduler sched, Collection<Plan> plans) Description copied from interface:PlanFollowerInit function that configures the PlanFollower, by providing:- Specified by:
initin interfacePlanFollower- Parameters:
clock- a reference to the system clock.sched- a reference to the underlying schedulerplans- references to the plans we should keep synchronized at every time tick.
-
run
public void run() -
setPlans
Description copied from interface:PlanFollowerSetter for the list of plans.- Specified by:
setPlansin interfacePlanFollower- Parameters:
plans- the collection of Plans we operate on at every time tick.
-
synchronizePlan
Description copied from interface:PlanFollowerThe function performing the actual synchronization operation for a given Plan. This is normally invoked by the run method, but it can be invoked synchronously to avoid race conditions when a user's reservation request start time is imminent.- Specified by:
synchronizePlanin interfacePlanFollower- Parameters:
plan- the Plan to synchronizeshouldReplan- replan on reduction of plan capacity if true or proportionally scale down reservations if false
-
getReservationIdFromQueueName
-
setQueueEntitlement
protected void setQueueEntitlement(String planQueueName, String currResId, float targetCapacity, float maxCapacity) throws org.apache.hadoop.yarn.exceptions.YarnException - Throws:
org.apache.hadoop.yarn.exceptions.YarnException
-
getReservationQueueName
-
cleanupExpiredQueues
protected void cleanupExpiredQueues(String planQueueName, boolean shouldMove, Set<String> toRemove, String defReservationQueue) First sets entitlement of queues to zero to prevent new app submission. Then move all apps in the set of queues to the parent plan queue's default reservation queue if move is enabled. Finally cleanups the queue by killing any apps (if move is disabled or move failed) and removing the queue- Parameters:
planQueueName- the name ofPlanQueueshouldMove- flag to indicate if any running apps should be moved or killedtoRemove- the remnant apps to clean updefReservationQueue- the defaultReservationQueueof thePlan
-
getReservedResources
protected int getReservedResources(long now, Set<ReservationAllocation> currentReservations, Set<String> curReservationNames, org.apache.hadoop.yarn.api.records.Resource reservedResources) -
sortByDelta
protected List<ReservationAllocation> sortByDelta(List<ReservationAllocation> currentReservations, long now, Plan plan) Sort in the order from the least new amount of resources asked (likely negative) to the highest. This prevents "order-of-operation" errors related to exceeding 100% capacity temporarily.- Parameters:
currentReservations- the currently active reservationsnow- the current timeplan- thePlanthat is being considered- Returns:
- the sorted list of
ReservationAllocations
-
getPlanQueue
Get queue associated with reservable queue named.- Parameters:
planQueueName- name of the reservable queue- Returns:
- queue associated with the reservable queue
-
getChildReservationQueues
Get a list of reservation queues for this planQueue.- Parameters:
planQueue- the queue for the currentPlan- Returns:
- the queues corresponding to the reservations
-
addReservationQueue
Add a new reservation queue for reservation currResId for this planQueue.- Parameters:
planQueueName- name of the reservable queue.queue- the queue for the currentPlan.currResId- curr reservationId.
-
createDefaultReservationQueue
protected abstract void createDefaultReservationQueue(String planQueueName, Queue queue, String defReservationQueue) Creates the default reservation queue for use when no reservation is used for applications submitted to this planQueue.- Parameters:
planQueueName- name of the reservable queuequeue- the queue for the currentPlandefReservationQueue- name of the defaultReservationQueue
-
getPlanResources
protected abstract org.apache.hadoop.yarn.api.records.Resource getPlanResources(Plan plan, Queue queue, org.apache.hadoop.yarn.api.records.Resource clusterResources) Get plan resources for this planQueue. -
getReservationQueueResourceIfExists
protected abstract org.apache.hadoop.yarn.api.records.Resource getReservationQueueResourceIfExists(Plan plan, org.apache.hadoop.yarn.api.records.ReservationId reservationId) Get reservation queue resources if it exists otherwise return null.- Parameters:
plan- the currentPlanbeing consideredreservationId- the identifier of the reservation- Returns:
- the resources allocated to the specified reservation
-