You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by we...@apache.org on 2019/06/17 22:19:48 UTC

[hadoop] branch branch-3.1 updated: HDFS-14465. When the Block expected replications is larger than the number of DataNodes, entering maintenance will never exit. Contributed by Yicong Cai.

This is an automated email from the ASF dual-hosted git repository.

weichiu pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new b3e0430  HDFS-14465. When the Block expected replications is larger than the number of DataNodes, entering maintenance will never exit. Contributed by Yicong Cai.
b3e0430 is described below

commit b3e0430c3bee30a52ec08786982522bfcf0bb911
Author: Wei-Chiu Chuang <we...@apache.org>
AuthorDate: Mon Jun 17 15:16:41 2019 -0700

    HDFS-14465. When the Block expected replications is larger than the number of DataNodes, entering maintenance will never exit. Contributed by Yicong Cai.
    
    (cherry picked from commit 7db922c6474cb29e0e9bad320fcda4769366340a)
    (cherry picked from commit 0eb42e1e05b780dab718bb3adfdd55f527dd5545)
---
 .../hdfs/server/blockmanagement/DatanodeAdminManager.java     | 11 +++++++++--
 .../java/org/apache/hadoop/hdfs/TestMaintenanceState.java     |  1 +
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeAdminManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeAdminManager.java
index a1dff08..09298f2 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeAdminManager.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/DatanodeAdminManager.java
@@ -345,7 +345,9 @@ public class DatanodeAdminManager {
    * @return true if sufficient, else false.
    */
   private boolean isSufficient(BlockInfo block, BlockCollection bc,
-      NumberReplicas numberReplicas, boolean isDecommission) {
+                               NumberReplicas numberReplicas,
+                               boolean isDecommission,
+                               boolean isMaintenance) {
     if (blockManager.hasEnoughEffectiveReplicas(block, numberReplicas, 0)) {
       // Block has enough replica, skip
       LOG.trace("Block {} does not need replication.", block);
@@ -379,6 +381,10 @@ public class DatanodeAdminManager {
         }
       }
     }
+    if (isMaintenance
+      && numLive >= blockManager.getMinReplicationToBeInMaintenance()) {
+      return true;
+    }
     return false;
   }
 
@@ -706,6 +712,7 @@ public class DatanodeAdminManager {
         // Schedule low redundancy blocks for reconstruction
         // if not already pending.
         boolean isDecommission = datanode.isDecommissionInProgress();
+        boolean isMaintenance = datanode.isEnteringMaintenance();
         boolean neededReconstruction = isDecommission ?
             blockManager.isNeededReconstruction(block, num) :
             blockManager.isNeededReconstructionForMaintenance(block, num);
@@ -724,7 +731,7 @@ public class DatanodeAdminManager {
         // Even if the block is without sufficient redundancy,
         // it might not block decommission/maintenance if it
         // has sufficient redundancy.
-        if (isSufficient(block, bc, num, isDecommission)) {
+        if (isSufficient(block, bc, num, isDecommission, isMaintenance)) {
           if (pruneReliableBlocks) {
             it.remove();
           }
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMaintenanceState.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMaintenanceState.java
index 7c536e9..279e093 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMaintenanceState.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMaintenanceState.java
@@ -373,6 +373,7 @@ public class TestMaintenanceState extends AdminStatesBaseTest {
     testExpectedReplication(2);
     testExpectedReplication(3);
     testExpectedReplication(4);
+    testExpectedReplication(10);
   }
 
   private void testExpectedReplication(int replicationFactor)


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org