Search in sources :

Example 1 with NextTaskRun

use of io.kestra.core.models.executions.NextTaskRun in project kestra by kestra-io.

the class ExecutorService method saveFlowableOutput.

private List<TaskRun> saveFlowableOutput(List<NextTaskRun> nextTaskRuns, Executor executor, TaskRun parentTaskRun) {
    return nextTaskRuns.stream().map(throwFunction(t -> {
        TaskRun taskRun = t.getTaskRun();
        if (!(t.getTask() instanceof FlowableTask)) {
            return taskRun;
        }
        FlowableTask<?> flowableTask = (FlowableTask<?>) t.getTask();
        try {
            RunContext runContext = runContextFactory.of(executor.getFlow(), t.getTask(), executor.getExecution(), t.getTaskRun());
            taskRun = taskRun.withOutputs(flowableTask.outputs(runContext, executor.getExecution(), parentTaskRun) != null ? flowableTask.outputs(runContext, executor.getExecution(), parentTaskRun).toMap() : ImmutableMap.of());
        } catch (Exception e) {
            executor.getFlow().logger().warn("Unable to save output on taskRun '{}'", taskRun, e);
        }
        return taskRun;
    })).collect(Collectors.toList());
}
Also used : FlowableTask(io.kestra.core.models.tasks.FlowableTask) TaskRun(io.kestra.core.models.executions.TaskRun) NextTaskRun(io.kestra.core.models.executions.NextTaskRun) InternalException(io.kestra.core.exceptions.InternalException)

Example 2 with NextTaskRun

use of io.kestra.core.models.executions.NextTaskRun in project kestra by kestra-io.

the class ExecutorService method childNextsTaskRun.

private List<TaskRun> childNextsTaskRun(Executor executor, TaskRun parentTaskRun) throws InternalException {
    Task parent = executor.getFlow().findTaskByTaskId(parentTaskRun.getTaskId());
    if (parent instanceof FlowableTask) {
        FlowableTask<?> flowableParent = (FlowableTask<?>) parent;
        List<NextTaskRun> nexts = flowableParent.resolveNexts(runContextFactory.of(executor.getFlow(), parent, executor.getExecution(), parentTaskRun), executor.getExecution(), parentTaskRun);
        if (nexts.size() > 0) {
            return this.saveFlowableOutput(nexts, executor, parentTaskRun);
        }
    }
    return new ArrayList<>();
}
Also used : FlowableTask(io.kestra.core.models.tasks.FlowableTask) ResolvedTask(io.kestra.core.models.tasks.ResolvedTask) Task(io.kestra.core.models.tasks.Task) FlowableTask(io.kestra.core.models.tasks.FlowableTask) ArrayList(java.util.ArrayList) NextTaskRun(io.kestra.core.models.executions.NextTaskRun)

Aggregations

NextTaskRun (io.kestra.core.models.executions.NextTaskRun)2 FlowableTask (io.kestra.core.models.tasks.FlowableTask)2 InternalException (io.kestra.core.exceptions.InternalException)1 TaskRun (io.kestra.core.models.executions.TaskRun)1 ResolvedTask (io.kestra.core.models.tasks.ResolvedTask)1 Task (io.kestra.core.models.tasks.Task)1 ArrayList (java.util.ArrayList)1