/** * Updates the worker and block metadata for blocks removed from a worker. * * <p>NOTE: {@link #mBlocks} should already be locked before calling this method. * * @param workerInfo The worker metadata object * @param removedBlockIds A list of block ids removed from the worker */ private void processWorkerRemovedBlocks( MasterWorkerInfo workerInfo, Collection<Long> removedBlockIds) { for (long removedBlockId : removedBlockIds) { MasterBlockInfo masterBlockInfo = mBlocks.get(removedBlockId); if (masterBlockInfo == null) { LOG.warn( "Worker {} removed block {} but block does not exist.", workerInfo.getId(), removedBlockId); // Continue to remove the remaining blocks. continue; } LOG.info("Block {} is removed on worker {}.", removedBlockId, workerInfo.getId()); workerInfo.removeBlock(masterBlockInfo.getBlockId()); masterBlockInfo.removeWorker(workerInfo.getId()); if (masterBlockInfo.getNumLocations() == 0) { mLostBlocks.add(removedBlockId); } } }
/** * Removes blocks from workers. * * @param blockIds a list of block ids to remove from Tachyon space */ public void removeBlocks(List<Long> blockIds) { synchronized (mBlocks) { synchronized (mWorkers) { for (long blockId : blockIds) { MasterBlockInfo masterBlockInfo = mBlocks.get(blockId); if (masterBlockInfo == null) { continue; } for (long workerId : new ArrayList<Long>(masterBlockInfo.getWorkers())) { masterBlockInfo.removeWorker(workerId); MasterWorkerInfo worker = mWorkers.getFirstByField(mIdIndex, workerId); if (worker != null) { worker.updateToRemovedBlock(true, blockId); } } mLostBlocks.remove(blockId); } } } }