From 9c9ff072499ad96a11996b11567e30a2b906fe57 Mon Sep 17 00:00:00 2001 From: Jonathan Hung Date: Fri, 6 Sep 2019 10:48:30 -0700 Subject: [PATCH] YARN-9763. Print application tags in application summary. Contributed by Manoj Kumar --- .../hadoop/yarn/server/resourcemanager/RMAppManager.java | 6 +++++- .../hadoop/yarn/server/resourcemanager/TestAppManager.java | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) 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 2783f3696c3..fe09371d7a7 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 @@ -21,6 +21,7 @@ import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.TreeSet; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; @@ -207,7 +208,10 @@ public class RMAppManager implements EventHandler, .getResourceSecondsString(metrics.getResourceSecondsMap())) .add("preemptedResourceSeconds", StringHelper .getResourceSecondsString( - metrics.getPreemptedResourceSecondsMap())); + metrics.getPreemptedResourceSecondsMap())) + .add("applicationTags", StringHelper.CSV_JOINER.join( + app.getApplicationTags() != null ? new TreeSet<>( + app.getApplicationTags()) : Collections.emptySet())); 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 31c16a43def..daa97b36470 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 @@ -1071,6 +1071,7 @@ public class TestAppManager extends AppManagerTestBase{ when(app.getApplicationType()).thenReturn("MAPREDUCE"); when(app.getSubmitTime()).thenReturn(1000L); when(app.getLaunchTime()).thenReturn(2000L); + when(app.getApplicationTags()).thenReturn(Sets.newHashSet("tag2", "tag1")); Map resourceSecondsMap = new HashMap<>(); resourceSecondsMap.put(ResourceInformation.MEMORY_MB.getName(), 16384L); resourceSecondsMap.put(ResourceInformation.VCORES.getName(), 64L); @@ -1098,7 +1099,8 @@ public class TestAppManager extends AppManagerTestBase{ assertTrue(msg.contains("preemptedNonAMContainers=10")); assertTrue(msg.contains("preemptedResources=")); assertTrue(msg.contains("applicationType=MAPREDUCE")); - } + assertTrue(msg.contains("applicationTags=tag1\\,tag2")); + } @Test public void testRMAppSubmitWithQueueChanged() throws Exception {