PlacementConstraintParser (Apache Hadoop YARN API 3.5.0 API)
Description: declaration: package: org.apache.hadoop.yarn.util.constraint, class: PlacementConstraintParser

Package org.apache.hadoop.yarn.util.constraint

# Class PlacementConstraintParser

java.lang.Object
org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser

@Public @Unstable public final class PlacementConstraintParser extends Object
Placement constraint expression parser.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `PlacementConstraintParser.BaseStringTokenizer`
  A basic tokenizer that splits an expression by a given delimiter.
  `static class`
  `PlacementConstraintParser.CardinalityConstraintParser`
  Constraint parser used to parse a given target expression, such as "cardinality, NODE, foo, 0, 1".
  `static class`
  `PlacementConstraintParser.ConjunctionConstraintParser`
  Parser used to parse conjunction form of constraints, such as AND(A, ..., B), OR(A, ..., B).
  `static final class`
  `PlacementConstraintParser.ConjunctionTokenizer`
  Tokenizer used to parse conjunction form of a constraint expression, [AND|OR](C1:C2:...
  `static class`
  `PlacementConstraintParser.ConstraintParser`
  Constraint Parser used to parse placement constraints from a given expression.
  `static interface`
  `PlacementConstraintParser.ConstraintTokenizer`
  Tokenizer interface that used to parse an expression.
  `static class`
  `PlacementConstraintParser.MultipleConstraintsTokenizer`
  Tokenizer used to handle a placement spec composed by multiple constraint expressions.
  `static class`
  `PlacementConstraintParser.NodeConstraintParser`
  Constraint parser used to parse a given target expression.
  `static final class`
  `PlacementConstraintParser.SourceTags`
  A helper class to encapsulate source tags and allocations in the placement specification.
  `static class`
  `PlacementConstraintParser.SourceTagsTokenizer`
  Tokenizer used to parse allocation tags expression, which should be in tag(numOfAllocations) syntax.
  `static class`
  `PlacementConstraintParser.TargetConstraintParser`
  Constraint parser used to parse a given target expression, such as "NOTIN, NODE, foo, bar".

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final char`
  `EXPRESSION_VAL_DELIM`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static PlacementConstraint.AbstractConstraint`
  `parseExpression(String constraintStr)`
  Parses a given constraint expression to a `PlacementConstraint.AbstractConstraint`, this expression can be any valid form of constraint expressions.
  `static Map<PlacementConstraintParser.SourceTags,PlacementConstraint>`
  `parsePlacementSpec(String expression)`
  Parses a placement constraint specification.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### EXPRESSION_VAL_DELIM

    public static final char EXPRESSION_VAL_DELIM
    See Also:
      - Constant Field Values

- ## Method Details

  - ### parseExpression

    public static PlacementConstraint.AbstractConstraint parseExpression(String constraintStr) throws PlacementConstraintParseException
    Parses a given constraint expression to a `PlacementConstraint.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)
    and NodeAttribute Constraint such as
    - 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.