Search in sources :

Example 1 with ExchangeClient

use of io.prestosql.operator.ExchangeClient in project hetu-core by openlookeng.

the class ExecutingStatementResource method getQuery.

protected Query getQuery(QueryId queryId, String slug) {
    Query query = queries.get(queryId);
    if (query != null) {
        if (!query.isSlugValid(slug)) {
            throw badRequest(NOT_FOUND, "Query not found");
        }
        return query;
    }
    // this is the first time the query has been accessed on this coordinator
    Session session;
    try {
        if (!queryManager.isQuerySlugValid(queryId, slug)) {
            throw badRequest(NOT_FOUND, "Query not found");
        }
        session = queryManager.getQuerySession(queryId);
    } catch (NoSuchElementException e) {
        throw badRequest(NOT_FOUND, "Query not found");
    }
    query = queries.computeIfAbsent(queryId, id -> {
        ExchangeClient exchangeClient = exchangeClientSupplier.get(new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), ExecutingStatementResource.class.getSimpleName()));
        if (SystemSessionProperties.isSnapshotEnabled(session)) {
            exchangeClient.setSnapshotEnabled(snapshotUtils.getOrCreateQuerySnapshotManager(queryId, session));
        }
        return Query.create(session, slug, queryManager, exchangeClient, responseExecutor, timeoutExecutor, blockEncodingSerde);
    });
    return query;
}
Also used : Produces(javax.ws.rs.Produces) SystemSessionProperties(io.prestosql.SystemSessionProperties) Path(javax.ws.rs.Path) Duration(io.airlift.units.Duration) QueryManager(io.prestosql.execution.QueryManager) PreDestroy(javax.annotation.PreDestroy) MediaType(javax.ws.rs.core.MediaType) Executors.newSingleThreadScheduledExecutor(java.util.concurrent.Executors.newSingleThreadScheduledExecutor) QueryParam(javax.ws.rs.QueryParam) BoundedExecutor(io.airlift.concurrent.BoundedExecutor) SimpleLocalMemoryContext(io.prestosql.memory.context.SimpleLocalMemoryContext) SnapshotUtils(io.prestosql.snapshot.SnapshotUtils) HeaderParam(javax.ws.rs.HeaderParam) X_FORWARDED_PROTO(com.google.common.net.HttpHeaders.X_FORWARDED_PROTO) PRESTO_SET_ROLE(io.prestosql.client.PrestoHeaders.PRESTO_SET_ROLE) DELETE(javax.ws.rs.DELETE) Context(javax.ws.rs.core.Context) AsyncResponse(javax.ws.rs.container.AsyncResponse) NOT_FOUND(javax.ws.rs.core.Response.Status.NOT_FOUND) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Threads.threadsNamed(io.airlift.concurrent.Threads.threadsNamed) QueryStatusInfo(io.prestosql.client.QueryStatusInfo) Suspended(javax.ws.rs.container.Suspended) MoreExecutors.directExecutor(com.google.common.util.concurrent.MoreExecutors.directExecutor) DataSize(io.airlift.units.DataSize) Response(javax.ws.rs.core.Response) Entry(java.util.Map.Entry) WebApplicationException(javax.ws.rs.WebApplicationException) UriInfo(javax.ws.rs.core.UriInfo) UnsupportedEncodingException(java.io.UnsupportedEncodingException) AsyncResponseHandler.bindAsyncResponse(io.airlift.jaxrs.AsyncResponseHandler.bindAsyncResponse) AggregatedMemoryContext.newSimpleAggregatedMemoryContext(io.prestosql.memory.context.AggregatedMemoryContext.newSimpleAggregatedMemoryContext) PRESTO_CLEAR_TRANSACTION_ID(io.prestosql.client.PrestoHeaders.PRESTO_CLEAR_TRANSACTION_ID) PathParam(javax.ws.rs.PathParam) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Logger(io.airlift.log.Logger) GET(javax.ws.rs.GET) PRESTO_SET_CATALOG(io.prestosql.client.PrestoHeaders.PRESTO_SET_CATALOG) MEGABYTE(io.airlift.units.DataSize.Unit.MEGABYTE) Strings.isNullOrEmpty(com.google.common.base.Strings.isNullOrEmpty) BlockEncodingSerde(io.prestosql.spi.block.BlockEncodingSerde) PRESTO_CLEAR_SESSION(io.prestosql.client.PrestoHeaders.PRESTO_CLEAR_SESSION) ExchangeClient(io.prestosql.operator.ExchangeClient) ConcurrentMap(java.util.concurrent.ConcurrentMap) Inject(javax.inject.Inject) Objects.requireNonNull(java.util.Objects.requireNonNull) Session(io.prestosql.Session) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) QueryId(io.prestosql.spi.QueryId) NoSuchElementException(java.util.NoSuchElementException) Status(javax.ws.rs.core.Response.Status) ResponseBuilder(javax.ws.rs.core.Response.ResponseBuilder) QueryResults(io.prestosql.client.QueryResults) ForStatementResource(io.prestosql.server.ForStatementResource) PRESTO_SET_PATH(io.prestosql.client.PrestoHeaders.PRESTO_SET_PATH) PRESTO_STARTED_TRANSACTION_ID(io.prestosql.client.PrestoHeaders.PRESTO_STARTED_TRANSACTION_ID) TEXT_PLAIN_TYPE(javax.ws.rs.core.MediaType.TEXT_PLAIN_TYPE) Futures(com.google.common.util.concurrent.Futures) URLEncoder(java.net.URLEncoder) PRESTO_SET_SCHEMA(io.prestosql.client.PrestoHeaders.PRESTO_SET_SCHEMA) PRESTO_ADDED_PREPARE(io.prestosql.client.PrestoHeaders.PRESTO_ADDED_PREPARE) Ordering(com.google.common.collect.Ordering) ExchangeClientSupplier(io.prestosql.operator.ExchangeClientSupplier) PRESTO_DEALLOCATED_PREPARE(io.prestosql.client.PrestoHeaders.PRESTO_DEALLOCATED_PREPARE) PRESTO_SET_SESSION(io.prestosql.client.PrestoHeaders.PRESTO_SET_SESSION) SECONDS(java.util.concurrent.TimeUnit.SECONDS) ExchangeClient(io.prestosql.operator.ExchangeClient) SimpleLocalMemoryContext(io.prestosql.memory.context.SimpleLocalMemoryContext) NoSuchElementException(java.util.NoSuchElementException) Session(io.prestosql.Session)

Example 2 with ExchangeClient

use of io.prestosql.operator.ExchangeClient in project hetu-core by openlookeng.

the class PagePublisherQueryRunner method getQuery.

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

Example 3 with ExchangeClient

use of io.prestosql.operator.ExchangeClient 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)

Aggregations

Session (io.prestosql.Session)3 SimpleLocalMemoryContext (io.prestosql.memory.context.SimpleLocalMemoryContext)3 ExchangeClient (io.prestosql.operator.ExchangeClient)3 NoSuchElementException (java.util.NoSuchElementException)3 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 Threads.threadsNamed (io.airlift.concurrent.Threads.threadsNamed)1 AsyncResponseHandler.bindAsyncResponse (io.airlift.jaxrs.AsyncResponseHandler.bindAsyncResponse)1 Logger (io.airlift.log.Logger)1 DataSize (io.airlift.units.DataSize)1 MEGABYTE (io.airlift.units.DataSize.Unit.MEGABYTE)1 Duration (io.airlift.units.Duration)1 SystemSessionProperties (io.prestosql.SystemSessionProperties)1 PRESTO_ADDED_PREPARE (io.prestosql.client.PrestoHeaders.PRESTO_ADDED_PREPARE)1 PRESTO_CLEAR_SESSION (io.prestosql.client.PrestoHeaders.PRESTO_CLEAR_SESSION)1