public static ApplicationRunner invoke(Config originalConfig, ApplicationRunnerOperation op) {
    Config config = ConfigUtil.rewriteConfig(originalConfig);

    ApplicationRunner appRunner =
        ApplicationRunners.getApplicationRunner(ApplicationUtil.fromConfig(config), config);

    switch (op) {
      case RUN:
        appRunner.run(null);
        break;
      case KILL:
        appRunner.kill();
        break;
      case STATUS:
        System.out.println(appRunner.status());
        break;
      default:
        throw new IllegalArgumentException("Unrecognized operation: " + op);
    }
    return appRunner;
  }
This method rewrites the passed in config, creates the {@link ApplicationRunner} from the rewritten config and
invokes the appropriate operation on the runner based on the specified {@link ApplicationRunnerOperation}.
It returns the runner so that the caller could get the status of application on STATUS op.

@param originalConfig the original configuration of the application
@param op the {@link ApplicationRunnerOperation} that needs to be performed on the Application.
@return the {@link ApplicationRunner} object.
samza-core/src/main/java/org/apache/samza/runtime/ApplicationRunnerUtil.java