Skip to content

Commit a2ed6a6

Browse files
committed
Optimized pendingReconstruction not timeout in this case
1 parent b21d58f commit a2ed6a6

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3855,6 +3855,9 @@ private Block addStoredBlock(final BlockInfo block,
38553855
} else {
38563856
updateNeededReconstructions(storedBlock, curReplicaDelta, 0);
38573857
}
3858+
if (storedBlock.isStriped() && !isNeededReconstruction(storedBlock, num, 0)) {
3859+
pendingReconstruction.remove(storedBlock);
3860+
}
38583861
if (shouldProcessExtraRedundancy(num, fileRedundancy)) {
38593862
processExtraRedundancyBlock(storedBlock, fileRedundancy, node,
38603863
delNodeHint);

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDistributedFileSystem.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
import org.apache.hadoop.hdfs.server.blockmanagement.BlockManagerTestUtil;
118118
import org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicy;
119119
import org.apache.hadoop.hdfs.server.blockmanagement.BlockPlacementPolicyRackFaultTolerant;
120+
import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.BlockUCState;
120121
import org.apache.hadoop.hdfs.server.datanode.DataNode;
121122
import org.apache.hadoop.hdfs.server.datanode.DataNodeTestUtils;
122123
import org.apache.hadoop.hdfs.server.datanode.fsdataset.FsDatasetSpi;
@@ -2808,6 +2809,7 @@ public void testECAddExpectedReplicasToPending() throws Exception {
28082809
for (int i = 0; i < 1024 * 1024; i++) {
28092810
str.write(i);
28102811
}
2812+
str.flush();
28112813
// Wait for dn2 IBR.
28122814
Thread.sleep(2000);
28132815
}
@@ -2824,25 +2826,11 @@ public void testECAddExpectedReplicasToPending() throws Exception {
28242826
// Wait for dn0 dn1 IBR.
28252827
Thread.sleep(2000);
28262828
pendingNum = BlockManagerTestUtil.getNumReplicasInPendingReconstruction(blockManager,blockInfo);
2827-
assertEquals(1, pendingNum);
2828-
2829-
long timeoutNum = 0;
2830-
// Wait for pendingReconstruction timeout because the block group only has two replicas.
2831-
while(timeoutNum == 0) {
2832-
timeoutNum = blockManager.getNumTimedOutPendingReconstructions();
2833-
}
2834-
pendingNum = BlockManagerTestUtil.getNumReplicasInPendingReconstruction(blockManager,blockInfo);
28352829
assertEquals(0, pendingNum);
2836-
blockInfo = (BlockInfoStriped)blockManager.getStoredBlock(locatedBlocks.getLocatedBlocks().get(0).getBlock().getLocalBlock());
2837-
assertEquals(2, blockInfo.numNodes());
2838-
28392830

2840-
// Wait for pendingReconstruction timeout blocks to needReconstruction
2841-
Thread.sleep(3000 * 2);
2842-
pendingNum = BlockManagerTestUtil.getNumReplicasInPendingReconstruction(blockManager,blockInfo);
2843-
assertEquals(0, pendingNum);
28442831
blockInfo = (BlockInfoStriped)blockManager.getStoredBlock(locatedBlocks.getLocatedBlocks().get(0).getBlock().getLocalBlock());
28452832
assertEquals(2, blockInfo.numNodes());
2833+
assertEquals(BlockUCState.COMPLETE, blockInfo.getBlockUCState());
28462834
}
28472835
}
28482836

0 commit comments

Comments
 (0)