Search in sources :

Example 1 with DataCenterResponse

use of io.prestosql.client.DataCenterResponse in project hetu-core by openlookeng.

the class DataCenterStatementResource method postStatement.

@POST
@Path("/v1/dc/statement/{globalQueryId}")
@Produces(APPLICATION_JSON)
public synchronized Response postStatement(@PathParam("globalQueryId") String globalQueryId, DataCenterRequest request, @Context HttpServletRequest servletRequest, @Context UriInfo uriInfo) {
    if (isNull(request)) {
        throw badRequest(BAD_REQUEST, "SQL statement is empty");
    }
    SessionContext context = new HttpRequestSessionContext(servletRequest, groupProvider);
    DataCenterResponse response;
    try {
        PagePublisherQueryRunner queryRunner = this.queryManager.submit(globalQueryId, request.getQuery(), request.getClientId(), request.getMaxAnticipatedDelay(), context);
        if (queryRunner != null) {
            response = new DataCenterResponse(DataCenterResponse.State.SUBMITTED, queryRunner.getSlug(), queryRunner.getConsumer(request.getClientId()) != null);
        } else {
            response = new DataCenterResponse(DataCenterResponse.State.FINISHED_ALREADY, null, false);
        }
    } catch (IllegalStateException ex) {
        response = new DataCenterResponse(DataCenterResponse.State.FINISHED_ALREADY, null, false);
    }
    return Response.ok(response).build();
}
Also used : DataCenterResponse(io.prestosql.client.DataCenterResponse) HttpRequestSessionContext(io.prestosql.server.HttpRequestSessionContext) SessionContext(io.prestosql.server.SessionContext) HttpRequestSessionContext(io.prestosql.server.HttpRequestSessionContext) PagePublisherQueryRunner(io.prestosql.server.protocol.PagePublisherQueryRunner) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

DataCenterResponse (io.prestosql.client.DataCenterResponse)1 HttpRequestSessionContext (io.prestosql.server.HttpRequestSessionContext)1 SessionContext (io.prestosql.server.SessionContext)1 PagePublisherQueryRunner (io.prestosql.server.protocol.PagePublisherQueryRunner)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1