org.apache.flink.runtime.rest.messages.queue.AsynchronouslyCreatedResource Java Examples
The following examples show how to use
org.apache.flink.runtime.rest.messages.queue.AsynchronouslyCreatedResource.
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: RestClusterClient.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
private <R, A extends AsynchronouslyCreatedResource<R>> CompletableFuture<R> pollResourceAsync( final Supplier<CompletableFuture<A>> resourceFutureSupplier, final CompletableFuture<R> resultFuture, final long attempt) { resourceFutureSupplier.get().whenComplete((asynchronouslyCreatedResource, throwable) -> { if (throwable != null) { resultFuture.completeExceptionally(throwable); } else { if (asynchronouslyCreatedResource.queueStatus().getId() == QueueStatus.Id.COMPLETED) { resultFuture.complete(asynchronouslyCreatedResource.resource()); } else { retryExecutorService.schedule(() -> { pollResourceAsync(resourceFutureSupplier, resultFuture, attempt + 1); }, waitStrategy.sleepTime(attempt), TimeUnit.MILLISECONDS); } } }); return resultFuture; }
Example #2
Source File: RestClusterClient.java From flink with Apache License 2.0 | 6 votes |
private <R, A extends AsynchronouslyCreatedResource<R>> CompletableFuture<R> pollResourceAsync( final Supplier<CompletableFuture<A>> resourceFutureSupplier, final CompletableFuture<R> resultFuture, final long attempt) { resourceFutureSupplier.get().whenComplete((asynchronouslyCreatedResource, throwable) -> { if (throwable != null) { resultFuture.completeExceptionally(throwable); } else { if (asynchronouslyCreatedResource.queueStatus().getId() == QueueStatus.Id.COMPLETED) { resultFuture.complete(asynchronouslyCreatedResource.resource()); } else { retryExecutorService.schedule(() -> { pollResourceAsync(resourceFutureSupplier, resultFuture, attempt + 1); }, waitStrategy.sleepTime(attempt), TimeUnit.MILLISECONDS); } } }); return resultFuture; }
Example #3
Source File: RestClusterClient.java From flink with Apache License 2.0 | 6 votes |
private <R, A extends AsynchronouslyCreatedResource<R>> CompletableFuture<R> pollResourceAsync( final Supplier<CompletableFuture<A>> resourceFutureSupplier, final CompletableFuture<R> resultFuture, final long attempt) { resourceFutureSupplier.get().whenComplete((asynchronouslyCreatedResource, throwable) -> { if (throwable != null) { resultFuture.completeExceptionally(throwable); } else { if (asynchronouslyCreatedResource.queueStatus().getId() == QueueStatus.Id.COMPLETED) { resultFuture.complete(asynchronouslyCreatedResource.resource()); } else { retryExecutorService.schedule(() -> { pollResourceAsync(resourceFutureSupplier, resultFuture, attempt + 1); }, waitStrategy.sleepTime(attempt), TimeUnit.MILLISECONDS); } } }); return resultFuture; }
Example #4
Source File: RestClusterClient.java From Flink-CEPplus with Apache License 2.0 | 2 votes |
/** * Creates a {@code CompletableFuture} that polls a {@code AsynchronouslyCreatedResource} until * its {@link AsynchronouslyCreatedResource#queueStatus() QueueStatus} becomes * {@link QueueStatus.Id#COMPLETED COMPLETED}. The future completes with the result of * {@link AsynchronouslyCreatedResource#resource()}. * * @param resourceFutureSupplier The operation which polls for the * {@code AsynchronouslyCreatedResource}. * @param <R> The type of the resource. * @param <A> The type of the {@code AsynchronouslyCreatedResource}. * @return A {@code CompletableFuture} delivering the resource. */ private <R, A extends AsynchronouslyCreatedResource<R>> CompletableFuture<R> pollResourceAsync( final Supplier<CompletableFuture<A>> resourceFutureSupplier) { return pollResourceAsync(resourceFutureSupplier, new CompletableFuture<>(), 0); }
Example #5
Source File: RestClusterClient.java From flink with Apache License 2.0 | 2 votes |
/** * Creates a {@code CompletableFuture} that polls a {@code AsynchronouslyCreatedResource} until * its {@link AsynchronouslyCreatedResource#queueStatus() QueueStatus} becomes * {@link QueueStatus.Id#COMPLETED COMPLETED}. The future completes with the result of * {@link AsynchronouslyCreatedResource#resource()}. * * @param resourceFutureSupplier The operation which polls for the * {@code AsynchronouslyCreatedResource}. * @param <R> The type of the resource. * @param <A> The type of the {@code AsynchronouslyCreatedResource}. * @return A {@code CompletableFuture} delivering the resource. */ private <R, A extends AsynchronouslyCreatedResource<R>> CompletableFuture<R> pollResourceAsync( final Supplier<CompletableFuture<A>> resourceFutureSupplier) { return pollResourceAsync(resourceFutureSupplier, new CompletableFuture<>(), 0); }
Example #6
Source File: RestClusterClient.java From flink with Apache License 2.0 | 2 votes |
/** * Creates a {@code CompletableFuture} that polls a {@code AsynchronouslyCreatedResource} until * its {@link AsynchronouslyCreatedResource#queueStatus() QueueStatus} becomes * {@link QueueStatus.Id#COMPLETED COMPLETED}. The future completes with the result of * {@link AsynchronouslyCreatedResource#resource()}. * * @param resourceFutureSupplier The operation which polls for the * {@code AsynchronouslyCreatedResource}. * @param <R> The type of the resource. * @param <A> The type of the {@code AsynchronouslyCreatedResource}. * @return A {@code CompletableFuture} delivering the resource. */ private <R, A extends AsynchronouslyCreatedResource<R>> CompletableFuture<R> pollResourceAsync( final Supplier<CompletableFuture<A>> resourceFutureSupplier) { return pollResourceAsync(resourceFutureSupplier, new CompletableFuture<>(), 0); }