浏览代码

YARN-8625. Aggregate Resource Allocation for each job is not present in ATS. Contributed by Prabhu Joseph.

Eric E Payne 6 年之前
父节点
当前提交
6079107d91

+ 3 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java

@@ -19,6 +19,7 @@
 package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp;
 package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp;
 
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 import static org.junit.Assert.fail;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
@@ -320,6 +321,8 @@ public class TestAHSWebServices extends JerseyTestBase {
     assertEquals(FinalApplicationStatus.UNDEFINED.toString(),
     assertEquals(FinalApplicationStatus.UNDEFINED.toString(),
       app.get("finalAppStatus"));
       app.get("finalAppStatus"));
     assertEquals(YarnApplicationState.FINISHED.toString(), app.get("appState"));
     assertEquals(YarnApplicationState.FINISHED.toString(), app.get("appState"));
+    assertNotNull("Aggregate resource allocation is null",
+        app.get("aggregateResourceAllocation"));
   }
   }
 
 
   @Test
   @Test

+ 15 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppInfo.java

@@ -57,6 +57,7 @@ public class AppInfo {
   protected long finishedTime;
   protected long finishedTime;
   protected long elapsedTime;
   protected long elapsedTime;
   protected String applicationTags;
   protected String applicationTags;
+  private String aggregateResourceAllocation;
 
 
   public AppInfo() {
   public AppInfo() {
     // JAXB needs this
     // JAXB needs this
@@ -82,6 +83,15 @@ public class AppInfo {
     finishedTime = app.getFinishTime();
     finishedTime = app.getFinishTime();
     elapsedTime = Times.elapsed(startedTime, finishedTime);
     elapsedTime = Times.elapsed(startedTime, finishedTime);
     finalAppStatus = app.getFinalApplicationStatus();
     finalAppStatus = app.getFinalApplicationStatus();
+
+    if (app.getApplicationResourceUsageReport() != null) {
+      Long memorySeconds = app.getApplicationResourceUsageReport().
+          getMemorySeconds();
+      Long vcoreSeconds = app.getApplicationResourceUsageReport().
+          getVcoreSeconds();
+      aggregateResourceAllocation = memorySeconds + " MB-seconds, "
+          + vcoreSeconds + " vcore-seconds";
+    }
     progress = app.getProgress() * 100; // in percent
     progress = app.getProgress() * 100; // in percent
     if (app.getApplicationTags() != null && !app.getApplicationTags().isEmpty()) {
     if (app.getApplicationTags() != null && !app.getApplicationTags().isEmpty()) {
       this.applicationTags = CSV_JOINER.join(app.getApplicationTags());
       this.applicationTags = CSV_JOINER.join(app.getApplicationTags());
@@ -163,4 +173,9 @@ public class AppInfo {
   public String getApplicationTags() {
   public String getApplicationTags() {
     return applicationTags;
     return applicationTags;
   }
   }
+
+  public String getAggregateResourceAllocation() {
+    return aggregateResourceAllocation;
+  }
+
 }
 }