keith-turner commented on code in PR #5697: URL: https://github.com/apache/accumulo/pull/5697#discussion_r2177925561
########## 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 loop seems like it will burn CPU when waiting as it never blocks. Could potentially use this, it waits for all to be done and blocks. https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html#invokeAll-java.util.Collection- There is also this version of the method w/ a timeout https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html#invokeAll-java.util.Collection-long-java.util.concurrent.TimeUnit- not sure how that would interact w/ the `proc.waitFor` above. -- 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