public static <T> T executeWithRetry(Callable<T> command) throws AmbariException {
    RetryHelper.clearAffectedClusters();
    int retryAttempts = RetryHelper.getOperationsRetryAttempts();
    do {
      try {
        return command.call();
      } catch (Exception e) {
        if (RetryHelper.isDatabaseException(e)) {

          RetryHelper.invalidateAffectedClusters();

          if (retryAttempts > 0) {
            LOG.error("Ignoring database exception to perform operation retry, attempts remaining: " + retryAttempts, e);
            retryAttempts--;
          } else {
            RetryHelper.clearAffectedClusters();
            throw new AmbariException(e.getMessage(), e);
          }
        } else {
          RetryHelper.clearAffectedClusters();
          throw new AmbariException(e.getMessage(), e);
        }
      }

    } while (true);
  }
Provides utility methods to support operations retry
TODO injection as Guice singleon, static for now to avoid major modifications
ambari-server/src/main/java/org/apache/ambari/server/utils/RetryHelper.java