klsince commented on code in PR #9171: URL: https://github.com/apache/pinot/pull/9171#discussion_r940776949
########## pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java: ########## @@ -141,6 +152,50 @@ public void processSqlQueryPost(String query, @Suspended AsyncResponse asyncResp } } + @DELETE + @Path("query/{queryId}") + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Cancel a query as identified by the queryId", notes = "No effect if no query exists for the " + + "given queryId on the requested broker. Query may continue to run for a short while after calling cancel as " + + "it's done in a non-blocking manner. The cancel method can be called multiple times.") + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error"), + @ApiResponse(code = 404, message = "Query not found on the requested broker") + }) + public String cancelQuery( + @ApiParam(value = "QueryId as in the format of <brokerId>_<requestId>", required = true) @PathParam("queryId") + String queryId, + @ApiParam(value = "Timeout for servers to respond the cancel request") @QueryParam("timeoutMs") + @DefaultValue("3000") int timeoutMs, + @ApiParam(value = "Return server responses for troubleshooting") @QueryParam("detailed") @DefaultValue("false") + boolean detailed) { + Map<String, Integer> serverResponses = null; + if (detailed) { + serverResponses = new HashMap<>(); + } + if (!_requestHandler.cancelQuery(queryId, timeoutMs, _executor, _httpConnMgr, serverResponses)) { + throw new WebApplicationException( + Response.status(Response.Status.NOT_FOUND).entity("Query: " + queryId + " not found on the broker").build()); + } + String resp = "Cancelled query: " + queryId; + if (detailed) { + resp += " with responses from servers: " + serverResponses; + } + return resp; + } + + @GET + @Path("queries") + @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Get queryIds of the running queries submitted via this broker", notes = "QueryIds are in the" + + " format of <brokerId>_<requestId>") Review Comment: This is a good point. Broker doesn’t need to prepend its broker id to form the query id to track queries submitted to it. I carried the server side way of forming unique query id here. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org