From 0b708ab75d050b61c030b1d164d6992dabf82653 Mon Sep 17 00:00:00 2001 From: Vinod Kumar Vavilapalli Date: Fri, 1 Mar 2013 20:39:18 +0000 Subject: [PATCH] YARN-380. Fix yarn node -status output to be better readable. Contributed by Omkar Vinit Joshi. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1451711 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../java/org/apache/hadoop/yarn/client/cli/NodeCLI.java | 9 ++++++--- .../org/apache/hadoop/yarn/client/cli/TestYarnCLI.java | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 18f0381cca1..c621aead169 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -25,6 +25,9 @@ Release 2.0.4-beta - UNRELEASED YARN-365. Change NM heartbeat handling to not generate a scheduler event on each heartbeat. (Xuan Gong via sseth) + YARN-380. Fix yarn node -status output to be better readable. (Omkar Vinit + Joshi via vinodkv) + OPTIMIZATIONS BUG FIXES 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 9be2067649b..943a673e4d9 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 @@ -20,12 +20,14 @@ package org.apache.hadoop.yarn.client.cli; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintWriter; +import java.util.Date; import java.util.List; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.GnuParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Options; +import org.apache.commons.lang.time.DateFormatUtils; import org.apache.hadoop.util.ToolRunner; import org.apache.hadoop.yarn.api.records.NodeId; import org.apache.hadoop.yarn.api.records.NodeReport; @@ -129,9 +131,10 @@ public class NodeCLI extends YarnCLI { nodeReportStr.print("\tHealth-Status(isNodeHealthy) : "); nodeReportStr.println(nodeReport.getNodeHealthStatus() .getIsNodeHealthy()); - nodeReportStr.print("\tLast-Last-Health-Update : "); - nodeReportStr.println(nodeReport.getNodeHealthStatus() - .getLastHealthReportTime()); + nodeReportStr.print("\tLast-Health-Update : "); + nodeReportStr.println(DateFormatUtils.format( + new Date(nodeReport.getNodeHealthStatus(). + getLastHealthReportTime()),"E dd/MMM/yy hh:mm:ss:SSzz")); nodeReportStr.print("\tHealth-Report : "); nodeReportStr .println(nodeReport.getNodeHealthStatus().getHealthReport()); 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 018476b8915..fb1065c6183 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 @@ -31,10 +31,12 @@ import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.Date; import java.util.List; import junit.framework.Assert; +import org.apache.commons.lang.time.DateFormatUtils; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.api.records.FinalApplicationStatus; @@ -185,7 +187,8 @@ public class TestYarnCLI { pw.println("\tNode-State : RUNNING"); pw.println("\tNode-Http-Address : host1:8888"); pw.println("\tHealth-Status(isNodeHealthy) : false"); - pw.println("\tLast-Last-Health-Update : 0"); + pw.println("\tLast-Health-Update : " + + DateFormatUtils.format(new Date(0), "E dd/MMM/yy hh:mm:ss:SSzz")); pw.println("\tHealth-Report : null"); pw.println("\tContainers : 0"); pw.println("\tMemory-Used : 0M");