Search in sources :

Example 1 with ExtractionNamespace

use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.

the class NamespacedExtractorModuleTest method setUp.

@Before
public void setUp() throws Exception {
    final Map<Class<? extends ExtractionNamespace>, ExtractionNamespaceCacheFactory<?>> factoryMap = ImmutableMap.<Class<? extends ExtractionNamespace>, ExtractionNamespaceCacheFactory<?>>of(URIExtractionNamespace.class, new URIExtractionNamespaceCacheFactory(ImmutableMap.<String, SearchableVersionedDataFinder>of("file", new LocalFileTimestampVersionFinder())), JDBCExtractionNamespace.class, new JDBCExtractionNamespaceCacheFactory());
    lifecycle = new Lifecycle();
    lifecycle.start();
    NoopServiceEmitter noopServiceEmitter = new NoopServiceEmitter();
    scheduler = new CacheScheduler(noopServiceEmitter, factoryMap, new OnHeapNamespaceExtractionCacheManager(lifecycle, noopServiceEmitter));
}
Also used : SearchableVersionedDataFinder(io.druid.data.SearchableVersionedDataFinder) OnHeapNamespaceExtractionCacheManager(io.druid.server.lookup.namespace.cache.OnHeapNamespaceExtractionCacheManager) Lifecycle(io.druid.java.util.common.lifecycle.Lifecycle) NoopServiceEmitter(io.druid.server.metrics.NoopServiceEmitter) ExtractionNamespaceCacheFactory(io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory) ExtractionNamespace(io.druid.query.lookup.namespace.ExtractionNamespace) URIExtractionNamespace(io.druid.query.lookup.namespace.URIExtractionNamespace) JDBCExtractionNamespace(io.druid.query.lookup.namespace.JDBCExtractionNamespace) LocalFileTimestampVersionFinder(io.druid.segment.loading.LocalFileTimestampVersionFinder) CacheScheduler(io.druid.server.lookup.namespace.cache.CacheScheduler) Before(org.junit.Before)

Example 2 with ExtractionNamespace

use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.

the class NamespaceLookupExtractorFactoryTest method testStartFailsToSchedule.

@Test
public void testStartFailsToSchedule() {
    final ExtractionNamespace extractionNamespace = new ExtractionNamespace() {

        @Override
        public long getPollMs() {
            return 0;
        }
    };
    try {
        EasyMock.expect(scheduler.scheduleAndWait(EasyMock.eq(extractionNamespace), EasyMock.eq(60000L))).andReturn(null).once();
    } catch (InterruptedException e) {
        throw new AssertionError(e);
    }
    mockReplay();
    final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
    Assert.assertFalse(namespaceLookupExtractorFactory.start());
    // true because it never fully started
    Assert.assertTrue(namespaceLookupExtractorFactory.close());
    mockVerify();
}
Also used : ExtractionNamespace(io.druid.query.lookup.namespace.ExtractionNamespace) URIExtractionNamespace(io.druid.query.lookup.namespace.URIExtractionNamespace) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with ExtractionNamespace

use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.

the class NamespaceLookupExtractorFactoryTest method testSimpleStartRacyGetDuringDelete.

@Test
public void testSimpleStartRacyGetDuringDelete() {
    final ExtractionNamespace extractionNamespace = new ExtractionNamespace() {

        @Override
        public long getPollMs() {
            return 0;
        }
    };
    expectScheduleAndWaitOnce(extractionNamespace);
    expectEntryGetCacheStateOnce(CacheScheduler.NoCache.ENTRY_CLOSED);
    mockReplay();
    final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
    Assert.assertTrue(namespaceLookupExtractorFactory.start());
    try {
        namespaceLookupExtractorFactory.get();
        Assert.fail("Should have thrown ISE");
    } catch (ISE ise) {
    // NOOP
    }
    mockVerify();
}
Also used : ExtractionNamespace(io.druid.query.lookup.namespace.ExtractionNamespace) URIExtractionNamespace(io.druid.query.lookup.namespace.URIExtractionNamespace) ISE(io.druid.java.util.common.ISE) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with ExtractionNamespace

use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.

the class NamespaceLookupExtractorFactoryTest method testSimpleStartStart.

@Test
public void testSimpleStartStart() {
    final ExtractionNamespace extractionNamespace = new ExtractionNamespace() {

        @Override
        public long getPollMs() {
            return 0;
        }
    };
    expectScheduleAndWaitOnce(extractionNamespace);
    mockReplay();
    final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
    Assert.assertTrue(namespaceLookupExtractorFactory.start());
    Assert.assertTrue(namespaceLookupExtractorFactory.start());
    mockVerify();
}
Also used : ExtractionNamespace(io.druid.query.lookup.namespace.ExtractionNamespace) URIExtractionNamespace(io.druid.query.lookup.namespace.URIExtractionNamespace) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with ExtractionNamespace

use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.

the class NamespaceLookupExtractorFactoryTest method testSimpleStartStopStop.

@Test
public void testSimpleStartStopStop() {
    final ExtractionNamespace extractionNamespace = new ExtractionNamespace() {

        @Override
        public long getPollMs() {
            return 0;
        }
    };
    expectScheduleAndWaitOnce(extractionNamespace);
    expectEntryCloseOnce();
    mockReplay();
    final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
    Assert.assertTrue(namespaceLookupExtractorFactory.start());
    Assert.assertTrue(namespaceLookupExtractorFactory.close());
    Assert.assertTrue(namespaceLookupExtractorFactory.close());
    mockVerify();
}
Also used : ExtractionNamespace(io.druid.query.lookup.namespace.ExtractionNamespace) URIExtractionNamespace(io.druid.query.lookup.namespace.URIExtractionNamespace) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

ExtractionNamespace (io.druid.query.lookup.namespace.ExtractionNamespace)14 URIExtractionNamespace (io.druid.query.lookup.namespace.URIExtractionNamespace)13 Test (org.junit.Test)11 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)11 Lifecycle (io.druid.java.util.common.lifecycle.Lifecycle)3 ExtractionNamespaceCacheFactory (io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory)3 NoopServiceEmitter (io.druid.server.metrics.NoopServiceEmitter)3 Before (org.junit.Before)3 CacheScheduler (io.druid.server.lookup.namespace.cache.CacheScheduler)2 OnHeapNamespaceExtractionCacheManager (io.druid.server.lookup.namespace.cache.OnHeapNamespaceExtractionCacheManager)2 SearchableVersionedDataFinder (io.druid.data.SearchableVersionedDataFinder)1 ISE (io.druid.java.util.common.ISE)1 JDBCExtractionNamespace (io.druid.query.lookup.namespace.JDBCExtractionNamespace)1 StaticMapExtractionNamespace (io.druid.query.lookup.namespace.StaticMapExtractionNamespace)1 LocalFileTimestampVersionFinder (io.druid.segment.loading.LocalFileTimestampVersionFinder)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Path (java.nio.file.Path)1 Response (javax.ws.rs.core.Response)1