public static boolean retry(Supplier<Boolean> function, long scaleMs, int base, int maxAttempts) {
        if (maxAttempts > 0) {
            int attempts = 0;
            long timeToSleep = scaleMs;
            boolean retry;
            do {
                retry = function.get();
                if (retry) {
                    try {
                        if (++attempts == maxAttempts) {
                            return false;
                        }
                        timeToSleep *= base;
                        Thread.sleep(timeToSleep);
                    } catch (InterruptedException ignored) {

                    }
                }
            } while (retry);
        } else {
            throw new ConfigException("Max attempts has to be greater than zero.");
        }
        return true;
    }
Retries the {@code Supplier<Boolean>} function while it returns {@code true} and for the specified max number of attempts.
The delay between each attempt is computed as: delay = scaleMs * base ^ attempt

@param function    the code to call and retry if needed
@param scaleMs     the scale for computing the delay
@param base        the base for computing the delay
@param maxAttempts the max number of attempts on calling the function
@return {@code false} if the function requires a retry, but it cannot be retried, because the max attempts have been exceeded.
{@code true} if the function stopped requiring a retry before exceeding the max attempts.
core/src/main/java/kafka/autobalancer/metricsreporter/AutoBalancerMetricsUtils.java