/** * Remove block from the set of blocks belonging to the data-node. Remove * data-node from the block. */ static boolean removeBlock(DatanodeDescriptor dn, BlockInfo b) { final DatanodeStorageInfo s = b.findStorageInfo(dn); // if block exists on this datanode return s != null && s.removeBlock(b); }
@Override boolean removeBlock(BlockInfo b) { ProvidedDescriptor dn = (ProvidedDescriptor) getDatanodeDescriptor(); if (dn.activeProvidedDatanodes() == 0) { return super.removeBlock(b); } else { return false; } }
public AddBlockResult addBlock(BlockInfo b, Block reportedBlock) { // First check whether the block belongs to a different storage // on the same DN. AddBlockResult result = AddBlockResult.ADDED; DatanodeStorageInfo otherStorage = b.findStorageInfo(getDatanodeDescriptor()); if (otherStorage != null) { if (otherStorage != this) { // The block belongs to a different storage. Remove it first. otherStorage.removeBlock(b); result = AddBlockResult.REPLACED; } else { // The block is already associated with this storage. return AddBlockResult.ALREADY_EXIST; } } b.addStorage(this, reportedBlock); blocks.add(b); return result; }
/** * For use during startup. Expects block to be added in sorted order * to enable fast insert in to the DatanodeStorageInfo * * @param b Block to add to DatanodeStorageInfo * @param reportedBlock The reported replica * @return Enum describing if block was added, replaced or already existed */ public AddBlockResult addBlockInitial(BlockInfo b, Block reportedBlock) { // First check whether the block belongs to a different storage // on the same DN. AddBlockResult result = AddBlockResult.ADDED; DatanodeStorageInfo otherStorage = b.findStorageInfo(getDatanodeDescriptor()); if (otherStorage != null) { if (otherStorage != this) { // The block belongs to a different storage. Remove it first. otherStorage.removeBlock(b); result = AddBlockResult.REPLACED; } else { // The block is already associated with this storage. return AddBlockResult.ALREADY_EXIST; } } b.addStorage(this, reportedBlock); blocks.addSortedLast(b); return result; }
/** * Remove block from the list of blocks belonging to the data-node. Remove * data-node from the block. */ boolean removeBlock(BlockInfoContiguous b) { final DatanodeStorageInfo s = b.findStorageInfo(this); // if block exists on this datanode if (s != null) { return s.removeBlock(b); } return false; }
/** * Remove block from the list of blocks belonging to the data-node. Remove * data-node from the block. */ boolean removeBlock(String storageID, BlockInfoContiguous b) { DatanodeStorageInfo s = getStorageInfo(storageID); if (s != null) { return s.removeBlock(b); } return false; }
/** * Remove block from the list of blocks belonging to the data-node. Remove * data-node from the block. */ boolean removeBlock(BlockInfoContiguous b) { final DatanodeStorageInfo s = b.findStorageInfo(this); // if block exists on this datanode if (s != null) { return s.removeBlock(b); } return false; }
/** * Remove block from the list of blocks belonging to the data-node. Remove * data-node from the block. */ boolean removeBlock(String storageID, BlockInfoContiguous b) { DatanodeStorageInfo s = getStorageInfo(storageID); if (s != null) { return s.removeBlock(b); } return false; }
/** * Replace a block in the block map by a new block. * The new block and the old one have the same key. * @param newBlock - block for replacement * @return new block */ BlockInfoContiguous replaceBlock(BlockInfoContiguous newBlock) { BlockInfoContiguous currentBlock = blocks.get(newBlock); assert currentBlock != null : "the block if not in blocksMap"; // replace block in data-node lists for (int i = currentBlock.numNodes() - 1; i >= 0; i--) { final DatanodeDescriptor dn = currentBlock.getDatanode(i); final DatanodeStorageInfo storage = currentBlock.findStorageInfo(dn); final boolean removed = storage.removeBlock(currentBlock); Preconditions.checkState(removed, "currentBlock not found."); final AddBlockResult result = storage.addBlock(newBlock); Preconditions.checkState(result == AddBlockResult.ADDED, "newBlock already exists."); } // replace block in the map itself blocks.put(newBlock); return newBlock; } }
public AddBlockResult addBlock(BlockInfoContiguous b) { // First check whether the block belongs to a different storage // on the same DN. AddBlockResult result = AddBlockResult.ADDED; DatanodeStorageInfo otherStorage = b.findStorageInfo(getDatanodeDescriptor()); if (otherStorage != null) { if (otherStorage != this) { // The block belongs to a different storage. Remove it first. otherStorage.removeBlock(b); result = AddBlockResult.REPLACED; } else { // The block is already associated with this storage. return AddBlockResult.ALREADY_EXIST; } } // add to the head of the data-node list b.addStorage(this); blockList = b.listInsert(blockList, this); numBlocks++; return result; }
public AddBlockResult addBlock(BlockInfoContiguous b) { // First check whether the block belongs to a different storage // on the same DN. AddBlockResult result = AddBlockResult.ADDED; DatanodeStorageInfo otherStorage = b.findStorageInfo(getDatanodeDescriptor()); if (otherStorage != null) { if (otherStorage != this) { // The block belongs to a different storage. Remove it first. otherStorage.removeBlock(b); result = AddBlockResult.REPLACED; } else { // The block is already associated with this storage. return AddBlockResult.ALREADY_EXIST; } } // add to the head of the data-node list b.addStorage(this); blockList = b.listInsert(blockList, this); numBlocks++; return result; }
while(it.hasNext()) toRemove.add(it.next()); storageInfo.removeBlock(delimiter);
while(it.hasNext()) toRemove.add(it.next()); storageInfo.removeBlock(delimiter);
/** * Replace a block in the block map by a new block. * The new block and the old one have the same key. * @param newBlock - block for replacement * @return new block */ BlockInfoContiguous replaceBlock(BlockInfoContiguous newBlock) { BlockInfoContiguous currentBlock = blocks.get(newBlock); assert currentBlock != null : "the block if not in blocksMap"; // replace block in data-node lists for (int i = currentBlock.numNodes() - 1; i >= 0; i--) { final DatanodeDescriptor dn = currentBlock.getDatanode(i); final DatanodeStorageInfo storage = currentBlock.findStorageInfo(dn); final boolean removed = storage.removeBlock(currentBlock); Preconditions.checkState(removed, "currentBlock not found."); final AddBlockResult result = storage.addBlock(newBlock); Preconditions.checkState(result == AddBlockResult.ADDED, "newBlock already exists."); } // replace block in the map itself blocks.put(newBlock); return newBlock; } }