From 45220d115797663b8749980b78a61bafcb2344f1 Mon Sep 17 00:00:00 2001 From: Jonathan Hung Date: Sun, 8 Sep 2019 19:07:05 -0700 Subject: [PATCH] YARN-9764. Print application submission context label in application summary. Contributed by Manoj Kumar (cherry picked from commit 43e389b9801e09741fdf78fef067b8ac60f691c8) --- .../hadoop/yarn/server/resourcemanager/RMAppManager.java | 9 ++++++++- .../yarn/server/resourcemanager/TestAppManager.java | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java index fe09371d7a7..ffe34d03e3c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/RMAppManager.java @@ -211,7 +211,14 @@ public class RMAppManager implements EventHandler, metrics.getPreemptedResourceSecondsMap())) .add("applicationTags", StringHelper.CSV_JOINER.join( app.getApplicationTags() != null ? new TreeSet<>( - app.getApplicationTags()) : Collections.emptySet())); + app.getApplicationTags()) : Collections.emptySet())) + .add("applicationNodeLabel", + app.getApplicationSubmissionContext().getNodeLabelExpression() + == null + ? "" + : app.getApplicationSubmissionContext() + .getNodeLabelExpression()); + return summary; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java index daa97b36470..f3bfc90fd39 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/test/java/org/apache/hadoop/yarn/server/resourcemanager/TestAppManager.java @@ -1062,6 +1062,9 @@ public class TestAppManager extends AppManagerTestBase{ @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"); @@ -1100,6 +1103,7 @@ public class TestAppManager extends AppManagerTestBase{ assertTrue(msg.contains("preemptedResources=")); assertTrue(msg.contains("applicationType=MAPREDUCE")); assertTrue(msg.contains("applicationTags=tag1\\,tag2")); + assertTrue(msg.contains("applicationNodeLabel=test")); } @Test