use of alluxio.exception.BlockDoesNotExistException in project alluxio by Alluxio.
the class SwapRestoreTask method getBalancingTransfersList.
/**
* @return the list of transfer in order to balance swap-space within tier
*/
private List<BlockTransferInfo> getBalancingTransfersList() {
List<BlockTransferInfo> transferInfos = new LinkedList<>();
for (StorageTierView tierView : mEvictorView.getTierViews()) {
for (StorageDirView dirView : tierView.getDirViews()) {
Iterator<Long> dirBlockIter = mMetadataManager.getBlockIterator().getIterator(new BlockStoreLocation(tierView.getTierViewAlias(), dirView.getDirViewIndex()), BlockOrder.NATURAL);
while (dirBlockIter.hasNext() && dirView.getAvailableBytes() < dirView.getReservedBytes()) {
long blockId = dirBlockIter.next();
try {
BlockMeta movingOutBlock = mEvictorView.getBlockMeta(blockId);
if (movingOutBlock == null) {
LOG.debug("Block:{} exist but not available for balancing.", blockId);
continue;
}
// Find where to move the block.
StorageDirView dstDirView = null;
for (StorageDirView candidateDirView : tierView.getDirViews()) {
if (candidateDirView.getDirViewIndex() == dirView.getDirViewIndex()) {
continue;
}
if (candidateDirView.getAvailableBytes() - candidateDirView.getReservedBytes() >= movingOutBlock.getBlockSize()) {
dstDirView = candidateDirView;
break;
}
}
if (dstDirView == null) {
LOG.warn("Could not balance swap-restore space for location: {}", dirView.toBlockStoreLocation());
break;
}
// TODO(ggezer): Consider allowing evictions for this move.
transferInfos.add(BlockTransferInfo.createMove(movingOutBlock.getBlockLocation(), blockId, dstDirView.toBlockStoreLocation()));
// Account for moving-out blocks.
((StorageDirEvictorView) dirView).markBlockMoveOut(blockId, movingOutBlock.getBlockSize());
// Account for moving-in blocks.
((StorageDirEvictorView) dstDirView).markBlockMoveIn(blockId, movingOutBlock.getBlockSize());
} catch (BlockDoesNotExistException e) {
LOG.warn("Failed to find metadata for block:{} during swap-restore balancing.", blockId);
}
}
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Generated {} balance transfers:\n ->{}", transferInfos.size(), transferInfos.stream().map(Object::toString).collect(Collectors.joining(",\n ->")));
}
return transferInfos;
}
Aggregations