Browse Source

HDFS-16350. Datanode start time should be set after RPC server starts successfully (#3711)

(cherry picked from commit cdc13e91b619159dc4bf185ad53b950bdf5de52a)
Viraj Jasani 3 năm trước cách đây
mục cha
commit
2ff303ea00

+ 2 - 1
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/DataNode.java

@@ -413,7 +413,7 @@ public class DataNode extends ReconfigurableBase
 
   private ScheduledThreadPoolExecutor metricsLoggerTimer;
 
-  private final long startTime = now();
+  private long startTime = 0;
 
   /**
    * Creates a dummy DataNode for testing purpose.
@@ -2675,6 +2675,7 @@ public class DataNode extends ReconfigurableBase
     }
     ipcServer.setTracer(tracer);
     ipcServer.start();
+    startTime = now();
     startPlugins(getConf());
   }
 

+ 1 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDataNodeMXBean.java

@@ -77,6 +77,7 @@ public class TestDataNodeMXBean extends SaslDataTransferTestCase {
       Assert.assertEquals(datanode.getVersion(),version);
       // get attribute "DNStartedTimeInMillis"
       long startTime = (long) mbs.getAttribute(mxbeanName, "DNStartedTimeInMillis");
+      Assert.assertTrue("Datanode start time should not be 0", startTime > 0);
       Assert.assertEquals(datanode.getDNStartedTimeInMillis(), startTime);
       // get attribute "SotfwareVersion"
       String softwareVersion =