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;
}
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));
}
}
Aggregations