ソースを参照

YARN-3432. Cluster metrics have wrong Total Memory when there is reserved memory on CS. (Brahma Reddy Battula via curino)

(cherry picked from commit 892a8348fceb42069ea9877251c413fe33415e16)
Carlo Curino 8 年 前
コミット
2de984ac3d

+ 3 - 0
hadoop-yarn-project/CHANGES.txt

@@ -53,6 +53,9 @@ Release 2.7.4 - UNRELEASED
     YARN-5382. RM does not audit log kill request for active applications
     YARN-5382. RM does not audit log kill request for active applications
     (Vrushali C via jlowe)
     (Vrushali C via jlowe)
 
 
+    YARN-3432.  Cluster metrics have wrong Total Memory when there is reserved
+    memory on CS. (Brahma Reddy Battula via curino)
+
 Release 2.7.3 - 2016-08-25
 Release 2.7.3 - 2016-08-25
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 9 - 2
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/dao/ClusterMetricsInfo.java

@@ -25,6 +25,7 @@ import org.apache.hadoop.yarn.server.resourcemanager.ClusterMetrics;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
 import org.apache.hadoop.yarn.server.resourcemanager.ResourceManager;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
 import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
+import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacityScheduler;
 
 
 @XmlRootElement(name = "clusterMetrics")
 @XmlRootElement(name = "clusterMetrics")
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlAccessorType(XmlAccessType.FIELD)
@@ -85,8 +86,14 @@ public class ClusterMetricsInfo {
     this.containersPending = metrics.getPendingContainers();
     this.containersPending = metrics.getPendingContainers();
     this.containersReserved = metrics.getReservedContainers();
     this.containersReserved = metrics.getReservedContainers();
 
 
-    this.totalMB = availableMB + allocatedMB;
-    this.totalVirtualCores = availableVirtualCores + allocatedVirtualCores;
+    if (rs instanceof CapacityScheduler) {
+      this.totalMB = availableMB + allocatedMB + reservedMB;
+      this.totalVirtualCores = availableVirtualCores + allocatedVirtualCores
+          + containersReserved;
+    } else {
+      this.totalMB = availableMB + allocatedMB;
+      this.totalVirtualCores = availableVirtualCores + allocatedVirtualCores;
+    }
     this.activeNodes = clusterMetrics.getNumActiveNMs();
     this.activeNodes = clusterMetrics.getNumActiveNMs();
     this.lostNodes = clusterMetrics.getNumLostNMs();
     this.lostNodes = clusterMetrics.getNumLostNMs();
     this.unhealthyNodes = clusterMetrics.getUnhealthyNMs();
     this.unhealthyNodes = clusterMetrics.getUnhealthyNMs();