Class PlacementConstraint.SingleConstraint
java.lang.Object
org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint
org.apache.hadoop.yarn.api.resource.PlacementConstraint.SingleConstraint
- All Implemented Interfaces:
PlacementConstraint.Visitable
- Enclosing class:
- PlacementConstraint
public static class PlacementConstraint.SingleConstraint
extends PlacementConstraint.AbstractConstraint
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 max-cardinality times in the node set N, then the
constraint is satisfied.
For example, a constraint of the form
{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".-
Constructor Summary
ConstructorsConstructorDescriptionSingleConstraint(String scope, int minCardinality, int maxCardinality, Set<PlacementConstraint.TargetExpression> targetExpressions) SingleConstraint(String scope, int minCardinality, int maxCardinality, NodeAttributeOpCode opCode, Set<PlacementConstraint.TargetExpression> targetExpressions) SingleConstraint(String scope, int minC, int maxC, NodeAttributeOpCode opCode, PlacementConstraint.TargetExpression... targetExpressions) SingleConstraint(String scope, int minC, int maxC, PlacementConstraint.TargetExpression... targetExpressions) -
Method Summary
Modifier and TypeMethodDescription<T> Taccept(PlacementConstraint.Visitor<T> visitor) Visitor pattern.booleanintGet the maximum cardinality of the constraint.intGet the minimum cardinality of the constraint.Get the NodeAttributeOpCode of the constraint.getScope()Get the scope of the constraint.Get the target expressions of the constraint.inthashCode()toString()Methods inherited from class org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint
build
-
Constructor Details
-
SingleConstraint
public SingleConstraint(String scope, int minCardinality, int maxCardinality, NodeAttributeOpCode opCode, Set<PlacementConstraint.TargetExpression> targetExpressions) -
SingleConstraint
public SingleConstraint(String scope, int minCardinality, int maxCardinality, Set<PlacementConstraint.TargetExpression> targetExpressions) -
SingleConstraint
public SingleConstraint(String scope, int minC, int maxC, PlacementConstraint.TargetExpression... targetExpressions) -
SingleConstraint
public SingleConstraint(String scope, int minC, int maxC, NodeAttributeOpCode opCode, PlacementConstraint.TargetExpression... targetExpressions)
-
-
Method Details
-
getScope
Get the scope of the constraint.- Returns:
- the scope of the constraint
-
getMinCardinality
public int getMinCardinality()Get the minimum cardinality of the constraint.- Returns:
- the minimum cardinality of the constraint
-
getMaxCardinality
public int getMaxCardinality()Get the maximum cardinality of the constraint.- Returns:
- the maximum cardinality of the constraint
-
getTargetExpressions
Get the target expressions of the constraint.- Returns:
- the set of target expressions
-
getNodeAttributeOpCode
Get the NodeAttributeOpCode of the constraint.- Returns:
- nodeAttribute Op Code
-
equals
-
hashCode
public int hashCode() -
toString
- Overrides:
toStringin classPlacementConstraint.AbstractConstraint
-
accept
Description copied from interface:PlacementConstraint.VisitableVisitor pattern.- Type Parameters:
T- defines the type that the visitor will use and the return type of the accept.- Parameters:
visitor- visitor to be used- Returns:
- the result of visiting a given object.
-