Search in sources :

Example 11 with SimpleLocalMemoryContext

use of io.prestosql.memory.context.SimpleLocalMemoryContext in project hetu-core by openlookeng.

the class AutoVacuumScanner method getQuery.

private synchronized Query getQuery(QueryId queryId, String slug) {
    // this is the first time the query has been accessed on this coordinator
    Session session = null;
    try {
        if (!queryManager.isQuerySlugValid(queryId, slug)) {
            return null;
        }
        session = queryManager.getQuerySession(queryId);
        if (null == session) {
            return null;
        }
    } catch (NoSuchElementException e) {
        return null;
    }
    ExchangeClient exchangeClient = this.exchangeClientSupplier.get(new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), DataCenterStatementResource.class.getSimpleName()));
    return Query.create(session, slug, queryManager, exchangeClient, directExecutor(), timeoutExecutor, blockEncodingSerde);
}
Also used : ExchangeClient(io.prestosql.operator.ExchangeClient) SimpleLocalMemoryContext(io.prestosql.memory.context.SimpleLocalMemoryContext) NoSuchElementException(java.util.NoSuchElementException) Session(io.prestosql.Session)

Example 12 with SimpleLocalMemoryContext

use of io.prestosql.memory.context.SimpleLocalMemoryContext in project hetu-core by openlookeng.

the class TestExchangeClient method testHappyPath.

@Test
public void testHappyPath() {
    DataSize maxResponseSize = new DataSize(10, Unit.MEGABYTE);
    MockExchangeRequestProcessor processor = new MockExchangeRequestProcessor(maxResponseSize);
    URI location = URI.create("http://localhost:8080");
    String instanceId = "testing instance id";
    processor.addPage(location, createPage(1));
    processor.addPage(location, createPage(2));
    processor.addPage(location, createPage(3));
    processor.setComplete(location);
    @SuppressWarnings("resource") ExchangeClient exchangeClient = new ExchangeClient(new DataSize(32, Unit.MEGABYTE), maxResponseSize, 1, new Duration(1, TimeUnit.MINUTES), true, new TestingHttpClient(processor, scheduler), scheduler, new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), "test"), pageBufferClientCallbackExecutor, new NoOpFailureDetector());
    exchangeClient.addLocation(new TaskLocation(location, instanceId));
    exchangeClient.noMoreLocations();
    assertEquals(exchangeClient.isClosed(), false);
    assertPageEquals(getNextPage(exchangeClient), createPage(1));
    assertEquals(exchangeClient.isClosed(), false);
    assertPageEquals(getNextPage(exchangeClient), createPage(2));
    assertEquals(exchangeClient.isClosed(), false);
    assertPageEquals(getNextPage(exchangeClient), createPage(3));
    assertNull(getNextPage(exchangeClient));
    assertEquals(exchangeClient.isClosed(), true);
    ExchangeClientStatus status = exchangeClient.getStatus();
    assertEquals(status.getBufferedPages(), 0);
    assertEquals(status.getBufferedBytes(), 0);
    // client should have sent only 2 requests: one to get all pages and once to get the done signal
    assertStatus(status.getPageBufferClientStatuses().get(0), location, "closed", 3, 3, 3, "not scheduled");
}
Also used : NoOpFailureDetector(io.prestosql.failuredetector.NoOpFailureDetector) SimpleLocalMemoryContext(io.prestosql.memory.context.SimpleLocalMemoryContext) DataSize(io.airlift.units.DataSize) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) Duration(io.airlift.units.Duration) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 13 with SimpleLocalMemoryContext

use of io.prestosql.memory.context.SimpleLocalMemoryContext in project boostkit-bigdata by kunpengcompute.

the class OmniLocalQueryRunner method createDriversWithPlanOnly.

private void createDriversWithPlanOnly(Session session, Plan plan, OutputFactory outputFactory, TaskContext taskContext) {
    if (printPlan) {
        System.out.println(PlanPrinter.textLogicalPlan(plan.getRoot(), plan.getTypes(), metadata, plan.getStatsAndCosts(), session, 0, false));
    }
    SubPlan subplan = planFragmenter.createSubPlans(session, plan, true, WarningCollector.NOOP);
    if (!subplan.getChildren().isEmpty()) {
        throw new AssertionError("Expected subplan to have no children");
    }
    NodeInfo nodeInfo = new NodeInfo("test");
    FileSystemClientManager fileSystemClientManager = new FileSystemClientManager();
    SeedStoreManager seedStoreManager = new SeedStoreManager(fileSystemClientManager);
    StateStoreProvider stateStoreProvider = new LocalStateStoreProvider(seedStoreManager);
    LocalExecutionPlanner localExecutionPlanner = new LocalExecutionPlanner(metadata, new TypeAnalyzer(sqlParser, metadata), Optional.empty(), pageSourceManager, indexManager, nodePartitioningManager, pageSinkManager, null, expressionCompiler, pageFunctionCompiler, joinFilterFunctionCompiler, new IndexJoinLookupStats(), this.taskManagerConfig, spillerFactory, singleStreamSpillerFactory, partitioningSpillerFactory, new PagesIndex.TestingFactory(false), joinCompiler, new LookupJoinOperators(), new OrderingCompiler(), nodeInfo, stateStoreProvider, new StateStoreListenerManager(stateStoreProvider), new DynamicFilterCacheManager(), heuristicIndexerManager, cubeManager);
    OmniLocalExecutionPlanner omniLocalExecutionPlanner = new OmniLocalExecutionPlanner(localExecutionPlanner);
    ScheduledExecutorService taskNotificationExecutor = newScheduledThreadPool(10, threadsNamed("task-notification-%s"));
    OutputBuffer outputBuffer = new PartitionedOutputBuffer(new StateMachine<>("bufferState", taskNotificationExecutor, OPEN, TERMINAL_BUFFER_STATES), createInitialEmptyOutputBuffers(PARTITIONED).withBuffer(new OutputBuffers.OutputBufferId(0), 0).withNoMoreBufferIds(), new DataSize(1, MEGABYTE), () -> new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), "test"), taskNotificationExecutor);
    StageExecutionDescriptor stageExecutionDescriptor = subplan.getFragment().getStageExecutionDescriptor();
    omniLocalExecutionPlanner.plan(taskContext, subplan.getFragment().getRoot(), plan.getTypes(), new PartitioningScheme(Partitioning.create(FIXED_HASH_DISTRIBUTION, ImmutableList.of()), subplan.getFragment().getRoot().getOutputSymbols(), Optional.empty(), false, Optional.of(new int[] { 1 })), stageExecutionDescriptor, subplan.getFragment().getPartitionedSources(), outputBuffer, Optional.empty(), Optional.empty(), null);
}
Also used : StateStoreListenerManager(io.prestosql.statestore.listener.StateStoreListenerManager) PagesIndex(io.prestosql.operator.PagesIndex) LocalStateStoreProvider(io.prestosql.statestore.LocalStateStoreProvider) StateStoreProvider(io.prestosql.statestore.StateStoreProvider) OutputBuffer(io.prestosql.execution.buffer.OutputBuffer) PartitionedOutputBuffer(io.prestosql.execution.buffer.PartitionedOutputBuffer) LocalStateStoreProvider(io.prestosql.statestore.LocalStateStoreProvider) OutputBuffers.createInitialEmptyOutputBuffers(io.prestosql.execution.buffer.OutputBuffers.createInitialEmptyOutputBuffers) OutputBuffers(io.prestosql.execution.buffer.OutputBuffers) SeedStoreManager(io.prestosql.seedstore.SeedStoreManager) DataSize(io.airlift.units.DataSize) OrderingCompiler(io.prestosql.sql.gen.OrderingCompiler) LookupJoinOperators(io.prestosql.operator.LookupJoinOperators) DynamicFilterCacheManager(io.prestosql.dynamicfilter.DynamicFilterCacheManager) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) LocalExecutionPlanner(io.prestosql.sql.planner.LocalExecutionPlanner) PartitionedOutputBuffer(io.prestosql.execution.buffer.PartitionedOutputBuffer) SimpleLocalMemoryContext(io.prestosql.memory.context.SimpleLocalMemoryContext) IndexJoinLookupStats(io.prestosql.operator.index.IndexJoinLookupStats) StageExecutionDescriptor(io.prestosql.operator.StageExecutionDescriptor) PartitioningScheme(io.prestosql.sql.planner.PartitioningScheme) TypeAnalyzer(io.prestosql.sql.planner.TypeAnalyzer) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) NodeInfo(io.airlift.node.NodeInfo) SubPlan(io.prestosql.sql.planner.SubPlan)

Aggregations

SimpleLocalMemoryContext (io.prestosql.memory.context.SimpleLocalMemoryContext)13 DataSize (io.airlift.units.DataSize)8 Duration (io.airlift.units.Duration)7 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)6 NoOpFailureDetector (io.prestosql.failuredetector.NoOpFailureDetector)6 Test (org.testng.annotations.Test)6 URI (java.net.URI)5 Session (io.prestosql.Session)3 ExchangeClient (io.prestosql.operator.ExchangeClient)3 QueryId (io.prestosql.spi.QueryId)3 OutputBuffers.createInitialEmptyOutputBuffers (io.prestosql.execution.buffer.OutputBuffers.createInitialEmptyOutputBuffers)2 MarkerPage (io.prestosql.spi.snapshot.MarkerPage)2 NoSuchElementException (java.util.NoSuchElementException)2 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 Ordering (com.google.common.collect.Ordering)1 X_FORWARDED_PROTO (com.google.common.net.HttpHeaders.X_FORWARDED_PROTO)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MoreExecutors.directExecutor (com.google.common.util.concurrent.MoreExecutors.directExecutor)1 BoundedExecutor (io.airlift.concurrent.BoundedExecutor)1