Search in sources :

Example 1 with ExchangeHandleResolver

use of io.trino.metadata.ExchangeHandleResolver in project trino by trinodb.

the class TestSqlTask method createInitialTask.

private SqlTask createInitialTask() {
    TaskId taskId = new TaskId(new StageId("query", 0), nextTaskId.incrementAndGet(), 0);
    URI location = URI.create("fake://task/" + taskId);
    QueryContext queryContext = new QueryContext(new QueryId("query"), DataSize.of(1, MEGABYTE), new MemoryPool(DataSize.of(1, GIGABYTE)), new TestingGcMonitor(), taskNotificationExecutor, driverYieldExecutor, DataSize.of(1, MEGABYTE), new SpillSpaceTracker(DataSize.of(1, GIGABYTE)));
    queryContext.addTaskContext(new TaskStateMachine(taskId, taskNotificationExecutor), testSessionBuilder().build(), () -> {
    }, false, false);
    return createSqlTask(taskId, location, "fake", queryContext, sqlTaskExecutionFactory, taskNotificationExecutor, sqlTask -> {
    }, DataSize.of(32, MEGABYTE), DataSize.of(200, MEGABYTE), new ExchangeManagerRegistry(new ExchangeHandleResolver()), new CounterStat());
}
Also used : SpillSpaceTracker(io.trino.spiller.SpillSpaceTracker) CounterStat(io.airlift.stats.CounterStat) QueryId(io.trino.spi.QueryId) TestingGcMonitor(io.airlift.stats.TestingGcMonitor) QueryContext(io.trino.memory.QueryContext) URI(java.net.URI) ExchangeManagerRegistry(io.trino.exchange.ExchangeManagerRegistry) ExchangeHandleResolver(io.trino.metadata.ExchangeHandleResolver) MemoryPool(io.trino.memory.MemoryPool)

Example 2 with ExchangeHandleResolver

use of io.trino.metadata.ExchangeHandleResolver in project trino by trinodb.

the class TaskTestUtils method createTestingPlanner.

public static LocalExecutionPlanner createTestingPlanner() {
    PageSourceManager pageSourceManager = new PageSourceManager();
    pageSourceManager.addConnectorPageSourceProvider(CONNECTOR_ID, new TestingPageSourceProvider());
    // we don't start the finalizer so nothing will be collected, which is ok for a test
    FinalizerService finalizerService = new FinalizerService();
    BlockTypeOperators blockTypeOperators = new BlockTypeOperators(PLANNER_CONTEXT.getTypeOperators());
    NodeScheduler nodeScheduler = new NodeScheduler(new UniformNodeSelectorFactory(new InMemoryNodeManager(), new NodeSchedulerConfig().setIncludeCoordinator(true), new NodeTaskMap(finalizerService)));
    NodePartitioningManager nodePartitioningManager = new NodePartitioningManager(nodeScheduler, blockTypeOperators);
    PageFunctionCompiler pageFunctionCompiler = new PageFunctionCompiler(PLANNER_CONTEXT.getFunctionManager(), 0);
    return new LocalExecutionPlanner(PLANNER_CONTEXT, createTestingTypeAnalyzer(PLANNER_CONTEXT), Optional.empty(), pageSourceManager, new IndexManager(), nodePartitioningManager, new PageSinkManager(), new MockDirectExchangeClientSupplier(), new ExpressionCompiler(PLANNER_CONTEXT.getFunctionManager(), pageFunctionCompiler), pageFunctionCompiler, new JoinFilterFunctionCompiler(PLANNER_CONTEXT.getFunctionManager()), new IndexJoinLookupStats(), new TaskManagerConfig(), new GenericSpillerFactory((types, spillContext, memoryContext) -> {
        throw new UnsupportedOperationException();
    }), (types, spillContext, memoryContext) -> {
        throw new UnsupportedOperationException();
    }, (types, partitionFunction, spillContext, memoryContext) -> {
        throw new UnsupportedOperationException();
    }, new PagesIndex.TestingFactory(false), new JoinCompiler(PLANNER_CONTEXT.getTypeOperators()), new TrinoOperatorFactories(), new OrderingCompiler(PLANNER_CONTEXT.getTypeOperators()), new DynamicFilterConfig(), blockTypeOperators, new TableExecuteContextManager(), new ExchangeManagerRegistry(new ExchangeHandleResolver()));
}
Also used : PlanFragment(io.trino.sql.planner.PlanFragment) JoinFilterFunctionCompiler(io.trino.sql.gen.JoinFilterFunctionCompiler) ObjectMapperProvider(io.airlift.json.ObjectMapperProvider) CatalogName(io.trino.connector.CatalogName) NodeScheduler(io.trino.execution.scheduler.NodeScheduler) FinalizerService(io.trino.util.FinalizerService) PlanNodeId(io.trino.sql.planner.plan.PlanNodeId) TEST_SESSION(io.trino.SessionTestUtils.TEST_SESSION) SINGLE_DISTRIBUTION(io.trino.sql.planner.SystemPartitioningHandle.SINGLE_DISTRIBUTION) TableScanNode(io.trino.sql.planner.plan.TableScanNode) ImmutableMap(com.google.common.collect.ImmutableMap) NodeSchedulerConfig(io.trino.execution.scheduler.NodeSchedulerConfig) PageSinkManager(io.trino.split.PageSinkManager) PageFunctionCompiler(io.trino.sql.gen.PageFunctionCompiler) TrinoOperatorFactories(io.trino.operator.TrinoOperatorFactories) UniformNodeSelectorFactory(io.trino.execution.scheduler.UniformNodeSelectorFactory) IndexJoinLookupStats(io.trino.operator.index.IndexJoinLookupStats) SplitMonitor(io.trino.event.SplitMonitor) MockDirectExchangeClientSupplier(io.trino.execution.TestSqlTaskManager.MockDirectExchangeClientSupplier) List(java.util.List) BIGINT(io.trino.spi.type.BigintType.BIGINT) Split(io.trino.metadata.Split) InMemoryNodeManager(io.trino.metadata.InMemoryNodeManager) Optional(java.util.Optional) PlanFragmentId(io.trino.sql.planner.plan.PlanFragmentId) TestingColumnHandle(io.trino.testing.TestingMetadata.TestingColumnHandle) TypeAnalyzer.createTestingTypeAnalyzer(io.trino.sql.planner.TypeAnalyzer.createTestingTypeAnalyzer) OrderingCompiler(io.trino.sql.gen.OrderingCompiler) NodePartitioningManager(io.trino.sql.planner.NodePartitioningManager) JoinCompiler(io.trino.sql.gen.JoinCompiler) ExchangeHandleResolver(io.trino.metadata.ExchangeHandleResolver) Partitioning(io.trino.sql.planner.Partitioning) PartitioningScheme(io.trino.sql.planner.PartitioningScheme) StatsAndCosts(io.trino.cost.StatsAndCosts) ExpressionCompiler(io.trino.sql.gen.ExpressionCompiler) VARCHAR(io.trino.spi.type.VarcharType.VARCHAR) ImmutableList(com.google.common.collect.ImmutableList) TestingSplit(io.trino.testing.TestingSplit) StageExecutionDescriptor.ungroupedExecution(io.trino.operator.StageExecutionDescriptor.ungroupedExecution) EventListenerConfig(io.trino.eventlistener.EventListenerConfig) IndexManager(io.trino.index.IndexManager) PagesIndex(io.trino.operator.PagesIndex) Symbol(io.trino.sql.planner.Symbol) BlockTypeOperators(io.trino.type.BlockTypeOperators) GenericSpillerFactory(io.trino.spiller.GenericSpillerFactory) PageSourceManager(io.trino.split.PageSourceManager) LocalExecutionPlanner(io.trino.sql.planner.LocalExecutionPlanner) PLANNER_CONTEXT(io.trino.sql.planner.TestingPlannerContext.PLANNER_CONTEXT) EventListenerManager(io.trino.eventlistener.EventListenerManager) TEST_TABLE_HANDLE(io.trino.testing.TestingHandles.TEST_TABLE_HANDLE) OutputBuffers(io.trino.execution.buffer.OutputBuffers) SOURCE_DISTRIBUTION(io.trino.sql.planner.SystemPartitioningHandle.SOURCE_DISTRIBUTION) ExchangeManagerRegistry(io.trino.exchange.ExchangeManagerRegistry) PageFunctionCompiler(io.trino.sql.gen.PageFunctionCompiler) MockDirectExchangeClientSupplier(io.trino.execution.TestSqlTaskManager.MockDirectExchangeClientSupplier) TrinoOperatorFactories(io.trino.operator.TrinoOperatorFactories) NodeSchedulerConfig(io.trino.execution.scheduler.NodeSchedulerConfig) PagesIndex(io.trino.operator.PagesIndex) PageSourceManager(io.trino.split.PageSourceManager) NodePartitioningManager(io.trino.sql.planner.NodePartitioningManager) ExchangeHandleResolver(io.trino.metadata.ExchangeHandleResolver) BlockTypeOperators(io.trino.type.BlockTypeOperators) OrderingCompiler(io.trino.sql.gen.OrderingCompiler) NodeScheduler(io.trino.execution.scheduler.NodeScheduler) GenericSpillerFactory(io.trino.spiller.GenericSpillerFactory) PageSinkManager(io.trino.split.PageSinkManager) JoinCompiler(io.trino.sql.gen.JoinCompiler) LocalExecutionPlanner(io.trino.sql.planner.LocalExecutionPlanner) IndexJoinLookupStats(io.trino.operator.index.IndexJoinLookupStats) UniformNodeSelectorFactory(io.trino.execution.scheduler.UniformNodeSelectorFactory) JoinFilterFunctionCompiler(io.trino.sql.gen.JoinFilterFunctionCompiler) ExchangeManagerRegistry(io.trino.exchange.ExchangeManagerRegistry) InMemoryNodeManager(io.trino.metadata.InMemoryNodeManager) IndexManager(io.trino.index.IndexManager) FinalizerService(io.trino.util.FinalizerService) ExpressionCompiler(io.trino.sql.gen.ExpressionCompiler)

Example 3 with ExchangeHandleResolver

use of io.trino.metadata.ExchangeHandleResolver in project trino by trinodb.

the class TestDeduplicatingDirectExchangeBuffer method testExchangeManagerNotConfigured.

@Test
public void testExchangeManagerNotConfigured() {
    // no overflow
    try (DirectExchangeBuffer buffer = new DeduplicatingDirectExchangeBuffer(directExecutor(), DataSize.of(100, BYTE), RetryPolicy.QUERY, new ExchangeManagerRegistry(new ExchangeHandleResolver()), new QueryId("query"), createRandomExchangeId())) {
        TaskId task = createTaskId(0, 0);
        Slice page = createPage("1234", DataSize.of(10, BYTE));
        buffer.addTask(task);
        buffer.addPages(task, ImmutableList.of(page));
        buffer.taskFinished(task);
        buffer.noMoreTasks();
        assertFalse(buffer.isFinished());
        assertNotBlocked(buffer.isBlocked());
        assertEquals(buffer.pollPage(), page);
        assertNull(buffer.pollPage());
        assertTrue(buffer.isFinished());
    }
    // overflow
    try (DirectExchangeBuffer buffer = new DeduplicatingDirectExchangeBuffer(directExecutor(), DataSize.of(100, BYTE), RetryPolicy.QUERY, new ExchangeManagerRegistry(new ExchangeHandleResolver()), new QueryId("query"), createRandomExchangeId())) {
        TaskId task = createTaskId(0, 0);
        Slice page1 = utf8Slice("1234");
        Slice page2 = utf8Slice("123456789");
        assertThat(page1.getRetainedSize()).isLessThanOrEqualTo(100);
        assertThat(page1.getRetainedSize() + page2.getRetainedSize()).isGreaterThan(100);
        buffer.addTask(task);
        buffer.addPages(task, ImmutableList.of(page1));
        assertFalse(buffer.isFinished());
        assertBlocked(buffer.isBlocked());
        assertEquals(buffer.getRetainedSizeInBytes(), page1.getRetainedSize());
        buffer.addPages(task, ImmutableList.of(page2));
        assertFalse(buffer.isFinished());
        assertTrue(buffer.isFailed());
        assertNotBlocked(buffer.isBlocked());
        assertEquals(buffer.getRetainedSizeInBytes(), 0);
        assertEquals(buffer.getBufferedPageCount(), 0);
        assertThatThrownBy(buffer::pollPage).isInstanceOf(TrinoException.class);
    }
}
Also used : TaskId(io.trino.execution.TaskId) Slice(io.airlift.slice.Slice) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) QueryId(io.trino.spi.QueryId) ExchangeManagerRegistry(io.trino.exchange.ExchangeManagerRegistry) ExchangeHandleResolver(io.trino.metadata.ExchangeHandleResolver) Test(org.testng.annotations.Test)

Example 4 with ExchangeHandleResolver

use of io.trino.metadata.ExchangeHandleResolver in project trino by trinodb.

the class TestMemoryRevokingScheduler method newSqlTask.

private SqlTask newSqlTask(QueryId queryId) {
    QueryContext queryContext = getOrCreateQueryContext(queryId);
    TaskId taskId = new TaskId(new StageId(queryId.getId(), 0), idGeneator.incrementAndGet(), 0);
    URI location = URI.create("fake://task/" + taskId);
    return createSqlTask(taskId, location, "fake", queryContext, sqlTaskExecutionFactory, executor, sqlTask -> {
    }, DataSize.of(32, MEGABYTE), DataSize.of(200, MEGABYTE), new ExchangeManagerRegistry(new ExchangeHandleResolver()), new CounterStat());
}
Also used : CounterStat(io.airlift.stats.CounterStat) QueryContext(io.trino.memory.QueryContext) URI(java.net.URI) ExchangeManagerRegistry(io.trino.exchange.ExchangeManagerRegistry) ExchangeHandleResolver(io.trino.metadata.ExchangeHandleResolver)

Example 5 with ExchangeHandleResolver

use of io.trino.metadata.ExchangeHandleResolver in project trino by trinodb.

the class TestDeduplicatingDirectExchangeBuffer method beforeClass.

@BeforeClass
public void beforeClass() {
    exchangeManagerRegistry = new ExchangeManagerRegistry(new ExchangeHandleResolver());
    exchangeManagerRegistry.addExchangeManagerFactory(new FileSystemExchangeManagerFactory());
    exchangeManagerRegistry.loadExchangeManager("filesystem", ImmutableMap.of("exchange.base-directory", System.getProperty("java.io.tmpdir") + "/trino-local-file-system-exchange-manager"));
}
Also used : FileSystemExchangeManagerFactory(io.trino.plugin.exchange.FileSystemExchangeManagerFactory) ExchangeManagerRegistry(io.trino.exchange.ExchangeManagerRegistry) ExchangeHandleResolver(io.trino.metadata.ExchangeHandleResolver) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

ExchangeManagerRegistry (io.trino.exchange.ExchangeManagerRegistry)9 ExchangeHandleResolver (io.trino.metadata.ExchangeHandleResolver)9 QueryId (io.trino.spi.QueryId)4 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)3 TaskId (io.trino.execution.TaskId)3 URI (java.net.URI)3 Slice (io.airlift.slice.Slice)2 CounterStat (io.airlift.stats.CounterStat)2 DataSize (io.airlift.units.DataSize)2 Duration (io.airlift.units.Duration)2 StageId (io.trino.execution.StageId)2 QueryContext (io.trino.memory.QueryContext)2 SimpleLocalMemoryContext (io.trino.memory.context.SimpleLocalMemoryContext)2 Test (org.testng.annotations.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ObjectMapperProvider (io.airlift.json.ObjectMapperProvider)1 NodeInfo (io.airlift.node.NodeInfo)1 Slices.utf8Slice (io.airlift.slice.Slices.utf8Slice)1 TestingGcMonitor (io.airlift.stats.TestingGcMonitor)1