use of io.crate.jobs.PageDownstreamContext in project crate by crate.
the class RemoteCollector method createPageDownstreamContext.
private JobExecutionContext.Builder createPageDownstreamContext() {
JobExecutionContext.Builder builder = jobContextService.newBuilder(jobId, localNode);
PassThroughPagingIterator<Integer, Row> pagingIterator;
if (scrollRequired) {
pagingIterator = PassThroughPagingIterator.repeatable();
} else {
pagingIterator = PassThroughPagingIterator.oneShot();
}
builder.addSubContext(new PageDownstreamContext(LOGGER, localNode, RECEIVER_PHASE_ID, "remoteCollectReceiver", consumer, pagingIterator, DataTypes.getStreamers(collectPhase.outputTypes()), ramAccountingContext, 1));
return builder;
}
use of io.crate.jobs.PageDownstreamContext in project crate by crate.
the class DistributingConsumerTest method testSendUsingDistributingConsumerAndReceiveWithPageDownstreamContext.
@Test
public void testSendUsingDistributingConsumerAndReceiveWithPageDownstreamContext() throws Exception {
Streamer<?>[] streamers = { DataTypes.INTEGER.streamer() };
TestingBatchConsumer collectingConsumer = new TestingBatchConsumer();
PageDownstreamContext pageDownstreamContext = createPageDownstreamContext(streamers, collectingConsumer);
TransportDistributedResultAction distributedResultAction = createFakeTransport(streamers, pageDownstreamContext);
DistributingConsumer distributingConsumer = createDistributingConsumer(streamers, distributedResultAction);
distributingConsumer.accept(TestingBatchIterators.range(0, 5), null);
List<Object[]> result = collectingConsumer.getResult();
assertThat(TestingHelpers.printedTable(new CollectionBucket(result)), is("0\n" + "1\n" + "2\n" + "3\n" + "4\n"));
// pageSize=2 and 5 rows causes 3x pushResult
verify(distributedResultAction, times(3)).pushResult(anyString(), any(), any());
}
use of io.crate.jobs.PageDownstreamContext in project crate by crate.
the class DistributingConsumerTest method testDistributingConsumerForwardsFailure.
@Test
public void testDistributingConsumerForwardsFailure() throws Exception {
Streamer<?>[] streamers = { DataTypes.INTEGER.streamer() };
TestingBatchConsumer collectingConsumer = new TestingBatchConsumer();
PageDownstreamContext pageDownstreamContext = createPageDownstreamContext(streamers, collectingConsumer);
TransportDistributedResultAction distributedResultAction = createFakeTransport(streamers, pageDownstreamContext);
DistributingConsumer distributingConsumer = createDistributingConsumer(streamers, distributedResultAction);
distributingConsumer.accept(null, new CompletionException(new IllegalArgumentException("foobar")));
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("foobar");
collectingConsumer.getResult();
}
Aggregations