Interface PlacementConstraintManager
- All Known Implementing Classes:
MemoryPlacementConstraintManager,PlacementConstraintManagerService
@Private
@Unstable
public interface PlacementConstraintManager
Interface for storing and retrieving placement constraints (see
PlacementConstraint).-
Method Summary
Modifier and TypeMethodDescriptionvoidaddConstraint(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.voidaddGlobalConstraint(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.PlacementConstraintgetConstraint(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.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.PlacementConstraintgetGlobalConstraint(Set<String> sourceTags) Retrieve a global constraint that is associated with a given set of allocation tags.org.apache.hadoop.yarn.api.resource.PlacementConstraintgetMultilevelConstraint(org.apache.hadoop.yarn.api.records.ApplicationId applicationId, 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.intReturns the number of global constraints registered in the Placement Constraint Manager.intReturns the number of currently registered applications in the Placement Constraint Manager.voidregisterApplication(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.voidremoveGlobalConstraint(Set<String> sourceTags) Remove a global constraint that is associated with the given allocation tags.voidunregisterApplication(org.apache.hadoop.yarn.api.records.ApplicationId appId) Remove the constraints that correspond to a given application.default booleanvalidateConstraint(Set<String> sourceTags, org.apache.hadoop.yarn.api.resource.PlacementConstraint placementConstraint) Validate a placement constraint and the set of allocation tags that will enable it.
-
Method Details
-
registerApplication
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.- Parameters:
appId- the application IDconstraintMap- the map of allocation tags to constraints for this application
-
addConstraint
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. 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 IDsourceTags- the set of allocation tags that will enable this constraintplacementConstraint- the constraintreplace- if true, an existing constraint for these tags will be replaced by the given one
-
addGlobalConstraint
void addGlobalConstraint(Set<String> sourceTags, org.apache.hadoop.yarn.api.resource.PlacementConstraint placementConstraint, boolean replace) 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 constraintplacementConstraint- the constraintreplace- if true, an existing constraint for these tags will be replaced by the given one
-
getConstraints
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.- Parameters:
appId- the application ID- Returns:
- the constraints for this application with the associated tags
-
getConstraint
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.- Parameters:
appId- the application IDsourceTags- the allocation tags that enable this constraint- Returns:
- the constraint
-
getGlobalConstraint
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
org.apache.hadoop.yarn.api.resource.PlacementConstraint getMultilevelConstraint(org.apache.hadoop.yarn.api.records.ApplicationId applicationId, 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.- Parameters:
applicationId- application IDsourceTags- a set of source allocation tagsschedulingRequestConstraint- placement constraint at scheduling request level- Returns:
- a merged placement constraint
-
unregisterApplication
void unregisterApplication(org.apache.hadoop.yarn.api.records.ApplicationId appId) Remove the constraints that correspond to a given application.- Parameters:
appId- the application that will be removed.
-
removeGlobalConstraint
Remove a global constraint that is associated with the given allocation tags.- Parameters:
sourceTags- the allocation tags
-
getNumRegisteredApplications
int getNumRegisteredApplications()Returns the number of currently registered applications in the Placement Constraint Manager.- Returns:
- number of registered applications.
-
getNumGlobalConstraints
int getNumGlobalConstraints()Returns the number of global constraints registered in the Placement Constraint Manager.- Returns:
- number of global constraints.
-
validateConstraint
default boolean validateConstraint(Set<String> sourceTags, org.apache.hadoop.yarn.api.resource.PlacementConstraint placementConstraint) Validate a placement constraint and the set of allocation tags that will enable it.- Parameters:
sourceTags- the associated allocation tagsplacementConstraint- the constraint- Returns:
- true if constraint and tags are valid
-