Search in sources :

Example 6 with Firehose

use of org.apache.druid.data.input.Firehose in project druid by druid-io.

the class PrefetchableTextFilesFirehoseFactoryTest method testWithoutCache.

@Test
public void testWithoutCache() throws IOException {
    final TestPrefetchableTextFilesFirehoseFactory factory = TestPrefetchableTextFilesFirehoseFactory.with(TEST_DIR, 0, 2048);
    final List<Row> rows = new ArrayList<>();
    final File firehoseTmpDir = createFirehoseTmpDir("testWithoutCache");
    try (Firehose firehose = factory.connect(PARSER, firehoseTmpDir)) {
        while (firehose.hasMore()) {
            rows.add(firehose.nextRow());
        }
    }
    Assert.assertEquals(0, factory.getCacheManager().getTotalCachedBytes());
    assertResult(rows);
    assertNumRemainingCacheFiles(firehoseTmpDir, 0);
}
Also used : Firehose(org.apache.druid.data.input.Firehose) ArrayList(java.util.ArrayList) Row(org.apache.druid.data.input.Row) File(java.io.File) Test(org.junit.Test)

Example 7 with Firehose

use of org.apache.druid.data.input.Firehose in project druid by druid-io.

the class PrefetchableTextFilesFirehoseFactoryTest method testWithoutCacheAndFetchAgainstConnectionReset.

@Test
public void testWithoutCacheAndFetchAgainstConnectionReset() throws IOException {
    final TestPrefetchableTextFilesFirehoseFactory factory = TestPrefetchableTextFilesFirehoseFactory.withConnectionResets(TEST_DIR, 0, 0, 2);
    final List<Row> rows = new ArrayList<>();
    final File firehoseTmpDir = createFirehoseTmpDir("testWithoutCacheAndFetch");
    try (Firehose firehose = factory.connect(PARSER, firehoseTmpDir)) {
        while (firehose.hasMore()) {
            rows.add(firehose.nextRow());
        }
    }
    Assert.assertEquals(0, factory.getCacheManager().getTotalCachedBytes());
    assertResult(rows);
    assertNumRemainingCacheFiles(firehoseTmpDir, 0);
}
Also used : Firehose(org.apache.druid.data.input.Firehose) ArrayList(java.util.ArrayList) Row(org.apache.druid.data.input.Row) File(java.io.File) Test(org.junit.Test)

Example 8 with Firehose

use of org.apache.druid.data.input.Firehose in project druid by druid-io.

the class PrefetchableTextFilesFirehoseFactoryTest method testWithLargeCacheAndSmallFetch.

@Test
public void testWithLargeCacheAndSmallFetch() throws IOException {
    final TestPrefetchableTextFilesFirehoseFactory factory = TestPrefetchableTextFilesFirehoseFactory.with(TEST_DIR, 2048, 1024);
    final List<Row> rows = new ArrayList<>();
    final File firehoseTmpDir = createFirehoseTmpDir("testWithLargeCacheAndSmallFetch");
    try (Firehose firehose = factory.connect(PARSER, firehoseTmpDir)) {
        while (firehose.hasMore()) {
            rows.add(firehose.nextRow());
        }
    }
    assertResult(rows);
    assertNumRemainingCacheFiles(firehoseTmpDir, 2);
}
Also used : Firehose(org.apache.druid.data.input.Firehose) ArrayList(java.util.ArrayList) Row(org.apache.druid.data.input.Row) File(java.io.File) Test(org.junit.Test)

Example 9 with Firehose

use of org.apache.druid.data.input.Firehose in project druid by druid-io.

the class PrefetchableTextFilesFirehoseFactoryTest method testMaxRetry.

@Test
public void testMaxRetry() throws IOException {
    expectedException.expect(RuntimeException.class);
    expectedException.expectCause(CoreMatchers.instanceOf(ExecutionException.class));
    expectedException.expectMessage("Exception for retry test");
    final TestPrefetchableTextFilesFirehoseFactory factory = TestPrefetchableTextFilesFirehoseFactory.withOpenExceptions(TEST_DIR, 5);
    try (Firehose firehose = factory.connect(PARSER, createFirehoseTmpDir("testMaxRetry"))) {
        while (firehose.hasMore()) {
            firehose.nextRow();
        }
    }
}
Also used : Firehose(org.apache.druid.data.input.Firehose) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 10 with Firehose

use of org.apache.druid.data.input.Firehose in project druid by druid-io.

the class PrefetchableTextFilesFirehoseFactoryTest method testRetry.

@Test
public void testRetry() throws IOException {
    final TestPrefetchableTextFilesFirehoseFactory factory = TestPrefetchableTextFilesFirehoseFactory.withOpenExceptions(TEST_DIR, 1);
    final List<Row> rows = new ArrayList<>();
    final File firehoseTmpDir = createFirehoseTmpDir("testRetry");
    try (Firehose firehose = factory.connect(PARSER, firehoseTmpDir)) {
        while (firehose.hasMore()) {
            rows.add(firehose.nextRow());
        }
    }
    assertResult(rows);
    assertNumRemainingCacheFiles(firehoseTmpDir, 2);
}
Also used : Firehose(org.apache.druid.data.input.Firehose) ArrayList(java.util.ArrayList) Row(org.apache.druid.data.input.Row) File(java.io.File) Test(org.junit.Test)

Aggregations

Firehose (org.apache.druid.data.input.Firehose)30 Test (org.junit.Test)25 File (java.io.File)19 ArrayList (java.util.ArrayList)16 Row (org.apache.druid.data.input.Row)14 InputRow (org.apache.druid.data.input.InputRow)13 List (java.util.List)7 ImmutableList (com.google.common.collect.ImmutableList)6 ImmutableMap (com.google.common.collect.ImmutableMap)6 IOException (java.io.IOException)6 Map (java.util.Map)6 InputRowParser (org.apache.druid.data.input.impl.InputRowParser)6 MapInputRowParser (org.apache.druid.data.input.impl.MapInputRowParser)6 DataSchema (org.apache.druid.segment.indexing.DataSchema)6 TypeReference (com.fasterxml.jackson.core.type.TypeReference)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)5 Iterables (com.google.common.collect.Iterables)4 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)4 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)4