private <C> CompletableFuture<C> retry( CheckedSupplier<CompletableFuture<C>> operation, Predicate<Throwable> retryPredicate) { return FutureUtils.retryWithDelay( CheckedSupplier.unchecked(operation), restClusterClientConfiguration.getRetryMaxAttempts(), Time.milliseconds(restClusterClientConfiguration.getRetryDelay()), retryPredicate, new ScheduledExecutorServiceAdapter(retryExecutorService)); }
CompletableFuture<String> savepointPathFuture = FutureUtils.retryWithDelay( () -> { try {
/** * Retry the given operation with the given delay in between failures. * * @param operation to retry * @param retries number of retries * @param retryDelay delay between retries * @param scheduledExecutor executor to be used for the retry operation * @param <T> type of the result * @return Future which retries the given operation a given amount of times and delays the retry in case of failures */ public static <T> CompletableFuture<T> retryWithDelay( final Supplier<CompletableFuture<T>> operation, final int retries, final Time retryDelay, final ScheduledExecutor scheduledExecutor) { return retryWithDelay( operation, retries, retryDelay, (throwable) -> true, scheduledExecutor); }
/** * Retry the given operation with the given delay in between failures. * * @param operation to retry * @param retries number of retries * @param retryDelay delay between retries * @param scheduledExecutor executor to be used for the retry operation * @param <T> type of the result * @return Future which retries the given operation a given amount of times and delays the retry in case of failures */ public static <T> CompletableFuture<T> retryWithDelay( final Supplier<CompletableFuture<T>> operation, final int retries, final Time retryDelay, final ScheduledExecutor scheduledExecutor) { return retryWithDelay( operation, retries, retryDelay, (throwable) -> true, scheduledExecutor); }
/** * Retry the given operation with the given delay in between failures. * * @param operation to retry * @param retries number of retries * @param retryDelay delay between retries * @param scheduledExecutor executor to be used for the retry operation * @param <T> type of the result * @return Future which retries the given operation a given amount of times and delays the retry in case of failures */ public static <T> CompletableFuture<T> retryWithDelay( final Supplier<CompletableFuture<T>> operation, final int retries, final Time retryDelay, final ScheduledExecutor scheduledExecutor) { return retryWithDelay( operation, retries, retryDelay, (throwable) -> true, scheduledExecutor); }
@Override protected CompletableFuture<T> createGateway(CompletableFuture<Tuple2<String, UUID>> leaderFuture) { return FutureUtils.retryWithDelay( () -> leaderFuture.thenCompose( (Tuple2<String, UUID> addressLeaderTuple) -> rpcService.connect( addressLeaderTuple.f0, fencingTokenMapper.apply(addressLeaderTuple.f1), gatewayType)), retries, retryDelay, rpcService.getScheduledExecutor()); } }
@Override protected CompletableFuture<T> createGateway(CompletableFuture<Tuple2<String, UUID>> leaderFuture) { return FutureUtils.retryWithDelay( () -> leaderFuture.thenCompose( (Tuple2<String, UUID> addressLeaderTuple) -> rpcService.connect( addressLeaderTuple.f0, fencingTokenMapper.apply(addressLeaderTuple.f1), gatewayType)), retries, retryDelay, rpcService.getScheduledExecutor()); } }
@Override protected CompletableFuture<T> createGateway(CompletableFuture<Tuple2<String, UUID>> leaderFuture) { return FutureUtils.retryWithDelay( () -> leaderFuture.thenCompose( (Tuple2<String, UUID> addressLeaderTuple) -> rpcService.connect( addressLeaderTuple.f0, fencingTokenMapper.apply(addressLeaderTuple.f1), gatewayType)), retries, retryDelay, rpcService.getScheduledExecutor()); } }
@Override protected CompletableFuture<JobManagerGateway> createGateway(CompletableFuture<Tuple2<String, UUID>> leaderFuture) { return FutureUtils.retryWithDelay( () -> leaderFuture.thenCompose( (Tuple2<String, UUID> addressLeaderId) -> FutureUtils.toJava( AkkaUtils.getActorRefFuture( addressLeaderId.f0, actorSystem, FutureUtils.toFiniteDuration(timeout))) .thenApply( (ActorRef jobManagerRef) -> { ActorGateway leaderGateway = new AkkaActorGateway( jobManagerRef, addressLeaderId.f1); return new AkkaJobManagerGateway(leaderGateway); } )), retries, retryDelay, scheduledExecutor); } }
@Override protected CompletableFuture<JobManagerGateway> createGateway(CompletableFuture<Tuple2<String, UUID>> leaderFuture) { return FutureUtils.retryWithDelay( () -> leaderFuture.thenCompose( (Tuple2<String, UUID> addressLeaderId) -> FutureUtils.toJava( AkkaUtils.getActorRefFuture( addressLeaderId.f0, actorSystem, FutureUtils.toFiniteDuration(timeout))) .thenApply( (ActorRef jobManagerRef) -> { ActorGateway leaderGateway = new AkkaActorGateway( jobManagerRef, addressLeaderId.f1); return new AkkaJobManagerGateway(leaderGateway); } )), retries, retryDelay, scheduledExecutor); } }
@Override protected CompletableFuture<JobManagerGateway> createGateway(CompletableFuture<Tuple2<String, UUID>> leaderFuture) { return FutureUtils.retryWithDelay( () -> leaderFuture.thenCompose( (Tuple2<String, UUID> addressLeaderId) -> FutureUtils.toJava( AkkaUtils.getActorRefFuture( addressLeaderId.f0, actorSystem, FutureUtils.toFiniteDuration(timeout))) .thenApply( (ActorRef jobManagerRef) -> { ActorGateway leaderGateway = new AkkaActorGateway( jobManagerRef, addressLeaderId.f1); return new AkkaJobManagerGateway(leaderGateway); } )), retries, retryDelay, scheduledExecutor); } }
private <C> CompletableFuture<C> retry( CheckedSupplier<CompletableFuture<C>> operation, Predicate<Throwable> retryPredicate) { return FutureUtils.retryWithDelay( CheckedSupplier.unchecked(operation), restClusterClientConfiguration.getRetryMaxAttempts(), Time.milliseconds(restClusterClientConfiguration.getRetryDelay()), retryPredicate, new ScheduledExecutorServiceAdapter(retryExecutorService)); }
private <C> CompletableFuture<C> retry( CheckedSupplier<CompletableFuture<C>> operation, Predicate<Throwable> retryPredicate) { return FutureUtils.retryWithDelay( CheckedSupplier.unchecked(operation), restClusterClientConfiguration.getRetryMaxAttempts(), Time.milliseconds(restClusterClientConfiguration.getRetryDelay()), retryPredicate, new ScheduledExecutorServiceAdapter(retryExecutorService)); }