DomGarguilo commented on code in PR #5697:
URL: https://github.com/apache/accumulo/pull/5697#discussion_r2177938199
##########
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()) {
+ try {
+ f.get();
+ } catch (ExecutionException | InterruptedException e) {
+ log.warn("{} did not fully stop after 30 seconds", type, e);
+ } finally {
+ iter.remove();
+ }
+ }
+ }
+ }
Review Comment:
This loop could be really tight while waiting for the futures to complete.
Also we should use the actual `timeout` and `unit` in the log.warn instead of
the hardcoded 30 seconds.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]