Search in sources :

Example 1 with DownstreamRXTask

use of io.crate.execution.jobs.DownstreamRXTask in project crate by crate.

the class JobLauncher method getHandlerBucketReceivers.

private List<PageBucketReceiver> getHandlerBucketReceivers(RootTask rootTask, List<Tuple<ExecutionPhase, RowConsumer>> handlerPhases) {
    final List<PageBucketReceiver> pageBucketReceivers = new ArrayList<>(handlerPhases.size());
    for (Tuple<ExecutionPhase, ?> handlerPhase : handlerPhases) {
        Task ctx = rootTask.getTaskOrNull(handlerPhase.v1().phaseId());
        if (ctx instanceof DownstreamRXTask) {
            PageBucketReceiver pageBucketReceiver = ((DownstreamRXTask) ctx).getBucketReceiver((byte) 0);
            pageBucketReceivers.add(pageBucketReceiver);
        }
    }
    return pageBucketReceivers;
}
Also used : Task(io.crate.execution.jobs.Task) RootTask(io.crate.execution.jobs.RootTask) DownstreamRXTask(io.crate.execution.jobs.DownstreamRXTask) PageBucketReceiver(io.crate.execution.jobs.PageBucketReceiver) ArrayList(java.util.ArrayList) ExecutionPhase(io.crate.execution.dsl.phases.ExecutionPhase) DownstreamRXTask(io.crate.execution.jobs.DownstreamRXTask)

Example 2 with DownstreamRXTask

use of io.crate.execution.jobs.DownstreamRXTask in project crate by crate.

the class TransportDistributedResultAction method nodeOperation.

private CompletableFuture<DistributedResultResponse> nodeOperation(final DistributedResultRequest request, @Nullable Iterator<TimeValue> retryDelay) {
    RootTask rootTask = tasksService.getTaskOrNull(request.jobId());
    if (rootTask == null) {
        if (tasksService.recentlyFailed(request.jobId())) {
            return CompletableFuture.failedFuture(JobKilledException.of("Received result for job=" + request.jobId() + " but there is no context for this job due to a failure during the setup."));
        } else {
            return retryOrFailureResponse(request, retryDelay);
        }
    }
    DownstreamRXTask rxTask;
    try {
        rxTask = rootTask.getTask(request.executionPhaseId());
    } catch (ClassCastException e) {
        return CompletableFuture.failedFuture(new IllegalStateException(String.format(Locale.ENGLISH, "Found execution rootTask for %d but it's not a downstream rootTask", request.executionPhaseId()), e));
    } catch (Throwable t) {
        return CompletableFuture.failedFuture(t);
    }
    PageBucketReceiver pageBucketReceiver = rxTask.getBucketReceiver(request.executionPhaseInputId());
    if (pageBucketReceiver == null) {
        return CompletableFuture.failedFuture(new IllegalStateException(String.format(Locale.ENGLISH, "Couldn't find BucketReceiver for input %d", request.executionPhaseInputId())));
    }
    Throwable throwable = request.throwable();
    if (throwable == null) {
        SendResponsePageResultListener pageResultListener = new SendResponsePageResultListener();
        pageBucketReceiver.setBucket(request.bucketIdx(), request.readRows(pageBucketReceiver.streamers()), request.isLast(), pageResultListener);
        return pageResultListener.future;
    } else {
        pageBucketReceiver.kill(throwable);
        return CompletableFuture.completedFuture(new DistributedResultResponse(false));
    }
}
Also used : PageBucketReceiver(io.crate.execution.jobs.PageBucketReceiver) DownstreamRXTask(io.crate.execution.jobs.DownstreamRXTask) RootTask(io.crate.execution.jobs.RootTask)

Aggregations

DownstreamRXTask (io.crate.execution.jobs.DownstreamRXTask)2 PageBucketReceiver (io.crate.execution.jobs.PageBucketReceiver)2 RootTask (io.crate.execution.jobs.RootTask)2 ExecutionPhase (io.crate.execution.dsl.phases.ExecutionPhase)1 Task (io.crate.execution.jobs.Task)1 ArrayList (java.util.ArrayList)1