Search in sources :

Example 1 with PageDownstreamContext

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;
}
Also used : PageDownstreamContext(io.crate.jobs.PageDownstreamContext) JobExecutionContext(io.crate.jobs.JobExecutionContext) Row(io.crate.data.Row)

Example 2 with PageDownstreamContext

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());
}
Also used : PageDownstreamContext(io.crate.jobs.PageDownstreamContext) Streamer(io.crate.Streamer) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) CollectionBucket(io.crate.data.CollectionBucket) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 3 with PageDownstreamContext

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();
}
Also used : PageDownstreamContext(io.crate.jobs.PageDownstreamContext) Streamer(io.crate.Streamer) CompletionException(java.util.concurrent.CompletionException) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

PageDownstreamContext (io.crate.jobs.PageDownstreamContext)3 Streamer (io.crate.Streamer)2 CrateUnitTest (io.crate.test.integration.CrateUnitTest)2 TestingBatchConsumer (io.crate.testing.TestingBatchConsumer)2 Test (org.junit.Test)2 CollectionBucket (io.crate.data.CollectionBucket)1 Row (io.crate.data.Row)1 JobExecutionContext (io.crate.jobs.JobExecutionContext)1 CompletionException (java.util.concurrent.CompletionException)1