use of alluxio.worker.block.management.BlockOperationResult in project alluxio by Alluxio.
the class SwapRestoreTask method run.
@Override
public BlockManagementTaskResult run() {
LOG.debug("Running swap-restore task.");
// Generate swap-restore plan.
Pair<List<Long>, List<BlockTransferInfo>> swapRestorePlan = getSwapRestorePlan();
LOG.debug("Generated swap-restore plan with {} deletions and {} transfers.", swapRestorePlan.getFirst().size(), swapRestorePlan.getSecond().size());
BlockManagementTaskResult result = new BlockManagementTaskResult();
// Execute to-be-removed blocks from the plan.
int removalFailCount = 0;
for (Long blockId : swapRestorePlan.getFirst()) {
try {
mBlockStore.removeBlock(Sessions.createInternalSessionId(), blockId);
} catch (Exception e) {
LOG.warn("Failed to remove block: {} during swap-restore task.", blockId);
removalFailCount++;
}
}
result.addOpResults(BlockOperationType.SWAP_RESTORE_REMOVE, new BlockOperationResult(swapRestorePlan.getFirst().size(), removalFailCount, 0));
// Execute to-be-transferred blocks from the plan.
BlockOperationResult flushResult = mTransferExecutor.executeTransferList(swapRestorePlan.getSecond());
result.addOpResults(BlockOperationType.SWAP_RESTORE_FLUSH, flushResult);
// Re-balance each tier.
BlockOperationResult balanceResult = mTransferExecutor.executeTransferList(getBalancingTransfersList());
result.addOpResults(BlockOperationType.SWAP_RESTORE_BALANCE, balanceResult);
return result;
}
use of alluxio.worker.block.management.BlockOperationResult in project alluxio by Alluxio.
the class PromoteTask method run.
@Override
public BlockManagementTaskResult run() {
LOG.debug("Running promote task.");
BlockManagementTaskResult result = new BlockManagementTaskResult();
// Iterate each tier intersection and move to upper tier whenever required.
for (Pair<BlockStoreLocation, BlockStoreLocation> intersection : mMetadataManager.getStorageTierAssoc().intersectionList()) {
BlockStoreLocation tierUpLoc = intersection.getFirst();
BlockStoreLocation tierDownLoc = intersection.getSecond();
// Acquire iterator for the tier below.
Iterator<Long> tierDownIterator = mMetadataManager.getBlockIterator().getIterator(tierDownLoc, BlockOrder.REVERSE);
// Acquire and execute promotion transfers.
BlockOperationResult tierResult = mTransferExecutor.executeTransferList(getTransferInfos(tierDownIterator, tierUpLoc, tierDownLoc));
result.addOpResults(BlockOperationType.PROMOTE_MOVE, tierResult);
}
return result;
}
use of alluxio.worker.block.management.BlockOperationResult in project alluxio by Alluxio.
the class AlignTask method run.
@Override
public BlockManagementTaskResult run() {
LOG.debug("Running align task.");
// Acquire align range from the configuration.
// This will limit swap operations in a single run.
final int alignRange = ServerConfiguration.getInt(PropertyKey.WORKER_MANAGEMENT_TIER_ALIGN_RANGE);
BlockManagementTaskResult result = new BlockManagementTaskResult();
// Align each tier intersection by swapping blocks.
for (Pair<BlockStoreLocation, BlockStoreLocation> intersection : mMetadataManager.getStorageTierAssoc().intersectionList()) {
BlockStoreLocation tierUpLoc = intersection.getFirst();
BlockStoreLocation tierDownLoc = intersection.getSecond();
// Get list per tier that will be swapped for aligning the intersection.
Pair<List<Long>, List<Long>> swapLists = mMetadataManager.getBlockIterator().getSwaps(tierUpLoc, BlockOrder.NATURAL, tierDownLoc, BlockOrder.REVERSE, alignRange, BlockOrder.REVERSE, (blockId) -> !mEvictorView.isBlockEvictable(blockId));
Preconditions.checkArgument(swapLists.getFirst().size() == swapLists.getSecond().size());
LOG.debug("Acquired {} block pairs to align tiers {} - {}", swapLists.getFirst().size(), tierUpLoc.tierAlias(), tierDownLoc.tierAlias());
// Create exception handler to trigger swap-restore task when swap fails
// due to insufficient reserved space.
Consumer<Exception> excHandler = (e) -> {
if (e instanceof WorkerOutOfSpaceException) {
LOG.warn("Insufficient space for worker swap space, swap restore task called.");
// Mark the need for running swap-space restoration task.
TierManagementTaskProvider.setSwapRestoreRequired(true);
}
};
// Execute swap transfers.
BlockOperationResult tierResult = mTransferExecutor.executeTransferList(generateSwapTransferInfos(swapLists), excHandler);
result.addOpResults(BlockOperationType.ALIGN_SWAP, tierResult);
}
return result;
}
Aggregations