code: public static void retry(String action, RunnableThrowsIOException f, RetryPolicy policy)
        throws IOException {
      IOException e = null;
      while (policy.attempt()) {
        try {
          f.run();
          return;
        } catch (IOException ioe) {
          e = ioe;
          LOG.warn("Failed to {} (attempt {}): {}", action, policy.getAttemptCount(), e.toString());
        }
      }
      throw e;
    }
docs: Retries the given method until it doesn't throw an IO exception or the retry policy expires. If
  the retry policy expires, the last exception generated will be rethrown.
  
  @param action a description of the action that fits the phrase "Failed to ${action}"
  @param f the function to retry
  @param policy the retry policy to use