Search in sources :

Example 11 with SimpleRowIngestionMeters

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

the class StreamAppenderatorTest method testTaskDoesNotFailAsExceededMemoryWithSkipBytesInMemoryOverheadCheckConfig.

@Test
public void testTaskDoesNotFailAsExceededMemoryWithSkipBytesInMemoryOverheadCheckConfig() throws Exception {
    try (final StreamAppenderatorTester tester = new StreamAppenderatorTester(100, 10, null, true, new SimpleRowIngestionMeters(), true)) {
        final Appenderator appenderator = tester.getAppenderator();
        final AtomicInteger eventCount = new AtomicInteger(0);
        final Supplier<Committer> committerSupplier = () -> {
            final Object metadata = ImmutableMap.of(eventCount, eventCount.get());
            return new Committer() {

                @Override
                public Object getMetadata() {
                    return metadata;
                }

                @Override
                public void run() {
                // Do nothing
                }
            };
        };
        appenderator.startJob();
        appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier);
        // Expected 0 since we persisted after the add
        Assert.assertEquals(0, ((StreamAppenderator) appenderator).getBytesCurrentlyInMemory());
        appenderator.add(IDENTIFIERS.get(0), ir("2000", "foo", 1), committerSupplier);
        // Expected 0 since we persisted after the add
        Assert.assertEquals(0, ((StreamAppenderator) appenderator).getBytesCurrentlyInMemory());
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SimpleRowIngestionMeters(org.apache.druid.segment.incremental.SimpleRowIngestionMeters) Committer(org.apache.druid.data.input.Committer) InitializedNullHandlingTest(org.apache.druid.testing.InitializedNullHandlingTest) Test(org.junit.Test)

Aggregations

SimpleRowIngestionMeters (org.apache.druid.segment.incremental.SimpleRowIngestionMeters)11 InitializedNullHandlingTest (org.apache.druid.testing.InitializedNullHandlingTest)10 Test (org.junit.Test)10 RowIngestionMeters (org.apache.druid.segment.incremental.RowIngestionMeters)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Committer (org.apache.druid.data.input.Committer)3 ParseExceptionHandler (org.apache.druid.segment.incremental.ParseExceptionHandler)1 Before (org.junit.Before)1