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-05-29 16:05:39 +00:00
parent 544876fe12
commit 3c63551101
2 changed files with 21 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import static org.assertj.core.api.Assertions.assertThat;
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;
@ -415,6 +416,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

View File

@ -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;
}
}