/** * Remove the block from a file. */ boolean removeBlock(String path, INodeFileUnderConstruction fileNode, Block block) throws IOException { waitForReady(); writeLock(); try { // modify file-> block and blocksMap fileNode.removeBlock(block); getFSNamesystem().blocksMap.removeBlock(block); // Remove the block from corruptReplicasMap getFSNamesystem().corruptReplicas.removeFromCorruptReplicasMap(block); // write modified block locations to log fsImage.getEditLog().logOpenFile(path, fileNode); if (NameNode.stateChangeLog.isDebugEnabled()) { NameNode.stateChangeLog.debug("DIR* FSDirectory.removeBlock: " +path+" with "+block +" block is removed from the file system"); } } finally { writeUnlock(); } return true; }
/** * From the given list, incrementally remove the blocks. Add the blocks * to invalidates, and set a flag that explicit ACK from DataNode is not * required. This function should be used only for deleting entire files. */ private void removeBlocks(List<Block> blocks) { if (blocks == null) { return; } for (Block b : blocks) { removeFromExcessReplicateMap(b); neededReplications.remove(b, -1); corruptReplicas.removeFromCorruptReplicasMap(b); if (pendingReplications != null) { int replicas = pendingReplications.getNumReplicas(b); for (int i = 0; i < replicas; i++) { pendingReplications.remove(b); } } addToInvalidates(b, false); blocksMap.removeBlock(b); } }
/** * Add block b belonging to the specified file inode to the map, this * overwrites the map with the new block information. */ BlockInfo updateINode(BlockInfo oldBlock, Block newBlock, INodeFile iNode) throws IOException { // If the old block is not same as the new block, probably the GS was // bumped up, hence remove the old block and replace it with the new one. if (oldBlock != null && !oldBlock.equals(newBlock)) { if (oldBlock.getBlockId() != newBlock.getBlockId()) { throw new IOException("block ids don't match : " + oldBlock + ", " + newBlock); } removeBlock(oldBlock); } BlockInfo info = checkBlockInfo(newBlock, iNode.getReplication()); info.set(newBlock.getBlockId(), newBlock.getNumBytes(), newBlock.getGenerationStamp()); info.inode = iNode; return info; }
" abandoned"); getFSNamesystem().blocksMap.removeBlock(oldblocks[oldblocks.length - 1]);
blocksMap.removeBlock(oldblockinfo);
blocksMap.removeBlock(oldblockinfo);