public void appendUCPartsConcise(StringBuilder sb) { sb.append("replicas="); int i = 0; for (ReplicaUnderConstruction r : replicas) { sb.append(r.getExpectedStorageLocation().getDatanodeDescriptor()); if (++i < replicas.length) { sb.append(", "); } } } }
/** * 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; }
@Override public DatanodeStorageInfo next() { if (!hasNext()) { throw new NoSuchElementException(); } return replicas[index++].getExpectedStorageLocation(); } };
private void removeStaleReplicas(List<ReplicaUnderConstruction> staleReplicas, BlockInfo block) { for (ReplicaUnderConstruction r : staleReplicas) { removeStoredBlock(block, r.getExpectedStorageLocation().getDatanodeDescriptor()); NameNode.blockStateChangeLog .debug("BLOCK* Removing stale replica {}" + " of {}", r, Block.toString(r)); } } /**
final long lastUpdate = ruc.getExpectedStorageLocation() .getDatanodeDescriptor().getLastUpdateMonotonic(); if (lastUpdate > mostRecentLastUpdate) { primary.getExpectedStorageLocation().getDatanodeDescriptor() .addBlockToBeRecovered(blockInfo); primary.setChosenAsPrimary(true);
for (int i = 0; i < replicas.length; i++) { DatanodeStorageInfo expected = replicas[i].getExpectedStorageLocation(); if (expected == storage) { replicas[i].setGenerationStamp(reportedBlock.getGenerationStamp());
/** * 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()); } } } }