Sfoglia il codice sorgente

HDFS-10769. BlockIdManager.clear doesn't reset the counter for blockGroupIdGenerator (Contributed by Yiqun Lin and Rakesh R)

Vinayakumar B 8 anni fa
parent
commit
77f2684dd3

+ 1 - 0
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockIdManager.java

@@ -225,6 +225,7 @@ public class BlockIdManager {
     generationStamp.setCurrentValue(GenerationStamp.LAST_RESERVED_STAMP);
     getBlockIdGenerator().setCurrentValue(SequentialBlockIdGenerator
       .LAST_RESERVED_BLOCK_ID);
+    getBlockGroupIdGenerator().setCurrentValue(Long.MIN_VALUE);
     legacyGenerationStampLimit = HdfsConstants.GRANDFATHER_GENERATION_STAMP;
   }
 

+ 5 - 0
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestSequentialBlockGroupId.java

@@ -124,6 +124,11 @@ public class TestSequentialBlockGroupId {
       assertThat("BlockGrpId mismatches!", nextBlockGrpId,
           is(nextBlockExpectedId));
     }
+
+    // verify that the blockGroupId resets on #clear call.
+    cluster.getNamesystem().getBlockManager().clear();
+    assertThat("BlockGrpId mismatches!", blockGrpIdGenerator.getCurrentValue(),
+        is(Long.MIN_VALUE));
   }
 
   /**