dlmarion commented on code in PR #5697:
URL: https://github.com/apache/accumulo/pull/5697#discussion_r2180475224


##########
minicluster/src/main/java/org/apache/accumulo/miniclusterImpl/MiniAccumuloClusterImpl.java:
##########
@@ -1094,6 +1098,35 @@ protected ExecutorService getShutdownExecutor() {
     return executor;
   }
 
+  public void stopProcessesWithTimeout(final ServerType type, final 
List<Process> procs,
+      final long timeout, final TimeUnit unit) {
+
+    final List<Future<Integer>> futures = new ArrayList<>();
+    for (Process proc : procs) {
+      futures.add(executor.submit(() -> {
+        proc.destroy();
+        proc.waitFor(timeout, unit);
+        return proc.exitValue();
+      }));
+    }
+
+    while (!futures.isEmpty()) {
+      Iterator<Future<Integer>> iter = futures.iterator();
+      while (iter.hasNext()) {
+        Future<Integer> f = iter.next();
+        if (f.isDone()) {

Review Comment:
   
[This](https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/concurrent/AbstractExecutorService.java#L263)
 is the implementation of `invokeAll`. It's going to wait on `f.get()` to 
return for each task. I think it's functionally equivalent to what I have here 
at this point.



-- 
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: notifications-unsubscr...@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to