BlockCollection getBlockCollection(Block b) { BlockInfoContiguous info = blocks.get(b); return (info != null) ? info.getBlockCollection() : null; }
BlockCollection getBlockCollection(Block b) { BlockInfoContiguous info = blocks.get(b); return (info != null) ? info.getBlockCollection() : null; }
/** * 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; }
/** * Remove data-node reference from the block. * Remove the block from the block map * only if it does not belong to any file and data-nodes. */ boolean removeNode(Block b, DatanodeDescriptor node) { BlockInfoContiguous info = blocks.get(b); if (info == null) return false; // remove block from the data-node list and the node from the block info boolean removed = node.removeBlock(info); if (info.getDatanode(0) == null // no datanodes left && info.getBlockCollection() == null) { // does not belong to a file blocks.remove(b); // remove block from the map } return removed; }
/** * Remove data-node reference from the block. * Remove the block from the block map * only if it does not belong to any file and data-nodes. */ boolean removeNode(Block b, DatanodeDescriptor node) { BlockInfoContiguous info = blocks.get(b); if (info == null) return false; // remove block from the data-node list and the node from the block info boolean removed = node.removeBlock(info); if (info.getDatanode(0) == null // no datanodes left && info.getBlockCollection() == null) { // does not belong to a file blocks.remove(b); // remove block from the map } return removed; }
LOG.info("Cannot find block info for block " + b); } else { if (blockInfo.getBlockCollection().getStoragePolicyID() == lpPolicy.getId()) { filesToDelete.add(blockInfo.getBlockCollection());
final INodeFile file = ((INode)storedBlock.getBlockCollection()).asFile(); if (file == null || !file.isUnderConstruction() || isFileDeleted(file)) { throw new IOException("The file " + storedBlock +
BlockCollection bc = ((BlockInfoContiguous) block).getBlockCollection(); String fileName = (bc == null) ? "[orphaned]" : bc.getName(); out.print(fileName + ": ");
/** * Update the cached quota space for a block that is being completed. * Must only be called once, as the block is being completed. * @param completeBlk - Completed block for which to update space * @param inodes - INodes in path to file containing completeBlk; if null * this will be resolved internally */ public void updateSpaceForCompleteBlock(BlockInfoContiguous completeBlk, INodesInPath inodes) throws IOException { assert namesystem.hasWriteLock(); INodesInPath iip = inodes != null ? inodes : INodesInPath.fromINode((INodeFile) completeBlk.getBlockCollection()); INodeFile fileINode = iip.getLastINode().asFile(); // Adjust disk space consumption if required final long diff = fileINode.getPreferredBlockSize() - completeBlk.getNumBytes(); if (diff > 0) { try { updateSpaceConsumed(iip, 0, -diff, fileINode.getFileReplication()); } catch (IOException e) { LOG.warn("Unexpected exception while updating disk space.", e); } } }
final INodeFile file = ((INode)storedBlock.getBlockCollection()).asFile(); if (file == null || !file.isUnderConstruction() || isFileDeleted(file)) { throw new IOException("The file " + storedBlock +
LOG.info("Cannot find block info for block " + b); } else { if (blockInfo.getBlockCollection().getStoragePolicyID() == lpPolicy.getId()) { filesToDelete.add(blockInfo.getBlockCollection());
static void assertBlockCollection(final BlockManager blkManager, final INodeFile file, final BlockInfoContiguous b) { Assert.assertSame(b, blkManager.getStoredBlock(b)); Assert.assertSame(file, blkManager.getBlockCollection(b)); Assert.assertSame(file, b.getBlockCollection()); }
/** * Update the cached quota space for a block that is being completed. * Must only be called once, as the block is being completed. * @param completeBlk - Completed block for which to update space * @param inodes - INodes in path to file containing completeBlk; if null * this will be resolved internally */ public void updateSpaceForCompleteBlock(BlockInfoContiguous completeBlk, INodesInPath inodes) throws IOException { assert namesystem.hasWriteLock(); INodesInPath iip = inodes != null ? inodes : INodesInPath.fromINode((INodeFile) completeBlk.getBlockCollection()); INodeFile fileINode = iip.getLastINode().asFile(); // Adjust disk space consumption if required final long diff = fileINode.getPreferredBlockSize() - completeBlk.getNumBytes(); if (diff > 0) { try { updateSpaceConsumed(iip, 0, -diff, fileINode.getFileReplication()); } catch (IOException e) { LOG.warn("Unexpected exception while updating disk space.", e); } } }
if (storedBlock.getBlockUCState() == BlockUCState.COMMITTED && numCurrentReplica >= minReplication) { completeBlock(storedBlock.getBlockCollection(), storedBlock, null, false); } else if (storedBlock.isComplete() && result == AddBlockResult.ADDED) {
BlockCollection bc = block.getBlockCollection(); if (bc == null) {
BlockCollection bc = block.getBlockCollection(); if (bc == null) {
if (storedBlock.getBlockUCState() == BlockUCState.COMMITTED && numCurrentReplica >= minReplication) { completeBlock(storedBlock.getBlockCollection(), storedBlock, null, false); } else if (storedBlock.isComplete() && result == AddBlockResult.ADDED) {
DatanodeDescriptor node) throws IOException { BlockCollection bc = b.corrupted.getBlockCollection(); if (bc == null) { blockLog.info("BLOCK markBlockAsCorrupt: {} cannot be marked as" +
DatanodeDescriptor node) throws IOException { BlockCollection bc = b.corrupted.getBlockCollection(); if (bc == null) { blockLog.info("BLOCK markBlockAsCorrupt: {} cannot be marked as" +