|
@@ -535,8 +535,8 @@ public class BlockManager {
|
|
|
int usableReplicas = numReplicas.liveReplicas() +
|
|
|
numReplicas.decommissionedReplicas();
|
|
|
|
|
|
- if (block instanceof BlockInfo) {
|
|
|
- BlockCollection bc = ((BlockInfo) block).getBlockCollection();
|
|
|
+ if (block instanceof BlockInfoContiguous) {
|
|
|
+ BlockCollection bc = ((BlockInfoContiguous) block).getBlockCollection();
|
|
|
String fileName = (bc == null) ? "[orphaned]" : bc.getName();
|
|
|
out.print(fileName + ": ");
|
|
|
}
|
|
@@ -590,8 +590,9 @@ public class BlockManager {
|
|
|
* @throws IOException if the block does not have at least a minimal number
|
|
|
* of replicas reported from data-nodes.
|
|
|
*/
|
|
|
- private static boolean commitBlock(final BlockInfoUnderConstruction block,
|
|
|
- final Block commitBlock) throws IOException {
|
|
|
+ private static boolean commitBlock(
|
|
|
+ final BlockInfoContiguousUnderConstruction block, final Block commitBlock)
|
|
|
+ throws IOException {
|
|
|
if (block.getBlockUCState() == BlockUCState.COMMITTED)
|
|
|
return false;
|
|
|
assert block.getNumBytes() <= commitBlock.getNumBytes() :
|
|
@@ -615,13 +616,14 @@ public class BlockManager {
|
|
|
Block commitBlock) throws IOException {
|
|
|
if(commitBlock == null)
|
|
|
return false; // not committing, this is a block allocation retry
|
|
|
- BlockInfo lastBlock = bc.getLastBlock();
|
|
|
+ BlockInfoContiguous lastBlock = bc.getLastBlock();
|
|
|
if(lastBlock == null)
|
|
|
return false; // no blocks in file yet
|
|
|
if(lastBlock.isComplete())
|
|
|
return false; // already completed (e.g. by syncBlock)
|
|
|
|
|
|
- final boolean b = commitBlock((BlockInfoUnderConstruction)lastBlock, commitBlock);
|
|
|
+ final boolean b = commitBlock(
|
|
|
+ (BlockInfoContiguousUnderConstruction) lastBlock, commitBlock);
|
|
|
if(countNodes(lastBlock).liveReplicas() >= minReplication)
|
|
|
completeBlock(bc, bc.numBlocks()-1, false);
|
|
|
return b;
|
|
@@ -634,14 +636,15 @@ public class BlockManager {
|
|
|
* @throws IOException if the block does not have at least a minimal number
|
|
|
* of replicas reported from data-nodes.
|
|
|
*/
|
|
|
- private BlockInfo completeBlock(final BlockCollection bc,
|
|
|
+ private BlockInfoContiguous completeBlock(final BlockCollection bc,
|
|
|
final int blkIndex, boolean force) throws IOException {
|
|
|
if(blkIndex < 0)
|
|
|
return null;
|
|
|
- BlockInfo curBlock = bc.getBlocks()[blkIndex];
|
|
|
+ BlockInfoContiguous curBlock = bc.getBlocks()[blkIndex];
|
|
|
if(curBlock.isComplete())
|
|
|
return curBlock;
|
|
|
- BlockInfoUnderConstruction ucBlock = (BlockInfoUnderConstruction)curBlock;
|
|
|
+ BlockInfoContiguousUnderConstruction ucBlock =
|
|
|
+ (BlockInfoContiguousUnderConstruction) curBlock;
|
|
|
int numNodes = ucBlock.numNodes();
|
|
|
if (!force && numNodes < minReplication)
|
|
|
throw new IOException("Cannot complete block: " +
|
|
@@ -649,7 +652,7 @@ public class BlockManager {
|
|
|
if(!force && ucBlock.getBlockUCState() != BlockUCState.COMMITTED)
|
|
|
throw new IOException(
|
|
|
"Cannot complete block: block has not been COMMITTED by the client");
|
|
|
- BlockInfo completeBlock = ucBlock.convertToCompleteBlock();
|
|
|
+ BlockInfoContiguous completeBlock = ucBlock.convertToCompleteBlock();
|
|
|
// replace penultimate block in file
|
|
|
bc.setBlock(blkIndex, completeBlock);
|
|
|
|
|
@@ -667,9 +670,9 @@ public class BlockManager {
|
|
|
return blocksMap.replaceBlock(completeBlock);
|
|
|
}
|
|
|
|
|
|
- private BlockInfo completeBlock(final BlockCollection bc,
|
|
|
- final BlockInfo block, boolean force) throws IOException {
|
|
|
- BlockInfo[] fileBlocks = bc.getBlocks();
|
|
|
+ private BlockInfoContiguous completeBlock(final BlockCollection bc,
|
|
|
+ final BlockInfoContiguous block, boolean force) throws IOException {
|
|
|
+ BlockInfoContiguous[] fileBlocks = bc.getBlocks();
|
|
|
for(int idx = 0; idx < fileBlocks.length; idx++)
|
|
|
if(fileBlocks[idx] == block) {
|
|
|
return completeBlock(bc, idx, force);
|
|
@@ -682,8 +685,8 @@ public class BlockManager {
|
|
|
* regardless of whether enough replicas are present. This is necessary
|
|
|
* when tailing edit logs as a Standby.
|
|
|
*/
|
|
|
- public BlockInfo forceCompleteBlock(final BlockCollection bc,
|
|
|
- final BlockInfoUnderConstruction block) throws IOException {
|
|
|
+ public BlockInfoContiguous forceCompleteBlock(final BlockCollection bc,
|
|
|
+ final BlockInfoContiguousUnderConstruction block) throws IOException {
|
|
|
block.commitBlock(block);
|
|
|
return completeBlock(bc, block, true);
|
|
|
}
|
|
@@ -705,7 +708,7 @@ public class BlockManager {
|
|
|
*/
|
|
|
public LocatedBlock convertLastBlockToUnderConstruction(
|
|
|
BlockCollection bc, long bytesToRemove) throws IOException {
|
|
|
- BlockInfo oldBlock = bc.getLastBlock();
|
|
|
+ BlockInfoContiguous oldBlock = bc.getLastBlock();
|
|
|
if(oldBlock == null ||
|
|
|
bc.getPreferredBlockSize() == oldBlock.getNumBytes() - bytesToRemove)
|
|
|
return null;
|
|
@@ -714,7 +717,8 @@ public class BlockManager {
|
|
|
|
|
|
DatanodeStorageInfo[] targets = getStorages(oldBlock);
|
|
|
|
|
|
- BlockInfoUnderConstruction ucBlock = bc.setLastBlock(oldBlock, targets);
|
|
|
+ BlockInfoContiguousUnderConstruction ucBlock =
|
|
|
+ bc.setLastBlock(oldBlock, targets);
|
|
|
blocksMap.replaceBlock(ucBlock);
|
|
|
|
|
|
// Remove block from replication queue.
|
|
@@ -756,7 +760,8 @@ public class BlockManager {
|
|
|
return locations;
|
|
|
}
|
|
|
|
|
|
- private List<LocatedBlock> createLocatedBlockList(final BlockInfo[] blocks,
|
|
|
+ private List<LocatedBlock> createLocatedBlockList(
|
|
|
+ final BlockInfoContiguous[] blocks,
|
|
|
final long offset, final long length, final int nrBlocksToReturn,
|
|
|
final AccessMode mode) throws IOException {
|
|
|
int curBlk = 0;
|
|
@@ -786,7 +791,7 @@ public class BlockManager {
|
|
|
return results;
|
|
|
}
|
|
|
|
|
|
- private LocatedBlock createLocatedBlock(final BlockInfo[] blocks,
|
|
|
+ private LocatedBlock createLocatedBlock(final BlockInfoContiguous[] blocks,
|
|
|
final long endPos, final AccessMode mode) throws IOException {
|
|
|
int curBlk = 0;
|
|
|
long curPos = 0;
|
|
@@ -802,7 +807,7 @@ public class BlockManager {
|
|
|
return createLocatedBlock(blocks[curBlk], curPos, mode);
|
|
|
}
|
|
|
|
|
|
- private LocatedBlock createLocatedBlock(final BlockInfo blk, final long pos,
|
|
|
+ private LocatedBlock createLocatedBlock(final BlockInfoContiguous blk, final long pos,
|
|
|
final BlockTokenSecretManager.AccessMode mode) throws IOException {
|
|
|
final LocatedBlock lb = createLocatedBlock(blk, pos);
|
|
|
if (mode != null) {
|
|
@@ -812,15 +817,16 @@ public class BlockManager {
|
|
|
}
|
|
|
|
|
|
/** @return a LocatedBlock for the given block */
|
|
|
- private LocatedBlock createLocatedBlock(final BlockInfo blk, final long pos
|
|
|
+ private LocatedBlock createLocatedBlock(final BlockInfoContiguous blk, final long pos
|
|
|
) throws IOException {
|
|
|
- if (blk instanceof BlockInfoUnderConstruction) {
|
|
|
+ if (blk instanceof BlockInfoContiguousUnderConstruction) {
|
|
|
if (blk.isComplete()) {
|
|
|
throw new IOException(
|
|
|
"blk instanceof BlockInfoUnderConstruction && blk.isComplete()"
|
|
|
+ ", blk=" + blk);
|
|
|
}
|
|
|
- final BlockInfoUnderConstruction uc = (BlockInfoUnderConstruction)blk;
|
|
|
+ final BlockInfoContiguousUnderConstruction uc =
|
|
|
+ (BlockInfoContiguousUnderConstruction) blk;
|
|
|
final DatanodeStorageInfo[] storages = uc.getExpectedStorageLocations();
|
|
|
final ExtendedBlock eb = new ExtendedBlock(namesystem.getBlockPoolId(), blk);
|
|
|
return new LocatedBlock(eb, storages, pos, false);
|
|
@@ -859,7 +865,7 @@ public class BlockManager {
|
|
|
}
|
|
|
|
|
|
/** Create a LocatedBlocks. */
|
|
|
- public LocatedBlocks createLocatedBlocks(final BlockInfo[] blocks,
|
|
|
+ public LocatedBlocks createLocatedBlocks(final BlockInfoContiguous[] blocks,
|
|
|
final long fileSizeExcludeBlocksUnderConstruction,
|
|
|
final boolean isFileUnderConstruction, final long offset,
|
|
|
final long length, final boolean needBlockToken,
|
|
@@ -882,7 +888,7 @@ public class BlockManager {
|
|
|
final LocatedBlock lastlb;
|
|
|
final boolean isComplete;
|
|
|
if (!inSnapshot) {
|
|
|
- final BlockInfo last = blocks[blocks.length - 1];
|
|
|
+ final BlockInfoContiguous last = blocks[blocks.length - 1];
|
|
|
final long lastPos = last.isComplete()?
|
|
|
fileSizeExcludeBlocksUnderConstruction - last.getNumBytes()
|
|
|
: fileSizeExcludeBlocksUnderConstruction;
|
|
@@ -971,7 +977,7 @@ public class BlockManager {
|
|
|
/**
|
|
|
* Check if a block is replicated to at least the minimum replication.
|
|
|
*/
|
|
|
- public boolean isSufficientlyReplicated(BlockInfo b) {
|
|
|
+ public boolean isSufficientlyReplicated(BlockInfoContiguous b) {
|
|
|
// Compare against the lesser of the minReplication and number of live DNs.
|
|
|
final int replication =
|
|
|
Math.min(minReplication, getDatanodeManager().getNumLiveDataNodes());
|
|
@@ -1012,7 +1018,7 @@ public class BlockManager {
|
|
|
if(numBlocks == 0) {
|
|
|
return new BlocksWithLocations(new BlockWithLocations[0]);
|
|
|
}
|
|
|
- Iterator<BlockInfo> iter = node.getBlockIterator();
|
|
|
+ Iterator<BlockInfoContiguous> iter = node.getBlockIterator();
|
|
|
int startBlock = DFSUtil.getRandom().nextInt(numBlocks); // starting from a random block
|
|
|
// skip blocks
|
|
|
for(int i=0; i<startBlock; i++) {
|
|
@@ -1020,7 +1026,7 @@ public class BlockManager {
|
|
|
}
|
|
|
List<BlockWithLocations> results = new ArrayList<BlockWithLocations>();
|
|
|
long totalSize = 0;
|
|
|
- BlockInfo curBlock;
|
|
|
+ BlockInfoContiguous curBlock;
|
|
|
while(totalSize<size && iter.hasNext()) {
|
|
|
curBlock = iter.next();
|
|
|
if(!curBlock.isComplete()) continue;
|
|
@@ -1119,7 +1125,7 @@ public class BlockManager {
|
|
|
public void findAndMarkBlockAsCorrupt(final ExtendedBlock blk,
|
|
|
final DatanodeInfo dn, String storageID, String reason) throws IOException {
|
|
|
assert namesystem.hasWriteLock();
|
|
|
- final BlockInfo storedBlock = getStoredBlock(blk.getLocalBlock());
|
|
|
+ final BlockInfoContiguous storedBlock = getStoredBlock(blk.getLocalBlock());
|
|
|
if (storedBlock == null) {
|
|
|
// Check if the replica is in the blockMap, if not
|
|
|
// ignore the request for now. This could happen when BlockScanner
|
|
@@ -1699,11 +1705,11 @@ public class BlockManager {
|
|
|
* reported by the datanode in the block report.
|
|
|
*/
|
|
|
static class StatefulBlockInfo {
|
|
|
- final BlockInfoUnderConstruction storedBlock;
|
|
|
+ final BlockInfoContiguousUnderConstruction storedBlock;
|
|
|
final Block reportedBlock;
|
|
|
final ReplicaState reportedState;
|
|
|
|
|
|
- StatefulBlockInfo(BlockInfoUnderConstruction storedBlock,
|
|
|
+ StatefulBlockInfo(BlockInfoContiguousUnderConstruction storedBlock,
|
|
|
Block reportedBlock, ReplicaState reportedState) {
|
|
|
this.storedBlock = storedBlock;
|
|
|
this.reportedBlock = reportedBlock;
|
|
@@ -1717,15 +1723,16 @@ public class BlockManager {
|
|
|
*/
|
|
|
private static class BlockToMarkCorrupt {
|
|
|
/** The corrupted block in a datanode. */
|
|
|
- final BlockInfo corrupted;
|
|
|
+ final BlockInfoContiguous corrupted;
|
|
|
/** The corresponding block stored in the BlockManager. */
|
|
|
- final BlockInfo stored;
|
|
|
+ final BlockInfoContiguous stored;
|
|
|
/** The reason to mark corrupt. */
|
|
|
final String reason;
|
|
|
/** The reason code to be stored */
|
|
|
final Reason reasonCode;
|
|
|
|
|
|
- BlockToMarkCorrupt(BlockInfo corrupted, BlockInfo stored, String reason,
|
|
|
+ BlockToMarkCorrupt(BlockInfoContiguous corrupted,
|
|
|
+ BlockInfoContiguous stored, String reason,
|
|
|
Reason reasonCode) {
|
|
|
Preconditions.checkNotNull(corrupted, "corrupted is null");
|
|
|
Preconditions.checkNotNull(stored, "stored is null");
|
|
@@ -1736,13 +1743,14 @@ public class BlockManager {
|
|
|
this.reasonCode = reasonCode;
|
|
|
}
|
|
|
|
|
|
- BlockToMarkCorrupt(BlockInfo stored, String reason, Reason reasonCode) {
|
|
|
+ BlockToMarkCorrupt(BlockInfoContiguous stored, String reason,
|
|
|
+ Reason reasonCode) {
|
|
|
this(stored, stored, reason, reasonCode);
|
|
|
}
|
|
|
|
|
|
- BlockToMarkCorrupt(BlockInfo stored, long gs, String reason,
|
|
|
+ BlockToMarkCorrupt(BlockInfoContiguous stored, long gs, String reason,
|
|
|
Reason reasonCode) {
|
|
|
- this(new BlockInfo(stored), stored, reason, reasonCode);
|
|
|
+ this(new BlockInfoContiguous(stored), stored, reason, reasonCode);
|
|
|
//the corrupted block in datanode has a different generation stamp
|
|
|
corrupted.setGenerationStamp(gs);
|
|
|
}
|
|
@@ -1867,7 +1875,7 @@ public class BlockManager {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- BlockInfo bi = blocksMap.getStoredBlock(b);
|
|
|
+ BlockInfoContiguous bi = blocksMap.getStoredBlock(b);
|
|
|
if (bi == null) {
|
|
|
if (LOG.isDebugEnabled()) {
|
|
|
LOG.debug("BLOCK* rescanPostponedMisreplicatedBlocks: " +
|
|
@@ -1907,7 +1915,7 @@ public class BlockManager {
|
|
|
// Modify the (block-->datanode) map, according to the difference
|
|
|
// between the old and new block report.
|
|
|
//
|
|
|
- Collection<BlockInfo> toAdd = new LinkedList<BlockInfo>();
|
|
|
+ Collection<BlockInfoContiguous> toAdd = new LinkedList<BlockInfoContiguous>();
|
|
|
Collection<Block> toRemove = new TreeSet<Block>();
|
|
|
Collection<Block> toInvalidate = new LinkedList<Block>();
|
|
|
Collection<BlockToMarkCorrupt> toCorrupt = new LinkedList<BlockToMarkCorrupt>();
|
|
@@ -1924,7 +1932,7 @@ public class BlockManager {
|
|
|
removeStoredBlock(b, node);
|
|
|
}
|
|
|
int numBlocksLogged = 0;
|
|
|
- for (BlockInfo b : toAdd) {
|
|
|
+ for (BlockInfoContiguous b : toAdd) {
|
|
|
addStoredBlock(b, storageInfo, null, numBlocksLogged < maxNumBlocksToLog);
|
|
|
numBlocksLogged++;
|
|
|
}
|
|
@@ -1972,7 +1980,7 @@ public class BlockManager {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- BlockInfo storedBlock = blocksMap.getStoredBlock(iblk);
|
|
|
+ BlockInfoContiguous storedBlock = blocksMap.getStoredBlock(iblk);
|
|
|
// If block does not belong to any file, we are done.
|
|
|
if (storedBlock == null) continue;
|
|
|
|
|
@@ -1995,12 +2003,13 @@ public class BlockManager {
|
|
|
|
|
|
// If block is under construction, add this replica to its list
|
|
|
if (isBlockUnderConstruction(storedBlock, ucState, reportedState)) {
|
|
|
- ((BlockInfoUnderConstruction)storedBlock).addReplicaIfNotPresent(
|
|
|
- storageInfo, iblk, reportedState);
|
|
|
+ ((BlockInfoContiguousUnderConstruction)storedBlock)
|
|
|
+ .addReplicaIfNotPresent(storageInfo, iblk, reportedState);
|
|
|
// OpenFileBlocks only inside snapshots also will be added to safemode
|
|
|
// threshold. So we need to update such blocks to safemode
|
|
|
// refer HDFS-5283
|
|
|
- BlockInfoUnderConstruction blockUC = (BlockInfoUnderConstruction) storedBlock;
|
|
|
+ BlockInfoContiguousUnderConstruction blockUC =
|
|
|
+ (BlockInfoContiguousUnderConstruction) storedBlock;
|
|
|
if (namesystem.isInSnapshot(blockUC)) {
|
|
|
int numOfReplicas = blockUC.getNumExpectedLocations();
|
|
|
namesystem.incrementSafeBlockCount(numOfReplicas);
|
|
@@ -2016,7 +2025,7 @@ public class BlockManager {
|
|
|
|
|
|
private void reportDiff(DatanodeStorageInfo storageInfo,
|
|
|
BlockListAsLongs newReport,
|
|
|
- Collection<BlockInfo> toAdd, // add to DatanodeDescriptor
|
|
|
+ Collection<BlockInfoContiguous> toAdd, // add to DatanodeDescriptor
|
|
|
Collection<Block> toRemove, // remove from DatanodeDescriptor
|
|
|
Collection<Block> toInvalidate, // should be removed from DN
|
|
|
Collection<BlockToMarkCorrupt> toCorrupt, // add to corrupt replicas list
|
|
@@ -2024,7 +2033,7 @@ public class BlockManager {
|
|
|
|
|
|
// place a delimiter in the list which separates blocks
|
|
|
// that have been reported from those that have not
|
|
|
- BlockInfo delimiter = new BlockInfo(new Block(), (short) 1);
|
|
|
+ BlockInfoContiguous delimiter = new BlockInfoContiguous(new Block(), (short) 1);
|
|
|
AddBlockResult result = storageInfo.addBlock(delimiter);
|
|
|
assert result == AddBlockResult.ADDED
|
|
|
: "Delimiting block cannot be present in the node";
|
|
@@ -2039,7 +2048,7 @@ public class BlockManager {
|
|
|
while(itBR.hasNext()) {
|
|
|
Block iblk = itBR.next();
|
|
|
ReplicaState iState = itBR.getCurrentReplicaState();
|
|
|
- BlockInfo storedBlock = processReportedBlock(storageInfo,
|
|
|
+ BlockInfoContiguous storedBlock = processReportedBlock(storageInfo,
|
|
|
iblk, iState, toAdd, toInvalidate, toCorrupt, toUC);
|
|
|
|
|
|
// move block to the head of the list
|
|
@@ -2051,7 +2060,8 @@ public class BlockManager {
|
|
|
|
|
|
// collect blocks that have not been reported
|
|
|
// all of them are next to the delimiter
|
|
|
- Iterator<BlockInfo> it = storageInfo.new BlockIterator(delimiter.getNext(0));
|
|
|
+ Iterator<BlockInfoContiguous> it =
|
|
|
+ storageInfo.new BlockIterator(delimiter.getNext(0));
|
|
|
while(it.hasNext())
|
|
|
toRemove.add(it.next());
|
|
|
storageInfo.removeBlock(delimiter);
|
|
@@ -2088,10 +2098,10 @@ public class BlockManager {
|
|
|
* @return the up-to-date stored block, if it should be kept.
|
|
|
* Otherwise, null.
|
|
|
*/
|
|
|
- private BlockInfo processReportedBlock(
|
|
|
+ private BlockInfoContiguous processReportedBlock(
|
|
|
final DatanodeStorageInfo storageInfo,
|
|
|
final Block block, final ReplicaState reportedState,
|
|
|
- final Collection<BlockInfo> toAdd,
|
|
|
+ final Collection<BlockInfoContiguous> toAdd,
|
|
|
final Collection<Block> toInvalidate,
|
|
|
final Collection<BlockToMarkCorrupt> toCorrupt,
|
|
|
final Collection<StatefulBlockInfo> toUC) {
|
|
@@ -2112,7 +2122,7 @@ public class BlockManager {
|
|
|
}
|
|
|
|
|
|
// find block by blockId
|
|
|
- BlockInfo storedBlock = blocksMap.getStoredBlock(block);
|
|
|
+ BlockInfoContiguous storedBlock = blocksMap.getStoredBlock(block);
|
|
|
if(storedBlock == null) {
|
|
|
// If blocksMap does not contain reported block id,
|
|
|
// the replica should be removed from the data-node.
|
|
@@ -2155,7 +2165,8 @@ public class BlockManager {
|
|
|
}
|
|
|
|
|
|
if (isBlockUnderConstruction(storedBlock, ucState, reportedState)) {
|
|
|
- toUC.add(new StatefulBlockInfo((BlockInfoUnderConstruction) storedBlock,
|
|
|
+ toUC.add(new StatefulBlockInfo(
|
|
|
+ (BlockInfoContiguousUnderConstruction) storedBlock,
|
|
|
new Block(block), reportedState));
|
|
|
return storedBlock;
|
|
|
}
|
|
@@ -2243,7 +2254,7 @@ public class BlockManager {
|
|
|
*/
|
|
|
private BlockToMarkCorrupt checkReplicaCorrupt(
|
|
|
Block reported, ReplicaState reportedState,
|
|
|
- BlockInfo storedBlock, BlockUCState ucState,
|
|
|
+ BlockInfoContiguous storedBlock, BlockUCState ucState,
|
|
|
DatanodeDescriptor dn) {
|
|
|
switch(reportedState) {
|
|
|
case FINALIZED:
|
|
@@ -2316,7 +2327,7 @@ public class BlockManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private boolean isBlockUnderConstruction(BlockInfo storedBlock,
|
|
|
+ private boolean isBlockUnderConstruction(BlockInfoContiguous storedBlock,
|
|
|
BlockUCState ucState, ReplicaState reportedState) {
|
|
|
switch(reportedState) {
|
|
|
case FINALIZED:
|
|
@@ -2339,7 +2350,7 @@ public class BlockManager {
|
|
|
|
|
|
void addStoredBlockUnderConstruction(StatefulBlockInfo ucBlock,
|
|
|
DatanodeStorageInfo storageInfo) throws IOException {
|
|
|
- BlockInfoUnderConstruction block = ucBlock.storedBlock;
|
|
|
+ BlockInfoContiguousUnderConstruction block = ucBlock.storedBlock;
|
|
|
block.addReplicaIfNotPresent(
|
|
|
storageInfo, ucBlock.reportedBlock, ucBlock.reportedState);
|
|
|
|
|
@@ -2350,9 +2361,8 @@ public class BlockManager {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Faster version of
|
|
|
- * {@link #addStoredBlock(BlockInfo, DatanodeStorageInfo, DatanodeDescriptor, boolean)}
|
|
|
- * , intended for use with initial block report at startup. If not in startup
|
|
|
+ * Faster version of {@link #addStoredBlock},
|
|
|
+ * intended for use with initial block report at startup. If not in startup
|
|
|
* safe mode, will call standard addStoredBlock(). Assumes this method is
|
|
|
* called "immediately" so there is no need to refresh the storedBlock from
|
|
|
* blocksMap. Doesn't handle underReplication/overReplication, or worry about
|
|
@@ -2361,7 +2371,7 @@ public class BlockManager {
|
|
|
*
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- private void addStoredBlockImmediate(BlockInfo storedBlock,
|
|
|
+ private void addStoredBlockImmediate(BlockInfoContiguous storedBlock,
|
|
|
DatanodeStorageInfo storageInfo)
|
|
|
throws IOException {
|
|
|
assert (storedBlock != null && namesystem.hasWriteLock());
|
|
@@ -2393,15 +2403,15 @@ public class BlockManager {
|
|
|
* needed replications if this takes care of the problem.
|
|
|
* @return the block that is stored in blockMap.
|
|
|
*/
|
|
|
- private Block addStoredBlock(final BlockInfo block,
|
|
|
+ private Block addStoredBlock(final BlockInfoContiguous block,
|
|
|
DatanodeStorageInfo storageInfo,
|
|
|
DatanodeDescriptor delNodeHint,
|
|
|
boolean logEveryBlock)
|
|
|
throws IOException {
|
|
|
assert block != null && namesystem.hasWriteLock();
|
|
|
- BlockInfo storedBlock;
|
|
|
+ BlockInfoContiguous storedBlock;
|
|
|
DatanodeDescriptor node = storageInfo.getDatanodeDescriptor();
|
|
|
- if (block instanceof BlockInfoUnderConstruction) {
|
|
|
+ if (block instanceof BlockInfoContiguousUnderConstruction) {
|
|
|
//refresh our copy in case the block got completed in another thread
|
|
|
storedBlock = blocksMap.getStoredBlock(block);
|
|
|
} else {
|
|
@@ -2500,7 +2510,8 @@ public class BlockManager {
|
|
|
return storedBlock;
|
|
|
}
|
|
|
|
|
|
- private void logAddStoredBlock(BlockInfo storedBlock, DatanodeDescriptor node) {
|
|
|
+ private void logAddStoredBlock(BlockInfoContiguous storedBlock,
|
|
|
+ DatanodeDescriptor node) {
|
|
|
if (!blockLog.isInfoEnabled()) {
|
|
|
return;
|
|
|
}
|
|
@@ -2527,7 +2538,7 @@ public class BlockManager {
|
|
|
*
|
|
|
* @param blk Block whose corrupt replicas need to be invalidated
|
|
|
*/
|
|
|
- private void invalidateCorruptReplicas(BlockInfo blk) {
|
|
|
+ private void invalidateCorruptReplicas(BlockInfoContiguous blk) {
|
|
|
Collection<DatanodeDescriptor> nodes = corruptReplicas.getNodes(blk);
|
|
|
boolean removedFromBlocksMap = true;
|
|
|
if (nodes == null)
|
|
@@ -2606,7 +2617,7 @@ public class BlockManager {
|
|
|
long nrInvalid = 0, nrOverReplicated = 0;
|
|
|
long nrUnderReplicated = 0, nrPostponed = 0, nrUnderConstruction = 0;
|
|
|
long startTimeMisReplicatedScan = Time.now();
|
|
|
- Iterator<BlockInfo> blocksItr = blocksMap.getBlocks().iterator();
|
|
|
+ Iterator<BlockInfoContiguous> blocksItr = blocksMap.getBlocks().iterator();
|
|
|
long totalBlocks = blocksMap.size();
|
|
|
replicationQueuesInitProgress = 0;
|
|
|
long totalProcessed = 0;
|
|
@@ -2618,7 +2629,7 @@ public class BlockManager {
|
|
|
namesystem.writeLockInterruptibly();
|
|
|
try {
|
|
|
while (processed < numBlocksPerIteration && blocksItr.hasNext()) {
|
|
|
- BlockInfo block = blocksItr.next();
|
|
|
+ BlockInfoContiguous block = blocksItr.next();
|
|
|
MisReplicationResult res = processMisReplicatedBlock(block);
|
|
|
if (LOG.isTraceEnabled()) {
|
|
|
LOG.trace("block " + block + ": " + res);
|
|
@@ -2692,7 +2703,7 @@ public class BlockManager {
|
|
|
* appropriate queues if necessary, and returns a result code indicating
|
|
|
* what happened with it.
|
|
|
*/
|
|
|
- private MisReplicationResult processMisReplicatedBlock(BlockInfo block) {
|
|
|
+ private MisReplicationResult processMisReplicatedBlock(BlockInfoContiguous block) {
|
|
|
BlockCollection bc = block.getBlockCollection();
|
|
|
if (bc == null) {
|
|
|
// block does not belong to any file
|
|
@@ -3021,7 +3032,7 @@ public class BlockManager {
|
|
|
ReplicaState reportedState, DatanodeDescriptor delHintNode)
|
|
|
throws IOException {
|
|
|
// blockReceived reports a finalized block
|
|
|
- Collection<BlockInfo> toAdd = new LinkedList<BlockInfo>();
|
|
|
+ Collection<BlockInfoContiguous> toAdd = new LinkedList<BlockInfoContiguous>();
|
|
|
Collection<Block> toInvalidate = new LinkedList<Block>();
|
|
|
Collection<BlockToMarkCorrupt> toCorrupt = new LinkedList<BlockToMarkCorrupt>();
|
|
|
Collection<StatefulBlockInfo> toUC = new LinkedList<StatefulBlockInfo>();
|
|
@@ -3038,7 +3049,7 @@ public class BlockManager {
|
|
|
addStoredBlockUnderConstruction(b, storageInfo);
|
|
|
}
|
|
|
long numBlocksLogged = 0;
|
|
|
- for (BlockInfo b : toAdd) {
|
|
|
+ for (BlockInfoContiguous b : toAdd) {
|
|
|
addStoredBlock(b, storageInfo, delHintNode, numBlocksLogged < maxNumBlocksToLog);
|
|
|
numBlocksLogged++;
|
|
|
}
|
|
@@ -3162,7 +3173,7 @@ public class BlockManager {
|
|
|
* @param b - the block being tested
|
|
|
* @return count of live nodes for this block
|
|
|
*/
|
|
|
- int countLiveNodes(BlockInfo b) {
|
|
|
+ int countLiveNodes(BlockInfoContiguous b) {
|
|
|
if (!namesystem.isInStartupSafeMode()) {
|
|
|
return countNodes(b).liveReplicas();
|
|
|
}
|
|
@@ -3317,7 +3328,7 @@ public class BlockManager {
|
|
|
return blocksMap.size();
|
|
|
}
|
|
|
|
|
|
- public DatanodeStorageInfo[] getStorages(BlockInfo block) {
|
|
|
+ public DatanodeStorageInfo[] getStorages(BlockInfoContiguous block) {
|
|
|
final DatanodeStorageInfo[] storages = new DatanodeStorageInfo[block.numNodes()];
|
|
|
int i = 0;
|
|
|
for(DatanodeStorageInfo s : blocksMap.getStorages(block)) {
|
|
@@ -3347,7 +3358,7 @@ public class BlockManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public BlockInfo getStoredBlock(Block block) {
|
|
|
+ public BlockInfoContiguous getStoredBlock(Block block) {
|
|
|
return blocksMap.getStoredBlock(block);
|
|
|
}
|
|
|
|
|
@@ -3495,7 +3506,8 @@ public class BlockManager {
|
|
|
return this.neededReplications.getCorruptReplOneBlockSize();
|
|
|
}
|
|
|
|
|
|
- public BlockInfo addBlockCollection(BlockInfo block, BlockCollection bc) {
|
|
|
+ public BlockInfoContiguous addBlockCollection(BlockInfoContiguous block,
|
|
|
+ BlockCollection bc) {
|
|
|
return blocksMap.addBlockCollection(block, bc);
|
|
|
}
|
|
|
|
|
@@ -3704,7 +3716,7 @@ public class BlockManager {
|
|
|
|
|
|
/**
|
|
|
* A simple result enum for the result of
|
|
|
- * {@link BlockManager#processMisReplicatedBlock(BlockInfo)}.
|
|
|
+ * {@link BlockManager#processMisReplicatedBlock(BlockInfoContiguous)}.
|
|
|
*/
|
|
|
enum MisReplicationResult {
|
|
|
/** The block should be invalidated since it belongs to a deleted file. */
|