private ProgramController addStateChangeListener(ProgramController controller) { controller.addListener(new StateChangeListener(controller.getProgramRunId(), null, programStateWriter), Threads.SAME_THREAD_EXECUTOR); return controller; }
private ProgramController addStateChangeListener(ProgramController controller) { controller.addListener(new StateChangeListener(controller.getProgramRunId(), null, programStateWriter), Threads.SAME_THREAD_EXECUTOR); return controller; }
protected void doMain() throws Exception { TwillRuntimeSpecification twillRuntimeSpec = TwillRuntimeSpecificationAdapter.create() .fromJson(new File(Constants.Files.RUNTIME_CONFIG_JAR, Constants.Files.TWILL_SPEC)); org.apache.twill.internal.Arguments arguments = readJsonFile(new File(Constants.Files.RUNTIME_CONFIG_JAR, Constants.Files.ARGUMENTS), org.apache.twill.internal.Arguments.class); TwillContext context = new DirectExecutionTwillContext(name, twillRuntimeSpec, arguments); initialize(context); Runtime.getRuntime().addShutdownHook(new Thread(AbstractProgramTwillRunnable.this::stop)); // Add the program state writer listener when the program controller is available ProgramStateWriter programStateWriter = injector.getInstance(ProgramStateWriter.class); controllerFuture.thenAcceptAsync( c -> c.addListener(new StateChangeListener(c.getProgramRunId(), null, programStateWriter), Threads.SAME_THREAD_EXECUTOR), command -> { Thread t = new Thread(command); t.start(); }); run(); }
protected void doMain() throws Exception { TwillRuntimeSpecification twillRuntimeSpec = TwillRuntimeSpecificationAdapter.create() .fromJson(new File(Constants.Files.RUNTIME_CONFIG_JAR, Constants.Files.TWILL_SPEC)); org.apache.twill.internal.Arguments arguments = readJsonFile(new File(Constants.Files.RUNTIME_CONFIG_JAR, Constants.Files.ARGUMENTS), org.apache.twill.internal.Arguments.class); TwillContext context = new DirectExecutionTwillContext(name, twillRuntimeSpec, arguments); initialize(context); Runtime.getRuntime().addShutdownHook(new Thread(AbstractProgramTwillRunnable.this::stop)); // Add the program state writer listener when the program controller is available ProgramStateWriter programStateWriter = injector.getInstance(ProgramStateWriter.class); controllerFuture.thenAcceptAsync( c -> c.addListener(new StateChangeListener(c.getProgramRunId(), null, programStateWriter), Threads.SAME_THREAD_EXECUTOR), command -> { Thread t = new Thread(command); t.start(); }); run(); }