FutureUtils.waitForAll(futures.values()).get();
/** * Copies all the files from the given stream state handles to the given path, renaming the files w.r.t. their * {@link StateHandleID}. */ private void downloadDataForAllStateHandles( Map<StateHandleID, StreamStateHandle> stateHandleMap, Path restoreInstancePath, CloseableRegistry closeableRegistry) throws Exception { try { List<Runnable> runnables = createDownloadRunnables(stateHandleMap, restoreInstancePath, closeableRegistry); List<CompletableFuture<Void>> futures = new ArrayList<>(runnables.size()); for (Runnable runnable : runnables) { futures.add(CompletableFuture.runAsync(runnable, executorService)); } FutureUtils.waitForAll(futures).get(); } catch (ExecutionException e) { Throwable throwable = ExceptionUtils.stripExecutionException(e); throwable = ExceptionUtils.stripException(throwable, RuntimeException.class); if (throwable instanceof IOException) { throw (IOException) throwable; } else { throw new FlinkRuntimeException("Failed to download data for state handles.", e); } } }
/** * Shuts the given rpc services down and waits for their termination. * * @param rpcServices to shut down * @param timeout for this operation * @throws InterruptedException if the operation has been interrupted * @throws ExecutionException if a problem occurred * @throws TimeoutException if a timeout occurred */ public static void terminateRpcServices( Time timeout, RpcService... rpcServices) throws InterruptedException, ExecutionException, TimeoutException { final Collection<CompletableFuture<?>> terminationFutures = new ArrayList<>(rpcServices.length); for (RpcService service : rpcServices) { if (service != null) { terminationFutures.add(service.stopService()); } } FutureUtils.waitForAll(terminationFutures).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); }
terminationFuture.get(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception);
terminationFuture.get(); } catch (Exception e) { exception = ExceptionUtils.firstOrSuppressed(e, exception);
Collection<JobException> exceptions = FutureUtils.combineAll(futures).get();
/** * Shuts the given rpc services down and waits for their termination. * * @param rpcServices to shut down * @param timeout for this operation * @throws InterruptedException if the operation has been interrupted * @throws ExecutionException if a problem occurred * @throws TimeoutException if a timeout occurred */ public static void terminateRpcServices( Time timeout, RpcService... rpcServices) throws InterruptedException, ExecutionException, TimeoutException { final Collection<CompletableFuture<?>> terminationFutures = new ArrayList<>(rpcServices.length); for (RpcService service : rpcServices) { if (service != null) { terminationFutures.add(service.stopService()); } } FutureUtils.waitForAll(terminationFutures).get(timeout.toMilliseconds(), TimeUnit.MILLISECONDS); }