Class RLESparseResourceAllocation

java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.reservation.RLESparseResourceAllocation
Direct Known Subclasses:
PeriodicRLESparseResourceAllocation

public class RLESparseResourceAllocation extends Object
This is a run length encoded sparse data structure that maintains resource allocations over time.
  • Field Details

    • cumulativeCapacity

      protected NavigableMap<Long,org.apache.hadoop.yarn.api.records.Resource> cumulativeCapacity
    • readLock

      protected final Lock readLock
  • Constructor Details

    • RLESparseResourceAllocation

      public RLESparseResourceAllocation(org.apache.hadoop.yarn.util.resource.ResourceCalculator resourceCalculator)
    • RLESparseResourceAllocation

      public RLESparseResourceAllocation(NavigableMap<Long,org.apache.hadoop.yarn.api.records.Resource> out, 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 added
      totCap - 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 removed
      totCap - 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

      public String toString()
      Overrides:
      toString in class Object
    • toIntervalMap

      public Map<ReservationInterval,org.apache.hadoop.yarn.api.records.Resource> 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

      public NavigableMap<Long,org.apache.hadoop.yarn.api.records.Resource> 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 two RLESparseResourceAllocation using a given RLEOperator.
      Parameters:
      resCalc - the resource calculator
      clusterResource - the total cluster resources (for DRF)
      a - the left operand
      b - the right operand
      operator - the operator to be applied during merge
      start - the start-time of the range to be considered
      end - 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

      public RLESparseResourceAllocation getRangeOverlapping(long start, long end)
      Get a RLESparseResourceAllocation view of the Resource allocations between the specified start and end times.
      Parameters:
      start - the time from which the Resource allocations are required
      end - the time upto which the Resource allocations are required
      Returns:
      the overlapping allocations
    • shift

      public void shift(long delta)
      This method shifts all the timestamp of the Resource entries by the specified "delta".
      Parameters:
      delta - the time by which to shift the Resource allocations
    • 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 instance
      period - 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 - the ReservationInterval to be searched
      Returns:
      minimum resource allocation