HDFS-16337. Show start time of Datanode on Web (#3682)
Reviewed-by: Inigo Goiri <inigoiri@apache.org>
(cherry picked from commit 0ed817babb
)
This commit is contained in:
parent
cbb3ba135c
commit
d746e2cdd8
|
@ -50,6 +50,7 @@ import static org.apache.hadoop.hdfs.protocol.datatransfer.BlockConstructionStag
|
||||||
import static org.apache.hadoop.hdfs.protocol.datatransfer.BlockConstructionStage.PIPELINE_SETUP_CREATE;
|
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.hdfs.protocol.datatransfer.BlockConstructionStage.PIPELINE_SETUP_STREAMING_RECOVERY;
|
||||||
import static org.apache.hadoop.util.ExitUtil.terminate;
|
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.CommonConfigurationKeysPublic;
|
||||||
import org.apache.hadoop.hdfs.protocol.proto.ReconfigurationProtocolProtos.ReconfigurationProtocolService;
|
import org.apache.hadoop.hdfs.protocol.proto.ReconfigurationProtocolProtos.ReconfigurationProtocolService;
|
||||||
|
@ -415,6 +416,8 @@ public class DataNode extends ReconfigurableBase
|
||||||
|
|
||||||
private ScheduledThreadPoolExecutor metricsLoggerTimer;
|
private ScheduledThreadPoolExecutor metricsLoggerTimer;
|
||||||
|
|
||||||
|
private final long startTime = now();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a dummy DataNode for testing purpose.
|
* Creates a dummy DataNode for testing purpose.
|
||||||
*/
|
*/
|
||||||
|
@ -3109,6 +3112,11 @@ public class DataNode extends ReconfigurableBase
|
||||||
return this.getConf().get("dfs.datanode.info.port");
|
return this.getConf().get("dfs.datanode.info.port");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override // DataNodeMXBean
|
||||||
|
public long getDNStartedTimeInMillis() {
|
||||||
|
return this.startTime;
|
||||||
|
}
|
||||||
|
|
||||||
public String getRevision() {
|
public String getRevision() {
|
||||||
return VersionInfo.getRevision();
|
return VersionInfo.getRevision();
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,4 +157,11 @@ public interface DataNodeMXBean {
|
||||||
* @return true, if security is enabled.
|
* @return true, if security is enabled.
|
||||||
*/
|
*/
|
||||||
boolean isSecurityEnabled();
|
boolean isSecurityEnabled();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the start time of the DataNode.
|
||||||
|
*
|
||||||
|
* @return Start time of the DataNode.
|
||||||
|
*/
|
||||||
|
long getDNStartedTimeInMillis();
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
<div class="page-header"><h1>DataNode on <small>{HostName}:{DataPort}</small></h1></div>
|
<div class="page-header"><h1>DataNode on <small>{HostName}:{DataPort}</small></h1></div>
|
||||||
<table class="table table-bordered table-striped">
|
<table class="table table-bordered table-striped">
|
||||||
<tr><th>Cluster ID:</th><td>{ClusterId}</td></tr>
|
<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>
|
<tr><th>Version:</th><td>{Version}</td></tr>
|
||||||
</table>
|
</table>
|
||||||
{/dn}
|
{/dn}
|
||||||
|
|
|
@ -75,6 +75,9 @@ public class TestDataNodeMXBean extends SaslDataTransferTestCase {
|
||||||
// get attribute "Version"
|
// get attribute "Version"
|
||||||
String version = (String)mbs.getAttribute(mxbeanName, "Version");
|
String version = (String)mbs.getAttribute(mxbeanName, "Version");
|
||||||
Assert.assertEquals(datanode.getVersion(),version);
|
Assert.assertEquals(datanode.getVersion(),version);
|
||||||
|
// get attribute "DNStartedTimeInMillis"
|
||||||
|
long startTime = (long) mbs.getAttribute(mxbeanName, "DNStartedTimeInMillis");
|
||||||
|
Assert.assertEquals(datanode.getDNStartedTimeInMillis(), startTime);
|
||||||
// get attribute "SotfwareVersion"
|
// get attribute "SotfwareVersion"
|
||||||
String softwareVersion =
|
String softwareVersion =
|
||||||
(String)mbs.getAttribute(mxbeanName, "SoftwareVersion");
|
(String)mbs.getAttribute(mxbeanName, "SoftwareVersion");
|
||||||
|
|
Loading…
Reference in New Issue