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

This commit is contained in:
Eric E Payne 2019-06-04 18:57:44 +00:00
parent 500dc05924
commit 441339a716
2 changed files with 32 additions and 12 deletions

View File

@ -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.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@ -408,6 +409,10 @@ 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"));
assertNotNull("Aggregate Preempted Resource Allocation is null",
app.get("aggregatePreemptedResourceAllocation"));
} }
@Test @Test

View File

@ -28,6 +28,7 @@ import org.apache.hadoop.classification.InterfaceAudience.Public;
import org.apache.hadoop.classification.InterfaceStability.Evolving; import org.apache.hadoop.classification.InterfaceStability.Evolving;
import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.ApplicationReport;
import org.apache.hadoop.yarn.api.records.ApplicationResourceUsageReport;
import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus;
import org.apache.hadoop.yarn.api.records.YarnApplicationState; import org.apache.hadoop.yarn.api.records.YarnApplicationState;
import org.apache.hadoop.yarn.util.Times; import org.apache.hadoop.yarn.util.Times;
@ -67,6 +68,8 @@ public class AppInfo {
protected boolean unmanagedApplication; protected boolean unmanagedApplication;
private String appNodeLabelExpression; private String appNodeLabelExpression;
private String amNodeLabelExpression; private String amNodeLabelExpression;
private String aggregateResourceAllocation;
private String aggregatePreemptedResourceAllocation;
public AppInfo() { public AppInfo() {
// JAXB needs this // JAXB needs this
@ -97,19 +100,23 @@ public class AppInfo {
if (app.getPriority() != null) { if (app.getPriority() != null) {
priority = app.getPriority().getPriority(); priority = app.getPriority().getPriority();
} }
if (app.getApplicationResourceUsageReport() != null) { ApplicationResourceUsageReport usageReport =
runningContainers = app.getApplicationResourceUsageReport() app.getApplicationResourceUsageReport();
.getNumUsedContainers(); if (usageReport != null) {
if (app.getApplicationResourceUsageReport().getUsedResources() != null) { runningContainers = usageReport.getNumUsedContainers();
allocatedCpuVcores = app.getApplicationResourceUsageReport() if (usageReport.getUsedResources() != null) {
.getUsedResources().getVirtualCores(); allocatedCpuVcores = usageReport.getUsedResources().getVirtualCores();
allocatedMemoryMB = app.getApplicationResourceUsageReport() allocatedMemoryMB = usageReport.getUsedResources().getMemorySize();
.getUsedResources().getMemorySize(); reservedCpuVcores = usageReport.getReservedResources().
reservedCpuVcores = app.getApplicationResourceUsageReport() getVirtualCores();
.getReservedResources().getVirtualCores(); reservedMemoryMB = usageReport.getReservedResources().getMemorySize();
reservedMemoryMB = app.getApplicationResourceUsageReport()
.getReservedResources().getMemorySize();
} }
aggregateResourceAllocation = usageReport.getMemorySeconds()
+ " MB-seconds, " + usageReport.getVcoreSeconds()
+ " vcore-seconds";
aggregatePreemptedResourceAllocation = usageReport.
getPreemptedMemorySeconds() + " MB-seconds, " +
usageReport.getPreemptedVcoreSeconds() + " 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()) {
@ -235,4 +242,12 @@ public class AppInfo {
public String getAmNodeLabelExpression() { public String getAmNodeLabelExpression() {
return amNodeLabelExpression; return amNodeLabelExpression;
} }
public String getAggregateResourceAllocation() {
return aggregateResourceAllocation;
}
public String getAggregatePreemptedResourceAllocation() {
return aggregatePreemptedResourceAllocation;
}
} }