HDFS-7652. Process block reports for erasure coded blocks. Contributed by Zhe Zhang

This commit is contained in:
Zhe Zhang 2015-02-09 10:27:14 -08:00 committed by Zhe Zhang
parent bc2833b1c9
commit 0c1da5a030
2 changed files with 21 additions and 5 deletions

View File

@ -212,4 +212,12 @@ public class BlockIdManager {
.LAST_RESERVED_BLOCK_ID);
generationStampV1Limit = HdfsConstants.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));
}
}

View File

@ -1943,7 +1943,7 @@ public class BlockManager {
break;
}
BlockInfoContiguous bi = blocksMap.getStoredBlock(b);
BlockInfoContiguous bi = getStoredBlock(b);
if (bi == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("BLOCK* rescanPostponedMisreplicatedBlocks: " +
@ -2091,7 +2091,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;
@ -2231,7 +2231,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.
@ -2529,7 +2529,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;
}
@ -3410,7 +3410,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 */