/** * Convert an under construction block to complete. */ void convertToCompleteBlock() { assert getBlockUCState() != BlockUCState.COMPLETE : "Trying to convert a COMPLETE block"; uc = null; }
/** * Is this block complete? * * @return true if the state of the block is {@link BlockUCState#COMPLETE} */ public boolean isComplete() { return getBlockUCState().equals(BlockUCState.COMPLETE); }
public boolean isUnderRecovery() { return getBlockUCState().equals(BlockUCState.UNDER_RECOVERY); }
public final boolean isCompleteOrCommitted() { final BlockUCState state = getBlockUCState(); return state.equals(BlockUCState.COMPLETE) || state.equals(BlockUCState.COMMITTED); }
void addCommittedBlocksToPending(final INodeFile pendingFile) { final BlockInfo[] blocks = pendingFile.getBlocks(); int i = blocks.length - numCommittedAllowed; if (i < 0) { i = 0; } for(; i < blocks.length; i++) { final BlockInfo b = blocks[i]; if (b != null && b.getBlockUCState() == BlockUCState.COMMITTED) { // b is COMMITTED but not yet COMPLETE, add it to pending replication. blockManager.addExpectedReplicasToPending(b); } } }
/** * Check if the i-th block is COMPLETE; * when the i-th block is the last block, it may be allowed to be COMMITTED. * * @return null if the block passes the check; * otherwise, return an error message. */ static String checkBlockComplete(BlockInfo[] blocks, int i, int numCommittedAllowed, short minReplication) { final BlockInfo b = blocks[i]; final BlockUCState state = b.getBlockUCState(); if (state == BlockUCState.COMPLETE) { return null; } if (b.isStriped() || i < blocks.length - numCommittedAllowed) { return b + " is " + state + " but not COMPLETE"; } if (state != BlockUCState.COMMITTED) { return b + " is " + state + " but neither COMPLETE nor COMMITTED"; } final int numExpectedLocations = b.getUnderConstructionFeature().getNumExpectedLocations(); if (numExpectedLocations <= minReplication) { return b + " is " + state + " but numExpectedLocations = " + numExpectedLocations + " <= minReplication = " + minReplication; } return null; }
throw new IOException(block + " does not exist."); if (storedBlock.getBlockUCState() != BlockUCState.UNDER_CONSTRUCTION) { throw new IOException("Unexpected BlockUCState: " + block + " is " + storedBlock.getBlockUCState() + " but not " + BlockUCState.UNDER_CONSTRUCTION);
+ "block does not satisfy minimal replication requirement."); if (!force && curBlock.getBlockUCState() != BlockUCState.COMMITTED) { throw new IOException( "Cannot complete block: block has not been COMMITTED by the client");
/** * Commit a block of a file * * @param block block to be committed * @param commitBlock - contains client reported block length and generation * @return true if the block is changed to committed state. * @throws IOException if the block does not have at least a minimal number * of replicas reported from data-nodes. */ private boolean commitBlock(final BlockInfo block, final Block commitBlock) throws IOException { if (block.getBlockUCState() == BlockUCState.COMMITTED) return false; assert block.getNumBytes() <= commitBlock.getNumBytes() : "commitBlock length is less than the stored one " + commitBlock.getNumBytes() + " vs. " + block.getNumBytes(); if(block.getGenerationStamp() != commitBlock.getGenerationStamp()) { throw new IOException("Commit block with mismatching GS. NN has " + block + ", client submits " + commitBlock); } List<ReplicaUnderConstruction> staleReplicas = block.commitBlock(commitBlock); removeStaleReplicas(staleReplicas, block); return true; }
BlockUCState ucState = storedBlock.getBlockUCState();
if (storedBlock.getBlockUCState() == BlockUCState.COMMITTED && hasMinStorage(storedBlock, numCurrentReplica)) { completeBlock(storedBlock, null, false);
final BlockInfo lastBlock = file.getLastBlock(); if (lastBlock != null && lastBlock.getBlockUCState() == BlockUCState.UNDER_RECOVERY) { throw new RecoveryInProgressException( op.getExceptionMessage(src, holder, clientMachine,
if (lastBlock.getBlockUCState() == BlockUCState.COMMITTED) { throw new RetriableException( new NotReplicatedYetException("append: lastBlock="
if (!blockInfo.getBlockUCState().equals(BlockUCState.COMPLETE)) { blockInfo.getBlockUCState() ); continue;
BlockUCState ucState = storedBlock.getBlockUCState();
nrCompleteBlocks == nrBlocks - 2 && curBlock != null && curBlock.getBlockUCState() != BlockUCState.COMMITTED) { final String message = "DIR* NameSystem.internalReleaseLease: " + "attempt to release a create lock on " BlockUCState lastBlockState = lastBlock.getBlockUCState(); BlockInfo penultimateBlock = pendingFile.getPenultimateBlock();
int numCurrentReplica = numLiveReplicas + pendingNum; if(storedBlock.getBlockUCState() == BlockUCState.COMMITTED && hasMinStorage(storedBlock, numLiveReplicas)) { addExpectedReplicasToPending(storedBlock);
BlockUCState ucState = storedBlock.getBlockUCState(); BlockToMarkCorrupt c = checkReplicaCorrupt( iblk, reportedState, storedBlock, ucState,
if (lastBlock != null && lastBlock.getBlockUCState().equals( HdfsServerConstants.BlockUCState.UNDER_RECOVERY)) { dontRemoveBlock = lastBlock.getUnderConstructionFeature()
if (last != null && last.getBlockUCState() == BlockUCState.UNDER_RECOVERY) { final BlockInfo truncatedBlock = last.getUnderConstructionFeature()