YARN-4628. Display application priority in yarn top. Contributed by Bibin A Chundatt.
(cherry picked from commit 663a80031cf6f17151622fff327171dedd976df3) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/05b57c87 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/05b57c87 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/05b57c87 Branch: refs/heads/branch-2 Commit: 05b57c87f963ac833a6f6f387adad46b6cc353ac Parents: 0c9110d Author: Varun Vasudev <vvasu...@apache.org> Authored: Thu Feb 11 11:56:09 2016 +0530 Committer: Varun Vasudev <vvasu...@apache.org> Committed: Thu Feb 11 12:00:32 2016 +0530 ---------------------------------------------------------------------- hadoop-yarn-project/CHANGES.txt | 3 +++ .../org/apache/hadoop/yarn/client/cli/TopCLI.java | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/05b57c87/hadoop-yarn-project/CHANGES.txt ---------------------------------------------------------------------- diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 6ee90bf..ed9665e 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -67,6 +67,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 http://git-wip-us.apache.org/repos/asf/hadoop/blob/05b57c87/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/TopCLI.java ---------------------------------------------------------------------- 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 8bcbcf3..67d29ad 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<ApplicationInformation> AppPriorityComparator = + new Comparator<ApplicationInformation>() { + @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;