Search in sources :

Example 11 with RowIngestionMeters

use of org.apache.druid.segment.incremental.RowIngestionMeters in project druid by druid-io.

the class ClosedSegmentsSinksBatchAppenderatorTest method testPushContract.

@Test(timeout = 10000L)
public void testPushContract() throws Exception {
    final RowIngestionMeters rowIngestionMeters = new SimpleRowIngestionMeters();
    try (final ClosedSegmensSinksBatchAppenderatorTester tester = new ClosedSegmensSinksBatchAppenderatorTester(1, 50000L, null, false, rowIngestionMeters)) {
        final Appenderator appenderator = tester.getAppenderator();
        appenderator.startJob();
        appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "bar", 1), null);
        appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "bar2", 1), null);
        appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bar3", 1), null);
        // push only a single segment
        final SegmentsAndCommitMetadata segmentsAndCommitMetadata = appenderator.push(Collections.singletonList(IDENTIFIERS.get(0)), null, false).get();
        // only one segment must have been pushed:
        Assert.assertEquals(Collections.singletonList(IDENTIFIERS.get(0)), Lists.transform(segmentsAndCommitMetadata.getSegments(), SegmentIdWithShardSpec::fromDataSegment).stream().sorted().collect(Collectors.toList()));
        Assert.assertEquals(tester.getPushedSegments().stream().sorted().collect(Collectors.toList()), segmentsAndCommitMetadata.getSegments().stream().sorted().collect(Collectors.toList()));
        // the responsability for dropping is in the BatchAppenderatorDriver, drop manually:
        appenderator.drop(IDENTIFIERS.get(0));
        // and the segment that was not pushed should still be active
        Assert.assertEquals(Collections.singletonList(IDENTIFIERS.get(1)), appenderator.getSegments());
    }
}
Also used : SimpleRowIngestionMeters(org.apache.druid.segment.incremental.SimpleRowIngestionMeters) SimpleRowIngestionMeters(org.apache.druid.segment.incremental.SimpleRowIngestionMeters) RowIngestionMeters(org.apache.druid.segment.incremental.RowIngestionMeters) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

RowIngestionMeters (org.apache.druid.segment.incremental.RowIngestionMeters)11 InputRow (org.apache.druid.data.input.InputRow)6 ParseExceptionHandler (org.apache.druid.segment.incremental.ParseExceptionHandler)5 Test (org.junit.Test)5 DataSchema (org.apache.druid.segment.indexing.DataSchema)4 IOException (java.io.IOException)3 ExecutionException (java.util.concurrent.ExecutionException)3 TimeoutException (java.util.concurrent.TimeoutException)3 InputFormat (org.apache.druid.data.input.InputFormat)3 SimpleRowIngestionMeters (org.apache.druid.segment.incremental.SimpleRowIngestionMeters)3 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Preconditions (com.google.common.base.Preconditions)2 Supplier (com.google.common.base.Supplier)2 Throwables (com.google.common.base.Throwables)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Futures (com.google.common.util.concurrent.Futures)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2