klsince commented on code in PR #9171:
URL: https://github.com/apache/pinot/pull/9171#discussion_r944950056


##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java:
##########
@@ -167,6 +182,60 @@ private String getDefaultBrokerId() {
     }
   }
 
+  @Override
+  public Map<Long, String> getRunningQueries() {
+    return 
_queriesById.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, e 
-> e.getValue()._query));
+  }
+
+  @VisibleForTesting
+  Set<ServerInstance> getRunningServers(long queryId) {
+    if (_queriesById.isEmpty()) {
+      return Collections.emptySet();
+    }
+    return _queriesById.get(queryId)._servers;
+  }
+
+  @Override
+  public boolean cancelQuery(long queryId, int timeoutMs, Executor executor, 
HttpConnectionManager connMgr,
+      Map<String, Integer> serverResponses) {
+    QueryRoutingTable routingTable = _queriesById.get(queryId);
+    if (routingTable == null) {
+      return false;
+    }
+    String globalId = getGlobalQueryId(queryId);
+    List<String> serverUrls = new ArrayList<>();
+    for (ServerInstance server : routingTable._servers) {
+      serverUrls.add(String.format("%s/query/%s", server.getAdminEndpoint(), 
globalId));
+    }
+    if (serverUrls.isEmpty()) {
+      LOGGER.debug("No servers running the query: {} right now", globalId);
+      return true;
+    }
+    LOGGER.debug("Cancelling the query: {} via server urls: {}", globalId, 
serverUrls);
+    CompletionService<DeleteMethod> completionService =

Review Comment:
   Good question. But I think it'd be very very rare that query cancellation 
might arrive earlier than the query being actually sent out to servers, perhaps 
when the broker gets stuck for many seconds due to GC. 
   
   For simplicity, the query can continue to run, simply missing the first 
cancel request. The user can list running queries and notice his is still 
running and just do another cancel.



-- 
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

Reply via email to