private <E extends Exception> void retryOrThrow(RetryCounter retryCounter, E ex, String user,
    String cmd) throws E {
    if (retryCounter.shouldRetry()) {
      LOG.warn(
        "Local command: {}, user: {}, failed at attempt {}. Retrying until maxAttempts: {}."
          + "Exception {}",
        cmd, user, retryCounter.getAttemptTimes(), retryCounter.getMaxAttempts(), ex.getMessage());
      return;
    }
    throw ex;
  }
Below function executes command with retries with given user. Uses LocalShell to execute a
command.
@param user user name, default none
@param cmd  Command to execute
@return A pair of Exit Code and Shell output
@throws IOException Exception while executing shell command
hbase-it/src/main/java/org/apache/hadoop/hbase/chaos/ChaosAgent.java