use of io.crate.jobs.PageBucketReceiver 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));
}
}
use of io.crate.jobs.PageBucketReceiver in project crate by crate.
the class SetBucketAction method setBuckets.
protected void setBuckets(List<Bucket> result) {
initializationTracker.jobInitialized();
for (int i = 0; i < pageBucketReceivers.size(); i++) {
PageBucketReceiver pageBucketReceiver = pageBucketReceivers.get(i);
Bucket bucket = result.get(i);
assert bucket != null : "expected directResponse but didn't get one idx=" + i;
pageBucketReceiver.setBucket(bucketIdx, bucket, true, bucketResultListener);
}
}
Aggregations