use of io.crate.jobs.DownstreamExecutionSubContext in project crate by crate.
the class TransportDistributedResultAction method nodeOperation.
private void nodeOperation(final DistributedResultRequest request, final ActionListener<DistributedResultResponse> listener, final int retry) {
JobExecutionContext context = jobContextService.getContextOrNull(request.jobId());
if (context == null) {
retryOrFailureResponse(request, listener, retry);
return;
}
DownstreamExecutionSubContext executionContext;
try {
executionContext = context.getSubContext(request.executionPhaseId());
} catch (ClassCastException e) {
listener.onFailure(new IllegalStateException(String.format(Locale.ENGLISH, "Found execution context for %d but it's not a downstream context", request.executionPhaseId()), e));
return;
} catch (Throwable t) {
listener.onFailure(t);
return;
}
PageBucketReceiver pageBucketReceiver = executionContext.getBucketReceiver(request.executionPhaseInputId());
if (pageBucketReceiver == null) {
listener.onFailure(new IllegalStateException(String.format(Locale.ENGLISH, "Couldn't find BucketReciever for input %d", request.executionPhaseInputId())));
return;
}
Throwable throwable = request.throwable();
if (throwable == null) {
request.streamers(pageBucketReceiver.streamers());
pageBucketReceiver.setBucket(request.bucketIdx(), request.rows(), request.isLast(), new SendResponsePageResultListener(listener));
} else {
if (request.isKilled()) {
pageBucketReceiver.killed(request.bucketIdx(), throwable);
} else {
pageBucketReceiver.failure(request.bucketIdx(), throwable);
}
listener.onResponse(new DistributedResultResponse(false));
}
}
Aggregations