Search in sources :

Example 11 with Lifespan

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

the class HttpRemoteTask method processTaskUpdate.

private synchronized void processTaskUpdate(TaskInfo newValue, List<TaskSource> sources) {
    updateTaskInfo(newValue);
    // remove acknowledged splits, which frees memory
    for (TaskSource source : sources) {
        PlanNodeId planNodeId = source.getPlanNodeId();
        boolean isTableScanSource = tableScanPlanNodeIds.contains(planNodeId);
        int removed = 0;
        long removedWeight = 0;
        for (ScheduledSplit split : source.getSplits()) {
            if (pendingSplits.remove(planNodeId, split)) {
                if (isTableScanSource) {
                    removed++;
                    removedWeight = addExact(removedWeight, split.getSplit().getSplitWeight().getRawValue());
                }
            }
        }
        if (source.isNoMoreSplits()) {
            noMoreSplits.put(planNodeId, false);
        }
        for (Lifespan lifespan : source.getNoMoreSplitsForLifespan()) {
            pendingNoMoreSplitsForLifespan.remove(planNodeId, lifespan);
        }
        if (isTableScanSource) {
            pendingSourceSplitCount -= removed;
            pendingSourceSplitsWeight -= removedWeight;
        }
    }
    // Update stats before split queue space to ensure node stats are up to date before waking up the scheduler
    updateTaskStats();
    updateSplitQueueSpace();
}
Also used : PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) ScheduledSplit(com.facebook.presto.execution.ScheduledSplit) Lifespan(com.facebook.presto.execution.Lifespan) TaskSource(com.facebook.presto.execution.TaskSource)

Example 12 with Lifespan

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

the class TestHttpRemoteTask method testRegular.

@Test(timeOut = 30000, dataProvider = "thriftEncodingToggle")
public void testRegular(boolean useThriftEncoding) throws Exception {
    AtomicLong lastActivityNanos = new AtomicLong(System.nanoTime());
    TestingTaskResource testingTaskResource = new TestingTaskResource(lastActivityNanos, FailureScenario.NO_FAILURE);
    HttpRemoteTaskFactory httpRemoteTaskFactory = createHttpRemoteTaskFactory(testingTaskResource, useThriftEncoding);
    RemoteTask remoteTask = createRemoteTask(httpRemoteTaskFactory);
    testingTaskResource.setInitialTaskInfo(remoteTask.getTaskInfo());
    remoteTask.start();
    Lifespan lifespan = Lifespan.driverGroup(3);
    remoteTask.addSplits(ImmutableMultimap.of(TABLE_SCAN_NODE_ID, new Split(new ConnectorId("test"), TestingTransactionHandle.create(), TestingSplit.createLocalSplit(), lifespan, NON_CACHEABLE)));
    poll(() -> testingTaskResource.getTaskSource(TABLE_SCAN_NODE_ID) != null);
    poll(() -> testingTaskResource.getTaskSource(TABLE_SCAN_NODE_ID).getSplits().size() == 1);
    remoteTask.noMoreSplits(TABLE_SCAN_NODE_ID, lifespan);
    poll(() -> testingTaskResource.getTaskSource(TABLE_SCAN_NODE_ID).getNoMoreSplitsForLifespan().size() == 1);
    remoteTask.noMoreSplits(TABLE_SCAN_NODE_ID);
    poll(() -> testingTaskResource.getTaskSource(TABLE_SCAN_NODE_ID).isNoMoreSplits());
    remoteTask.cancel();
    poll(() -> remoteTask.getTaskStatus().getState().isDone());
    poll(() -> remoteTask.getTaskInfo().getTaskStatus().getState().isDone());
    httpRemoteTaskFactory.stop();
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) RemoteTask(com.facebook.presto.execution.RemoteTask) Split(com.facebook.presto.metadata.Split) TestingSplit(com.facebook.presto.testing.TestingSplit) Lifespan(com.facebook.presto.execution.Lifespan) ConnectorId(com.facebook.presto.spi.ConnectorId) Test(org.testng.annotations.Test)

Aggregations

Lifespan (com.facebook.presto.execution.Lifespan)12 RemoteTask (com.facebook.presto.execution.RemoteTask)4 Split (com.facebook.presto.metadata.Split)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)3 ArrayList (java.util.ArrayList)3 Optional (java.util.Optional)3 ScheduledSplit (com.facebook.presto.execution.ScheduledSplit)2 TaskSource (com.facebook.presto.execution.TaskSource)2 PagesReleasedListener (com.facebook.presto.execution.buffer.SerializedPageReference.PagesReleasedListener)2 InternalNode (com.facebook.presto.metadata.InternalNode)2 PlanNodeId (com.facebook.presto.spi.plan.PlanNodeId)2 EmptySplit (com.facebook.presto.split.EmptySplit)2 Preconditions.checkState (com.google.common.base.Preconditions.checkState)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 ImmutableSet.toImmutableSet (com.google.common.collect.ImmutableSet.toImmutableSet)2 Test (org.testng.annotations.Test)2 Page (com.facebook.presto.common.Page)1 BigintType (com.facebook.presto.common.type.BigintType)1 BIGINT (com.facebook.presto.common.type.BigintType.BIGINT)1 BufferResult.emptyResults (com.facebook.presto.execution.buffer.BufferResult.emptyResults)1