diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockIdManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockIdManager.java index 3f21d9b206..7bdea642f3 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockIdManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockIdManager.java @@ -225,6 +225,7 @@ void clear() { generationStamp.setCurrentValue(GenerationStamp.LAST_RESERVED_STAMP); getBlockIdGenerator().setCurrentValue(SequentialBlockIdGenerator .LAST_RESERVED_BLOCK_ID); + getBlockGroupIdGenerator().setCurrentValue(Long.MIN_VALUE); legacyGenerationStampLimit = HdfsConstants.GRANDFATHER_GENERATION_STAMP; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestSequentialBlockGroupId.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestSequentialBlockGroupId.java index 8d1bbad36d..41a7878815 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestSequentialBlockGroupId.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/blockmanagement/TestSequentialBlockGroupId.java @@ -124,6 +124,11 @@ public void testBlockGroupIdGeneration() throws IOException { 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)); } /**