class RetryRunnable implements Runnable, Scheduler.Cancellable {

    private static final Logger LOGGER = LogManager.getLogger(RetryRunnable.class);

    private final ThreadPool threadPool;
    private final String executorName;
    private final Executor executor;
    private final Iterator<TimeValue> delay;
    private final Runnable retryCommand;
    private volatile Scheduler.Cancellable cancellable;

    public RetryRunnable(ThreadPool threadPool,
                         String executorName,
                         Runnable command,
                         Iterable<TimeValue> backOffPolicy) {
        this.threadPool = threadPool;
        this.executorName = executorName;
        this.executor = threadPool.executor(executorName);
        this.delay = backOffPolicy.iterator();
        this.retryCommand = command;
    }

    @Override
    public void run() {<FILL_FUNCTION_BODY>}

    @Override
    public boolean cancel() {
        if (cancellable != null) {
            return cancellable.cancel();
        }
        return false;
    }

    @Override
    public boolean isCancelled() {
        if (cancellable != null) {
            return cancellable.isCancelled();
        }
        return false;
    }
}

        try {
            executor.execute(retryCommand);
        } catch (EsRejectedExecutionException e) {
            if (delay.hasNext()) {
                long currentDelay = delay.next().millis();
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Received RejectedExecutionException, will retry again in {}ms", currentDelay);
                }
                cancellable = threadPool.scheduleUnlessShuttingDown(
                    new TimeValue(currentDelay, TimeUnit.MILLISECONDS),
                    executorName,
                    retryCommand
                );
            } else {
                LOGGER.warn("Received RejectedExecutionException after max retries, giving up");
            }
        } catch (Exception e) {
            LOGGER.error("Received unhandled exception", e);
        }
    
<no_super_class>