@Override public boolean equals(Object obj) { if (obj instanceof BlockRecoveryAttempt) { return this.blockInfo.equals(((BlockRecoveryAttempt) obj).blockInfo); } return false; } }
/** * Remove a block from the block list. This block should be * the last one on the list. */ BlockInfo removeLastBlock(Block oldblock) { Preconditions.checkState(isUnderConstruction(), "file is no longer under construction"); if (blocks.length == 0) { return null; } int size_1 = blocks.length - 1; if (!blocks[size_1].equals(oldblock)) { return null; } BlockInfo lastBlock = blocks[size_1]; //copy to a new list BlockInfo[] newlist = new BlockInfo[size_1]; System.arraycopy(blocks, 0, newlist, 0, size_1); setBlocks(newlist); lastBlock.delete(); return lastBlock; }
/** * Add a to-be-deleted block into the * {@link BlocksMapUpdateInfo#toDeleteList} * @param toDelete the to-be-deleted block */ public void addDeleteBlock(BlockInfo toDelete) { assert toDelete != null : "toDelete is null"; toDelete.delete(); toDeleteList.add(toDelete); // If the file is being truncated // the copy-on-truncate block should also be collected for deletion BlockUnderConstructionFeature uc = toDelete.getUnderConstructionFeature(); if(uc == null) { return; } BlockInfo truncateBlock = uc.getTruncateBlock(); if(truncateBlock == null || truncateBlock.equals(toDelete)) { return; } addDeleteBlock(truncateBlock); }
numLive); if (isDecommission && numExpected > numLive) { if (bc.isUnderConstruction() && block.equals(bc.getLastBlock())) {
if (sblocks != null && i < sblocks.length && bi.equals(sblocks[i])) { truncatedBytes -= bi.getNumBytes();
if(dontRemoveBlock == null || !removedBlocks[i].equals(dontRemoveBlock)) { reclaimContext.collectedBlocks().addDeleteBlock(removedBlocks[i]);