File tree Expand file tree Collapse file tree 4 files changed +19
-0
lines changed
hadoop-hdfs-project/hadoop-hdfs/src
java/org/apache/hadoop/hdfs/server/datanode
test/java/org/apache/hadoop/hdfs/server/datanode Expand file tree Collapse file tree 4 files changed +19
-0
lines changed Original file line number Diff line number Diff line change 5050import static org .apache .hadoop .hdfs .protocol .datatransfer .BlockConstructionStage .PIPELINE_SETUP_CREATE ;
5151import static org .apache .hadoop .hdfs .protocol .datatransfer .BlockConstructionStage .PIPELINE_SETUP_STREAMING_RECOVERY ;
5252import static org .apache .hadoop .util .ExitUtil .terminate ;
53+ import static org .apache .hadoop .util .Time .now ;
5354
5455import org .apache .hadoop .fs .CommonConfigurationKeysPublic ;
5556import org .apache .hadoop .hdfs .protocol .proto .ReconfigurationProtocolProtos .ReconfigurationProtocolService ;
@@ -415,6 +416,8 @@ private static Tracer createTracer(Configuration conf) {
415416
416417 private ScheduledThreadPoolExecutor metricsLoggerTimer ;
417418
419+ private final long startTime = now ();
420+
418421 /**
419422 * Creates a dummy DataNode for testing purpose.
420423 */
@@ -3109,6 +3112,11 @@ public String getHttpPort(){
31093112 return this .getConf ().get ("dfs.datanode.info.port" );
31103113 }
31113114
3115+ @ Override // DataNodeMXBean
3116+ public long getDNStartedTimeInMillis () {
3117+ return this .startTime ;
3118+ }
3119+
31123120 public String getRevision () {
31133121 return VersionInfo .getRevision ();
31143122 }
Original file line number Diff line number Diff line change @@ -157,4 +157,11 @@ public interface DataNodeMXBean {
157157 * @return true, if security is enabled.
158158 */
159159 boolean isSecurityEnabled ();
160+
161+ /**
162+ * Get the start time of the DataNode.
163+ *
164+ * @return Start time of the DataNode.
165+ */
166+ long getDNStartedTimeInMillis ();
160167}
Original file line number Diff line number Diff line change 7171< div class = "page-header" > < h1 > DataNode on < small > { HostName } :{ DataPort } </ small > </ h1 > </ div >
7272< table class = "table table-bordered table-striped" >
7373 < tr > < th > Cluster ID:</ th > < td > { ClusterId } </ td > </ tr >
74+ < tr > < th > Started:</ th > < td > { DNStartedTimeInMillis | date_tostring} < / t d > < / tr>
7475 < tr > < th > Version:</ th > < td > { Version } </ td > </ tr >
7576< / t a b l e >
7677{ / dn}
Original file line number Diff line number Diff line change @@ -75,6 +75,9 @@ public void testDataNodeMXBean() throws Exception {
7575 // get attribute "Version"
7676 String version = (String )mbs .getAttribute (mxbeanName , "Version" );
7777 Assert .assertEquals (datanode .getVersion (),version );
78+ // get attribute "DNStartedTimeInMillis"
79+ long startTime = (long ) mbs .getAttribute (mxbeanName , "DNStartedTimeInMillis" );
80+ Assert .assertEquals (datanode .getDNStartedTimeInMillis (), startTime );
7881 // get attribute "SotfwareVersion"
7982 String softwareVersion =
8083 (String )mbs .getAttribute (mxbeanName , "SoftwareVersion" );
You can’t perform that action at this time.
0 commit comments