/** * Add/Update the under construction feature. */ public void convertToBlockUnderConstruction(BlockUCState s, DatanodeStorageInfo[] targets) { if (isComplete()) { uc = new BlockUnderConstructionFeature(this, s, targets, this.getBlockType()); } else { // the block is already under construction uc.setBlockUCState(s); uc.setExpectedLocations(this, targets, this.getBlockType()); } }
@Override public String toString() { final StringBuilder b = new StringBuilder(100); appendUCParts(b); return b.toString(); }
private static void logAllocatedBlock(String src, BlockInfo b) { if (!NameNode.stateChangeLog.isInfoEnabled()) { return; } StringBuilder sb = new StringBuilder(150); sb.append("BLOCK* allocate "); b.appendStringTo(sb); sb.append(", "); BlockUnderConstructionFeature uc = b.getUnderConstructionFeature(); if (uc != null) { uc.appendUCPartsConcise(sb); } sb.append(" for " + src); NameNode.stateChangeLog.info(sb.toString()); }
public BlockUnderConstructionFeature(Block blk, BlockUCState state, DatanodeStorageInfo[] targets, BlockType blockType) { assert getBlockUCState() != COMPLETE : "BlockUnderConstructionFeature cannot be in COMPLETE state"; this.blockUCState = state; setExpectedLocations(blk, targets, blockType); }
"where it is not under construction."); final DatanodeStorageInfo[] storages = uc.getExpectedStorageLocations(); boolean truncateRecovery = uc.getTruncateBlock() != null; boolean copyOnTruncateRecovery = truncateRecovery && uc.getTruncateBlock().getBlockId() != b.getBlockId(); ExtendedBlock primaryBlock = (copyOnTruncateRecovery) ? new ExtendedBlock(blockPoolId, uc.getTruncateBlock()) : new ExtendedBlock(blockPoolId, b); Block recoveryBlock = (copyOnTruncateRecovery) ? b : uc.getTruncateBlock(); rBlock = new RecoveringBlock(primaryBlock, recoveryInfos, recoveryBlock); } else { rBlock = new RecoveringBlock(primaryBlock, recoveryInfos, uc.getBlockRecoveryId()); if (b.isStriped()) { rBlock = new RecoveringStripedBlock(rBlock, uc.getBlockIndices(), ((BlockInfoStriped) b).getErasureCodingPolicy());
.addReplicaIfNotPresent(storageInfo, iblk, reportedState); .getNumExpectedLocations(); bmSafeMode.incrementSafeBlockCount(numOfReplicas, storedBlock);
final BlockUnderConstructionFeature uc = blk.getUnderConstructionFeature(); if (blk.isStriped()) { final DatanodeStorageInfo[] storages = uc.getExpectedStorageLocations(); final ExtendedBlock eb = new ExtendedBlock(getBlockPoolId(), blk); return newLocatedStripedBlock(eb, storages, uc.getBlockIndices(), pos, false); } else { final DatanodeStorageInfo[] storages = uc.getExpectedStorageLocations(); final ExtendedBlock eb = new ExtendedBlock(getBlockPoolId(), blk);
/** * If IBR is not sent from expected locations yet, add the datanodes to * pendingReconstruction in order to keep RedundancyMonitor from scheduling * the block. */ public void addExpectedReplicasToPending(BlockInfo blk) { if (!blk.isStriped()) { DatanodeStorageInfo[] expectedStorages = blk.getUnderConstructionFeature().getExpectedStorageLocations(); if (expectedStorages.length - blk.numNodes() > 0) { ArrayList<DatanodeDescriptor> pendingNodes = new ArrayList<>(); for (DatanodeStorageInfo storage : expectedStorages) { DatanodeDescriptor dnd = storage.getDatanodeDescriptor(); if (blk.findStorageInfo(dnd) == null) { pendingNodes.add(dnd); } } pendingReconstruction.increment(blk, pendingNodes.toArray(new DatanodeDescriptor[pendingNodes.size()])); } } }
public BlockUCState getBlockUCState() { return uc == null ? BlockUCState.COMPLETE : uc.getBlockUCState(); }
public static LocatedBlock newLocatedBlock(ExtendedBlock eb, BlockInfo info, DatanodeStorageInfo[] locs, long offset) throws IOException { final LocatedBlock lb; if (info.isStriped()) { lb = newLocatedStripedBlock(eb, locs, info.getUnderConstructionFeature().getBlockIndices(), offset, false); } else { lb = newLocatedBlock(eb, locs, offset, false); } return lb; }
void addStoredBlockUnderConstruction(StatefulBlockInfo ucBlock, DatanodeStorageInfo storageInfo) throws IOException { BlockInfo block = ucBlock.storedBlock; block.getUnderConstructionFeature().addReplicaIfNotPresent( storageInfo, ucBlock.reportedBlock, ucBlock.reportedState); // Add replica if appropriate. If the replica was previously corrupt // but now okay, it might need to be updated. if (ucBlock.reportedState == ReplicaState.FINALIZED && ( block.findStorageInfo(storageInfo) < 0) || corruptReplicas .isReplicaCorrupt(block, storageInfo.getDatanodeDescriptor())) { addStoredBlock(block, ucBlock.reportedBlock, storageInfo, null, true); } }
} else { storagesItr = storedBlock.getUnderConstructionFeature() .getExpectedStorageLocationsIterator();
/** * Commit block's length and generation stamp as reported by the client. * Set block state to {@link BlockUCState#COMMITTED}. * @param block - contains client reported block length and generation * @return staleReplica's List. * @throws IOException if block ids are inconsistent. */ List<ReplicaUnderConstruction> commitBlock(Block block) throws IOException { if (getBlockId() != block.getBlockId()) { throw new IOException("Trying to commit inconsistent block: id = " + block.getBlockId() + ", expected id = " + getBlockId()); } Preconditions.checkState(!isComplete()); uc.commit(); this.setNumBytes(block.getNumBytes()); // Sort out invalid replicas. return setGenerationStampAndVerifyReplicas(block.getGenerationStamp()); } }
.getBlockRecoveryId(); copyTruncate = truncatedBlock.getBlockId() != storedBlock.getBlockId(); if(recoveryId != newgenerationstamp) {
static boolean unprotectedRemoveBlock( FSDirectory fsd, String path, INodesInPath iip, INodeFile fileNode, Block block) throws IOException { // modify file-> block and blocksMap // fileNode should be under construction BlockInfo uc = fileNode.removeLastBlock(block); if (uc == null) { return false; } if (uc.getUnderConstructionFeature() != null) { DatanodeStorageInfo.decrementBlocksScheduled(uc .getUnderConstructionFeature().getExpectedStorageLocations()); } fsd.getBlockManager().removeBlockFromMap(uc); if(NameNode.stateChangeLog.isDebugEnabled()) { NameNode.stateChangeLog.debug("DIR* FSDirectory.removeBlock: " +path+" with "+block +" block is removed from the file system"); } // update space consumed fsd.updateCount(iip, 0, -fileNode.getPreferredBlockSize(), fileNode.getPreferredBlockReplication(), true); return true; }
block.getLocalBlock()); DatanodeStorageInfo[] storages = storedBlock .getUnderConstructionFeature().getExpectedStorageLocations(); report.append('\n'); report.append("Under Construction Block:\n");
lastBlockInFile.getUnderConstructionFeature(); onRetryBlock[0] = makeLocatedBlock(fsn, lastBlockInFile, uc.getExpectedStorageLocations(), offset); return new FileState(file, src, iip); } else {