use of pipelite.stage.executor.StageExecutorResultCallback in project pipelite by enasequence.
the class StageRunner method executeStage.
private void executeStage(StageExecutorResultCallback processRunnerResultCallback) {
StageExecutorResultCallback stageRunnerResultCallback = (executorResult) -> internalErrorHandler.execute(() -> {
if (executorResult == null) {
throw new PipeliteException("Missing executor result");
}
if (executorResult.isSubmitted()) {
logContext(log.atFine()).log("Submitted asynchronous stage execution");
pipeliteServices.stage().saveStage(stage);
} else if (executorResult.isActive()) {
if (ZonedDateTime.now().isAfter(timeout)) {
logContext(log.atSevere()).log("Maximum stage execution time exceeded.");
// Terminate executor.
internalErrorHandler.execute(() -> stage.getExecutor().terminate());
endStageExecution(processRunnerResultCallback, StageExecutorResult.timeoutError());
} else {
logContext(log.atFiner()).log("Waiting asynchronous stage execution to complete");
}
} else if (executorResult.isSuccess() || executorResult.isError()) {
endStageExecution(processRunnerResultCallback, executorResult);
}
}, (ex) -> endStageExecution(processRunnerResultCallback, StageExecutorResult.internalError(ex)));
executeStage(processRunnerResultCallback, stageRunnerResultCallback);
}
Aggregations