public <T> T doWithRetries(Callable<T> action, String actionName, String partitionPath) throws CloudStorageException {
    int attempts = 0;
    while (attempts < maxAttempts) {
      try {
        return action.call();
      } catch (Exception e) {
        attempts++;
        throwOrDelay(e, actionName, partitionPath, attempts);
      }
    }
    // Line should never be reached
    throw new CloudStorageException(
        actionName + " failed, " + (Utils.isNullOrEmpty(partitionPath) ? "" : ("partition " + partitionPath)) + " made "
            + attempts + " attempts");
  }
Execute an action up to the configured number of attempts.
@param action the {@link Callable} to call.
@param actionName the name of the action.
@param partitionPath the partition acted on.
@return the return value of the action.
@throws CloudStorageException if any error encountered in executing action.
ambry-cloud/src/main/java/com/github/ambry/cloud/CloudRequestAgent.java