use of org.apache.flink.util.AutoCloseableAsync in project flink by apache.
the class RpcUtils method terminateAsyncCloseables.
private static void terminateAsyncCloseables(Collection<? extends AutoCloseableAsync> closeables, Time timeout) throws InterruptedException, ExecutionException, TimeoutException {
final Collection<CompletableFuture<?>> terminationFutures = new ArrayList<>(closeables.size());
for (AutoCloseableAsync closeableAsync : closeables) {
if (closeableAsync != null) {
terminationFutures.add(closeableAsync.closeAsync());
}
}
FutureUtils.waitForAll(terminationFutures).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS);
}
Aggregations