/** * If the block is committed/completed and its length is less than a full * stripe, it returns the the number of actual data blocks. * Otherwise it returns the number of data units specified by erasure coding policy. */ public short getRealDataBlockNum() { if (isComplete() || getBlockUCState() == BlockUCState.COMMITTED) { return (short) Math.min(getDataBlockNum(), (getNumBytes() - 1) / ecPolicy.getCellSize() + 1); } else { return getDataBlockNum(); } }
/** * @return true if the current source nodes cover all the internal blocks. * I.e., we only need to have more racks. */ private boolean hasAllInternalBlocks() { final BlockInfoStriped block = (BlockInfoStriped) getBlock(); if (getSrcNodes().length < block.getRealTotalBlockNum()) { return false; } BitSet bitSet = new BitSet(block.getTotalBlockNum()); for (byte index : liveBlockIndicies) { bitSet.set(index); } for (int i = 0; i < block.getRealDataBlockNum(); i++) { if (!bitSet.get(i)) { return false; } } for (int i = block.getDataBlockNum(); i < block.getTotalBlockNum(); i++) { if (!bitSet.get(i)) { return false; } } return true; }
blockStriped.getDataBlockNum(), blockStriped.getCellSize())); return block.getNumBytes() / blockStriped.getDataBlockNum(); }else{ results.add(blkWithLocs);
private void createReplicationWork(int sourceIndex, DatanodeStorageInfo target) { BlockInfoStriped stripedBlk = (BlockInfoStriped) getBlock(); final byte blockIndex = liveBlockIndicies[sourceIndex]; final DatanodeDescriptor source = getSrcNodes()[sourceIndex]; final long internBlkLen = StripedBlockUtil.getInternalBlockLength( stripedBlk.getNumBytes(), stripedBlk.getCellSize(), stripedBlk.getDataBlockNum(), blockIndex); final Block targetBlk = new Block(stripedBlk.getBlockId() + blockIndex, internBlkLen, stripedBlk.getGenerationStamp()); source.addBlockToBeReplicated(targetBlk, new DatanodeStorageInfo[] {target}); if (BlockManager.LOG.isDebugEnabled()) { BlockManager.LOG.debug("Add replication task from source {} to " + "target {} for EC block {}", source, target, targetBlk); } }
/** * when committing a striped block whose size is less than a stripe, we need * to decrease the scheduled block size of the DataNodes that do not store * any internal block. */ void updateStorageScheduledSize(BlockInfoStriped storedBlock) { assert storedBlock.getUnderConstructionFeature() == this; if (replicas.length == 0) { return; } final int dataBlockNum = storedBlock.getDataBlockNum(); final int realDataBlockNum = storedBlock.getRealDataBlockNum(); if (realDataBlockNum < dataBlockNum) { for (ReplicaUnderConstruction replica : replicas) { int index = BlockIdManager.getBlockIndex(replica); if (index >= realDataBlockNum && index < dataBlockNum) { final DatanodeStorageInfo storage = replica.getExpectedStorageLocation(); storage.getDatanodeDescriptor() .decrementBlocksScheduled(storage.getStorageType()); } } } }
size = isStriped()? getPreferredBlockSize() * ((BlockInfoStriped)lastBlk).getDataBlockNum() : getPreferredBlockSize();
wrongSize = reported.getNumBytes() != getInternalBlockLength( stripedBlock.getNumBytes(), stripedBlock.getCellSize(), stripedBlock.getDataBlockNum(), reportedBlkIdx); } else { wrongSize = storedBlock.getNumBytes() != reported.getNumBytes();