Class RLESparseResourceAllocation
java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.reservation.RLESparseResourceAllocation
- Direct Known Subclasses:
PeriodicRLESparseResourceAllocation
This is a run length encoded sparse data structure that maintains resource
allocations over time.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe set of operators that can be applied to twoRLESparseResourceAllocationduring a merge operation. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected NavigableMap<Long,org.apache.hadoop.yarn.api.records.Resource> protected final Lock -
Constructor Summary
ConstructorsConstructorDescriptionRLESparseResourceAllocation(NavigableMap<Long, org.apache.hadoop.yarn.api.records.Resource> out, org.apache.hadoop.yarn.util.resource.ResourceCalculator resourceCalculator) RLESparseResourceAllocation(org.apache.hadoop.yarn.util.resource.ResourceCalculator resourceCalculator) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddInterval(ReservationInterval reservationInterval, org.apache.hadoop.yarn.api.records.Resource totCap) Add a resource for the specified interval.org.apache.hadoop.yarn.api.records.ResourcegetCapacityAtTime(long tick) Returns the capacity, i.e. total resources allocated at the specified point of time.NavigableMap<Long,org.apache.hadoop.yarn.api.records.Resource> longGet the timestamp of the earliest resource allocation.longGet the timestamp of the latest non-null resource allocation.org.apache.hadoop.yarn.api.records.ResourcegetMaximumPeriodicCapacity(long tick, long period) Get the maximum capacity across specified time instances.org.apache.hadoop.yarn.api.records.ResourceGet the minimum capacity in the specified time range.getRangeOverlapping(long start, long end) Get aRLESparseResourceAllocationview of theResourceallocations between the specified start and end times.org.apache.hadoop.yarn.util.resource.ResourceCalculatorbooleanisEmpty()Returns true if there are no non-zero entries.static RLESparseResourceAllocationmerge(org.apache.hadoop.yarn.util.resource.ResourceCalculator resCalc, org.apache.hadoop.yarn.api.records.Resource clusterResource, RLESparseResourceAllocation a, RLESparseResourceAllocation b, RLESparseResourceAllocation.RLEOperator operator, long start, long end) Merges the range start to end of twoRLESparseResourceAllocationusing a givenRLEOperator.booleanremoveInterval(ReservationInterval reservationInterval, org.apache.hadoop.yarn.api.records.Resource totCap) Removes a resource for the specified interval.voidshift(long delta) This method shifts all the timestamp of theResourceentries by the specified "delta".Map<ReservationInterval,org.apache.hadoop.yarn.api.records.Resource> Returns the representation of the current resources allocated over time as an interval map (in the defined non-null range).toString()
-
Field Details
-
cumulativeCapacity
-
readLock
-
-
Constructor Details
-
RLESparseResourceAllocation
public RLESparseResourceAllocation(org.apache.hadoop.yarn.util.resource.ResourceCalculator resourceCalculator)
-
-
Method Details
-
addInterval
public boolean addInterval(ReservationInterval reservationInterval, org.apache.hadoop.yarn.api.records.Resource totCap) Add a resource for the specified interval.- Parameters:
reservationInterval- the interval for which the resource is to be addedtotCap- the resource to be added- Returns:
- true if addition is successful, false otherwise
-
removeInterval
public boolean removeInterval(ReservationInterval reservationInterval, org.apache.hadoop.yarn.api.records.Resource totCap) Removes a resource for the specified interval.- Parameters:
reservationInterval- the interval for which the resource is to be removedtotCap- the resource to be removed- Returns:
- true if removal is successful, false otherwise
-
getCapacityAtTime
public org.apache.hadoop.yarn.api.records.Resource getCapacityAtTime(long tick) Returns the capacity, i.e. total resources allocated at the specified point of time.- Parameters:
tick- timeStap at which resource needs to be known- Returns:
- the resources allocated at the specified time
-
getEarliestStartTime
public long getEarliestStartTime()Get the timestamp of the earliest resource allocation.- Returns:
- the timestamp of the first resource allocation
-
getLatestNonNullTime
public long getLatestNonNullTime()Get the timestamp of the latest non-null resource allocation.- Returns:
- the timestamp of the last resource allocation
-
isEmpty
public boolean isEmpty()Returns true if there are no non-zero entries.- Returns:
- true if there are no allocations or false otherwise
-
toString
-
toIntervalMap
Returns the representation of the current resources allocated over time as an interval map (in the defined non-null range).- Returns:
- the representation of the current resources allocated over time as an interval map.
-
getCumulative
-
getResourceCalculator
public org.apache.hadoop.yarn.util.resource.ResourceCalculator getResourceCalculator() -
merge
public static RLESparseResourceAllocation merge(org.apache.hadoop.yarn.util.resource.ResourceCalculator resCalc, org.apache.hadoop.yarn.api.records.Resource clusterResource, RLESparseResourceAllocation a, RLESparseResourceAllocation b, RLESparseResourceAllocation.RLEOperator operator, long start, long end) throws PlanningException Merges the range start to end of twoRLESparseResourceAllocationusing a givenRLEOperator.- Parameters:
resCalc- the resource calculatorclusterResource- the total cluster resources (for DRF)a- the left operandb- the right operandoperator- the operator to be applied during mergestart- the start-time of the range to be consideredend- the end-time of the range to be considered- Returns:
- the a merged RLESparseResourceAllocation, produced by applying "operator" to "a" and "b"
- Throws:
PlanningException- in case the operator is subtractTestPositive and the result would contain a negative value
-
getRangeOverlapping
Get aRLESparseResourceAllocationview of theResourceallocations between the specified start and end times.- Parameters:
start- the time from which theResourceallocations are requiredend- the time upto which theResourceallocations are required- Returns:
- the overlapping allocations
-
shift
public void shift(long delta) This method shifts all the timestamp of theResourceentries by the specified "delta".- Parameters:
delta- the time by which to shift theResourceallocations
-
getMaximumPeriodicCapacity
public org.apache.hadoop.yarn.api.records.Resource getMaximumPeriodicCapacity(long tick, long period) Get the maximum capacity across specified time instances. The search-space is specified using the starting value, tick, and the periodic interval for search. Maximum resource allocation across tick, tick + period, tick + 2 * period,..., tick + n * period .. is returned.- Parameters:
tick- the starting time instanceperiod- interval at which capacity is evaluated- Returns:
- maximum resource allocation
-
getMinimumCapacityInInterval
public org.apache.hadoop.yarn.api.records.Resource getMinimumCapacityInInterval(ReservationInterval interval) Get the minimum capacity in the specified time range.- Parameters:
interval- theReservationIntervalto be searched- Returns:
- minimum resource allocation
-