Search in sources :

Example 11 with SqlStageExecution

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

the class TestSourcePartitionedScheduler method testScheduleSplitsBatched.

@Test
public void testScheduleSplitsBatched() throws Exception {
    StageExecutionPlan plan = createPlan(createFixedSplitSource(60, TestingSplit::createRemoteSplit));
    NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
    SqlStageExecution stage = createSqlStageExecution(plan, nodeTaskMap);
    SourcePartitionedScheduler scheduler = getSourcePartitionedScheduler(plan, stage, nodeManager, nodeTaskMap, 7);
    for (int i = 0; i <= (60 / 7); i++) {
        ScheduleResult scheduleResult = scheduler.schedule();
        // finishes when last split is fetched
        assertEquals(scheduleResult.isFinished(), i == (60 / 7));
        // never blocks
        assertTrue(scheduleResult.getBlocked().isDone());
        // first three splits create new tasks
        assertEquals(scheduleResult.getNewTasks().size(), i == 0 ? 3 : 0);
        assertEquals(stage.getAllTasks().size(), 3);
        assertPartitionedSplitCount(stage, min((i + 1) * 7, 60));
    }
    for (RemoteTask remoteTask : stage.getAllTasks()) {
        assertEquals(remoteTask.getPartitionedSplitCount(), 20);
    }
    stage.abort();
}
Also used : NodeTaskMap(com.facebook.presto.execution.NodeTaskMap) StageExecutionPlan(com.facebook.presto.sql.planner.StageExecutionPlan) MockRemoteTask(com.facebook.presto.execution.MockRemoteTaskFactory.MockRemoteTask) RemoteTask(com.facebook.presto.execution.RemoteTask) SqlStageExecution(com.facebook.presto.execution.SqlStageExecution) Test(org.testng.annotations.Test)

Example 12 with SqlStageExecution

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

the class TestSourcePartitionedScheduler method testNoNodes.

@Test
public void testNoNodes() throws Exception {
    try {
        NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
        InMemoryNodeManager nodeManager = new InMemoryNodeManager();
        NodeScheduler nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), nodeManager, new NodeSchedulerConfig().setIncludeCoordinator(false), nodeTaskMap);
        StageExecutionPlan plan = createPlan(createFixedSplitSource(20, TestingSplit::createRemoteSplit));
        SqlStageExecution stage = createSqlStageExecution(plan, nodeTaskMap);
        SourcePartitionedScheduler scheduler = new SourcePartitionedScheduler(stage, Iterables.getOnlyElement(plan.getSplitSources().keySet()), Iterables.getOnlyElement(plan.getSplitSources().values()), new DynamicSplitPlacementPolicy(nodeScheduler.createNodeSelector(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) StageExecutionPlan(com.facebook.presto.sql.planner.StageExecutionPlan) PrestoException(com.facebook.presto.spi.PrestoException) SqlStageExecution(com.facebook.presto.execution.SqlStageExecution) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) Test(org.testng.annotations.Test)

Aggregations

SqlStageExecution (com.facebook.presto.execution.SqlStageExecution)12 StageExecutionPlan (com.facebook.presto.sql.planner.StageExecutionPlan)9 NodeTaskMap (com.facebook.presto.execution.NodeTaskMap)8 Test (org.testng.annotations.Test)8 MockRemoteTask (com.facebook.presto.execution.MockRemoteTaskFactory.MockRemoteTask)5 RemoteTask (com.facebook.presto.execution.RemoteTask)5 StageId (com.facebook.presto.execution.StageId)3 InMemoryNodeManager (com.facebook.presto.metadata.InMemoryNodeManager)2 Node (com.facebook.presto.spi.Node)2 PrestoException (com.facebook.presto.spi.PrestoException)2 SetThreadName (io.airlift.concurrent.SetThreadName)2 ConnectorId (com.facebook.presto.connector.ConnectorId)1 MockRemoteTaskFactory (com.facebook.presto.execution.MockRemoteTaskFactory)1 StageState (com.facebook.presto.execution.StageState)1 PrestoNode (com.facebook.presto.metadata.PrestoNode)1 QueryId (com.facebook.presto.spi.QueryId)1 SplitSource (com.facebook.presto.split.SplitSource)1 NodePartitionMap (com.facebook.presto.sql.planner.NodePartitionMap)1 PartitioningHandle (com.facebook.presto.sql.planner.PartitioningHandle)1 JoinNode (com.facebook.presto.sql.planner.plan.JoinNode)1