/** * @return the index array indicating the block index in each storage. Used * only by striped blocks. */ public byte[] getBlockIndices() { int numLocations = getNumExpectedLocations(); byte[] indices = new byte[numLocations]; for (int i = 0; i < numLocations; i++) { indices[i] = BlockIdManager.getBlockIndex(replicas[i]); } return indices; }
/** * Create array of expected replica locations * (as has been assigned by chooseTargets()). */ public DatanodeStorageInfo[] getExpectedStorageLocations() { int numLocations = getNumExpectedLocations(); DatanodeStorageInfo[] storages = new DatanodeStorageInfo[numLocations]; for (int i = 0; i < numLocations; i++) { storages[i] = replicas[i].getExpectedStorageLocation(); } return storages; }
/** * Check if the i-th block is COMPLETE; * when the i-th block is the last block, it may be allowed to be COMMITTED. * * @return null if the block passes the check; * otherwise, return an error message. */ static String checkBlockComplete(BlockInfo[] blocks, int i, int numCommittedAllowed, short minReplication) { final BlockInfo b = blocks[i]; final BlockUCState state = b.getBlockUCState(); if (state == BlockUCState.COMPLETE) { return null; } if (b.isStriped() || i < blocks.length - numCommittedAllowed) { return b + " is " + state + " but not COMPLETE"; } if (state != BlockUCState.COMMITTED) { return b + " is " + state + " but neither COMPLETE nor COMMITTED"; } final int numExpectedLocations = b.getUnderConstructionFeature().getNumExpectedLocations(); if (numExpectedLocations <= minReplication) { return b + " is " + state + " but numExpectedLocations = " + numExpectedLocations + " <= minReplication = " + minReplication; } return null; }
if (uc.getNumExpectedLocations() == 0) { uc.setExpectedLocations(lastBlock, blockManager.getStorages(lastBlock), lastBlock.getBlockType()); if (uc.getNumExpectedLocations() == 0 && lastBlock.getNumBytes() == 0) {
.getNumExpectedLocations(); bmSafeMode.incrementSafeBlockCount(numOfReplicas, storedBlock);