Search in sources :

Example 1 with WorkerTaskResult

use of io.kestra.core.runners.WorkerTaskResult in project kestra by kestra-io.

the class ExecutorJoinerTransformer method transform.

@Override
public Executor transform(final String key, final Executor value) {
    if (value.getExecution() != null) {
        return value;
    }
    WorkerTaskResult workerTaskResult = value.getJoined();
    if (log.isDebugEnabled()) {
        log.debug("<< IN  WorkerTaskResult [key='{}', partition='{}, offset='{}'] : {}", key, context.partition(), context.offset(), workerTaskResult.getTaskRun().toStringState());
    }
    Executor executor = this.store.get(key);
    // already purge execution ?
    if (executor == null) {
        log.warn("Unable to find Executor with key '" + key + "' for WorkerTaskResult id '" + workerTaskResult.getTaskRun().getId() + "' '" + workerTaskResult.getTaskRun().toStringState() + "'");
        return null;
    }
    if (!executor.getExecution().hasTaskRunJoinable(value.getJoined().getTaskRun())) {
        return executor;
    }
    try {
        Execution newExecution = executor.getExecution().withTaskRun(workerTaskResult.getTaskRun());
        executor = executor.withExecution(newExecution, "joinWorkerResult");
    } catch (Exception e) {
        return executor.withException(e, "joinWorkerResult");
    }
    // send metrics
    metricRegistry.counter(MetricRegistry.KESTRA_EXECUTOR_TASKRUN_ENDED_COUNT, metricRegistry.tags(workerTaskResult)).increment();
    metricRegistry.timer(MetricRegistry.KESTRA_EXECUTOR_TASKRUN_ENDED_DURATION, metricRegistry.tags(workerTaskResult)).record(workerTaskResult.getTaskRun().getState().getDuration());
    return executor;
}
Also used : Executor(io.kestra.core.runners.Executor) Execution(io.kestra.core.models.executions.Execution) WorkerTaskResult(io.kestra.core.runners.WorkerTaskResult)

Aggregations

Execution (io.kestra.core.models.executions.Execution)1 Executor (io.kestra.core.runners.Executor)1 WorkerTaskResult (io.kestra.core.runners.WorkerTaskResult)1