PlacementConstraints (Apache Hadoop Main 3.5.0 API)
Description: declaration: package: org.apache.hadoop.yarn.api.resource, class: PlacementConstraints

Package org.apache.hadoop.yarn.api.resource

# Class PlacementConstraints

java.lang.Object
org.apache.hadoop.yarn.api.resource.PlacementConstraints

@Public @Unstable public final class PlacementConstraints extends Object
This class contains various static methods for the applications to create placement constraints (see also `PlacementConstraint`).

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `org.apache.hadoop.yarn.api.resource.PlacementConstraints.PlacementTargets`
  Class with static methods for constructing target expressions to be used in placement constraints.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `NODE`
  `static final String`
  `NODE_PARTITION`
  `static final String`
  `RACK`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.And`
  `and(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint... children)`
  A conjunction of constraints.
  `static PlacementConstraint`
  `build(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint constraintExpr)`
  Creates a `PlacementConstraint` given a constraint expression.
  `static org.apache.hadoop.yarn.api.resource.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).
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint`
  `cardinality(String scope, String namespace, int minCardinality, int maxCardinality, String... allocationTags)`
  Similar to `cardinality(String, int, int, String...)`, but let you attach a namespace to the given allocation tags.
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.DelayedOr`
  `delayedOr(org.apache.hadoop.yarn.api.resource.PlacementConstraint.TimedPlacementConstraint... children)`
  Creates a composite constraint that includes a list of timed placement constraints.
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint`
  `maxCardinality(String scope, int maxCardinality, String... allocationTags)`
  Similar to `cardinality(String, int, int, String...)`, but determines only the maximum cardinality (the minimum cardinality is 0).
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint`
  `maxCardinality(String scope, String tagNamespace, int maxCardinality, String... allocationTags)`
  Similar to `maxCardinality(String, int, String...)`, but let you specify a namespace for the tags, see supported namespaces in `AllocationTagNamespaceType`.
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint`
  `minCardinality(String scope, int minCardinality, String... allocationTags)`
  Similar to `cardinality(String, int, int, String...)`, but determines only the minimum cardinality (the maximum cardinality is unbound).
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint`
  `minCardinality(String scope, String namespace, int minCardinality, String... allocationTags)`
  Similar to `minCardinality(String, int, String...)`, but let you attach a namespace to the allocation tags.
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.Or`
  `or(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint... children)`
  A disjunction of constraints.
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint`
  `targetCardinality(String scope, int minCardinality, int maxCardinality, org.apache.hadoop.yarn.api.resource.PlacementConstraint.TargetExpression... targetExpressions)`
  This constraint generalizes the cardinality and target constraints.
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint`
  `targetIn(String scope, org.apache.hadoop.yarn.api.resource.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).
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint`
  `targetNodeAttribute(String scope, NodeAttributeOpCode opCode, org.apache.hadoop.yarn.api.resource.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.
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint`
  `targetNotIn(String scope, org.apache.hadoop.yarn.api.resource.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.
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.TimedPlacementConstraint`
  `timedClockConstraint(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint constraint, long delay, TimeUnit timeUnit)`
  Creates a placement constraint that has to be satisfied within a time window.
  `static org.apache.hadoop.yarn.api.resource.PlacementConstraint.TimedPlacementConstraint`
  `timedOpportunitiesConstraint(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint constraint, long delay)`
  Creates a placement constraint that has to be satisfied within a number of placement opportunities (invocations of the scheduler).

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

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

- ## Field Details

  - ### NODE

    public static final String NODE
    See Also:
      - Constant Field Values

  - ### RACK

    public static final String RACK
    See Also:
      - Constant Field Values

  - ### NODE_PARTITION

    public static final String NODE_PARTITION
    See Also:
      - Constant Field Values

- ## Method Details

  - ### targetIn

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint targetIn(String scope, org.apache.hadoop.yarn.api.resource.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 satisfied
      `targetExpressions` - the expressions that need to be satisfied within the scope
    Returns:
      the resulting placement constraint

  - ### targetNotIn

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint targetNotIn(String scope, org.apache.hadoop.yarn.api.resource.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 true
      `targetExpressions` - the expressions that need to not be true within the scope
    Returns:
      the resulting placement constraint

  - ### targetNodeAttribute

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint targetNodeAttribute(String scope, NodeAttributeOpCode opCode, org.apache.hadoop.yarn.api.resource.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 true
      `opCode` - 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 org.apache.hadoop.yarn.api.resource.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 constraint
      `minCardinality` - determines the minimum number of allocations within the scope
      `maxCardinality` - determines the maximum number of allocations within the scope
      `allocationTags` - the constraint targets allocations with these tags
    Returns:
      the resulting placement constraint

  - ### cardinality

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint cardinality(String scope, String namespace, int minCardinality, int maxCardinality, String... allocationTags)
    Similar to `cardinality(String, int, int, String...)`, but let you attach a namespace to the given allocation tags.
    Parameters:
      `scope` - the scope of the constraint
      `namespace` - the namespace of the allocation tags
      `minCardinality` - determines the minimum number of allocations within the scope
      `maxCardinality` - determines the maximum number of allocations within the scope
      `allocationTags` - allocation tags
    Returns:
      the resulting placement constraint

  - ### minCardinality

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint minCardinality(String scope, int minCardinality, String... allocationTags)
    Similar to `cardinality(String, int, int, String...)`, but determines only the minimum cardinality (the maximum cardinality is unbound).
    Parameters:
      `scope` - the scope of the constraint
      `minCardinality` - determines the minimum number of allocations within the scope
      `allocationTags` - the constraint targets allocations with these tags
    Returns:
      the resulting placement constraint

  - ### minCardinality

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint minCardinality(String scope, String namespace, int minCardinality, String... allocationTags)
    Similar to `minCardinality(String, int, String...)`, but let you attach a namespace to the allocation tags.
    Parameters:
      `scope` - the scope of the constraint
      `namespace` - the namespace of these tags
      `minCardinality` - determines the minimum number of allocations within the scope
      `allocationTags` - the constraint targets allocations with these tags
    Returns:
      the resulting placement constraint

  - ### maxCardinality

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint maxCardinality(String scope, int maxCardinality, String... allocationTags)
    Similar to `cardinality(String, int, int, String...)`, but determines only the maximum cardinality (the minimum cardinality is 0).
    Parameters:
      `scope` - the scope of the constraint
      `maxCardinality` - determines the maximum number of allocations within the scope
      `allocationTags` - the constraint targets allocations with these tags
    Returns:
      the resulting placement constraint

  - ### maxCardinality

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint maxCardinality(String scope, String tagNamespace, int maxCardinality, String... allocationTags)
    Similar to `maxCardinality(String, int, String...)`, but let you specify a namespace for the tags, see supported namespaces in `AllocationTagNamespaceType`.
    Parameters:
      `scope` - the scope of the constraint
      `tagNamespace` - the namespace of these tags
      `maxCardinality` - determines the maximum number of allocations within the scope
      `allocationTags` - allocation tags
    Returns:
      the resulting placement constraint

  - ### targetCardinality

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint targetCardinality(String scope, int minCardinality, int maxCardinality, org.apache.hadoop.yarn.api.resource.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 constraint
      `minCardinality` - the minimum number of times the target expressions have to be satisfied with the given scope
      `maxCardinality` - the maximum number of times the target expressions have to be satisfied with the given scope
      `targetExpressions` - the target expressions
    Returns:
      the resulting placement constraint

  - ### and

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.And and(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint... children)
    A conjunction of constraints.
    Parameters:
      `children` - the children constraints that should all be satisfied
    Returns:
      the resulting placement constraint

  - ### or

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.Or or(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint... children)
    A disjunction of constraints.
    Parameters:
      `children` - the children constraints, one of which should be satisfied
    Returns:
      the resulting placement constraint

  - ### delayedOr

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.DelayedOr delayedOr(org.apache.hadoop.yarn.api.resource.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 org.apache.hadoop.yarn.api.resource.PlacementConstraint.TimedPlacementConstraint timedClockConstraint(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint constraint, long delay, TimeUnit timeUnit)
    Creates a placement constraint that has to be satisfied within a time window.
    Parameters:
      `constraint` - the placement constraint
      `delay` - the length of the time window within which the constraint has to be satisfied
      `timeUnit` - the unit of time of the time window
    Returns:
      the resulting timed placement constraint

  - ### timedOpportunitiesConstraint

    public static org.apache.hadoop.yarn.api.resource.PlacementConstraint.TimedPlacementConstraint timedOpportunitiesConstraint(org.apache.hadoop.yarn.api.resource.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 constraint
      `delay` - the number of scheduling opportunities within which the constraint has to be satisfied
    Returns:
      the resulting timed placement constraint

  - ### build

    public static PlacementConstraint build(org.apache.hadoop.yarn.api.resource.PlacementConstraint.AbstractConstraint constraintExpr)
    Creates a `PlacementConstraint` given a constraint expression.
    Parameters:
      `constraintExpr` - the constraint expression
    Returns:
      the placement constraint