All Known Implementing Classes:
CapacityOverTimePolicy, NoOverCommitPolicy

@LimitedPrivate("yarn") @Unstable public interface SharingPolicy
This is the interface for policy that validate new ReservationAllocations for allocations being added to a Plan. Individual policies will be enforcing different invariants.
  • Method Details

    • init

      void init(String planQueuePath, ReservationSchedulerConfiguration conf)
      Initialize this policy.
      Parameters:
      planQueuePath - the name of the queue for this plan
      conf - the system configuration
    • validate

      void validate(Plan plan, ReservationAllocation newAllocation) throws PlanningException
      This method runs the policy validation logic, and return true/false on whether the ReservationAllocation is acceptable according to this sharing policy.
      Parameters:
      plan - the Plan we validate against
      newAllocation - the allocation proposed to be added to the Plan
      Throws:
      PlanningException - if the policy is respected if we add this ReservationAllocation to the Plan
    • availableResources

      RLESparseResourceAllocation availableResources(RLESparseResourceAllocation available, Plan plan, String user, org.apache.hadoop.yarn.api.records.ReservationId oldId, long start, long end) throws PlanningException
      This method provide a (partial) instantaneous validation by applying business rules (such as max number of parallel containers allowed for a user). To provide the agent with more feedback the returned parameter is expressed in number of containers that can be fit in this time according to the business rules.
      Parameters:
      available - the amount of resources that would be offered if not constrained by the policy
      plan - reference the the current Plan
      user - the username
      start - the start time for the range we are querying
      end - the end time for the range we are querying
      oldId - (optional) the id of a reservation being updated
      Returns:
      the available resources expressed as a RLESparseResourceAllocation
      Throws:
      PlanningException - throws if the request is not valid
    • getValidWindow

      long getValidWindow()
      Returns the time range before and after the current reservation considered by this policy. In particular, this informs the archival process for the Plan, i.e., reservations regarding times before (now - validWindow) can be deleted.
      Returns:
      validWindow the window of validity considered by the policy.