diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java index 96f753315d..371c974377 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/scheduler/capacity/CapacitySchedulerConfiguration.java @@ -21,6 +21,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; +import org.apache.hadoop.yarn.server.resourcemanager.placement.MappingRule; import org.apache.hadoop.yarn.server.resourcemanager.placement.QueuePlacementRuleUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -279,6 +280,10 @@ public class CapacitySchedulerConfiguration extends ReservationSchedulerConfigur @Private public static final String QUEUE_MAPPING = PREFIX + "queue-mappings"; + @Private + public static final String QUEUE_MAPPING_NAME = + YarnConfiguration.QUEUE_PLACEMENT_RULES + ".app-name"; + @Private public static final String ENABLE_QUEUE_MAPPING_OVERRIDE = QUEUE_MAPPING + "-override.enable"; @@ -1159,6 +1164,46 @@ public List getQueueMappings() { return mappings; } + public List getMappingRules() { + List mappings = new ArrayList(); + Collection mappingsString = + getTrimmedStringCollection(QUEUE_MAPPING); + + for (String mappingValue : mappingsString) { + String[] mapping = + StringUtils.getTrimmedStringCollection(mappingValue, ":") + .toArray(new String[] {}); + if (mapping.length != 3 || mapping[1].length() == 0 + || mapping[2].length() == 0) { + throw new IllegalArgumentException( + "Illegal queue mapping " + mappingValue); + } + + if (mapping[0].equals("u") || mapping[0].equals("g")) { + mappings.add(MappingRule.createLegacyRule( + mapping[0], mapping[1], mapping[2])); + } else { + throw new IllegalArgumentException( + "unknown mapping prefix " + mapping[0]); + } + } + + mappingsString = getTrimmedStringCollection(QUEUE_MAPPING_NAME); + for (String mappingValue : mappingsString) { + String[] mapping = + StringUtils.getTrimmedStringCollection(mappingValue, ":") + .toArray(new String[] {}); + if (mapping.length != 2 || mapping[1].length() == 0) { + throw new IllegalArgumentException( + "Illegal queue mapping " + mappingValue); + } + + mappings.add(MappingRule.createLegacyRule(mapping[0], mapping[1])); + } + + return mappings; + } + @Private @VisibleForTesting public void setQueuePlacementRules(Collection queuePlacementRules) {