private static void awaitNextRetry(final Throwable e,
      @Nullable final String messageOnRetry,
      final int nTry,
      final int maxRetries,
      final boolean quiet) throws InterruptedException {
    final long sleepMillis = nextRetrySleepMillis(nTry);
    final String fullMessage;

    if (messageOnRetry == null) {
      fullMessage = String.format("Retrying (%d of %d) in %,dms.", nTry, maxRetries, sleepMillis);
    } else {
      fullMessage = String.format("%s, retrying (%d of %d) in %,dms.", messageOnRetry, nTry, maxRetries, sleepMillis);
    }

    if (quiet) {
      LOG.debug(fullMessage, e);
    } else {
      LOG.warn(fullMessage, e);
    }

    Thread.sleep(sleepMillis);
  }
Retry an operation using fuzzy exponentially increasing backoff. The wait time after the nth failed attempt is
min(60000ms, 1000ms * pow(2, n - 1)), fuzzed by a number drawn from a Gaussian distribution with mean 0 and
standard deviation 0.2.

If maxTries is exhausted, or if shouldRetry returns false, the last exception thrown by "f" will be thrown
by this function.

@param f           the operation
@param shouldRetry predicate determining whether we should retry after a particular exception thrown by "f"
@param quietTries  first quietTries attempts will LOG exceptions at DEBUG level rather than WARN
@param maxTries    maximum number of attempts

@return result of the first successful operation

@throws Exception if maxTries is exhausted, or shouldRetry returns false
kafka-handler/src/java/org/apache/hadoop/hive/kafka/RetryUtils.java