From 469cfcd695da979e56c83d9303f9bc1f898c08ce Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Mon, 3 Aug 2015 15:53:32 +0000 Subject: [PATCH] YARN-3965. Add startup timestamp to nodemanager UI. Contributed by Hong Zhiguo --- hadoop-yarn-project/CHANGES.txt | 2 ++ .../hadoop/yarn/server/nodemanager/NodeManager.java | 5 +++++ .../hadoop/yarn/server/nodemanager/webapp/NodePage.java | 8 +++++--- .../yarn/server/nodemanager/webapp/dao/NodeInfo.java | 6 ++++++ .../yarn/server/nodemanager/webapp/TestNMWebServices.java | 2 +- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index cd8cbd3b247..14961440a18 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -361,6 +361,8 @@ Release 2.8.0 - UNRELEASED YARN-3950. Add unique SHELL_ID environment variable to DistributedShell (Robert Kanter via jlowe) + YARN-3965. Add startup timestamp to nodemanager UI (Hong Zhiguo via jlowe) + OPTIMIZATIONS YARN-3339. TestDockerContainerExecutor should pull a single image and not diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java index 185ba126a4d..b8889eeded8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java @@ -81,6 +81,7 @@ public class NodeManager extends CompositeService public static final int SHUTDOWN_HOOK_PRIORITY = 30; private static final Log LOG = LogFactory.getLog(NodeManager.class); + private static long nmStartupTime = System.currentTimeMillis(); protected final NodeManagerMetrics metrics = NodeManagerMetrics.create(); private ApplicationACLsManager aclsManager; private NodeHealthCheckerService nodeHealthChecker; @@ -101,6 +102,10 @@ public class NodeManager extends CompositeService super(NodeManager.class.getName()); } + public static long getNMStartupTime() { + return nmStartupTime; + } + protected NodeStatusUpdater createNodeStatusUpdater(Context context, Dispatcher dispatcher, NodeHealthCheckerService healthChecker) { return new NodeStatusUpdaterImpl(context, dispatcher, healthChecker, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NodePage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NodePage.java index 92c4187c201..f51f0c551af 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NodePage.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/NodePage.java @@ -73,15 +73,17 @@ public class NodePage extends NMView { StringUtils.byteDesc(info.getTotalPmemAllocated() * BYTES_IN_MB)) ._("Pmem enforcement enabled", info.isPmemCheckEnabled()) - ._("Total VCores allocated for Containers", - String.valueOf(info.getTotalVCoresAllocated())) + ._("Total VCores allocated for Containers", + String.valueOf(info.getTotalVCoresAllocated())) ._("NodeHealthyStatus", info.getHealthStatus()) ._("LastNodeHealthTime", new Date( info.getLastNodeUpdateTime())) ._("NodeHealthReport", info.getHealthReport()) - ._("Node Manager Version:", info.getNMBuildVersion() + + ._("NodeManager started on", new Date( + info.getNMStartupTime())) + ._("NodeManager Version:", info.getNMBuildVersion() + " on " + info.getNMVersionBuiltOn()) ._("Hadoop Version:", info.getHadoopBuildVersion() + " on " + info.getHadoopVersionBuiltOn()); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/dao/NodeInfo.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/dao/NodeInfo.java index 5d67c9e6d6b..32e39cf59fb 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/dao/NodeInfo.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/webapp/dao/NodeInfo.java @@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlRootElement; import org.apache.hadoop.util.VersionInfo; import org.apache.hadoop.yarn.server.nodemanager.Context; +import org.apache.hadoop.yarn.server.nodemanager.NodeManager; import org.apache.hadoop.yarn.server.nodemanager.ResourceView; import org.apache.hadoop.yarn.util.YarnVersionInfo; @@ -49,6 +50,7 @@ public class NodeInfo { protected String hadoopVersionBuiltOn; protected String id; protected String nodeHostName; + protected long nmStartupTime; public NodeInfo() { } // JAXB needs this @@ -77,6 +79,7 @@ public class NodeInfo { this.hadoopVersion = VersionInfo.getVersion(); this.hadoopBuildVersion = VersionInfo.getBuildVersion(); this.hadoopVersionBuiltOn = VersionInfo.getDate(); + this.nmStartupTime = NodeManager.getNMStartupTime(); } public String getNodeId() { @@ -143,4 +146,7 @@ public class NodeInfo { return this.pmemCheckEnabled; } + public long getNMStartupTime() { + return nmStartupTime; + } } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServices.java index 5a89e742190..1f5590ca46f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/webapp/TestNMWebServices.java @@ -402,7 +402,7 @@ public class TestNMWebServices extends JerseyTestBase { public void verifyNodeInfo(JSONObject json) throws JSONException, Exception { assertEquals("incorrect number of elements", 1, json.length()); JSONObject info = json.getJSONObject("nodeInfo"); - assertEquals("incorrect number of elements", 16, info.length()); + assertEquals("incorrect number of elements", 17, info.length()); verifyNodeInfoGeneric(info.getString("id"), info.getString("healthReport"), info.getLong("totalVmemAllocatedContainersMB"), info.getLong("totalPmemAllocatedContainersMB"),