YARN-9764. Print application submission context label in application summary. Contributed by Manoj Kumar

This commit is contained in:
Jonathan Hung 2019-09-08 19:07:05 -07:00
parent ca32917e0f
commit 43e389b980
2 changed files with 12 additions and 1 deletions

View File

@ -215,7 +215,14 @@ public static SummaryBuilder createAppSummary(RMApp app) {
metrics.getPreemptedResourceSecondsMap()))
.add("applicationTags", StringHelper.CSV_JOINER.join(
app.getApplicationTags() != null ? new TreeSet<>(
app.getApplicationTags()) : Collections.<String>emptySet()));
app.getApplicationTags()) : Collections.<String>emptySet()))
.add("applicationNodeLabel",
app.getApplicationSubmissionContext().getNodeLabelExpression()
== null
? ""
: app.getApplicationSubmissionContext()
.getNodeLabelExpression());
return summary;
}

View File

@ -1063,6 +1063,9 @@ public void testRMAppSubmitInvalidResourceRequest() throws Exception {
@Test (timeout = 30000)
public void testEscapeApplicationSummary() {
RMApp app = mock(RMAppImpl.class);
ApplicationSubmissionContext asc = mock(ApplicationSubmissionContext.class);
when(asc.getNodeLabelExpression()).thenReturn("test");
when(app.getApplicationSubmissionContext()).thenReturn(asc);
when(app.getApplicationId()).thenReturn(
ApplicationId.newInstance(100L, 1));
when(app.getName()).thenReturn("Multiline\n\n\r\rAppName");
@ -1101,6 +1104,7 @@ public void testEscapeApplicationSummary() {
assertTrue(msg.contains("preemptedResources=<memory:1234\\, vCores:56>"));
assertTrue(msg.contains("applicationType=MAPREDUCE"));
assertTrue(msg.contains("applicationTags=tag1\\,tag2"));
assertTrue(msg.contains("applicationNodeLabel=test"));
}
@Test