hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vinayakum...@apache.org
Subject [22/25] hadoop git commit: YARN-570. Time strings are formated in different timezone. (Akira Ajisaka and Peng Zhang via kasha)
Date Wed, 12 Nov 2014 03:47:44 GMT
YARN-570. Time strings are formated in different timezone. (Akira Ajisaka and Peng Zhang via
kasha)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/456b9738
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/456b9738
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/456b9738

Branch: refs/heads/HDFS-EC
Commit: 456b973819904e9647dabad292d2d6205dd84399
Parents: 99d9d0c
Author: Karthik Kambatla <kasha@apache.org>
Authored: Tue Nov 11 13:22:48 2014 -0800
Committer: Karthik Kambatla <kasha@apache.org>
Committed: Tue Nov 11 13:22:59 2014 -0800

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                 |  3 +++
 .../java/org/apache/hadoop/yarn/util/Times.java |  3 ++-
 .../resources/webapps/static/yarn.dt.plugins.js | 27 +++++++++++++++++++-
 3 files changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/456b9738/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index 3dc6d9f..b40d9b7 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -65,6 +65,9 @@ Release 2.7.0 - UNRELEASED
     YARN-2735. diskUtilizationPercentageCutoff and diskUtilizationSpaceCutoff 
     are initialized twice in DirectoryCollection. (Zhihai Xu via kasha)
 
+    YARN-570. Time strings are formated in different timezone. 
+    (Akira Ajisaka and Peng Zhang via kasha)
+
   OPTIMIZATIONS
 
   BUG FIXES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/456b9738/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/Times.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/Times.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/Times.java
index 92cc72a..8ae3842 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/Times.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/util/Times.java
@@ -29,10 +29,11 @@ import org.apache.hadoop.classification.InterfaceAudience.Private;
 public class Times {
   private static final Log LOG = LogFactory.getLog(Times.class);
 
+  // This format should match the one used in yarn.dt.plugins.js
   static final ThreadLocal<SimpleDateFormat> dateFormat =
       new ThreadLocal<SimpleDateFormat>() {
         @Override protected SimpleDateFormat initialValue() {
-          return new SimpleDateFormat("d-MMM-yyyy HH:mm:ss");
+          return new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy");
         }
       };
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/456b9738/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/yarn.dt.plugins.js
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/yarn.dt.plugins.js
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/yarn.dt.plugins.js
index 0c683e7..7b069df 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/yarn.dt.plugins.js
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/resources/webapps/static/yarn.dt.plugins.js
@@ -78,13 +78,38 @@ function renderHadoopDate(data, type, full) {
     if(data === '0'|| data === '-1') {
       return "N/A";
     }
-    return new Date(parseInt(data)).toUTCString();
+    var date = new Date(parseInt(data));
+    var monthList = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
+                     "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
+    var weekdayList = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
+    var offsetMinutes = date.getTimezoneOffset();
+    var offset
+    if (offsetMinutes <= 0) {
+      offset = "+" + zeroPad(-offsetMinutes / 60 * 100, 4);
+    } else {
+      offset = "-" + zeroPad(offsetMinutes / 60 * 100, 4);
+    }
+
+    // EEE MMM dd HH:mm:ss Z yyyy
+    return weekdayList[date.getDay()] + " " +
+        monthList[date.getMonth()] + " " +
+        date.getDate() + " " +
+        zeroPad(date.getHours(), 2) + ":" +
+        zeroPad(date.getMinutes(), 2) + ":" +
+        zeroPad(date.getSeconds(), 2) + " " +
+        offset + " " +
+        date.getFullYear();
   }
   // 'sort', 'type' and undefined all just use the number
   // If date is 0, then for purposes of sorting it should be consider max_int
   return data === '0' ? '9007199254740992' : data;  
 }
 
+function zeroPad(n, width) {
+  n = n + '';
+  return n.length >= width ? n : new Array(width - n.length + 1).join('0') + n;
+}
+
 function renderHadoopElapsedTime(data, type, full) {
   if (type === 'display' || type === 'filter') {
     var timeDiff = parseInt(data);


Mime
View raw message