private ResultModel executeOnRemote(GfshParseResult parseResult) {
    Path tempFile = null;

    if (!shell.isConnectedAndReady()) {
      shell.logWarning(
          "Can't execute a remote command without connection. Use 'connect' first to connect.",
          null);
      logWrapper.info("Can't execute a remote command \"" + parseResult.getUserInput()
          + "\" without connection. Use 'connect' first to connect to GemFire.");
      return null;
    }

    List<File> fileData = null;
    CliAroundInterceptor interceptor = null;

    String interceptorClass = getInterceptor(parseResult.getMethod());

    // 1. Pre Remote Execution
    if (!CliMetaData.ANNOTATION_NULL_VALUE.equals(interceptorClass)) {
      try {
        interceptor = (CliAroundInterceptor) ClassPathLoader.getLatest().forName(interceptorClass)
            .newInstance();
      } catch (InstantiationException | ClassNotFoundException | IllegalAccessException e) {
        shell.logWarning("Configuration error", e);
      }

      if (interceptor == null) {
        return ResultModel.createError("Interceptor Configuration Error");
      }

      ResultModel preExecResult = interceptor.preExecution(parseResult);
      if (preExecResult.getStatus() != Status.OK) {
        return preExecResult;
      }
      fileData = preExecResult.getFileList();
    }

    // 2. Remote Execution
    Object response = null;
    final Map<String, String> env = shell.getEnv();
    try {
      response = shell.getOperationInvoker()
          .processCommand(new CommandRequest(parseResult, env, fileData));

      if (response == null) {
        return ResultModel.createError("Response was null for: " + parseResult.getUserInput());
      }
    } catch (NotAuthorizedException e) {
      return ResultModel.createError("Unauthorized. Reason : " + e.getMessage());
    } catch (Exception e) {
      shell.logSevere(e.getMessage(), e);
      return ResultModel.createError(
          "Error occurred while executing \"" + parseResult.getUserInput() + "\" on manager.");
    } finally {
      env.clear();
    }

    // the response could be a string which is a json representation of the
    // ResultModel object
    // it can also be a Path to a temp file downloaded from the rest http request
    ResultModel commandResult = null;
    if (response instanceof String) {
      try {
        commandResult = ResultModel.fromJson((String) response);
      } catch (Exception e) {
        logWrapper.severe("Unable to parse the remote response.", e);
        String clientVersion = GemFireVersion.getGemFireVersion();
        String remoteVersion = null;
        try {
          remoteVersion = shell.getOperationInvoker().getRemoteVersion();
        } catch (Exception exception) {
          // unable to get the remote version (pre-1.5.0 manager does not have this capability)
          // ignore
        }
        String message = "Unable to parse the remote response. This might due to gfsh client "
            + "version(" + clientVersion + ") mismatch with the remote cluster version"
            + ((remoteVersion == null) ? "." : "(" + remoteVersion + ").");
        return ResultModel.createError(message);
      }
    } else if (response instanceof Path) {
      tempFile = (Path) response;
    }

    // 3. Post Remote Execution
    if (interceptor != null) {
      try {
        commandResult =
            interceptor.postExecution(parseResult, commandResult, tempFile);

      } catch (Exception e) {
        logWrapper.severe("error running post interceptor", e);
        commandResult = ResultModel.createError(e.getMessage());
      }
    }

    if (commandResult == null) {
      commandResult =
          ResultModel.createError("Unable to build ResultModel using the remote response.");
    }

    return commandResult;
  }
Sends the user input (command string) via {@link OperationInvoker} to a remote GemFire node for
processing & execution.

@return result of execution/processing of the command
@throws IllegalStateException if gfsh doesn't have an active connection.
geode-gfsh/src/main/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategy.java