Search in sources :

Example 1 with SplitRunner

use of com.facebook.presto.execution.SplitRunner in project presto by prestodb.

the class TaskExecutor method enqueueSplits.

public List<ListenableFuture<?>> enqueueSplits(TaskHandle taskHandle, boolean intermediate, List<? extends SplitRunner> taskSplits) {
    List<PrioritizedSplitRunner> splitsToDestroy = new ArrayList<>();
    List<ListenableFuture<?>> finishedFutures = new ArrayList<>(taskSplits.size());
    synchronized (this) {
        for (SplitRunner taskSplit : taskSplits) {
            PrioritizedSplitRunner prioritizedSplitRunner = new PrioritizedSplitRunner(taskHandle, taskSplit, ticker, globalCpuTimeMicros, globalScheduledTimeMicros, blockedQuantaWallTime, unblockedQuantaWallTime);
            if (taskHandle.isDestroyed()) {
                // If the handle is destroyed, we destroy the task splits to complete the future
                splitsToDestroy.add(prioritizedSplitRunner);
            } else if (intermediate) {
                // Note: we do not record queued time for intermediate splits
                startIntermediateSplit(prioritizedSplitRunner);
                // add the runner to the handle so it can be destroyed if the task is canceled
                taskHandle.recordIntermediateSplit(prioritizedSplitRunner);
            } else {
                // add this to the work queue for the task
                taskHandle.enqueueSplit(prioritizedSplitRunner);
                // if task is under the limit for guaranteed splits, start one
                scheduleTaskIfNecessary(taskHandle);
                // if globally we have more resources, start more
                addNewEntrants();
            }
            finishedFutures.add(prioritizedSplitRunner.getFinishedFuture());
        }
    }
    for (PrioritizedSplitRunner split : splitsToDestroy) {
        split.destroy();
    }
    return finishedFutures;
}
Also used : ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) SplitRunner(com.facebook.presto.execution.SplitRunner)

Aggregations

SplitRunner (com.facebook.presto.execution.SplitRunner)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ArrayList (java.util.ArrayList)1