Search in sources :

Example 21 with SqlStageExecution

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

the class TestSourcePartitionedScheduler method testScheduleSplitsOneAtATime.

@Test
public void testScheduleSplitsOneAtATime() {
    SubPlan plan = createPlan();
    NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
    SqlStageExecution stage = createSqlStageExecution(plan, nodeTaskMap);
    StageScheduler scheduler = getSourcePartitionedScheduler(createFixedSplitSource(60, TestingSplit::createRemoteSplit), stage, nodeManager, nodeTaskMap, 1);
    for (int i = 0; i < 60; i++) {
        ScheduleResult scheduleResult = scheduler.schedule();
        // only finishes when last split is fetched
        if (i == 59) {
            assertEffectivelyFinished(scheduleResult, scheduler);
        } else {
            assertFalse(scheduleResult.isFinished());
        }
        // never blocks
        assertTrue(scheduleResult.getBlocked().isDone());
        // first three splits create new tasks
        assertEquals(scheduleResult.getNewTasks().size(), i < 3 ? 1 : 0);
        assertEquals(stage.getAllTasks().size(), i < 3 ? i + 1 : 3);
        assertPartitionedSplitCount(stage, min(i + 1, 60));
    }
    for (RemoteTask remoteTask : stage.getAllTasks()) {
        PartitionedSplitsInfo splitsInfo = remoteTask.getPartitionedSplitsInfo();
        assertEquals(splitsInfo.getCount(), 20);
    }
    stage.abort();
}
Also used : NodeTaskMap(com.facebook.presto.execution.NodeTaskMap) PartitionedSplitsInfo(com.facebook.presto.execution.PartitionedSplitsInfo) MockRemoteTask(com.facebook.presto.execution.MockRemoteTaskFactory.MockRemoteTask) RemoteTask(com.facebook.presto.execution.RemoteTask) SubPlan(com.facebook.presto.sql.planner.SubPlan) SqlStageExecution(com.facebook.presto.execution.SqlStageExecution) SourcePartitionedScheduler.newSourcePartitionedSchedulerAsStageScheduler(com.facebook.presto.execution.scheduler.SourcePartitionedScheduler.newSourcePartitionedSchedulerAsStageScheduler) Test(org.testng.annotations.Test)

Example 22 with SqlStageExecution

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

the class TestSourcePartitionedScheduler method testNoNodes.

@Test
public void testNoNodes() {
    try {
        NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
        InMemoryNodeManager nodeManager = new InMemoryNodeManager();
        NodeScheduler nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), nodeManager, new NodeSelectionStats(), new NodeSchedulerConfig().setIncludeCoordinator(false), nodeTaskMap, new ThrowingNodeTtlFetcherManager(), new NoOpQueryManager(), new SimpleTtlNodeSelectorConfig());
        SubPlan plan = createPlan();
        SqlStageExecution stage = createSqlStageExecution(plan, nodeTaskMap);
        StageScheduler scheduler = newSourcePartitionedSchedulerAsStageScheduler(stage, TABLE_SCAN_NODE_ID, new ConnectorAwareSplitSource(CONNECTOR_ID, TestingTransactionHandle.create(), createFixedSplitSource(20, TestingSplit::createRemoteSplit)), new DynamicSplitPlacementPolicy(nodeScheduler.createNodeSelector(TestingSession.testSessionBuilder().build(), CONNECTOR_ID), stage::getAllTasks), 2);
        scheduler.schedule();
        fail("expected PrestoException");
    } catch (PrestoException e) {
        assertEquals(e.getErrorCode(), NO_NODES_AVAILABLE.toErrorCode());
    }
}
Also used : NodeTaskMap(com.facebook.presto.execution.NodeTaskMap) PrestoException(com.facebook.presto.spi.PrestoException) ThrowingNodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager) SqlStageExecution(com.facebook.presto.execution.SqlStageExecution) ConnectorAwareSplitSource(com.facebook.presto.split.ConnectorAwareSplitSource) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) SourcePartitionedScheduler.newSourcePartitionedSchedulerAsStageScheduler(com.facebook.presto.execution.scheduler.SourcePartitionedScheduler.newSourcePartitionedSchedulerAsStageScheduler) NoOpQueryManager(com.facebook.presto.dispatcher.NoOpQueryManager) NodeSelectionStats(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats) TestingSplit(com.facebook.presto.testing.TestingSplit) SimpleTtlNodeSelectorConfig(com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig) SubPlan(com.facebook.presto.sql.planner.SubPlan) Test(org.testng.annotations.Test)

Example 23 with SqlStageExecution

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

the class TestSourcePartitionedScheduler method testScheduleSlowSplitSource.

@Test
public void testScheduleSlowSplitSource() {
    QueuedSplitSource queuedSplitSource = new QueuedSplitSource(TestingSplit::createRemoteSplit);
    SubPlan plan = createPlan();
    NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
    SqlStageExecution stage = createSqlStageExecution(plan, nodeTaskMap);
    StageScheduler scheduler = getSourcePartitionedScheduler(queuedSplitSource, stage, nodeManager, nodeTaskMap, 1);
    // schedule with no splits - will block
    ScheduleResult scheduleResult = scheduler.schedule();
    assertFalse(scheduleResult.isFinished());
    assertFalse(scheduleResult.getBlocked().isDone());
    assertEquals(scheduleResult.getNewTasks().size(), 0);
    assertEquals(stage.getAllTasks().size(), 0);
    queuedSplitSource.addSplits(1);
    assertTrue(scheduleResult.getBlocked().isDone());
}
Also used : NodeTaskMap(com.facebook.presto.execution.NodeTaskMap) TestingSplit(com.facebook.presto.testing.TestingSplit) SubPlan(com.facebook.presto.sql.planner.SubPlan) SqlStageExecution(com.facebook.presto.execution.SqlStageExecution) SourcePartitionedScheduler.newSourcePartitionedSchedulerAsStageScheduler(com.facebook.presto.execution.scheduler.SourcePartitionedScheduler.newSourcePartitionedSchedulerAsStageScheduler) Test(org.testng.annotations.Test)

Aggregations

SqlStageExecution (com.facebook.presto.execution.SqlStageExecution)23 SourcePartitionedScheduler.newSourcePartitionedSchedulerAsStageScheduler (com.facebook.presto.execution.scheduler.SourcePartitionedScheduler.newSourcePartitionedSchedulerAsStageScheduler)10 SubPlan (com.facebook.presto.sql.planner.SubPlan)10 NodeTaskMap (com.facebook.presto.execution.NodeTaskMap)9 RemoteTask (com.facebook.presto.execution.RemoteTask)8 StageId (com.facebook.presto.execution.StageId)8 Test (org.testng.annotations.Test)8 PrestoException (com.facebook.presto.spi.PrestoException)6 ImmutableList (com.google.common.collect.ImmutableList)5 ImmutableSet (com.google.common.collect.ImmutableSet)5 SetThreadName (com.facebook.airlift.concurrent.SetThreadName)4 PlanFragmentId (com.facebook.presto.sql.planner.plan.PlanFragmentId)4 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)4 Session (com.facebook.presto.Session)3 MockRemoteTask (com.facebook.presto.execution.MockRemoteTaskFactory.MockRemoteTask)3 PartitionedSplitsInfo (com.facebook.presto.execution.PartitionedSplitsInfo)3 RemoteTaskFactory (com.facebook.presto.execution.RemoteTaskFactory)3 StageExecutionInfo (com.facebook.presto.execution.StageExecutionInfo)3 StageExecutionState (com.facebook.presto.execution.StageExecutionState)3 StageInfo (com.facebook.presto.execution.StageInfo)3