From 13b526b15f7e967d55d2c9ca75d98f0d8b174531 Mon Sep 17 00:00:00 2001 From: Luke Lu Date: Mon, 29 Jul 2013 07:34:19 +0000 Subject: [PATCH] YARN-347. Node CLI should show CPU info besides memory in node status. (Junping Du via llu) git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1507959 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../org/apache/hadoop/yarn/client/cli/NodeCLI.java | 11 ++++++++--- .../apache/hadoop/yarn/client/cli/TestYarnCLI.java | 6 ++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index e9d2d2edd6..61d3df3fda 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -256,6 +256,9 @@ Release 2.1.0-beta - 2013-07-02 IMPROVEMENTS + YARN-347. Node CLI should show CPU info besides memory in node status. + (Junping Du via llu) + YARN-365. Change NM heartbeat handling to not generate a scheduler event on each heartbeat. (Xuan Gong via sseth) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java index 6ad27942c2..16e80dd93d 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/NodeCLI.java @@ -143,10 +143,15 @@ private void printNodeStatus(String nodeIdStr) throws YarnException, nodeReportStr.print("\tContainers : "); nodeReportStr.println(nodeReport.getNumContainers()); nodeReportStr.print("\tMemory-Used : "); - nodeReportStr.println((nodeReport.getUsed() == null) ? "0M" - : (nodeReport.getUsed().getMemory() + "M")); + nodeReportStr.println((nodeReport.getUsed() == null) ? "0MB" + : (nodeReport.getUsed().getMemory() + "MB")); nodeReportStr.print("\tMemory-Capacity : "); - nodeReportStr.println(nodeReport.getCapability().getMemory()); + nodeReportStr.println(nodeReport.getCapability().getMemory() + "MB"); + nodeReportStr.print("\tCPU-Used : "); + nodeReportStr.println((nodeReport.getUsed() == null) ? "0 vcores" + : (nodeReport.getUsed().getVirtualCores() + " vcores")); + nodeReportStr.print("\tCPU-Capacity : "); + nodeReportStr.println(nodeReport.getCapability().getVirtualCores() + " vcores"); } if (nodeReport == null) { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java index 5b758f30b3..4bc405d67c 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/cli/TestYarnCLI.java @@ -375,8 +375,10 @@ public void testNodeStatus() throws Exception { + DateFormatUtils.format(new Date(0), "E dd/MMM/yy hh:mm:ss:SSzz")); pw.println("\tHealth-Report : "); pw.println("\tContainers : 0"); - pw.println("\tMemory-Used : 0M"); - pw.println("\tMemory-Capacity : 0"); + pw.println("\tMemory-Used : 0MB"); + pw.println("\tMemory-Capacity : 0MB"); + pw.println("\tCPU-Used : 0 vcores"); + pw.println("\tCPU-Capacity : 0 vcores"); pw.close(); String nodeStatusStr = baos.toString("UTF-8"); verify(sysOut, times(1)).println(isA(String.class));