HDFS-16444. Show start time of JournalNode on Web (#3943)
This commit is contained in:
parent
39cad5f28f
commit
bd50b9117e
|
@ -45,6 +45,7 @@ import org.apache.hadoop.util.DiskChecker;
|
|||
|
||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_JOURNALNODE_HTTP_BIND_HOST_KEY;
|
||||
import static org.apache.hadoop.util.ExitUtil.terminate;
|
||||
import static org.apache.hadoop.util.Time.now;
|
||||
import org.apache.hadoop.util.StringUtils;
|
||||
import org.apache.hadoop.util.Tool;
|
||||
import org.apache.hadoop.util.ToolRunner;
|
||||
|
@ -83,6 +84,7 @@ public class JournalNode implements Tool, Configurable, JournalNodeMXBean {
|
|||
private String httpServerURI;
|
||||
private final ArrayList<File> localDir = Lists.newArrayList();
|
||||
Tracer tracer;
|
||||
private long startTime = 0;
|
||||
|
||||
static {
|
||||
HdfsConfiguration.init();
|
||||
|
@ -241,6 +243,7 @@ public class JournalNode implements Tool, Configurable, JournalNodeMXBean {
|
|||
|
||||
rpcServer = new JournalNodeRpcServer(conf, this);
|
||||
rpcServer.start();
|
||||
startTime = now();
|
||||
} catch (IOException ioe) {
|
||||
//Shutdown JournalNode of JournalNodeRpcServer fails to start
|
||||
LOG.error("Failed to start JournalNode.", ioe);
|
||||
|
@ -415,6 +418,11 @@ public class JournalNode implements Tool, Configurable, JournalNodeMXBean {
|
|||
return VersionInfo.getVersion() + ", r" + VersionInfo.getRevision();
|
||||
}
|
||||
|
||||
@Override // JournalNodeMXBean
|
||||
public long getJNStartedTimeInMillis() {
|
||||
return this.startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register JournalNodeMXBean
|
||||
*/
|
||||
|
|
|
@ -57,4 +57,11 @@ public interface JournalNodeMXBean {
|
|||
* @return the version of Hadoop.
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* Get the start time of the JournalNode.
|
||||
*
|
||||
* @return the start time of the JournalNode.
|
||||
*/
|
||||
long getJNStartedTimeInMillis();
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
<div class="page-header"><h1>JournalNode on <small>{HostAndPort}</small></h1></div>
|
||||
<table class="table table-bordered table-striped">
|
||||
<tr><th>Cluster ID:</th><td>{ClusterIds}</td></tr>
|
||||
<tr><th>Started:</th><td>{JNStartedTimeInMillis|date_tostring}</td></tr>
|
||||
<tr><th>Version:</th><td>{Version}</td></tr>
|
||||
</table>
|
||||
{/jn}
|
||||
|
|
|
@ -104,6 +104,9 @@ public class TestJournalNodeMXBean {
|
|||
String[] clusterId = (String[]) mbs.getAttribute(mxbeanName, "ClusterIds");
|
||||
assertEquals(jn.getClusterIds().size(), clusterId.length);
|
||||
assertEquals("mycluster", clusterId[0]);
|
||||
long startTime = (long) mbs.getAttribute(mxbeanName, "JNStartedTimeInMillis");
|
||||
assertTrue("JournalNode start time should not be 0", startTime > 0);
|
||||
assertEquals(jn.getJNStartedTimeInMillis(), startTime);
|
||||
String version = (String) mbs.getAttribute(mxbeanName, "Version");
|
||||
assertEquals(jn.getVersion(), version);
|
||||
|
||||
|
|
Loading…
Reference in New Issue