java.lang.Object
org.apache.hadoop.yarn.server.resourcemanager.placement.csmappingrule.MappingRule

public class MappingRule extends Object
Mapping rule represents a single mapping setting defined by the user. All rules have matchers and actions. Matcher determine if a mapping rule applies to a given applicationSubmission, while action represent the course of action we need to take when a rule applies. MappingRules also support fallback actions, which will be evaluated when the main action fails due to any reason (Eg. trying to place to a queue which does not exist)
  • Field Details

  • Constructor Details

  • Method Details

    • evaluate

      public MappingRuleResult evaluate(VariableContext variables)
      This method evaluates the rule, and returns the MappingRuleResult, if the rule matches, skip action otherwise.
      Parameters:
      variables - The variable context, which contains all the variables
      Returns:
      The rule's result or skip action if the rule doesn't apply
    • getFallback

      public MappingRuleResult getFallback()
      Returns the associated action's fallback.
      Returns:
      The fallback of the action
    • createLegacyRule

      public static MappingRule createLegacyRule(String source, String path)
      Creates a MappingRule object from the legacy style configuration. The configuration is a [TYPE]:SOURCE:PATH (eg. u:bob:root.users.%user). Using the source and path parts of the legacy rule, this method will create an application MappingRule which behaves as the legacy rule defined. This version of the method does not require type, since legacy application mappings omitted the 'a', so this method is to be used for those rules, which in all case are application mappings.
      Parameters:
      source - This part of the rule determines which applications the rule will be applied
      path - The path where the application is to be placed
      Returns:
      MappingRule based on the provided settings
    • createLegacyRule

      public static MappingRule createLegacyRule(String type, String source, String path)
      Creates a MappingRule object from the legacy style configuration. The configuration is a [TYPE]:SOURCE:PATH (eg. u:bob:root.users.%user). Using the type, source and path parts of the legacy rule, this method will create a MappingRule which behaves as the legacy rule defined.
      Parameters:
      type - The type of the rule, can be 'u' for user mapping, 'g' for group mapping or 'a' for application mapping
      source - This part of the rule determines which submissions this rule should apply to (eg. if type is 'u', source will match against the user name)
      path - The path where the application is to be placed
      Returns:
      MappingRule based on the provided settings
    • validate

      public void validate(MappingRuleValidationContext ctx) throws org.apache.hadoop.yarn.exceptions.YarnException
      Throws:
      org.apache.hadoop.yarn.exceptions.YarnException
    • toString

      public String toString()
      Overrides:
      toString in class Object