Search in sources :

Example 1 with WorkflowTokenProvider

use of co.cask.cdap.app.runtime.WorkflowTokenProvider in project cdap by caskdata.

the class DefaultProgramWorkflowRunner method runAndWait.

private void runAndWait(ProgramRunner programRunner, Program program, ProgramOptions options) throws Exception {
    Closeable closeable = createCloseable(programRunner, program);
    ProgramController controller;
    try {
        controller = programRunner.run(program, options);
    } catch (Throwable t) {
        // If there is any exception when running the program, close the program to release resources.
        // Otherwise it will be released when the execution completed.
        Closeables.closeQuietly(closeable);
        throw t;
    }
    blockForCompletion(closeable, controller);
    if (controller instanceof WorkflowTokenProvider) {
        updateWorkflowToken(((WorkflowTokenProvider) controller).getWorkflowToken());
    } else {
        // This shouldn't happen
        throw new IllegalStateException("No WorkflowToken available after program completed: " + program.getId());
    }
}
Also used : ProgramController(co.cask.cdap.app.runtime.ProgramController) WorkflowTokenProvider(co.cask.cdap.app.runtime.WorkflowTokenProvider) Closeable(java.io.Closeable)

Aggregations

ProgramController (co.cask.cdap.app.runtime.ProgramController)1 WorkflowTokenProvider (co.cask.cdap.app.runtime.WorkflowTokenProvider)1 Closeable (java.io.Closeable)1