Package org.apache.hadoop.yarn.api.resource
Class PlacementConstraints
java.lang.Object
org.apache.hadoop.yarn.api.resource.PlacementConstraints
This class contains various static methods for the applications to create
placement constraints (see also
PlacementConstraint).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classorg.apache.hadoop.yarn.api.resource.PlacementConstraints.PlacementTargetsClass with static methods for constructing target expressions to be used in placement constraints. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.hadoop.yarn.api.resource.PlacementConstraint.Andand(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint... children) A conjunction of constraints.static PlacementConstraintbuild(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint constraintExpr) Creates aPlacementConstraintgiven a constraint expression.static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraintcardinality(String scope, int minCardinality, int maxCardinality, String... allocationTags) Creates a constraint that restricts the number of allocations within a given scope (e.g., node or rack).static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraintcardinality(String scope, String namespace, int minCardinality, int maxCardinality, String... allocationTags) Similar tocardinality(String, int, int, String...), but let you attach a namespace to the given allocation tags.static org.apache.hadoop.yarn.api.resource.PlacementConstraint.DelayedOrdelayedOr(org.apache.hadoop.yarn.api.resource.PlacementConstraint.TimedPlacementConstraint... children) Creates a composite constraint that includes a list of timed placement constraints.static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraintmaxCardinality(String scope, int maxCardinality, String... allocationTags) Similar tocardinality(String, int, int, String...), but determines only the maximum cardinality (the minimum cardinality is 0).static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraintmaxCardinality(String scope, String tagNamespace, int maxCardinality, String... allocationTags) Similar tomaxCardinality(String, int, String...), but let you specify a namespace for the tags, see supported namespaces inAllocationTagNamespaceType.static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraintminCardinality(String scope, int minCardinality, String... allocationTags) Similar tocardinality(String, int, int, String...), but determines only the minimum cardinality (the maximum cardinality is unbound).static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraintminCardinality(String scope, String namespace, int minCardinality, String... allocationTags) Similar tominCardinality(String, int, String...), but let you attach a namespace to the allocation tags.static org.apache.hadoop.yarn.api.resource.PlacementConstraint.Oror(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint... children) A disjunction of constraints.static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstrainttargetCardinality(String scope, int minCardinality, int maxCardinality, org.apache.hadoop.yarn.api.resource.PlacementConstraint.TargetExpression... targetExpressions) This constraint generalizes the cardinality and target constraints.static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstrainttargetIn(String scope, org.apache.hadoop.yarn.api.resource.PlacementConstraint.TargetExpression... targetExpressions) Creates a constraint that requires allocations to be placed on nodes that satisfy all target expressions within the given scope (e.g., node or rack).static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstrainttargetNodeAttribute(String scope, NodeAttributeOpCode opCode, org.apache.hadoop.yarn.api.resource.PlacementConstraint.TargetExpression... targetExpressions) Creates a constraint that requires allocations to be placed on nodes that belong to a scope (e.g., node or rack) that satisfy any of the target expressions based on node attribute op code.static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstrainttargetNotIn(String scope, org.apache.hadoop.yarn.api.resource.PlacementConstraint.TargetExpression... targetExpressions) Creates a constraint that requires allocations to be placed on nodes that belong to a scope (e.g., node or rack) that does not satisfy any of the target expressions.static org.apache.hadoop.yarn.api.resource.PlacementConstraint.TimedPlacementConstrainttimedClockConstraint(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint constraint, long delay, TimeUnit timeUnit) Creates a placement constraint that has to be satisfied within a time window.static org.apache.hadoop.yarn.api.resource.PlacementConstraint.TimedPlacementConstrainttimedOpportunitiesConstraint(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint constraint, long delay) Creates a placement constraint that has to be satisfied within a number of placement opportunities (invocations of the scheduler).
-
Field Details
-
NODE
- See Also:
-
RACK
- See Also:
-
NODE_PARTITION
- See Also:
-
-
Method Details
-
targetIn
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint targetIn(String scope, org.apache.hadoop.yarn.api.resource.PlacementConstraint.TargetExpression... targetExpressions) Creates a constraint that requires allocations to be placed on nodes that satisfy all target expressions within the given scope (e.g., node or rack). For example,targetIn(RACK, allocationTag("hbase-m")), allows allocations on nodes that belong to a rack that has at least one tag with value "hbase-m".- Parameters:
scope- the scope within which the target expressions should be satisfiedtargetExpressions- the expressions that need to be satisfied within the scope- Returns:
- the resulting placement constraint
-
targetNotIn
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint targetNotIn(String scope, org.apache.hadoop.yarn.api.resource.PlacementConstraint.TargetExpression... targetExpressions) Creates a constraint that requires allocations to be placed on nodes that belong to a scope (e.g., node or rack) that does not satisfy any of the target expressions.- Parameters:
scope- the scope within which the target expressions should not be truetargetExpressions- the expressions that need to not be true within the scope- Returns:
- the resulting placement constraint
-
targetNodeAttribute
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint targetNodeAttribute(String scope, NodeAttributeOpCode opCode, org.apache.hadoop.yarn.api.resource.PlacementConstraint.TargetExpression... targetExpressions) Creates a constraint that requires allocations to be placed on nodes that belong to a scope (e.g., node or rack) that satisfy any of the target expressions based on node attribute op code.- Parameters:
scope- the scope within which the target expressions should not be trueopCode- Node Attribute code which could be equals, not equals.targetExpressions- the expressions that need to not be true within the scope- Returns:
- the resulting placement constraint
-
cardinality
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint cardinality(String scope, int minCardinality, int maxCardinality, String... allocationTags) Creates a constraint that restricts the number of allocations within a given scope (e.g., node or rack). For example,cardinality(NODE, 3, 10, "zk")is satisfied on nodes where there are no less than 3 allocations with tag "zk" and no more than 10.- Parameters:
scope- the scope of the constraintminCardinality- determines the minimum number of allocations within the scopemaxCardinality- determines the maximum number of allocations within the scopeallocationTags- the constraint targets allocations with these tags- Returns:
- the resulting placement constraint
-
cardinality
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint cardinality(String scope, String namespace, int minCardinality, int maxCardinality, String... allocationTags) Similar tocardinality(String, int, int, String...), but let you attach a namespace to the given allocation tags.- Parameters:
scope- the scope of the constraintnamespace- the namespace of the allocation tagsminCardinality- determines the minimum number of allocations within the scopemaxCardinality- determines the maximum number of allocations within the scopeallocationTags- allocation tags- Returns:
- the resulting placement constraint
-
minCardinality
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint minCardinality(String scope, int minCardinality, String... allocationTags) Similar tocardinality(String, int, int, String...), but determines only the minimum cardinality (the maximum cardinality is unbound).- Parameters:
scope- the scope of the constraintminCardinality- determines the minimum number of allocations within the scopeallocationTags- the constraint targets allocations with these tags- Returns:
- the resulting placement constraint
-
minCardinality
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint minCardinality(String scope, String namespace, int minCardinality, String... allocationTags) Similar tominCardinality(String, int, String...), but let you attach a namespace to the allocation tags.- Parameters:
scope- the scope of the constraintnamespace- the namespace of these tagsminCardinality- determines the minimum number of allocations within the scopeallocationTags- the constraint targets allocations with these tags- Returns:
- the resulting placement constraint
-
maxCardinality
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint maxCardinality(String scope, int maxCardinality, String... allocationTags) Similar tocardinality(String, int, int, String...), but determines only the maximum cardinality (the minimum cardinality is 0).- Parameters:
scope- the scope of the constraintmaxCardinality- determines the maximum number of allocations within the scopeallocationTags- the constraint targets allocations with these tags- Returns:
- the resulting placement constraint
-
maxCardinality
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint maxCardinality(String scope, String tagNamespace, int maxCardinality, String... allocationTags) Similar tomaxCardinality(String, int, String...), but let you specify a namespace for the tags, see supported namespaces inAllocationTagNamespaceType.- Parameters:
scope- the scope of the constrainttagNamespace- the namespace of these tagsmaxCardinality- determines the maximum number of allocations within the scopeallocationTags- allocation tags- Returns:
- the resulting placement constraint
-
targetCardinality
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint targetCardinality(String scope, int minCardinality, int maxCardinality, org.apache.hadoop.yarn.api.resource.PlacementConstraint.TargetExpression... targetExpressions) This constraint generalizes the cardinality and target constraints. Consider a set of nodes N that belongs to the scope specified in the constraint. If the target expressions are satisfied at least minCardinality times and at most maxCardinality times in the node set N, then the constraint is satisfied. For example,targetCardinality(RACK, 2, 10, allocationTag("zk")), requires an allocation to be placed within a rack that has at least 2 and at most 10 other allocations with tag "zk".- Parameters:
scope- the scope of the constraintminCardinality- the minimum number of times the target expressions have to be satisfied with the given scopemaxCardinality- the maximum number of times the target expressions have to be satisfied with the given scopetargetExpressions- the target expressions- Returns:
- the resulting placement constraint
-
and
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.And and(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint... children) A conjunction of constraints.- Parameters:
children- the children constraints that should all be satisfied- Returns:
- the resulting placement constraint
-
or
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.Or or(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint... children) A disjunction of constraints.- Parameters:
children- the children constraints, one of which should be satisfied- Returns:
- the resulting placement constraint
-
delayedOr
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.DelayedOr delayedOr(org.apache.hadoop.yarn.api.resource.PlacementConstraint.TimedPlacementConstraint... children) Creates a composite constraint that includes a list of timed placement constraints. The scheduler should try to satisfy first the first timed child constraint within the specified time window. If this is not possible, it should attempt to satisfy the second, and so on.- Parameters:
children- the timed children constraints- Returns:
- the resulting composite constraint
-
timedClockConstraint
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.TimedPlacementConstraint timedClockConstraint(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint constraint, long delay, TimeUnit timeUnit) Creates a placement constraint that has to be satisfied within a time window.- Parameters:
constraint- the placement constraintdelay- the length of the time window within which the constraint has to be satisfiedtimeUnit- the unit of time of the time window- Returns:
- the resulting timed placement constraint
-
timedOpportunitiesConstraint
public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.TimedPlacementConstraint timedOpportunitiesConstraint(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint constraint, long delay) Creates a placement constraint that has to be satisfied within a number of placement opportunities (invocations of the scheduler).- Parameters:
constraint- the placement constraintdelay- the number of scheduling opportunities within which the constraint has to be satisfied- Returns:
- the resulting timed placement constraint
-
build
public static PlacementConstraint build(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint constraintExpr) Creates aPlacementConstraintgiven a constraint expression.- Parameters:
constraintExpr- the constraint expression- Returns:
- the placement constraint
-