hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rkan...@apache.org
Subject hadoop git commit: MAPREDUCE-6620. Jobs that did not start are shown as starting in 1969 in the JHS web UI (haibochen via rkanter)
Date Tue, 02 Feb 2016 23:23:20 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk 6d1213860 -> ccbba4a4d


MAPREDUCE-6620. Jobs that did not start are shown as starting in 1969 in the JHS web UI (haibochen
via rkanter)


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

Branch: refs/heads/trunk
Commit: ccbba4a4deb8ade54a04137c993526e461bcb46e
Parents: 6d12138
Author: Robert Kanter <rkanter@apache.org>
Authored: Tue Feb 2 15:19:35 2016 -0800
Committer: Robert Kanter <rkanter@apache.org>
Committed: Tue Feb 2 15:19:35 2016 -0800

----------------------------------------------------------------------
 hadoop-mapreduce-project/CHANGES.txt            |  3 +++
 .../mapreduce/v2/hs/webapp/HsJobBlock.java      |  2 +-
 .../mapreduce/v2/hs/webapp/HsJobsBlock.java     |  2 +-
 .../mapreduce/v2/hs/webapp/dao/JobInfo.java     | 12 +++++++++
 .../mapreduce/v2/hs/webapp/dao/TestJobInfo.java | 26 +++++++++++++++++++-
 5 files changed, 42 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/ccbba4a4/hadoop-mapreduce-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt
index a69453f..95accff 100644
--- a/hadoop-mapreduce-project/CHANGES.txt
+++ b/hadoop-mapreduce-project/CHANGES.txt
@@ -317,6 +317,9 @@ Release 2.9.0 - UNRELEASED
 
   BUG FIXES
 
+    MAPREDUCE-6620. Jobs that did not start are shown as starting in 1969 in
+    the JHS web UI (haibochen via rkanter)
+
 Release 2.8.0 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ccbba4a4/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsJobBlock.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsJobBlock.java
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsJobBlock.java
index dbd1dee..ddac853 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsJobBlock.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsJobBlock.java
@@ -86,7 +86,7 @@ public class HsJobBlock extends HtmlBlock {
         _("State:", job.getState()).
         _("Uberized:", job.isUber()).
         _("Submitted:", new Date(job.getSubmitTime())).
-        _("Started:", new Date(job.getStartTime())).
+        _("Started:", job.getStartTimeStr()).
         _("Finished:", new Date(job.getFinishTime())).
         _("Elapsed:", StringUtils.formatTime(
             Times.elapsed(job.getStartTime(), job.getFinishTime(), false)));

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ccbba4a4/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsJobsBlock.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsJobsBlock.java
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsJobsBlock.java
index 28c8eea..92c5e2b 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsJobsBlock.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsJobsBlock.java
@@ -79,7 +79,7 @@ public class HsJobsBlock extends HtmlBlock {
       JobInfo job = new JobInfo(j);
       jobsTableData.append("[\"")
       .append(dateFormat.format(new Date(job.getSubmitTime()))).append("\",\"")
-      .append(dateFormat.format(new Date(job.getStartTime()))).append("\",\"")
+      .append(job.getStartTimeStr()).append("\",\"")
       .append(dateFormat.format(new Date(job.getFinishTime()))).append("\",\"")
       .append("<a href='").append(url("job", job.getId())).append("'>")
       .append(job.getId()).append("</a>\",\"")

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ccbba4a4/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/JobInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/JobInfo.java
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/JobInfo.java
index 3fbb8d2..eddbccf 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/JobInfo.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/JobInfo.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.mapreduce.v2.hs.webapp.dao;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
@@ -43,6 +44,7 @@ import org.apache.hadoop.security.authorize.AccessControlList;
 @XmlRootElement(name = "job")
 @XmlAccessorType(XmlAccessType.FIELD)
 public class JobInfo {
+  private static final String NA = "N/A";
 
   protected long submitTime;
   protected long startTime;
@@ -226,6 +228,16 @@ public class JobInfo {
     return this.startTime;
   }
 
+  public String getStartTimeStr() {
+    String str = NA;
+
+    if (startTime >= 0) {
+      str = new Date(startTime).toString();
+    }
+
+    return str;
+  }
+
   public long getFinishTime() {
     return this.finishTime;
   }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/ccbba4a4/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/TestJobInfo.java
----------------------------------------------------------------------
diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/TestJobInfo.java
b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/TestJobInfo.java
index b4f8d5a..e75cce7 100644
--- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/TestJobInfo.java
+++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/TestJobInfo.java
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
 import java.io.IOException;
+import java.util.Date;
 import java.util.HashMap;
 
 import org.junit.Assert;
@@ -135,5 +136,28 @@ public class TestJobInfo {
     JobInfo jobInfo = new JobInfo(job);
   
     Assert.assertEquals(11L, jobInfo.getAvgReduceTime().longValue());
-  }  
+  }
+
+  @Test
+  public void testGetStartTimeStr() {
+    JobReport jobReport = mock(JobReport.class);
+    when(jobReport.getStartTime()).thenReturn(-1L);
+
+    Job job = mock(Job.class);
+    when(job.getReport()).thenReturn(jobReport);
+    when(job.getName()).thenReturn("TestJobInfo");
+    when(job.getState()).thenReturn(JobState.SUCCEEDED);
+
+    JobId  jobId = MRBuilderUtils.newJobId(1L, 1, 1);
+    when(job.getID()).thenReturn(jobId);
+
+    JobInfo jobInfo = new JobInfo(job);
+    Assert.assertEquals("N/A", jobInfo.getStartTimeStr());
+
+    Date date = new Date();
+    when(jobReport.getStartTime()).thenReturn(date.getTime());
+
+    jobInfo = new JobInfo(job);
+    Assert.assertEquals(date.toString(), jobInfo.getStartTimeStr());
+  }
 }


Mime
View raw message