HDFS-7652. Process block reports for erasure coded blocks. Contributed by Zhe Zhang
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/7886ed17 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/7886ed17 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/7886ed17 Branch: refs/heads/HDFS-7285 Commit: 7886ed1705a6c082475578e33bb9a715ab888b22 Parents: 42e26e2 Author: Zhe Zhang <z...@apache.org> Authored: Mon Feb 9 10:27:14 2015 -0800 Committer: Zhe Zhang <z...@apache.org> Committed: Mon Mar 30 10:11:23 2015 -0700 ---------------------------------------------------------------------- .../server/blockmanagement/BlockIdManager.java | 8 ++++++++ .../hdfs/server/blockmanagement/BlockManager.java | 18 +++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/7886ed17/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockIdManager.java ---------------------------------------------------------------------- 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 c8b9d20..e7f8a05 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 @@ -211,4 +211,12 @@ public class BlockIdManager { .LAST_RESERVED_BLOCK_ID); generationStampV1Limit = GenerationStamp.GRANDFATHER_GENERATION_STAMP; } + + public static boolean isStripedBlockID(long id) { + return id < 0; + } + + public static long convertToGroupID(long id) { + return id & (~(HdfsConstants.MAX_BLOCKS_IN_GROUP - 1)); + } } http://git-wip-us.apache.org/repos/asf/hadoop/blob/7886ed17/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java index f6e15a3..3102a08 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/blockmanagement/BlockManager.java @@ -1925,7 +1925,7 @@ public class BlockManager { break; } - BlockInfoContiguous bi = blocksMap.getStoredBlock(b); + BlockInfoContiguous bi = getStoredBlock(b); if (bi == null) { if (LOG.isDebugEnabled()) { LOG.debug("BLOCK* rescanPostponedMisreplicatedBlocks: " + @@ -2068,7 +2068,7 @@ public class BlockManager { continue; } - BlockInfoContiguous storedBlock = blocksMap.getStoredBlock(iblk); + BlockInfoContiguous storedBlock = getStoredBlock(iblk); // If block does not belong to any file, we are done. if (storedBlock == null) continue; @@ -2208,7 +2208,7 @@ public class BlockManager { } // find block by blockId - BlockInfoContiguous storedBlock = blocksMap.getStoredBlock(block); + BlockInfoContiguous storedBlock = getStoredBlock(block); if(storedBlock == null) { // If blocksMap does not contain reported block id, // the replica should be removed from the data-node. @@ -2499,7 +2499,7 @@ public class BlockManager { DatanodeDescriptor node = storageInfo.getDatanodeDescriptor(); if (block instanceof BlockInfoContiguousUnderConstruction) { //refresh our copy in case the block got completed in another thread - storedBlock = blocksMap.getStoredBlock(block); + storedBlock = getStoredBlock(block); } else { storedBlock = block; } @@ -3362,7 +3362,15 @@ public class BlockManager { } public BlockInfoContiguous getStoredBlock(Block block) { - return blocksMap.getStoredBlock(block); + BlockInfoContiguous info = null; + if (BlockIdManager.isStripedBlockID(block.getBlockId())) { + info = blocksMap.getStoredBlock( + new Block(BlockIdManager.convertToGroupID(block.getBlockId()))); + } + if (info == null) { + info = blocksMap.getStoredBlock(block); + } + return info; } /** updates a block in under replication queue */