public void runScript(ServiceInfo.ServiceAdvisorType serviceAdvisorType, StackAdvisorCommandType saCommandType, File actionDirectory)
      throws StackAdvisorException {
    LOG.info(String.format("StackAdvisorRunner. serviceAdvisorType=%s, actionDirectory=%s, command=%s", serviceAdvisorType.toString(), actionDirectory,
        saCommandType));

    String outputFile = actionDirectory + File.separator + "stackadvisor.out";
    String errorFile = actionDirectory + File.separator + "stackadvisor.err";

    String hostsFile = actionDirectory + File.separator + "hosts.json";
    String servicesFile = actionDirectory + File.separator + "services.json";

    LOG.info("StackAdvisorRunner. Expected files: hosts.json={}, services.json={}, output={}, error={}", hostsFile, servicesFile, outputFile, errorFile);

    int stackAdvisorReturnCode = -1;

    switch (serviceAdvisorType) {
      case JAVA:
        LOG.info("StackAdvisorRunner.runScript(): Calling Java ServiceAdvisor's run method.");
        stackAdvisorReturnCode = ServiceAdvisor.run(saCommandType.toString(), hostsFile, servicesFile, outputFile, errorFile);
        LOG.info(String.format("StackAdvisorRunner.runScript(): Java ServiceAdvisor's return code: %d", stackAdvisorReturnCode));
        break;
      case PYTHON:
        LOG.info("StackAdvisorRunner.runScript(): Calling Python Stack Advisor.");
        ProcessBuilder builder = prepareShellCommand(ServiceInfo.ServiceAdvisorType.PYTHON, configs.getStackAdvisorScript(), saCommandType,
            actionDirectory, outputFile,
            errorFile);
        builder.environment().put("METADATA_DIR_PATH", configs.getProperty(Configuration.METADATA_DIR_PATH));
        builder.environment().put("BASE_SERVICE_ADVISOR", Paths.get(configs.getProperty(Configuration.METADATA_DIR_PATH), "service_advisor.py").toString());
        builder.environment().put("BASE_STACK_ADVISOR", Paths.get(configs.getProperty(Configuration.METADATA_DIR_PATH), "stack_advisor.py").toString());
        stackAdvisorReturnCode = launchProcess(builder);
        break;
    }

    // For both Python and Java, need to process log files for now.
    processLogs(stackAdvisorReturnCode, outputFile, errorFile);
  }
Runs stack_advisor.py script in the specified {@code actionDirectory}.

@param serviceAdvisorType PYTHON or JAVA
@param saCommandType {@link StackAdvisorCommandType} to run.
@param actionDirectory directory for the action
ambari-server/src/main/java/org/apache/ambari/server/api/services/stackadvisor/StackAdvisorRunner.java