Sfoglia il codice sorgente

HDFS-11296. Maintenance state expiry should be an epoch time and not jvm monotonic. (Manoj Govindassamy via mingma)

(cherry picked from commit f3fb94be05a61a4c4c06ab279897e5de2b181b0e)
Ming Ma 8 anni fa
parent
commit
bed700e98f

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/protocol/DatanodeInfo.java

@@ -509,7 +509,7 @@ public class DatanodeInfo extends DatanodeID implements Node {
   }
 
   public static boolean maintenanceNotExpired(long maintenanceExpireTimeInMS) {
-    return Time.monotonicNow() < maintenanceExpireTimeInMS;
+    return Time.now() < maintenanceExpireTimeInMS;
   }
   /**
    * Returns true if the node is is entering_maintenance

+ 6 - 6
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMaintenanceState.java

@@ -114,7 +114,7 @@ public class TestMaintenanceState extends AdminStatesBaseTest {
 
     // Adjust the expiration.
     takeNodeOutofService(0, nodeOutofService.getDatanodeUuid(),
-        Time.monotonicNow() + EXPIRATION_IN_MS, null, AdminStates.NORMAL);
+        Time.now() + EXPIRATION_IN_MS, null, AdminStates.NORMAL);
 
     cleanupFile(fileSys, file);
   }
@@ -133,8 +133,8 @@ public class TestMaintenanceState extends AdminStatesBaseTest {
     final FileSystem fileSys = getCluster().getFileSystem(0);
     writeFile(fileSys, file, replicas, 1);
 
-    // expiration has to be greater than Time.monotonicNow().
-    takeNodeOutofService(0, null, Time.monotonicNow(), null,
+    // expiration has to be greater than Time.now().
+    takeNodeOutofService(0, null, Time.now(), null,
         AdminStates.NORMAL);
 
     cleanupFile(fileSys, file);
@@ -203,7 +203,7 @@ public class TestMaintenanceState extends AdminStatesBaseTest {
 
     // Adjust the expiration.
     takeNodeOutofService(0, nodeOutofService.getDatanodeUuid(),
-        Time.monotonicNow() + EXPIRATION_IN_MS, null, AdminStates.NORMAL);
+        Time.now() + EXPIRATION_IN_MS, null, AdminStates.NORMAL);
 
     // no change
     assertEquals(deadInMaintenance, ns.getNumInMaintenanceDeadDataNodes());
@@ -257,7 +257,7 @@ public class TestMaintenanceState extends AdminStatesBaseTest {
 
     // Adjust the expiration.
     takeNodeOutofService(0, nodeOutofService.getDatanodeUuid(),
-        Time.monotonicNow() + EXPIRATION_IN_MS, null, AdminStates.NORMAL);
+        Time.now() + EXPIRATION_IN_MS, null, AdminStates.NORMAL);
 
     cleanupFile(fileSys, file);
   }
@@ -398,7 +398,7 @@ public class TestMaintenanceState extends AdminStatesBaseTest {
 
     // Adjust the expiration.
     takeNodeOutofService(0, nodeOutofService.getDatanodeUuid(),
-        Time.monotonicNow() + EXPIRATION_IN_MS, null, AdminStates.NORMAL);
+        Time.now() + EXPIRATION_IN_MS, null, AdminStates.NORMAL);
 
     cleanupFile(fileSys, file);
   }

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java

@@ -359,7 +359,7 @@ public class TestNameNodeMXBean {
       // Add the 1st DataNode to Maintenance list
       Map<String, Long> maintenanceNodes = new HashMap<>();
       maintenanceNodes.put(cluster.getDataNodes().get(0).getDisplayName(),
-          Time.monotonicNow() + expirationInMs);
+          Time.now() + expirationInMs);
       hostsFileWriter.initOutOfServiceHosts(null, maintenanceNodes);
       fsn.getBlockManager().getDatanodeManager().refreshNodes(conf);