public static <T> CompletableFuture<T> retry(final Supplier<CompletableFuture<T>> operation, final int retries,
      Duration retryDelay, Predicate<Throwable> retryPredicate, Function<Throwable, Integer> retryDelayFromException,
      ScheduledExecutorService scheduledExecutor) {
    final CompletableFuture<T> resultFuture = new CompletableFuture<>();
    retryOperationWithDelay(resultFuture, operation, retries, retryDelay, retryPredicate, retryDelayFromException,
        scheduledExecutor);
    return resultFuture;
  }
Retry the given operation the given number of times in case of a failure.
@param <T> type of the result
@param operation to executed
@param retries if the operation failed
@param retryPredicate Predicate to test whether an exception is retryable
@param retryDelayFromException function to get retry delay from the exception if present
@param scheduledExecutor executor to schedule retries
@return Future containing either the result of the operation or a {@link Exception} if error occurred.
ambry-commons/src/main/java/com/github/ambry/commons/FutureUtils.java