/** * Save allocated block at the given pending filename * * @param src path to the file * @param inodesInPath representing each of the components of src. * The last INode is the INode for {@code src} file. * @param newBlock newly allocated block to be save * @param targets target datanodes where replicas of the new block is placed * @throws QuotaExceededException If addition of block exceeds space quota */ BlockInfoContiguous saveAllocatedBlock(String src, INodesInPath inodesInPath, Block newBlock, DatanodeStorageInfo[] targets) throws IOException { assert hasWriteLock(); BlockInfoContiguous b = dir.addBlock(src, inodesInPath, newBlock, targets); NameNode.stateChangeLog.info("BLOCK* allocate " + b + " for " + src); DatanodeStorageInfo.incrementBlocksScheduled(targets); return b; }
/** * Allocate a block at the given pending filename * * @param src path to the file * @param indoes INode representing each of the components of src. * <code>inodes[inodes.length-1]</code> is the INode for the file. */ private Block allocateBlock(String src, INode[] inodes) throws IOException { Block b = null; do { b = new Block(FSNamesystem.randBlockId.nextLong(), 0, getGenerationStamp()); } while (isValidBlock(b)); b = dir.addBlock(src, inodes, b); NameNode.stateChangeLog.info("BLOCK* NameSystem.allocateBlock: " +src+ ". "+b); return b; }
/** * Allocate a block at the given pending filename * * @param src path to the file * @param inodes INode representing each of the components of src. * <code>inodes[inodes.length-1]</code> is the INode for the file. */ private Block allocateBlock(String src, INode[] inodes) throws IOException { Block b = new Block(FSNamesystem.randBlockId.nextLong(), 0, 0); while (isValidBlock(b)) { b.setBlockId(FSNamesystem.randBlockId.nextLong()); } b.setGenerationStamp(getGenerationStamp()); b = dir.addBlock(src, inodes, b); return b; }
/** * Save allocated block at the given pending filename * * @param src path to the file * @param inodesInPath representing each of the components of src. * The last INode is the INode for {@code src} file. * @param newBlock newly allocated block to be save * @param targets target datanodes where replicas of the new block is placed * @throws QuotaExceededException If addition of block exceeds space quota */ BlockInfoContiguous saveAllocatedBlock(String src, INodesInPath inodesInPath, Block newBlock, DatanodeStorageInfo[] targets) throws IOException { assert hasWriteLock(); BlockInfoContiguous b = dir.addBlock(src, inodesInPath, newBlock, targets); NameNode.stateChangeLog.info("BLOCK* allocate " + b + " for " + src); DatanodeStorageInfo.incrementBlocksScheduled(targets); return b; }