From 9c3ab58aa735b1c3d642f7b58458cd1ea0dd3b83 Mon Sep 17 00:00:00 2001 From: Eric E Payne Date: Wed, 29 May 2019 16:05:39 +0000 Subject: [PATCH] YARN-8625. Aggregate Resource Allocation for each job is not present in ATS. Contributed by Prabhu Joseph. (cherry picked from commit 3c63551101dc17038efb9f5345833d2883fce86e) --- .../webapp/TestAHSWebServices.java | 5 +++++ .../hadoop/yarn/server/webapp/dao/AppInfo.java | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) 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 ff68f7fea3d..0ba17397e1f 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; @@ -413,6 +414,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; + } }