diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java index 5a660cea8a7..fc9b6839975 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/util/resource/ResourceUtils.java @@ -56,6 +56,7 @@ public static final String TYPE = ".type"; public static final String MINIMUM_ALLOCATION = ".minimum-allocation"; public static final String MAXIMUM_ALLOCATION = ".maximum-allocation"; + public static final String RESOURCE_FILE_RESOUR= ".maximum-allocation"; private static final String MEMORY = ResourceInformation.MEMORY_MB.getName(); private static final String VCORES = ResourceInformation.VCORES.getName(); @@ -87,17 +88,20 @@ private static void checkMandatoryResources( * Supporting 'memory' also as invalid resource name, in addition to * 'MEMORY' for historical reasons */ - String key = "memory"; - if (resourceInformationMap.containsKey(key)) { - LOG.warn( - "Attempt to define resource '" + key + "', but it is not allowed."); - throw new YarnRuntimeException( - "Attempt to re-define mandatory resource '" + key + "'."); + String keys[] = { "memory", ResourceInformation.MEMORY_URI, + ResourceInformation.VCORES_URI }; + for(String key : keys) { + if (resourceInformationMap.containsKey(key)) { + LOG.warn("Attempt to define resource '" + key + "', but it is not allowed."); + throw new YarnRuntimeException( + "Attempt to re-define mandatory resource '" + key + "'."); + } } + for (Map.Entry mandatoryResourceEntry : ResourceInformation.MANDATORY_RESOURCES.entrySet()) { - key = mandatoryResourceEntry.getKey(); + String key = mandatoryResourceEntry.getKey(); ResourceInformation mandatoryRI = mandatoryResourceEntry.getValue(); ResourceInformation newDefinedRI = resourceInformationMap.get(key); @@ -485,8 +489,8 @@ public static long getValue(String resourceValue) { if (!initializedNodeResources) { Map nodeResources = initializeNodeResourceInformation( conf); - addMandatoryResources(nodeResources); checkMandatoryResources(nodeResources); + addMandatoryResources(nodeResources); setAllocationForMandatoryResources(nodeResources, conf); readOnlyNodeResources = Collections.unmodifiableMap(nodeResources); initializedNodeResources = true;