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 classClass with static methods for constructing target expressions to be used in placement constraints. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic PlacementConstraint.Andand(PlacementConstraint.AbstractConstraint... children) A conjunction of constraints.static PlacementConstraintbuild(PlacementConstraint.AbstractConstraint constraintExpr) Creates aPlacementConstraintgiven a constraint expression.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).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.delayedOr(PlacementConstraint.TimedPlacementConstraint... children) Creates a composite constraint that includes a list of timed placement constraints.maxCardinality(String scope, int maxCardinality, String... allocationTags) Similar tocardinality(String, int, int, String...), but determines only the maximum cardinality (the minimum cardinality is 0).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.minCardinality(String scope, int minCardinality, String... allocationTags) Similar tocardinality(String, int, int, String...), but determines only the minimum cardinality (the maximum cardinality is unbound).minCardinality(String scope, String namespace, int minCardinality, String... allocationTags) Similar tominCardinality(String, int, String...), but let you attach a namespace to the allocation tags.static PlacementConstraint.Oror(PlacementConstraint.AbstractConstraint... children) A disjunction of constraints.targetCardinality(String scope, int minCardinality, int maxCardinality, PlacementConstraint.TargetExpression... targetExpressions) This constraint generalizes the cardinality and target constraints.targetIn(String scope, 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).targetNodeAttribute(String scope, NodeAttributeOpCode opCode, 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.targetNotIn(String scope, 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.timedClockConstraint(PlacementConstraint.AbstractConstraint constraint, long delay, TimeUnit timeUnit) Creates a placement constraint that has to be satisfied within a time window.timedOpportunitiesConstraint(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 PlacementConstraint.AbstractConstraint targetIn(String scope, 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 PlacementConstraint.AbstractConstraint targetNotIn(String scope, 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 PlacementConstraint.AbstractConstraint targetNodeAttribute(String scope, NodeAttributeOpCode opCode, 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 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 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 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 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 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 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 PlacementConstraint.AbstractConstraint targetCardinality(String scope, int minCardinality, int maxCardinality, 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
A conjunction of constraints.- Parameters:
children- the children constraints that should all be satisfied- Returns:
- the resulting placement constraint
-
or
A disjunction of constraints.- Parameters:
children- the children constraints, one of which should be satisfied- Returns:
- the resulting placement constraint
-
delayedOr
public static PlacementConstraint.DelayedOr delayedOr(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 PlacementConstraint.TimedPlacementConstraint timedClockConstraint(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 PlacementConstraint.TimedPlacementConstraint timedOpportunitiesConstraint(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
Creates aPlacementConstraintgiven a constraint expression.- Parameters:
constraintExpr- the constraint expression- Returns:
- the placement constraint
-