diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java index bb34626..6ef8c7d 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/conf/YarnConfiguration.java @@ -1582,13 +1582,32 @@ public static boolean isAclEnabled(Configuration conf) { public static final long DEFAULT_RM_APPLICATION_MONITOR_INTERVAL_MS = 3000; - /** Overallocation (= allocation based on utilization) configs. */ - public static final String NM_OVERALLOCATION_ALLOCATION_THRESHOLD = - NM_PREFIX + "overallocation.allocation-threshold"; - public static final float DEFAULT_NM_OVERALLOCATION_ALLOCATION_THRESHOLD + /** + * NM CPU utilization threshold up to which the scheduler allocates + * OPPORTUNISTIC containers. + */ + public static final String NM_OVERALLOCATION_CPU_ALLOCATION_THRESHOLD = + NM_PREFIX + "overallocation.cpu.allocation-threshold"; + public static final float DEFAULT_NM_OVERALLOCATION_CPU_ALLOCATION_THRESHOLD + = 0f; + + /** + * NM memory utilization threshold up to which the scheduler allocates + * OPPORTUNISTIC containers. + */ + public static final String NM_OVERALLOCATION_MEMORY_ALLOCATION_THRESHOLD = + NM_PREFIX + "overallocation.memory.allocation-threshold"; + public static final float DEFAULT_NM_OVERALLOCATION_MEMORY_ALLOCATION_THRESHOLD = 0f; + + /** + * The maximum value of utilization threshold for both cpu and memory + * up to which the scheduler allocates OPPORTUNISTIC containers. + */ @Private public static final float MAX_NM_OVERALLOCATION_ALLOCATION_THRESHOLD = 0.95f; + + public static final String NM_OVERALLOCATION_PREEMPTION_THRESHOLD = NM_PREFIX + "overallocation.preemption-threshold"; public static final float DEFAULT_NM_OVERALLOCATION_PREEMPTION_THRESHOLD diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml index c131eec..105864f 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/yarn-default.xml @@ -1565,12 +1565,25 @@ The extent of over-allocation (container-allocation based on current utilization instead of prior allocation) allowed on this node, - expressed as a float between 0 and 0.95. By default, over-allocation is + in terms of the percentage of overall NM memory capacity utilized ( + expressed as a float between 0 and 0.95). By default, over-allocation is turned off (value = 0). When turned on, the node allows running OPPORTUNISTIC containers when the aggregate utilization is under the value specified here multiplied by the node's advertised capacity. - yarn.nodemanager.overallocation.allocation-threshold + yarn.nodemanager.overallocation.memory.allocation-threshold + 0f + + + + The extent of over-allocation (container-allocation based on + current utilization instead of prior allocation) allowed on this node, + in terms of the percentage of overall NM CPU capacity utilized ( + expressed as a float between 0 and 0.95). By default, over-allocation is + OPPORTUNISTIC containers when the aggregate utilization is under the + value specified here multiplied by the node's advertised capacity. + + yarn.nodemanager.overallocation.cpu.allocation-threshold 0f diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/ResourceThresholds.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/ResourceThresholds.java index d57706a..342750f 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/ResourceThresholds.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/records/ResourceThresholds.java @@ -28,10 +28,18 @@ @InterfaceAudience.Private @InterfaceStability.Evolving public abstract class ResourceThresholds { - public static ResourceThresholds newInstance(float threshold) { + public static ResourceThresholds newInstance(float overallThreshold) { ResourceThresholds thresholds = new ResourceThresholdsPBImpl(); - thresholds.setMemoryThreshold(threshold); - thresholds.setCpuThreshold(threshold); + thresholds.setMemoryThreshold(overallThreshold); + thresholds.setCpuThreshold(overallThreshold); + return thresholds; + } + + public static ResourceThresholds newInstance(float cpuThreshold, + float memoryThreshold) { + ResourceThresholds thresholds = new ResourceThresholdsPBImpl(); + thresholds.setCpuThreshold(cpuThreshold); + thresholds.setMemoryThreshold(memoryThreshold); return thresholds; } diff --git hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java index 55aac26..90b41c5 100644 --- hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java +++ hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/monitor/ContainersMonitorImpl.java @@ -224,17 +224,25 @@ private boolean isContainerMonitorEnabled() { } private void initializeOverAllocation(Configuration conf) { - float overAllocationTreshold = conf.getFloat( - YarnConfiguration.NM_OVERALLOCATION_ALLOCATION_THRESHOLD, - YarnConfiguration.DEFAULT_NM_OVERALLOCATION_ALLOCATION_THRESHOLD); - overAllocationTreshold = Math.min(overAllocationTreshold, + float overAllocationMemoryThreshold = conf.getFloat( + YarnConfiguration.NM_OVERALLOCATION_MEMORY_ALLOCATION_THRESHOLD, + YarnConfiguration.DEFAULT_NM_OVERALLOCATION_MEMORY_ALLOCATION_THRESHOLD); + overAllocationMemoryThreshold = Math.min(overAllocationMemoryThreshold, YarnConfiguration.MAX_NM_OVERALLOCATION_ALLOCATION_THRESHOLD); - overAllocationTreshold = Math.max(0, overAllocationTreshold); + overAllocationMemoryThreshold = Math.max(0, overAllocationMemoryThreshold); - if (overAllocationTreshold > 0f) { + float overAllocationCpuTreshold = conf.getFloat( + YarnConfiguration.NM_OVERALLOCATION_CPU_ALLOCATION_THRESHOLD, + YarnConfiguration.DEFAULT_NM_OVERALLOCATION_CPU_ALLOCATION_THRESHOLD); + overAllocationCpuTreshold = Math.min(overAllocationCpuTreshold, + YarnConfiguration.MAX_NM_OVERALLOCATION_ALLOCATION_THRESHOLD); + overAllocationCpuTreshold = Math.max(0, overAllocationCpuTreshold); + + if (overAllocationCpuTreshold > 0 && overAllocationMemoryThreshold > 0) { ((NodeManager.NMContext) context).setOverAllocationInfo( OverAllocationInfo.newInstance( - ResourceThresholds.newInstance(overAllocationTreshold))); + ResourceThresholds.newInstance(overAllocationCpuTreshold, + overAllocationMemoryThreshold))); float preemptionThreshold = conf.getFloat( YarnConfiguration.NM_OVERALLOCATION_PREEMPTION_THRESHOLD,