/** * Returns the next block that we copy from all the block pools. This * function looks across all block pools to find the next block to copy. * * @param poolIters - List of BlockIterators * @return ExtendedBlock. */ ExtendedBlock getNextBlock(List<FsVolumeSpi.BlockIterator> poolIters, DiskBalancerWorkItem item) { Preconditions.checkNotNull(poolIters); int currentCount = 0; ExtendedBlock block = null; while (block == null && currentCount < poolIters.size()) { currentCount++; int index = poolIndex++ % poolIters.size(); FsVolumeSpi.BlockIterator currentPoolIter = poolIters.get(index); block = getBlockToCopy(currentPoolIter, item); } if (block == null) { try { item.setErrMsg("No source blocks found to move."); LOG.error("No movable source blocks found. {}", item.toJson()); } catch (IOException e) { LOG.error("Unable to get json from Item."); } } return block; }