Class MemoryPlacementConstraintManager

java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.server.resourcemanager.scheduler.constraint.PlacementConstraintManagerService
org.apache.hadoop.yarn.server.resourcemanager.scheduler.constraint.MemoryPlacementConstraintManager
All Implemented Interfaces:
Closeable, AutoCloseable, org.apache.hadoop.service.Service, PlacementConstraintManager

@Private @Unstable public class MemoryPlacementConstraintManager extends PlacementConstraintManagerService
In memory implementation of the PlacementConstraintManagerService.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service

    org.apache.hadoop.service.Service.STATE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addConstraint(org.apache.hadoop.yarn.api.records.ApplicationId appId, Set<String> sourceTags, org.apache.hadoop.yarn.api.resource.PlacementConstraint placementConstraint, boolean replace)
    Add a placement constraint for a given application and a given set of (source) allocation tags.
    void
    addGlobalConstraint(Set<String> sourceTags, org.apache.hadoop.yarn.api.resource.PlacementConstraint placementConstraint, boolean replace)
    Add a placement constraint that will be used globally.
    org.apache.hadoop.yarn.api.resource.PlacementConstraint
    getConstraint(org.apache.hadoop.yarn.api.records.ApplicationId appId, Set<String> sourceTags)
    Retrieve the placement constraint that is associated with a set of allocation tags for a given application.
    Map<Set<String>,org.apache.hadoop.yarn.api.resource.PlacementConstraint>
    getConstraints(org.apache.hadoop.yarn.api.records.ApplicationId appId)
    Retrieve all constraints for a given application, along with the allocation tags that enable each constraint.
    org.apache.hadoop.yarn.api.resource.PlacementConstraint
    Retrieve a global constraint that is associated with a given set of allocation tags.
    org.apache.hadoop.yarn.api.resource.PlacementConstraint
    getMultilevelConstraint(org.apache.hadoop.yarn.api.records.ApplicationId appId, Set<String> sourceTags, org.apache.hadoop.yarn.api.resource.PlacementConstraint schedulingRequestConstraint)
    Consider all levels of constraints (scheduling request, app, cluster) and return a merged constraint.
    int
    Returns the number of global constraints registered in the Placement Constraint Manager.
    int
    Returns the number of currently registered applications in the Placement Constraint Manager.
    void
    registerApplication(org.apache.hadoop.yarn.api.records.ApplicationId appId, Map<Set<String>,org.apache.hadoop.yarn.api.resource.PlacementConstraint> constraintMap)
    Register all placement constraints of an application.
    void
    Remove a global constraint that is associated with the given allocation tags.
    protected void
    serviceInit(org.apache.hadoop.conf.Configuration conf)
     
    void
    unregisterApplication(org.apache.hadoop.yarn.api.records.ApplicationId appId)
    Remove the constraints that correspond to a given application.

    Methods inherited from class org.apache.hadoop.yarn.server.resourcemanager.scheduler.constraint.PlacementConstraintManagerService

    getValidSourceTag, validateConstraint, validateSourceTags

    Methods inherited from class org.apache.hadoop.service.AbstractService

    close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, serviceStart, serviceStop, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MemoryPlacementConstraintManager

      public MemoryPlacementConstraintManager()
  • Method Details

    • serviceInit

      protected void serviceInit(org.apache.hadoop.conf.Configuration conf) throws Exception
      Overrides:
      serviceInit in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • registerApplication

      public void registerApplication(org.apache.hadoop.yarn.api.records.ApplicationId appId, Map<Set<String>,org.apache.hadoop.yarn.api.resource.PlacementConstraint> constraintMap)
      Description copied from interface: PlacementConstraintManager
      Register all placement constraints of an application.
      Parameters:
      appId - the application ID
      constraintMap - the map of allocation tags to constraints for this application
    • addConstraint

      public void addConstraint(org.apache.hadoop.yarn.api.records.ApplicationId appId, Set<String> sourceTags, org.apache.hadoop.yarn.api.resource.PlacementConstraint placementConstraint, boolean replace)
      Description copied from interface: PlacementConstraintManager
      Add a placement constraint for a given application and a given set of (source) allocation tags. The constraint will be used on Scheduling Requests that carry this set of allocation tags. TODO: Support merge and not only replace when adding a constraint.
      Parameters:
      appId - the application ID
      sourceTags - the set of allocation tags that will enable this constraint
      placementConstraint - the constraint
      replace - if true, an existing constraint for these tags will be replaced by the given one
    • addGlobalConstraint

      public void addGlobalConstraint(Set<String> sourceTags, org.apache.hadoop.yarn.api.resource.PlacementConstraint placementConstraint, boolean replace)
      Description copied from interface: PlacementConstraintManager
      Add a placement constraint that will be used globally. These constraints are added by the cluster administrator. TODO: Support merge and not only replace when adding a constraint.
      Parameters:
      sourceTags - the allocation tags that will enable this constraint
      placementConstraint - the constraint
      replace - if true, an existing constraint for these tags will be replaced by the given one
    • getConstraints

      public Map<Set<String>,org.apache.hadoop.yarn.api.resource.PlacementConstraint> getConstraints(org.apache.hadoop.yarn.api.records.ApplicationId appId)
      Description copied from interface: PlacementConstraintManager
      Retrieve all constraints for a given application, along with the allocation tags that enable each constraint.
      Parameters:
      appId - the application ID
      Returns:
      the constraints for this application with the associated tags
    • getConstraint

      public org.apache.hadoop.yarn.api.resource.PlacementConstraint getConstraint(org.apache.hadoop.yarn.api.records.ApplicationId appId, Set<String> sourceTags)
      Description copied from interface: PlacementConstraintManager
      Retrieve the placement constraint that is associated with a set of allocation tags for a given application.
      Parameters:
      appId - the application ID
      sourceTags - the allocation tags that enable this constraint
      Returns:
      the constraint
    • getGlobalConstraint

      public org.apache.hadoop.yarn.api.resource.PlacementConstraint getGlobalConstraint(Set<String> sourceTags)
      Description copied from interface: PlacementConstraintManager
      Retrieve a global constraint that is associated with a given set of allocation tags.
      Parameters:
      sourceTags - the allocation tags that enable this constraint
      Returns:
      the constraint
    • getMultilevelConstraint

      public org.apache.hadoop.yarn.api.resource.PlacementConstraint getMultilevelConstraint(org.apache.hadoop.yarn.api.records.ApplicationId appId, Set<String> sourceTags, org.apache.hadoop.yarn.api.resource.PlacementConstraint schedulingRequestConstraint)
      Description copied from interface: PlacementConstraintManager
      Consider all levels of constraints (scheduling request, app, cluster) and return a merged constraint.
      Parameters:
      appId - application ID
      sourceTags - a set of source allocation tags
      schedulingRequestConstraint - placement constraint at scheduling request level
      Returns:
      a merged placement constraint
    • unregisterApplication

      public void unregisterApplication(org.apache.hadoop.yarn.api.records.ApplicationId appId)
      Description copied from interface: PlacementConstraintManager
      Remove the constraints that correspond to a given application.
      Parameters:
      appId - the application that will be removed.
    • removeGlobalConstraint

      public void removeGlobalConstraint(Set<String> sourceTags)
      Description copied from interface: PlacementConstraintManager
      Remove a global constraint that is associated with the given allocation tags.
      Parameters:
      sourceTags - the allocation tags
    • getNumRegisteredApplications

      public int getNumRegisteredApplications()
      Description copied from interface: PlacementConstraintManager
      Returns the number of currently registered applications in the Placement Constraint Manager.
      Returns:
      number of registered applications.
    • getNumGlobalConstraints

      public int getNumGlobalConstraints()
      Description copied from interface: PlacementConstraintManager
      Returns the number of global constraints registered in the Placement Constraint Manager.
      Returns:
      number of global constraints.