public void removeBlock(BlockInfo block) { assert namesystem.hasWriteLock(); // No need to ACK blocks that are being removed entirely // from the namespace, since the removal of the associated // file already removes them from the block map below. block.setNumBytes(BlockCommand.NO_ACK); addToInvalidates(block); removeBlockFromMap(block); // Remove the block from pendingReconstruction and neededReconstruction pendingReconstruction.remove(block); neededReconstruction.remove(block, LowRedundancyBlocks.LEVEL); postponedMisreplicatedBlocks.remove(block); }
public void updateLastBlock(BlockInfo lastBlock, ExtendedBlock newBlock) { lastBlock.setNumBytes(newBlock.getNumBytes()); List<ReplicaUnderConstruction> staleReplicas = lastBlock .setGenerationStampAndVerifyReplicas(newBlock.getGenerationStamp()); removeStaleReplicas(staleReplicas, lastBlock); }
/** * Update the length for the last block * * @param lastBlockLength * The length of the last block reported from client * @throws IOException */ void updateLengthOfLastBlock(INodeFile f, long lastBlockLength) throws IOException { BlockInfo lastBlock = f.getLastBlock(); assert (lastBlock != null) : "The last block for path " + f.getFullPathName() + " is null when updating its length"; assert !lastBlock.isComplete() : "The last block for path " + f.getFullPathName() + " is not under-construction when updating its length"; lastBlock.setNumBytes(lastBlockLength); }
/** * Commit block's length and generation stamp as reported by the client. * Set block state to {@link BlockUCState#COMMITTED}. * @param block - contains client reported block length and generation * @return staleReplica's List. * @throws IOException if block ids are inconsistent. */ List<ReplicaUnderConstruction> commitBlock(Block block) throws IOException { if (getBlockId() != block.getBlockId()) { throw new IOException("Trying to commit inconsistent block: id = " + block.getBlockId() + ", expected id = " + getBlockId()); } Preconditions.checkState(!isComplete()); uc.commit(); this.setNumBytes(block.getNumBytes()); // Sort out invalid replicas. return setGenerationStampAndVerifyReplicas(block.getGenerationStamp()); } }
storedBlock.setNumBytes(newlength);
oldLastBlock.setNumBytes(pBlock.getNumBytes()); if (!oldLastBlock.isComplete()) { fsNamesys.getBlockManager().forceCompleteBlock(oldLastBlock);
oldBlock.setNumBytes(newBlock.getNumBytes()); boolean changeMade = oldBlock.getGenerationStamp() != newBlock.getGenerationStamp();
truncatedBlockUC.convertToBlockUnderConstruction( BlockUCState.UNDER_CONSTRUCTION, blockManager.getStorages(oldBlock)); truncatedBlockUC.setNumBytes(oldBlock.getNumBytes() - lastBlockDelta); truncatedBlockUC.getUnderConstructionFeature().setTruncateBlock(oldBlock); file.setLastBlock(truncatedBlockUC); uc.setTruncateBlock(new BlockInfoContiguous(oldBlock, oldBlock.getReplication())); uc.getTruncateBlock().setNumBytes(oldBlock.getNumBytes() - lastBlockDelta); uc.getTruncateBlock().setGenerationStamp(newBlock.getGenerationStamp()); truncatedBlockUC = oldBlock;