From 663a80031cf6f17151622fff327171dedd976df3 Mon Sep 17 00:00:00 2001 From: Varun Vasudev Date: Thu, 11 Feb 2016 11:56:09 +0530 Subject: [PATCH] YARN-4628. Display application priority in yarn top. Contributed by Bibin A Chundatt. --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../apache/hadoop/yarn/client/cli/TopCLI.java | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 329e04be950..571549faf8c 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -125,6 +125,9 @@ Release 2.9.0 - UNRELEASED YARN-4307. Display blacklisted nodes for AM container in the RM web UI. (Naganarasimha G R via vvasudev) + YARN-4628. Display application priority in yarn top. + (Bibin A Chundatt via vvasudev) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/TopCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/TopCLI.java index 423fb3c8733..1c664755ad8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/TopCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/TopCLI.java @@ -55,6 +55,7 @@ import org.apache.hadoop.util.Time; import org.apache.hadoop.util.ToolRunner; import org.apache.hadoop.yarn.api.protocolrecords.GetApplicationsRequest; import org.apache.hadoop.yarn.api.records.ApplicationReport; +import org.apache.hadoop.yarn.api.records.Priority; import org.apache.hadoop.yarn.api.records.QueueInfo; import org.apache.hadoop.yarn.api.records.QueueStatistics; import org.apache.hadoop.yarn.api.records.YarnApplicationState; @@ -141,7 +142,9 @@ public class TopCLI extends YarnCLI { displayStringsMap.put(Columns.NAME, name); queue = appReport.getQueue(); displayStringsMap.put(Columns.QUEUE, queue); - priority = 0; + Priority appPriority = appReport.getPriority(); + priority = null != appPriority ? appPriority.getPriority() : 0; + displayStringsMap.put(Columns.PRIORITY, String.valueOf(priority)); usedContainers = appReport.getApplicationResourceUsageReport().getNumUsedContainers(); displayStringsMap.put(Columns.CONT, String.valueOf(usedContainers)); @@ -305,6 +308,14 @@ public class TopCLI extends YarnCLI { return a1.name.compareTo(a2.name); } }; + public static final Comparator AppPriorityComparator = + new Comparator() { + @Override + public int compare(ApplicationInformation a1, + ApplicationInformation a2) { + return a1.priority - a2.priority; + } + }; private static class NodesInformation { int totalNodes; @@ -620,6 +631,8 @@ public class TopCLI extends YarnCLI { "%10s", true, "Application type", "t")); columnInformationEnumMap.put(Columns.QUEUE, new ColumnInformation("QUEUE", "%10s", true, "Application queue", "q")); + columnInformationEnumMap.put(Columns.PRIORITY, new ColumnInformation( + "PRIOR", "%5s", true, "Application priority", "l")); columnInformationEnumMap.put(Columns.CONT, new ColumnInformation("#CONT", "%7s", true, "Number of containers", "c")); columnInformationEnumMap.put(Columns.RCONT, new ColumnInformation("#RCONT", @@ -1010,6 +1023,9 @@ public class TopCLI extends YarnCLI { case "n": comparator = AppNameComparator; break; + case "l": + comparator = AppPriorityComparator; + break; default: // it wasn't a sort key currentSortField = f;