Search in sources :

Example 1 with BlockOperationResult

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;
}
Also used : BlockOperationResult(alluxio.worker.block.management.BlockOperationResult) LinkedList(java.util.LinkedList) List(java.util.List) BlockManagementTaskResult(alluxio.worker.block.management.BlockManagementTaskResult) BlockDoesNotExistException(alluxio.exception.BlockDoesNotExistException)

Example 2 with BlockOperationResult

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;
}
Also used : BlockOperationResult(alluxio.worker.block.management.BlockOperationResult) BlockManagementTaskResult(alluxio.worker.block.management.BlockManagementTaskResult) BlockStoreLocation(alluxio.worker.block.BlockStoreLocation)

Example 3 with BlockOperationResult

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;
}
Also used : BlockStoreLocation(alluxio.worker.block.BlockStoreLocation) BlockMetadataManager(alluxio.worker.block.BlockMetadataManager) LoggerFactory(org.slf4j.LoggerFactory) BlockOperationResult(alluxio.worker.block.management.BlockOperationResult) PropertyKey(alluxio.conf.PropertyKey) ArrayList(java.util.ArrayList) BlockManagementTaskResult(alluxio.worker.block.management.BlockManagementTaskResult) ExecutorService(java.util.concurrent.ExecutorService) WorkerOutOfSpaceException(alluxio.exception.WorkerOutOfSpaceException) Function(com.google.common.base.Function) Logger(org.slf4j.Logger) ServerConfiguration(alluxio.conf.ServerConfiguration) BlockOrder(alluxio.worker.block.annotator.BlockOrder) Pair(alluxio.collections.Pair) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) BlockTransferInfo(alluxio.worker.block.evictor.BlockTransferInfo) BlockOperationType(alluxio.worker.block.management.BlockOperationType) List(java.util.List) StoreLoadTracker(alluxio.worker.block.management.StoreLoadTracker) BlockStore(alluxio.worker.block.BlockStore) AbstractBlockManagementTask(alluxio.worker.block.management.AbstractBlockManagementTask) Preconditions(com.google.common.base.Preconditions) BlockMetadataEvictorView(alluxio.worker.block.BlockMetadataEvictorView) Comparator(java.util.Comparator) BlockDoesNotExistException(alluxio.exception.BlockDoesNotExistException) Collections(java.util.Collections) ManagementTaskCoordinator(alluxio.worker.block.management.ManagementTaskCoordinator) BlockOperationResult(alluxio.worker.block.management.BlockOperationResult) ArrayList(java.util.ArrayList) List(java.util.List) BlockManagementTaskResult(alluxio.worker.block.management.BlockManagementTaskResult) BlockStoreLocation(alluxio.worker.block.BlockStoreLocation) WorkerOutOfSpaceException(alluxio.exception.WorkerOutOfSpaceException) WorkerOutOfSpaceException(alluxio.exception.WorkerOutOfSpaceException) BlockDoesNotExistException(alluxio.exception.BlockDoesNotExistException)

Aggregations

BlockManagementTaskResult (alluxio.worker.block.management.BlockManagementTaskResult)3 BlockOperationResult (alluxio.worker.block.management.BlockOperationResult)3 BlockDoesNotExistException (alluxio.exception.BlockDoesNotExistException)2 BlockStoreLocation (alluxio.worker.block.BlockStoreLocation)2 List (java.util.List)2 Pair (alluxio.collections.Pair)1 PropertyKey (alluxio.conf.PropertyKey)1 ServerConfiguration (alluxio.conf.ServerConfiguration)1 WorkerOutOfSpaceException (alluxio.exception.WorkerOutOfSpaceException)1 BlockMetadataEvictorView (alluxio.worker.block.BlockMetadataEvictorView)1 BlockMetadataManager (alluxio.worker.block.BlockMetadataManager)1 BlockStore (alluxio.worker.block.BlockStore)1 BlockOrder (alluxio.worker.block.annotator.BlockOrder)1 BlockTransferInfo (alluxio.worker.block.evictor.BlockTransferInfo)1 AbstractBlockManagementTask (alluxio.worker.block.management.AbstractBlockManagementTask)1 BlockOperationType (alluxio.worker.block.management.BlockOperationType)1 ManagementTaskCoordinator (alluxio.worker.block.management.ManagementTaskCoordinator)1 StoreLoadTracker (alluxio.worker.block.management.StoreLoadTracker)1 Function (com.google.common.base.Function)1 Preconditions (com.google.common.base.Preconditions)1