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