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

(cherry picked from commit cdc13e91b6)
This commit is contained in:
Viraj Jasani 2021-11-25 07:53:04 +05:30 committed by Chao Sun
parent 328d3b84df
commit c6914b1cb6
2 changed files with 3 additions and 1 deletions

View File

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

View File

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