use of org.apache.drill.exec.proto.GeneralRPCProtos.Ack in project drill by apache.
the class ProfileResources method cancelQuery.
@GET
@Path("/profiles/cancel/{queryid}")
@Produces(MediaType.TEXT_PLAIN)
public String cancelQuery(@PathParam("queryid") String queryId) {
QueryId id = QueryIdHelper.getQueryIdFromString(queryId);
// Prevent XSS
String encodedQueryID = forHtml(queryId);
// first check local running
if (work.getBee().cancelForeman(id, principal)) {
return String.format("Cancelled query %s on locally running node.", encodedQueryID);
}
// then check remote running
try {
final TransientStore<QueryInfo> running = work.getContext().getProfileStoreContext().getRunningProfileStore();
final QueryInfo info = running.get(queryId);
checkOrThrowQueryCancelAuthorization(info.getUser(), queryId);
Ack a = work.getContext().getController().getTunnel(info.getForeman()).requestCancelQuery(id).checkedGet(2, TimeUnit.SECONDS);
if (a.getOk()) {
return String.format("Query %s canceled on node %s.", encodedQueryID, info.getForeman().getAddress());
} else {
return String.format("Attempted to cancel query %s on %s but the query is no longer active on that node.", encodedQueryID, info.getForeman().getAddress());
}
} catch (Exception e) {
logger.debug("Failure to find query as running profile.", e);
return String.format("Failure attempting to cancel query %s. Unable to find information about where query is actively running.", encodedQueryID);
}
}
Aggregations