From 6c5f37e46d5f70859777b553cbe00fc43dfdb008 Mon Sep 17 00:00:00 2001 From: Jason Darrell Lowe Date: Thu, 22 Nov 2012 00:05:26 +0000 Subject: [PATCH] MAPREDUCE-4811. JobHistoryServer should show when it was started in WebUI About page. Contributed by Ravi Prakash git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1412377 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-mapreduce-project/CHANGES.txt | 3 +++ .../hadoop/mapreduce/v2/hs/JobHistoryServer.java | 2 ++ .../hadoop/mapreduce/v2/hs/webapp/HsAboutPage.java | 6 +++++- .../mapreduce/v2/hs/webapp/dao/HistoryInfo.java | 7 +++++++ .../mapreduce/v2/hs/webapp/TestHsWebServices.java | 13 +++++++++---- .../src/site/apt/HistoryServerRest.apt.vm | 4 ++++ 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/hadoop-mapreduce-project/CHANGES.txt b/hadoop-mapreduce-project/CHANGES.txt index 45a3a921fd8..49556c4edbb 100644 --- a/hadoop-mapreduce-project/CHANGES.txt +++ b/hadoop-mapreduce-project/CHANGES.txt @@ -586,6 +586,9 @@ Release 0.23.6 - UNRELEASED IMPROVEMENTS + MAPREDUCE-4811. JobHistoryServer should show when it was started in WebUI + About page (Ravi Prakash via jlowe) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/JobHistoryServer.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/JobHistoryServer.java index 94d25f60f8b..f76f030cc69 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/JobHistoryServer.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/JobHistoryServer.java @@ -51,6 +51,8 @@ public class JobHistoryServer extends CompositeService { */ public static final int SHUTDOWN_HOOK_PRIORITY = 30; + public static final long historyServerTimeStamp = System.currentTimeMillis(); + private static final Log LOG = LogFactory.getLog(JobHistoryServer.class); private HistoryContext historyContext; private HistoryClientService clientService; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsAboutPage.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsAboutPage.java index 0542765c2ae..f607599a922 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsAboutPage.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsAboutPage.java @@ -21,7 +21,9 @@ package org.apache.hadoop.mapreduce.v2.hs.webapp; import static org.apache.hadoop.yarn.webapp.view.JQueryUI.ACCORDION; import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID; +import org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer; import org.apache.hadoop.mapreduce.v2.hs.webapp.dao.HistoryInfo; +import org.apache.hadoop.yarn.util.Times; import org.apache.hadoop.yarn.webapp.SubView; import org.apache.hadoop.yarn.webapp.view.InfoBlock; @@ -47,7 +49,9 @@ public class HsAboutPage extends HsView { @Override protected Class content() { HistoryInfo info = new HistoryInfo(); info("History Server"). - _("BuildVersion", info.getHadoopBuildVersion() + " on " + info.getHadoopVersionBuiltOn()); + _("BuildVersion", info.getHadoopBuildVersion() + + " on " + info.getHadoopVersionBuiltOn()). + _("History Server started on", Times.format(info.getStartedOn())); return InfoBlock.class; } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/HistoryInfo.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/HistoryInfo.java index 54cff302662..33d1c368513 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/HistoryInfo.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/dao/HistoryInfo.java @@ -22,17 +22,20 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlRootElement; +import org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer; import org.apache.hadoop.util.VersionInfo; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class HistoryInfo { + protected long startedOn; protected String hadoopVersion; protected String hadoopBuildVersion; protected String hadoopVersionBuiltOn; public HistoryInfo() { + this.startedOn = JobHistoryServer.historyServerTimeStamp; this.hadoopVersion = VersionInfo.getVersion(); this.hadoopBuildVersion = VersionInfo.getBuildVersion(); this.hadoopVersionBuiltOn = VersionInfo.getDate(); @@ -50,4 +53,8 @@ public class HistoryInfo { return this.hadoopVersionBuiltOn; } + public long getStartedOn() { + return this.startedOn; + } + } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServices.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServices.java index ce6a31bc727..45a464edbbb 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServices.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/test/java/org/apache/hadoop/mapreduce/v2/hs/webapp/TestHsWebServices.java @@ -36,6 +36,7 @@ import org.apache.hadoop.mapreduce.v2.app.MockJobs; import org.apache.hadoop.mapreduce.v2.app.job.Job; import org.apache.hadoop.mapreduce.v2.hs.HistoryContext; import org.apache.hadoop.mapreduce.v2.hs.JobHistory; +import org.apache.hadoop.mapreduce.v2.hs.JobHistoryServer; import org.apache.hadoop.mapreduce.v2.hs.webapp.dao.JobsInfo; import org.apache.hadoop.util.VersionInfo; import org.apache.hadoop.yarn.Clock; @@ -344,21 +345,24 @@ public class TestHsWebServices extends JerseyTest { } public void verifyHsInfoGeneric(String hadoopVersionBuiltOn, - String hadoopBuildVersion, String hadoopVersion) { + String hadoopBuildVersion, String hadoopVersion, long startedon) { WebServicesTestUtils.checkStringMatch("hadoopVersionBuiltOn", VersionInfo.getDate(), hadoopVersionBuiltOn); WebServicesTestUtils.checkStringMatch("hadoopBuildVersion", VersionInfo.getBuildVersion(), hadoopBuildVersion); WebServicesTestUtils.checkStringMatch("hadoopVersion", VersionInfo.getVersion(), hadoopVersion); + assertEquals("startedOn doesn't match: ", + JobHistoryServer.historyServerTimeStamp, startedon); } public void verifyHSInfo(JSONObject info, TestAppContext ctx) throws JSONException { - assertEquals("incorrect number of elements", 3, info.length()); + assertEquals("incorrect number of elements", 4, info.length()); verifyHsInfoGeneric(info.getString("hadoopVersionBuiltOn"), - info.getString("hadoopBuildVersion"), info.getString("hadoopVersion")); + info.getString("hadoopBuildVersion"), info.getString("hadoopVersion"), + info.getLong("startedOn")); } public void verifyHSInfoXML(String xml, TestAppContext ctx) @@ -376,7 +380,8 @@ public class TestHsWebServices extends JerseyTest { verifyHsInfoGeneric( WebServicesTestUtils.getXmlString(element, "hadoopVersionBuiltOn"), WebServicesTestUtils.getXmlString(element, "hadoopBuildVersion"), - WebServicesTestUtils.getXmlString(element, "hadoopVersion")); + WebServicesTestUtils.getXmlString(element, "hadoopVersion"), + WebServicesTestUtils.getXmlLong(element, "startedOn")); } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/apt/HistoryServerRest.apt.vm b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/apt/HistoryServerRest.apt.vm index 358f8ca0230..c51df0d73ac 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/apt/HistoryServerRest.apt.vm +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-site/src/site/apt/HistoryServerRest.apt.vm @@ -56,6 +56,8 @@ History Server REST API's. *---------------+--------------+-------------------------------+ || Item || Data Type || Description | *---------------+--------------+-------------------------------+ +| startedOn | long | The time the history server was started (in ms since epoch)| +*---------------+--------------+-------------------------------+ | hadoopVersion | string | Version of hadoop common | *---------------+--------------+-------------------------------+ | hadoopBuildVersion | string | Hadoop common build string with build version, user, and checksum | @@ -87,6 +89,7 @@ History Server REST API's. +---+ { "historyInfo" : { + "startedOn":1353512830963, "hadoopVersionBuiltOn" : "Wed Jan 11 21:18:36 UTC 2012", "hadoopBuildVersion" : "0.23.1-SNAPSHOT from 1230253 by user1 source checksum bb6e554c6d50b0397d826081017437a7", "hadoopVersion" : "0.23.1-SNAPSHOT" @@ -117,6 +120,7 @@ History Server REST API's. +---+ + 1353512830963 0.23.1-SNAPSHOT 0.23.1-SNAPSHOT from 1230253 by user1 source checksum bb6e554c6d50b0397d826081017437a7 Wed Jan 11 21:18:36 UTC 2012