org.apache.flink.util.AutoCloseableAsync Java Examples

The following examples show how to use org.apache.flink.util.AutoCloseableAsync. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RestServerEndpoint.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private FutureUtils.ConjunctFuture<Void> closeHandlersAsync() {
	return FutureUtils.waitForAll(handlers.stream()
		.map(tuple -> tuple.f1)
		.filter(handler -> handler instanceof AutoCloseableAsync)
		.map(handler -> ((AutoCloseableAsync) handler).closeAsync())
		.collect(Collectors.toList()));
}
 
Example #2
Source File: RestServerEndpoint.java    From flink with Apache License 2.0 5 votes vote down vote up
private FutureUtils.ConjunctFuture<Void> closeHandlersAsync() {
	return FutureUtils.waitForAll(handlers.stream()
		.map(tuple -> tuple.f1)
		.filter(handler -> handler instanceof AutoCloseableAsync)
		.map(handler -> ((AutoCloseableAsync) handler).closeAsync())
		.collect(Collectors.toList()));
}
 
Example #3
Source File: RpcUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * 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 {
	terminateAsyncCloseables(
		Arrays.stream(rpcServices)
			.map(rpcService -> (AutoCloseableAsync) rpcService::stopService)
			.collect(Collectors.toList()),
		timeout);
}
 
Example #4
Source File: RpcUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #5
Source File: RestServerEndpoint.java    From flink with Apache License 2.0 5 votes vote down vote up
private FutureUtils.ConjunctFuture<Void> closeHandlersAsync() {
	return FutureUtils.waitForAll(handlers.stream()
		.map(tuple -> tuple.f1)
		.filter(handler -> handler instanceof AutoCloseableAsync)
		.map(handler -> ((AutoCloseableAsync) handler).closeAsync())
		.collect(Collectors.toList()));
}