Search in sources :

Example 1 with NodeTaskMap

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

the class TestSourcePartitionedScheduler method testBlockCausesFullSchedule.

@Test
public void testBlockCausesFullSchedule() {
    NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
    // Schedule 60 splits - filling up all nodes
    SubPlan firstPlan = createPlan();
    SqlStageExecution firstStage = createSqlStageExecution(firstPlan, nodeTaskMap);
    StageScheduler firstScheduler = getSourcePartitionedScheduler(createFixedSplitSource(60, TestingSplit::createRemoteSplit), firstStage, nodeManager, nodeTaskMap, 200);
    ScheduleResult scheduleResult = firstScheduler.schedule();
    assertEffectivelyFinished(scheduleResult, firstScheduler);
    assertTrue(scheduleResult.getBlocked().isDone());
    assertEquals(scheduleResult.getNewTasks().size(), 3);
    assertEquals(firstStage.getAllTasks().size(), 3);
    for (RemoteTask remoteTask : firstStage.getAllTasks()) {
        PartitionedSplitsInfo splitsInfo = remoteTask.getPartitionedSplitsInfo();
        assertEquals(splitsInfo.getCount(), 20);
    }
    // Schedule more splits in another query, which will block since all nodes are full
    SubPlan secondPlan = createPlan();
    SqlStageExecution secondStage = createSqlStageExecution(secondPlan, nodeTaskMap);
    StageScheduler secondScheduler = getSourcePartitionedScheduler(createFixedSplitSource(5, TestingSplit::createRemoteSplit), secondStage, nodeManager, nodeTaskMap, 200);
    scheduleResult = secondScheduler.schedule();
    assertFalse(scheduleResult.isFinished());
    assertTrue(scheduleResult.getBlocked().isDone());
    assertEquals(scheduleResult.getNewTasks().size(), 3);
    assertEquals(secondStage.getAllTasks().size(), 3);
    for (RemoteTask remoteTask : secondStage.getAllTasks()) {
        PartitionedSplitsInfo splitsInfo = remoteTask.getPartitionedSplitsInfo();
        assertEquals(splitsInfo.getCount(), 0);
    }
    firstStage.abort();
    secondStage.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 2 with NodeTaskMap

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

the class TestSourcePartitionedScheduler method testBalancedSplitAssignment.

@Test
public void testBalancedSplitAssignment() {
    // use private node manager so we can add a node later
    InMemoryNodeManager nodeManager = new InMemoryNodeManager();
    nodeManager.addNode(CONNECTOR_ID, new InternalNode("other1", URI.create("http://127.0.0.1:11"), NodeVersion.UNKNOWN, false), new InternalNode("other2", URI.create("http://127.0.0.1:12"), NodeVersion.UNKNOWN, false), new InternalNode("other3", URI.create("http://127.0.0.1:13"), NodeVersion.UNKNOWN, false));
    NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
    // Schedule 15 splits - there are 3 nodes, each node should get 5 splits
    SubPlan firstPlan = createPlan();
    SqlStageExecution firstStage = createSqlStageExecution(firstPlan, nodeTaskMap);
    StageScheduler firstScheduler = getSourcePartitionedScheduler(createFixedSplitSource(15, TestingSplit::createRemoteSplit), firstStage, nodeManager, nodeTaskMap, 200);
    ScheduleResult scheduleResult = firstScheduler.schedule();
    assertEffectivelyFinished(scheduleResult, firstScheduler);
    assertTrue(scheduleResult.getBlocked().isDone());
    assertEquals(scheduleResult.getNewTasks().size(), 3);
    assertEquals(firstStage.getAllTasks().size(), 3);
    for (RemoteTask remoteTask : firstStage.getAllTasks()) {
        PartitionedSplitsInfo splitsInfo = remoteTask.getPartitionedSplitsInfo();
        assertEquals(splitsInfo.getCount(), 5);
    }
    // Add new node
    InternalNode additionalNode = new InternalNode("other4", URI.create("http://127.0.0.1:14"), NodeVersion.UNKNOWN, false);
    nodeManager.addNode(CONNECTOR_ID, additionalNode);
    // Schedule 5 splits in another query. Since the new node does not have any splits, all 5 splits are assigned to the new node
    SubPlan secondPlan = createPlan();
    SqlStageExecution secondStage = createSqlStageExecution(secondPlan, nodeTaskMap);
    StageScheduler secondScheduler = getSourcePartitionedScheduler(createFixedSplitSource(5, TestingSplit::createRemoteSplit), secondStage, nodeManager, nodeTaskMap, 200);
    scheduleResult = secondScheduler.schedule();
    assertEffectivelyFinished(scheduleResult, secondScheduler);
    assertTrue(scheduleResult.getBlocked().isDone());
    assertEquals(scheduleResult.getNewTasks().size(), 1);
    assertEquals(secondStage.getAllTasks().size(), 1);
    RemoteTask task = secondStage.getAllTasks().get(0);
    assertEquals(task.getPartitionedSplitsInfo().getCount(), 5);
    firstStage.abort();
    secondStage.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) InternalNode(com.facebook.presto.metadata.InternalNode) SubPlan(com.facebook.presto.sql.planner.SubPlan) SqlStageExecution(com.facebook.presto.execution.SqlStageExecution) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) SourcePartitionedScheduler.newSourcePartitionedSchedulerAsStageScheduler(com.facebook.presto.execution.scheduler.SourcePartitionedScheduler.newSourcePartitionedSchedulerAsStageScheduler) Test(org.testng.annotations.Test)

Example 3 with NodeTaskMap

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

the class TestSourcePartitionedScheduler method testScheduleNoSplits.

@Test
public void testScheduleNoSplits() {
    SubPlan plan = createPlan();
    NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
    SqlStageExecution stage = createSqlStageExecution(plan, nodeTaskMap);
    StageScheduler scheduler = getSourcePartitionedScheduler(createFixedSplitSource(0, TestingSplit::createRemoteSplit), stage, nodeManager, nodeTaskMap, 1);
    ScheduleResult scheduleResult = scheduler.schedule();
    assertEquals(scheduleResult.getNewTasks().size(), 1);
    assertEffectivelyFinished(scheduleResult, scheduler);
    stage.abort();
}
Also used : NodeTaskMap(com.facebook.presto.execution.NodeTaskMap) 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 4 with NodeTaskMap

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

the class TestCostCalculator method setUp.

@BeforeClass
public void setUp() {
    TaskCountEstimator taskCountEstimator = new TaskCountEstimator(() -> NUMBER_OF_NODES);
    costCalculatorUsingExchanges = new CostCalculatorUsingExchanges(taskCountEstimator);
    costCalculatorWithEstimatedExchanges = new CostCalculatorWithEstimatedExchanges(costCalculatorUsingExchanges, taskCountEstimator);
    session = testSessionBuilder().setCatalog("tpch").build();
    CatalogManager catalogManager = new CatalogManager();
    catalogManager.registerCatalog(createBogusTestingCatalog("tpch"));
    transactionManager = createTestTransactionManager(catalogManager);
    metadata = createTestMetadataManager(transactionManager, new FeaturesConfig());
    finalizerService = new FinalizerService();
    finalizerService.start();
    nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), new InMemoryNodeManager(), new NodeSelectionStats(), new NodeSchedulerConfig().setIncludeCoordinator(true), new NodeTaskMap(finalizerService), new ThrowingNodeTtlFetcherManager(), new NoOpQueryManager(), new SimpleTtlNodeSelectorConfig());
    PartitioningProviderManager partitioningProviderManager = new PartitioningProviderManager();
    nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager, new NodeSelectionStats());
    planFragmenter = new PlanFragmenter(metadata, nodePartitioningManager, new QueryManagerConfig(), new SqlParser(), new FeaturesConfig());
}
Also used : NodeTaskMap(com.facebook.presto.execution.NodeTaskMap) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) PartitioningProviderManager(com.facebook.presto.sql.planner.PartitioningProviderManager) SqlParser(com.facebook.presto.sql.parser.SqlParser) NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) PlanFragmenter(com.facebook.presto.sql.planner.PlanFragmenter) ThrowingNodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager) CatalogManager(com.facebook.presto.metadata.CatalogManager) NodePartitioningManager(com.facebook.presto.sql.planner.NodePartitioningManager) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) NoOpQueryManager(com.facebook.presto.dispatcher.NoOpQueryManager) NodeSelectionStats(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats) FinalizerService(com.facebook.presto.util.FinalizerService) LegacyNetworkTopology(com.facebook.presto.execution.scheduler.LegacyNetworkTopology) NodeScheduler(com.facebook.presto.execution.scheduler.NodeScheduler) QueryManagerConfig(com.facebook.presto.execution.QueryManagerConfig) SimpleTtlNodeSelectorConfig(com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with NodeTaskMap

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

the class TestSourcePartitionedScheduler method testScheduleSplitsBlock.

@Test
public void testScheduleSplitsBlock() {
    SubPlan plan = createPlan();
    NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
    SqlStageExecution stage = createSqlStageExecution(plan, nodeTaskMap);
    StageScheduler scheduler = getSourcePartitionedScheduler(createFixedSplitSource(80, TestingSplit::createRemoteSplit), stage, nodeManager, nodeTaskMap, 1);
    // schedule first 60 splits, which will cause the scheduler to block
    for (int i = 0; i <= 60; i++) {
        ScheduleResult scheduleResult = scheduler.schedule();
        assertFalse(scheduleResult.isFinished());
        // blocks at 20 per node
        assertEquals(scheduleResult.getBlocked().isDone(), i != 60);
        // 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);
    }
    // todo rewrite MockRemoteTask to fire a tate transition when splits are cleared, and then validate blocked future completes
    // drop the 20 splits from one node
    ((MockRemoteTask) stage.getAllTasks().get(0)).clearSplits();
    // schedule remaining 20 splits
    for (int i = 0; i < 20; i++) {
        ScheduleResult scheduleResult = scheduler.schedule();
        // finishes when last split is fetched
        if (i == 19) {
            assertEffectivelyFinished(scheduleResult, scheduler);
        } else {
            assertFalse(scheduleResult.isFinished());
        }
        // does not block again
        assertTrue(scheduleResult.getBlocked().isDone());
        // no additional tasks will be created
        assertEquals(scheduleResult.getNewTasks().size(), 0);
        assertEquals(stage.getAllTasks().size(), 3);
        // we dropped 20 splits so start at 40 and count to 60
        assertPartitionedSplitCount(stage, min(i + 41, 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) 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)

Aggregations

NodeTaskMap (com.facebook.presto.execution.NodeTaskMap)9 SqlStageExecution (com.facebook.presto.execution.SqlStageExecution)8 SourcePartitionedScheduler.newSourcePartitionedSchedulerAsStageScheduler (com.facebook.presto.execution.scheduler.SourcePartitionedScheduler.newSourcePartitionedSchedulerAsStageScheduler)8 SubPlan (com.facebook.presto.sql.planner.SubPlan)8 Test (org.testng.annotations.Test)8 MockRemoteTask (com.facebook.presto.execution.MockRemoteTaskFactory.MockRemoteTask)5 PartitionedSplitsInfo (com.facebook.presto.execution.PartitionedSplitsInfo)5 RemoteTask (com.facebook.presto.execution.RemoteTask)5 InMemoryNodeManager (com.facebook.presto.metadata.InMemoryNodeManager)3 NoOpQueryManager (com.facebook.presto.dispatcher.NoOpQueryManager)2 NodeSelectionStats (com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats)2 SimpleTtlNodeSelectorConfig (com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig)2 TestingSplit (com.facebook.presto.testing.TestingSplit)2 ThrowingNodeTtlFetcherManager (com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager)2 QueryManagerConfig (com.facebook.presto.execution.QueryManagerConfig)1 LegacyNetworkTopology (com.facebook.presto.execution.scheduler.LegacyNetworkTopology)1 NodeScheduler (com.facebook.presto.execution.scheduler.NodeScheduler)1 NodeSchedulerConfig (com.facebook.presto.execution.scheduler.NodeSchedulerConfig)1 CatalogManager (com.facebook.presto.metadata.CatalogManager)1 InternalNode (com.facebook.presto.metadata.InternalNode)1