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());
}
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()));
}
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);
}
}
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());
}
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"));
}
Aggregations