Class PlacementConstraintParser
java.lang.Object
org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser
Placement constraint expression parser.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA basic tokenizer that splits an expression by a given delimiter.static classConstraint parser used to parse a given target expression, such as "cardinality, NODE, foo, 0, 1".static classParser used to parse conjunction form of constraints, such as AND(A, ..., B), OR(A, ..., B).static final classTokenizer used to parse conjunction form of a constraint expression, [AND|OR](C1:C2:...static classConstraint Parser used to parse placement constraints from a given expression.static interfaceTokenizer interface that used to parse an expression.static classTokenizer used to handle a placement spec composed by multiple constraint expressions.static classConstraint parser used to parse a given target expression.static final classA helper class to encapsulate source tags and allocations in the placement specification.static classTokenizer used to parse allocation tags expression, which should be in tag(numOfAllocations) syntax.static classConstraint parser used to parse a given target expression, such as "NOTIN, NODE, foo, bar". -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionparseExpression(String constraintStr) Parses a given constraint expression to aPlacementConstraint.AbstractConstraint, this expression can be any valid form of constraint expressions.parsePlacementSpec(String expression) Parses a placement constraint specification.
-
Field Details
-
EXPRESSION_VAL_DELIM
public static final char EXPRESSION_VAL_DELIM- See Also:
-
-
Method Details
-
parseExpression
public static PlacementConstraint.AbstractConstraint parseExpression(String constraintStr) throws PlacementConstraintParseException Parses a given constraint expression to aPlacementConstraint.AbstractConstraint, this expression can be any valid form of constraint expressions.- Parameters:
constraintStr- expression string- Returns:
- a parsed
PlacementConstraint.AbstractConstraint - Throws:
PlacementConstraintParseException- when given expression is malformed
-
parsePlacementSpec
public static Map<PlacementConstraintParser.SourceTags,PlacementConstraint> parsePlacementSpec(String expression) throws PlacementConstraintParseException Parses a placement constraint specification. A placement constraint spec is a composite expression which is composed by multiple sub constraint expressions delimited by ":". With following syntax:Tag1(N1),P1:Tag2(N2),P2:...:TagN(Nn),Pn
where TagN(Nn) is a key value pair to determine the source allocation tag and the number of allocations, such as:foo(3)
Optional when using NodeAttribute Constraint. and where Pn can be any form of a valid constraint expression, such as:- in,node,foo,bar
- notin,node,foo,bar,1,2
- and(notin,node,foo:notin,node,bar)
- yarn.rm.io/foo=true
- java=1.7,1.8
- Parameters:
expression- expression string.- Returns:
- a map of source tags to placement constraint mapping.
- Throws:
PlacementConstraintParseException- when the placement constraint parser fails to parse an expression.
-