private boolean isBlockUnderConstruction(BlockInfoContiguous storedBlock, BlockUCState ucState, ReplicaState reportedState) { switch(reportedState) { case FINALIZED: switch(ucState) { case UNDER_CONSTRUCTION: case UNDER_RECOVERY: return true; default: return false; } case RBW: case RWR: return (!storedBlock.isComplete()); case RUR: // should not be reported case TEMPORARY: // should not be reported default: return false; } }
private boolean isBlockUnderConstruction(BlockInfoContiguous storedBlock, BlockUCState ucState, ReplicaState reportedState) { switch(reportedState) { case FINALIZED: switch(ucState) { case UNDER_CONSTRUCTION: case UNDER_RECOVERY: return true; default: return false; } case RBW: case RWR: return (!storedBlock.isComplete()); case RUR: // should not be reported case TEMPORARY: // should not be reported default: return false; } }
/** Assert all blocks are complete. */ private void assertAllBlocksComplete() { if (blocks == null) { return; } for (int i = 0; i < blocks.length; i++) { Preconditions.checkState(blocks[i].isComplete(), "Failed to finalize" + " %s %s since blocks[%s] is non-complete, where blocks=%s.", getClass().getSimpleName(), this, i, Arrays.asList(blocks)); } }
/** Assert all blocks are complete. */ private void assertAllBlocksComplete() { if (blocks == null) { return; } for (int i = 0; i < blocks.length; i++) { Preconditions.checkState(blocks[i].isComplete(), "Failed to finalize" + " %s %s since blocks[%s] is non-complete, where blocks=%s.", getClass().getSimpleName(), this, i, Arrays.asList(blocks)); } }
private static boolean isCompleteBlock(String src, BlockInfoContiguous b, int minRepl) { if (!b.isComplete()) { final BlockInfoContiguousUnderConstruction uc = (BlockInfoContiguousUnderConstruction)b; final int numNodes = b.numNodes(); LOG.info("BLOCK* " + b + " is not COMPLETE (ucState = " + uc.getBlockUCState() + ", replication# = " + numNodes + (numNodes < minRepl? " < ": " >= ") + " minimum = " + minRepl + ") in file " + src); return false; } return true; }
/** * A block needs replication if the number of replicas is less than expected * or if it does not have enough racks. */ boolean isNeededReplication(Block b, int expected, int current) { BlockInfoContiguous blockInfo; if (b instanceof BlockInfoContiguous) { blockInfo = (BlockInfoContiguous) b; } else { blockInfo = getStoredBlock(b); } return blockInfo.isComplete() && (current < expected || !isPlacementPolicySatisfied(b)); }
/** * A block needs replication if the number of replicas is less than expected * or if it does not have enough racks. */ boolean isNeededReplication(Block b, int expected, int current) { BlockInfoContiguous blockInfo; if (b instanceof BlockInfoContiguous) { blockInfo = (BlockInfoContiguous) b; } else { blockInfo = getStoredBlock(b); } return blockInfo.isComplete() && (current < expected || !isPlacementPolicySatisfied(b)); }
@Override public void decrementSafeBlockCount(Block b) { // safeMode is volatile, and may be set to null at any time SafeModeInfo safeMode = this.safeMode; if (safeMode == null) // mostly true return; BlockInfoContiguous storedBlock = getStoredBlock(b); if (storedBlock.isComplete()) { safeMode.decrementSafeBlockCount((short)blockManager.countNodes(b).liveReplicas()); } }
private static boolean isCompleteBlock(String src, BlockInfoContiguous b, int minRepl) { if (!b.isComplete()) { final BlockInfoContiguousUnderConstruction uc = (BlockInfoContiguousUnderConstruction)b; final int numNodes = b.numNodes(); LOG.info("BLOCK* " + b + " is not COMPLETE (ucState = " + uc.getBlockUCState() + ", replication# = " + numNodes + (numNodes < minRepl? " < ": " >= ") + " minimum = " + minRepl + ") in file " + src); return false; } return true; }
@Override public void decrementSafeBlockCount(Block b) { // safeMode is volatile, and may be set to null at any time SafeModeInfo safeMode = this.safeMode; if (safeMode == null) // mostly true return; BlockInfoContiguous storedBlock = getStoredBlock(b); if (storedBlock.isComplete()) { safeMode.decrementSafeBlockCount((short)blockManager.countNodes(b).liveReplicas()); } }
} else if (!blockInfo.isComplete()) {
} else if (!blockInfo.isComplete()) {
continue; for(BlockInfoContiguous b : blocks) { if(!b.isComplete()) numUCBlocks++;
if (trackBlockCounts) { BlockInfoContiguous bi = getStoredBlock(b); if (bi.isComplete()) { numRemovedComplete++; if (bi.numNodes() >= blockManager.minReplication) {
if(lastBlock == null) return false; // no blocks in file yet if(lastBlock.isComplete()) return false; // already completed (e.g. by syncBlock)
if(lastBlock == null) return false; // no blocks in file yet if(lastBlock.isComplete()) return false; // already completed (e.g. by syncBlock)
/** * Convert a complete block to an under construction block. * @return BlockInfoUnderConstruction - an under construction block. */ public BlockInfoContiguousUnderConstruction convertToBlockUnderConstruction( BlockUCState s, DatanodeStorageInfo[] targets) { if(isComplete()) { BlockInfoContiguousUnderConstruction ucBlock = new BlockInfoContiguousUnderConstruction(this, getBlockCollection().getBlockReplication(), s, targets); ucBlock.setBlockCollection(getBlockCollection()); return ucBlock; } // the block is already under construction BlockInfoContiguousUnderConstruction ucBlock = (BlockInfoContiguousUnderConstruction)this; ucBlock.setBlockUCState(s); ucBlock.setExpectedLocations(targets); ucBlock.setBlockCollection(getBlockCollection()); return ucBlock; }
/** * Convert a complete block to an under construction block. * @return BlockInfoUnderConstruction - an under construction block. */ public BlockInfoContiguousUnderConstruction convertToBlockUnderConstruction( BlockUCState s, DatanodeStorageInfo[] targets) { if(isComplete()) { BlockInfoContiguousUnderConstruction ucBlock = new BlockInfoContiguousUnderConstruction(this, getBlockCollection().getBlockReplication(), s, targets); ucBlock.setBlockCollection(getBlockCollection()); return ucBlock; } // the block is already under construction BlockInfoContiguousUnderConstruction ucBlock = (BlockInfoContiguousUnderConstruction)this; ucBlock.setBlockUCState(s); ucBlock.setExpectedLocations(targets); ucBlock.setBlockCollection(getBlockCollection()); return ucBlock; }
if (trackBlockCounts) { BlockInfoContiguous bi = getStoredBlock(b); if (bi.isComplete()) { numRemovedComplete++; if (bi.numNodes() >= blockManager.minReplication) {
&& numCurrentReplica >= minReplication) { completeBlock(storedBlock.getBlockCollection(), storedBlock, null, false); } else if (storedBlock.isComplete() && result == AddBlockResult.ADDED) {