Class RetryUtil

java.lang.Object
io.confluent.license.util.RetryUtil

public class RetryUtil extends Object
  • Constructor Details

    • RetryUtil

      public RetryUtil()
  • Method Details

    • retryUntilTimeout

      public static <T> T retryUntilTimeout(Callable<T> callable, Supplier<String> description, Duration timeoutDuration, long retryBackoffMs) throws Exception
      The method executes the callable at least once, optionally retrying the callable if RetriableException is being thrown. If timeout is exhausted, then the last exception is wrapped with a ConnectException and thrown.

      description supplies the message that indicates the purpose of the callable since the message will be used for logging. For example, "list offsets". If the supplier is null or the supplied string is null, callable will be used as the default string.

      The task will be executed at least once. No retries will be performed if timeoutDuration is 0 or negative, or if timeoutDuration is less than retryBackoffMs.

      A retryBackoffMs that is negative or zero will result in no delays between retries.

      Parameters:
      callable - the function to execute
      description - supplier that provides custom message for logging purpose
      timeoutDuration - timeout duration; must not be null
      retryBackoffMs - the number of milliseconds to delay upon receiving a RetriableException before retrying again
      Throws:
      org.apache.kafka.connect.errors.ConnectException - If the task exhausted all the retries
      Exception