diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java index b4792a8899c..43546a35e0f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-applicationhistoryservice/src/test/java/org/apache/hadoop/yarn/server/applicationhistoryservice/webapp/TestAHSWebServices.java @@ -21,6 +21,7 @@ package org.apache.hadoop.yarn.server.applicationhistoryservice.webapp; import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; import java.net.HttpURLConnection; @@ -414,6 +415,10 @@ public class TestAHSWebServices extends JerseyTestBase { assertEquals(FinalApplicationStatus.UNDEFINED.toString(), app.get("finalAppStatus")); assertEquals(YarnApplicationState.FINISHED.toString(), app.get("appState")); + assertNotNull("Aggregate resource allocation is null", + app.get("aggregateResourceAllocation")); + assertNotNull("Aggregate Preempted Resource Allocation is null", + app.get("aggregatePreemptedResourceAllocation")); } @Test diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppInfo.java index c4de022f025..d053f33bd0a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/dao/AppInfo.java @@ -31,6 +31,7 @@ import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.util.Times; +import org.apache.hadoop.yarn.util.StringHelper; @Public @Evolving @@ -67,6 +68,8 @@ public class AppInfo { protected boolean unmanagedApplication; private String appNodeLabelExpression; private String amNodeLabelExpression; + private String aggregateResourceAllocation; + private String aggregatePreemptedResourceAllocation; public AppInfo() { // JAXB needs this @@ -110,6 +113,11 @@ public class AppInfo { reservedMemoryMB = app.getApplicationResourceUsageReport() .getReservedResources().getMemorySize(); } + aggregateResourceAllocation = StringHelper.getResourceSecondsString( + app.getApplicationResourceUsageReport().getResourceSecondsMap()); + aggregatePreemptedResourceAllocation = StringHelper + .getResourceSecondsString(app.getApplicationResourceUsageReport() + .getPreemptedResourceSecondsMap()); } progress = app.getProgress() * 100; // in percent if (app.getApplicationTags() != null && !app.getApplicationTags().isEmpty()) { @@ -235,4 +243,12 @@ public class AppInfo { public String getAmNodeLabelExpression() { return amNodeLabelExpression; } + + public String getAggregateResourceAllocation() { + return aggregateResourceAllocation; + } + + public String getAggregatePreemptedResourceAllocation() { + return aggregatePreemptedResourceAllocation; + } }