Search in sources :

Example 1 with TestCommitterSupplier

use of org.apache.druid.segment.realtime.appenderator.StreamAppenderatorDriverTest.TestCommitterSupplier in project druid by druid-io.

the class StreamAppenderatorDriverFailTest method testFailDuringPublishInternal.

private void testFailDuringPublishInternal(boolean failWithException) throws Exception {
    driver = new StreamAppenderatorDriver(new FailableAppenderator(), allocator, segmentHandoffNotifierFactory, new NoopUsedSegmentChecker(), dataSegmentKiller, OBJECT_MAPPER, new FireDepartmentMetrics());
    driver.startJob(null);
    final TestCommitterSupplier<Integer> committerSupplier = new TestCommitterSupplier<>();
    segmentHandoffNotifierFactory.setHandoffDelay(100);
    Assert.assertNull(driver.startJob(null));
    for (int i = 0; i < ROWS.size(); i++) {
        committerSupplier.setMetadata(i + 1);
        Assert.assertTrue(driver.add(ROWS.get(i), "dummy", committerSupplier, false, true).isOk());
    }
    if (!failWithException) {
        // Should only kill segments if there was _no_ exception.
        dataSegmentKiller.killQuietly(new DataSegment("foo", Intervals.of("2000-01-01T00:00:00.000Z/2000-01-01T01:00:00.000Z"), "abc123", ImmutableMap.of(), ImmutableList.of(), ImmutableList.of(), new NumberedShardSpec(0, 0), 0, 0));
        EasyMock.expectLastCall().once();
        dataSegmentKiller.killQuietly(new DataSegment("foo", Intervals.of("2000-01-01T01:00:00.000Z/2000-01-01T02:00:00.000Z"), "abc123", ImmutableMap.of(), ImmutableList.of(), ImmutableList.of(), new NumberedShardSpec(0, 0), 0, 0));
        EasyMock.expectLastCall().once();
    }
    EasyMock.replay(dataSegmentKiller);
    try {
        driver.publish(StreamAppenderatorDriverTest.makeFailingPublisher(failWithException), committerSupplier.get(), ImmutableList.of("dummy")).get(PUBLISH_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    } catch (Exception e) {
        throw e;
    } finally {
        EasyMock.verify(dataSegmentKiller);
    }
}
Also used : TestCommitterSupplier(org.apache.druid.segment.realtime.appenderator.StreamAppenderatorDriverTest.TestCommitterSupplier) FireDepartmentMetrics(org.apache.druid.segment.realtime.FireDepartmentMetrics) DataSegment(org.apache.druid.timeline.DataSegment) NumberedShardSpec(org.apache.druid.timeline.partition.NumberedShardSpec) TimeoutException(java.util.concurrent.TimeoutException) ExpectedException(org.junit.rules.ExpectedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 FireDepartmentMetrics (org.apache.druid.segment.realtime.FireDepartmentMetrics)1 TestCommitterSupplier (org.apache.druid.segment.realtime.appenderator.StreamAppenderatorDriverTest.TestCommitterSupplier)1 DataSegment (org.apache.druid.timeline.DataSegment)1 NumberedShardSpec (org.apache.druid.timeline.partition.NumberedShardSpec)1 ExpectedException (org.junit.rules.ExpectedException)1