in client/src/main/java/org/apache/uniffle/client/util/ClientUtils.java [57:95]
public static boolean waitUntilDoneOrFail(
List<CompletableFuture<Boolean>> futures, boolean allowFastFail) {
int expected = futures.size();
int failed = 0;
CompletableFuture allFutures =
CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
List<Future> finished = new ArrayList<>();
while (true) {
for (Future<Boolean> future : futures) {
if (future.isDone() && !finished.contains(future)) {
finished.add(future);
try {
if (!future.get()) {
failed++;
}
} catch (Exception e) {
failed++;
}
}
}
if (expected == finished.size()) {
return failed <= 0;
}
if (failed > 0 && allowFastFail) {
futures.stream().filter(x -> !x.isDone()).forEach(x -> x.cancel(true));
return false;
}
try {
allFutures.get(10, TimeUnit.MILLISECONDS);
} catch (Exception e) {
// ignore
}
}
}