Search in sources :

Example 6 with ExtractionNamespace

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

the class NamespaceLookupExtractorFactoryTest method testSimpleStartRacyGetDuringDelete.

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

        @Override
        public long getPollMs() {
            return 0;
        }
    };
    expectScheduleAndWaitOnce(extractionNamespace);
    when(entry.getCacheState()).thenReturn(CacheScheduler.NoCache.ENTRY_CLOSED);
    final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
    Assert.assertTrue(namespaceLookupExtractorFactory.start());
    Assert.assertThrows(ISE.class, () -> namespaceLookupExtractorFactory.get());
    verify(scheduler).scheduleAndWait(extractionNamespace, 60000L);
    verify(entry).getCacheState();
    verifyNoMoreInteractions(scheduler, entry, versionedCache);
}
Also used : ExtractionNamespace(org.apache.druid.query.lookup.namespace.ExtractionNamespace) UriExtractionNamespace(org.apache.druid.query.lookup.namespace.UriExtractionNamespace) Test(org.junit.Test)

Example 7 with ExtractionNamespace

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

the class NamespaceLookupExtractorFactoryTest method testStartReturnsImmediately.

@Test
public void testStartReturnsImmediately() {
    final ExtractionNamespace extractionNamespace = () -> 0;
    when(scheduler.schedule(extractionNamespace)).thenReturn(entry);
    final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, 0, false, scheduler);
    Assert.assertTrue(namespaceLookupExtractorFactory.start());
    Assert.assertTrue(namespaceLookupExtractorFactory.close());
    verify(scheduler).schedule(any());
    verify(entry).close();
    verifyNoMoreInteractions(scheduler, entry, versionedCache);
}
Also used : ExtractionNamespace(org.apache.druid.query.lookup.namespace.ExtractionNamespace) UriExtractionNamespace(org.apache.druid.query.lookup.namespace.UriExtractionNamespace) Test(org.junit.Test)

Example 8 with ExtractionNamespace

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

the class NamespaceLookupExtractorFactoryTest method testReplaces.

@Test
public void testReplaces() {
    final ExtractionNamespace en1 = mock(ExtractionNamespace.class), en2 = mock(ExtractionNamespace.class);
    final NamespaceLookupExtractorFactory f1 = new NamespaceLookupExtractorFactory(en1, scheduler);
    final NamespaceLookupExtractorFactory f2 = new NamespaceLookupExtractorFactory(en2, scheduler);
    final NamespaceLookupExtractorFactory f1b = new NamespaceLookupExtractorFactory(en1, scheduler);
    Assert.assertTrue(f1.replaces(f2));
    Assert.assertTrue(f2.replaces(f1));
    Assert.assertFalse(f1.replaces(f1b));
    Assert.assertFalse(f1b.replaces(f1));
    Assert.assertFalse(f1.replaces(f1));
    Assert.assertTrue(f1.replaces(mock(LookupExtractorFactory.class)));
    verifyNoInteractions(en1, en2);
}
Also used : ExtractionNamespace(org.apache.druid.query.lookup.namespace.ExtractionNamespace) UriExtractionNamespace(org.apache.druid.query.lookup.namespace.UriExtractionNamespace) Test(org.junit.Test)

Example 9 with ExtractionNamespace

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

the class NamespaceLookupExtractorFactoryTest method testSimpleStartStopStop.

@Test
public void testSimpleStartStopStop() throws Exception {
    final ExtractionNamespace extractionNamespace = () -> 0;
    expectScheduleAndWaitOnce(extractionNamespace);
    final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
    Assert.assertTrue(namespaceLookupExtractorFactory.start());
    Assert.assertTrue(namespaceLookupExtractorFactory.close());
    Assert.assertTrue(namespaceLookupExtractorFactory.close());
    verify(entry).close();
    verify(scheduler).scheduleAndWait(extractionNamespace, 60000L);
    verifyNoMoreInteractions(scheduler, entry, versionedCache);
}
Also used : ExtractionNamespace(org.apache.druid.query.lookup.namespace.ExtractionNamespace) UriExtractionNamespace(org.apache.druid.query.lookup.namespace.UriExtractionNamespace) Test(org.junit.Test)

Example 10 with ExtractionNamespace

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

the class NamespaceLookupExtractorFactoryTest method testSimpleStartStop.

@Test
public void testSimpleStartStop() throws Exception {
    final ExtractionNamespace extractionNamespace = () -> 0;
    expectScheduleAndWaitOnce(extractionNamespace);
    final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
    Assert.assertTrue(namespaceLookupExtractorFactory.start());
    Assert.assertTrue(namespaceLookupExtractorFactory.close());
    verify(scheduler).scheduleAndWait(extractionNamespace, 60000L);
    verify(entry).close();
    verifyNoMoreInteractions(scheduler, entry, versionedCache);
}
Also used : ExtractionNamespace(org.apache.druid.query.lookup.namespace.ExtractionNamespace) UriExtractionNamespace(org.apache.druid.query.lookup.namespace.UriExtractionNamespace) Test(org.junit.Test)

Aggregations

ExtractionNamespace (org.apache.druid.query.lookup.namespace.ExtractionNamespace)13 UriExtractionNamespace (org.apache.druid.query.lookup.namespace.UriExtractionNamespace)12 Test (org.junit.Test)12 JdbcExtractionNamespace (org.apache.druid.query.lookup.namespace.JdbcExtractionNamespace)2 Std (com.fasterxml.jackson.databind.InjectableValues.Std)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Response (javax.ws.rs.core.Response)1 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)1 Lifecycle (org.apache.druid.java.util.common.lifecycle.Lifecycle)1 CacheGenerator (org.apache.druid.query.lookup.namespace.CacheGenerator)1 LocalFileTimestampVersionFinder (org.apache.druid.segment.loading.LocalFileTimestampVersionFinder)1 JdbcAccessSecurityConfig (org.apache.druid.server.initialization.JdbcAccessSecurityConfig)1 CacheScheduler (org.apache.druid.server.lookup.namespace.cache.CacheScheduler)1 OnHeapNamespaceExtractionCacheManager (org.apache.druid.server.lookup.namespace.cache.OnHeapNamespaceExtractionCacheManager)1 NoopServiceEmitter (org.apache.druid.server.metrics.NoopServiceEmitter)1 Period (org.joda.time.Period)1 Before (org.junit.Before)1