/** * @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; }
private int findSlot() { int i = getTotalBlockNum(); for (; i < getCapacity(); i++) { if (getStorageInfo(i) == null) { return i; } } // need to expand the storage size ensureCapacity(i + 1, true); return i; }
assert storedBlock instanceof BlockInfoStriped; BlockInfoStriped sblk = (BlockInfoStriped) storedBlock; short groupSize = sblk.getTotalBlockNum();
/** * For a striped block, it is possible it contains full number of internal * blocks (i.e., 9 by default), but with duplicated replicas of the same * internal block. E.g., for the following list of internal blocks * b0, b0, b1, b2, b3, b4, b5, b6, b7 * we have 9 internal blocks but we actually miss b8. * We should use this method to detect the above scenario and schedule * necessary reconstruction. */ private void countReplicasForStripedBlock(NumberReplicas counters, BlockInfoStriped block, Collection<DatanodeDescriptor> nodesCorrupt, boolean inStartupSafeMode) { BitSet bitSet = new BitSet(block.getTotalBlockNum()); for (StorageAndBlockIndex si : block.getStorageAndIndexInfos()) { StoredReplicaState state = checkReplicaOnStorage(counters, block, si.getStorage(), nodesCorrupt, inStartupSafeMode); if (state == StoredReplicaState.LIVE) { if (!bitSet.get(si.getBlockIndex())) { bitSet.set(si.getBlockIndex()); } else { counters.subtract(StoredReplicaState.LIVE, 1); counters.add(StoredReplicaState.REDUNDANT, 1); } } } }
public final QuotaCounts storagespaceConsumedStriped() { QuotaCounts counts = new QuotaCounts.Builder().build(); for (BlockInfo b : blocks) { Preconditions.checkState(b.isStriped()); long blockSize = b.isComplete() ? ((BlockInfoStriped)b).spaceConsumed() : getPreferredBlockSize() * ((BlockInfoStriped)b).getTotalBlockNum(); counts.addStorageSpace(blockSize); } return counts; }
new BitSet(((BlockInfoStriped) block).getTotalBlockNum()) : null; for (DatanodeStorageInfo storage : blocksMap.getStorages(block)) { final DatanodeDescriptor node = getDatanodeDescriptorFromStorage(storage);