Class InMemoryPlan
java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.reservation.InMemoryPlan
- All Implemented Interfaces:
Plan,PlanContext,PlanEdit
This class represents an in memory representation of the state of our
reservation system, and provides accelerated access to both individual
reservations and aggregate utilization of resources over time.
-
Constructor Summary
ConstructorsConstructorDescriptionInMemoryPlan(QueueMetrics queueMetrics, SharingPolicy policy, ReservationAgent agent, org.apache.hadoop.yarn.api.records.Resource totalCapacity, long step, org.apache.hadoop.yarn.util.resource.ResourceCalculator resCalc, org.apache.hadoop.yarn.api.records.Resource minAlloc, org.apache.hadoop.yarn.api.records.Resource maxAlloc, String queueName, Planner replanner, boolean getMoveOnExpiry, long maxPeriodicity, RMContext rmContext) InMemoryPlan(QueueMetrics queueMetrics, SharingPolicy policy, ReservationAgent agent, org.apache.hadoop.yarn.api.records.Resource totalCapacity, long step, org.apache.hadoop.yarn.util.resource.ResourceCalculator resCalc, org.apache.hadoop.yarn.api.records.Resource minAlloc, org.apache.hadoop.yarn.api.records.Resource maxAlloc, String queueName, Planner replanner, boolean getMoveOnExpiry, long maxPeriodicty, RMContext rmContext, org.apache.hadoop.yarn.util.Clock clock) InMemoryPlan(QueueMetrics queueMetrics, SharingPolicy policy, ReservationAgent agent, org.apache.hadoop.yarn.api.records.Resource totalCapacity, long step, org.apache.hadoop.yarn.util.resource.ResourceCalculator resCalc, org.apache.hadoop.yarn.api.records.Resource minAlloc, org.apache.hadoop.yarn.api.records.Resource maxAlloc, String queueName, Planner replanner, boolean getMoveOnExpiry, RMContext rmContext) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddReservation(ReservationAllocation reservation, boolean isRecovering) Add a newReservationAllocationto the plan.voidarchiveCompletedReservations(long tick) Method invoked to garbage collect old reservations.booleandeleteReservation(org.apache.hadoop.yarn.api.records.ReservationId reservationID) Delete an existingReservationAllocationfrom the plan identified uniquely by itsReservationId.getAvailableResourceOverTime(String user, org.apache.hadoop.yarn.api.records.ReservationId oldId, long start, long end, long period) getConsumptionForUserOverTime(String user, long start, long end) getCumulativeLoadOverTime(long start, long end) longlongorg.apache.hadoop.yarn.api.records.ResourceReturns the single largestResourceallocation that can be reserved in this planlongReturns the maximum periodicity allowed in a recurrence expression for reservations of a particular plan.org.apache.hadoop.yarn.api.records.ResourceReturns the single smallestResourceallocation that can be reserved in this planbooleanInstructs thePlanFolloweron what to do for applications which are still running when the reservation is expiring (move-to-default vs kill)Return theQueueMetricsfor the queue in theResourceSchedulercorresponding to this planReturn the name of the queue in theResourceSchedulercorresponding to this planReturn an instance of aPlanner, which will be invoked in response to unexpected reduction in the resources of this planReturn theReservationAgentconfigured for this plan that is responsible for optimally placing various reservation requestsgetReservationById(org.apache.hadoop.yarn.api.records.ReservationId reservationID) getReservationByUserAtTime(String user, long t) getReservationCountForUserOverTime(String user, long start, long end) getReservations(org.apache.hadoop.yarn.api.records.ReservationId reservationID, ReservationInterval interval) getReservations(org.apache.hadoop.yarn.api.records.ReservationId reservationID, ReservationInterval interval, String user) getReservationsAtTime(long tick) org.apache.hadoop.yarn.util.resource.ResourceCalculatorReturns the systemResourceCalculatorReturn the configuredSharingPolicythat governs the sharing of the resources of the plan between its various userslonggetStep()Returns the configured "step" or granularity of time of the plan in millis.org.apache.hadoop.yarn.api.records.Resourceorg.apache.hadoop.yarn.api.records.ResourcegetTotalCommittedResources(long t) voidsetTotalCapacity(org.apache.hadoop.yarn.api.records.Resource cap) Sets the overall capacity in terms ofResourceassigned to this plan.toString()booleanupdateReservation(ReservationAllocation reservation) Updates an existingReservationAllocationin the plan.
-
Constructor Details
-
InMemoryPlan
public InMemoryPlan(QueueMetrics queueMetrics, SharingPolicy policy, ReservationAgent agent, org.apache.hadoop.yarn.api.records.Resource totalCapacity, long step, org.apache.hadoop.yarn.util.resource.ResourceCalculator resCalc, org.apache.hadoop.yarn.api.records.Resource minAlloc, org.apache.hadoop.yarn.api.records.Resource maxAlloc, String queueName, Planner replanner, boolean getMoveOnExpiry, RMContext rmContext) -
InMemoryPlan
public InMemoryPlan(QueueMetrics queueMetrics, SharingPolicy policy, ReservationAgent agent, org.apache.hadoop.yarn.api.records.Resource totalCapacity, long step, org.apache.hadoop.yarn.util.resource.ResourceCalculator resCalc, org.apache.hadoop.yarn.api.records.Resource minAlloc, org.apache.hadoop.yarn.api.records.Resource maxAlloc, String queueName, Planner replanner, boolean getMoveOnExpiry, long maxPeriodicity, RMContext rmContext) -
InMemoryPlan
public InMemoryPlan(QueueMetrics queueMetrics, SharingPolicy policy, ReservationAgent agent, org.apache.hadoop.yarn.api.records.Resource totalCapacity, long step, org.apache.hadoop.yarn.util.resource.ResourceCalculator resCalc, org.apache.hadoop.yarn.api.records.Resource minAlloc, org.apache.hadoop.yarn.api.records.Resource maxAlloc, String queueName, Planner replanner, boolean getMoveOnExpiry, long maxPeriodicty, RMContext rmContext, org.apache.hadoop.yarn.util.Clock clock)
-
-
Method Details
-
getQueueMetrics
Description copied from interface:PlanContextReturn theQueueMetricsfor the queue in theResourceSchedulercorresponding to this plan- Specified by:
getQueueMetricsin interfacePlanContext- Returns:
- the
QueueMetricsfor the queue in theResourceSchedulercorresponding to this plan
-
getAllReservations
-
addReservation
public boolean addReservation(ReservationAllocation reservation, boolean isRecovering) throws PlanningException Description copied from interface:PlanEditAdd a newReservationAllocationto the plan.- Specified by:
addReservationin interfacePlanEdit- Parameters:
reservation- theReservationAllocationto be added to the planisRecovering- flag to indicate if reservation is being added as part of failover or not- Returns:
- true if addition is successful, false otherwise
- Throws:
PlanningException- if addition is unsuccessful
-
updateReservation
Description copied from interface:PlanEditUpdates an existingReservationAllocationin the plan. This is required for re-negotiation.- Specified by:
updateReservationin interfacePlanEdit- Parameters:
reservation- theReservationAllocationto be updated the plan- Returns:
- true if update is successful, false otherwise
- Throws:
PlanningException- if update is unsuccessful
-
deleteReservation
public boolean deleteReservation(org.apache.hadoop.yarn.api.records.ReservationId reservationID) Description copied from interface:PlanEditDelete an existingReservationAllocationfrom the plan identified uniquely by itsReservationId. This will generally be used for garbage collection.- Specified by:
deleteReservationin interfacePlanEdit- Parameters:
reservationID- theReservationAllocationto be deleted from the plan identified uniquely by itsReservationId- Returns:
- true if delete is successful, false otherwise
-
archiveCompletedReservations
public void archiveCompletedReservations(long tick) Description copied from interface:PlanEditMethod invoked to garbage collect old reservations. It cleans up expired reservations that have fallen out of the sliding archival window.- Specified by:
archiveCompletedReservationsin interfacePlanEdit- Parameters:
tick- the current time from which the archival window is computed
-
getReservationsAtTime
-
getStep
public long getStep()Description copied from interface:PlanContextReturns the configured "step" or granularity of time of the plan in millis.- Specified by:
getStepin interfacePlanContext- Returns:
- plan step in millis
-
getSharingPolicy
Description copied from interface:PlanContextReturn the configuredSharingPolicythat governs the sharing of the resources of the plan between its various users- Specified by:
getSharingPolicyin interfacePlanContext- Returns:
- the configured
SharingPolicythat governs the sharing of the resources of the plan between its various users
-
getReservationAgent
Description copied from interface:PlanContextReturn theReservationAgentconfigured for this plan that is responsible for optimally placing various reservation requests- Specified by:
getReservationAgentin interfacePlanContext- Returns:
- the
ReservationAgentconfigured for this plan
-
getReservationCountForUserOverTime
public RLESparseResourceAllocation getReservationCountForUserOverTime(String user, long start, long end) -
getConsumptionForUserOverTime
-
getTotalCommittedResources
public org.apache.hadoop.yarn.api.records.Resource getTotalCommittedResources(long t) -
getReservations
public Set<ReservationAllocation> getReservations(org.apache.hadoop.yarn.api.records.ReservationId reservationID, ReservationInterval interval) -
getReservations
public Set<ReservationAllocation> getReservations(org.apache.hadoop.yarn.api.records.ReservationId reservationID, ReservationInterval interval, String user) -
getReservationById
public ReservationAllocation getReservationById(org.apache.hadoop.yarn.api.records.ReservationId reservationID) -
getTotalCapacity
public org.apache.hadoop.yarn.api.records.Resource getTotalCapacity() -
getAvailableResourceOverTime
public RLESparseResourceAllocation getAvailableResourceOverTime(String user, org.apache.hadoop.yarn.api.records.ReservationId oldId, long start, long end, long period) throws PlanningException - Throws:
PlanningException
-
getMinimumAllocation
public org.apache.hadoop.yarn.api.records.Resource getMinimumAllocation()Description copied from interface:PlanContextReturns the single smallestResourceallocation that can be reserved in this plan- Specified by:
getMinimumAllocationin interfacePlanContext- Returns:
- the single smallest
Resourceallocation that can be reserved in this plan
-
setTotalCapacity
public void setTotalCapacity(org.apache.hadoop.yarn.api.records.Resource cap) Description copied from interface:PlanEditSets the overall capacity in terms ofResourceassigned to this plan.- Specified by:
setTotalCapacityin interfacePlanEdit- Parameters:
cap- the overall capacity in terms ofResourceassigned to this plan
-
getEarliestStartTime
public long getEarliestStartTime() -
getLastEndTime
public long getLastEndTime() -
getResourceCalculator
public org.apache.hadoop.yarn.util.resource.ResourceCalculator getResourceCalculator()Description copied from interface:PlanContextReturns the systemResourceCalculator- Specified by:
getResourceCalculatorin interfacePlanContext- Returns:
- the system
ResourceCalculator
-
getQueueName
Description copied from interface:PlanContextReturn the name of the queue in theResourceSchedulercorresponding to this plan- Specified by:
getQueueNamein interfacePlanContext- Returns:
- the name of the queue in the
ResourceSchedulercorresponding to this plan
-
getMaximumAllocation
public org.apache.hadoop.yarn.api.records.Resource getMaximumAllocation()Description copied from interface:PlanContextReturns the single largestResourceallocation that can be reserved in this plan- Specified by:
getMaximumAllocationin interfacePlanContext- Returns:
- the single largest
Resourceallocation that can be reserved in this plan
-
getMaximumPeriodicity
public long getMaximumPeriodicity()Description copied from interface:PlanContextReturns the maximum periodicity allowed in a recurrence expression for reservations of a particular plan. This value must be divisible by the recurrence expression of a newly submitted reservation. Otherwise, the reservation submission will fail.- Specified by:
getMaximumPeriodicityin interfacePlanContext- Returns:
- the maximum periodicity allowed in a recurrence expression for reservations of a particular plan.
-
toCumulativeString
-
getReplanner
Description copied from interface:PlanContextReturn an instance of aPlanner, which will be invoked in response to unexpected reduction in the resources of this plan- Specified by:
getReplannerin interfacePlanContext- Returns:
- an instance of a
Planner, which will be invoked in response to unexpected reduction in the resources of this plan
-
getMoveOnExpiry
public boolean getMoveOnExpiry()Description copied from interface:PlanContextInstructs thePlanFolloweron what to do for applications which are still running when the reservation is expiring (move-to-default vs kill)- Specified by:
getMoveOnExpiryin interfacePlanContext- Returns:
- true if remaining applications have to be killed, false if they have to migrated
-
toString
-
getReservationByUserAtTime
-
getCumulativeLoadOverTime
public RLESparseResourceAllocation getCumulativeLoadOverTime(long start, long end) throws PlanningException - Throws:
PlanningException
-