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 
    org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser.BaseStringTokenizer
    A basic tokenizer that splits an expression by a given delimiter.
    static class 
    org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser.CardinalityConstraintParser
    Constraint parser used to parse a given target expression, such as "cardinality, NODE, foo, 0, 1".
    static class 
    org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser.ConjunctionConstraintParser
    Parser used to parse conjunction form of constraints, such as AND(A, ..., B), OR(A, ..., B).
    static final class 
    org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser.ConjunctionTokenizer
    Tokenizer used to parse conjunction form of a constraint expression, [AND|OR](C1:C2:...
    static class 
    org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser.ConstraintParser
    Constraint Parser used to parse placement constraints from a given expression.
    static interface 
    org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser.ConstraintTokenizer
    Tokenizer interface that used to parse an expression.
    static class 
    org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser.MultipleConstraintsTokenizer
    Tokenizer used to handle a placement spec composed by multiple constraint expressions.
    static class 
    org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser.NodeConstraintParser
    Constraint parser used to parse a given target expression.
    static final class 
    org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser.SourceTags
    A helper class to encapsulate source tags and allocations in the placement specification.
    static class 
    org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser.SourceTagsTokenizer
    Tokenizer used to parse allocation tags expression, which should be in tag(numOfAllocations) syntax.
    static class 
    org.apache.hadoop.yarn.util.constraint.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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.hadoop.yarn.api.resource.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<org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser.SourceTags,PlacementConstraint>
    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

  • Method Details

    • parseExpression

      public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint parseExpression(String constraintStr) throws org.apache.hadoop.yarn.util.constraint.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:
      org.apache.hadoop.yarn.util.constraint.PlacementConstraintParseException - when given expression is malformed
    • parsePlacementSpec

      public static Map<org.apache.hadoop.yarn.util.constraint.PlacementConstraintParser.SourceTags,PlacementConstraint> parsePlacementSpec(String expression) throws org.apache.hadoop.yarn.util.constraint.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:
      org.apache.hadoop.yarn.util.constraint.PlacementConstraintParseException - when the placement constraint parser fails to parse an expression.