Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import static org.apache.hadoop.hdfs.protocol.datatransfer.BlockConstructionStage.PIPELINE_SETUP_CREATE;
import static org.apache.hadoop.hdfs.protocol.datatransfer.BlockConstructionStage.PIPELINE_SETUP_STREAMING_RECOVERY;
import static org.apache.hadoop.util.ExitUtil.terminate;
import static org.apache.hadoop.util.Time.now;

import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.fs.DF;
Expand Down Expand Up @@ -411,6 +412,8 @@ private static Tracer createTracer(Configuration conf) {

private ScheduledThreadPoolExecutor metricsLoggerTimer;

private final long startTime = now();

/**
* Creates a dummy DataNode for testing purpose.
*/
Expand Down Expand Up @@ -3195,6 +3198,11 @@ public String getHttpPort(){
return this.getConf().get("dfs.datanode.info.port");
}

@Override // DataNodeMXBean
public long getDNStartedTimeInMillis() {
return this.startTime;
}

public String getRevision() {
return VersionInfo.getRevision();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,11 @@ public interface DataNodeMXBean {
* @return true, if security is enabled.
*/
boolean isSecurityEnabled();

/**
* Get the start time of the DataNode.
*
* @return Start time of the DataNode.
*/
long getDNStartedTimeInMillis();
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
<div class="page-header"><h1>DataNode on <small>{HostName}:{DataPort}</small></h1></div>
<table class="table table-bordered table-striped">
<tr><th>Cluster ID:</th><td>{ClusterId}</td></tr>
<tr><th>Started:</th><td>{DNStartedTimeInMillis|date_tostring}</td></tr>
<tr><th>Version:</th><td>{Version}</td></tr>
</table>
{/dn}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ public void testDataNodeMXBean() throws Exception {
// get attribute "Version"
String version = (String)mbs.getAttribute(mxbeanName, "Version");
Assert.assertEquals(datanode.getVersion(),version);
// get attribute "DNStartedTimeInMillis"
long startTime = (long) mbs.getAttribute(mxbeanName, "DNStartedTimeInMillis");
Assert.assertEquals(datanode.getDNStartedTimeInMillis(), startTime);
// get attribute "SotfwareVersion"
String softwareVersion =
(String)mbs.getAttribute(mxbeanName, "SoftwareVersion");
Expand Down