Search in sources :

Example 1 with ExtractionNamespace

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

the class NamespaceLookupExtractorFactoryTest method testExceptionalIntrospectionHandler.

@Test
public void testExceptionalIntrospectionHandler() throws Exception {
    final ExtractionNamespace extractionNamespace = mock(ExtractionNamespace.class);
    when(scheduler.scheduleAndWait(eq(extractionNamespace), anyLong())).thenReturn(entry);
    final LookupExtractorFactory lookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
    Assert.assertTrue(lookupExtractorFactory.start());
    final LookupIntrospectHandler handler = lookupExtractorFactory.getIntrospectHandler();
    Assert.assertNotNull(handler);
    final Class<? extends LookupIntrospectHandler> clazz = handler.getClass();
    verify(scheduler).scheduleAndWait(eq(extractionNamespace), anyLong());
    verifyNoMoreInteractions(scheduler, entry, versionedCache);
    reset(scheduler, entry, versionedCache);
    when(entry.getCacheState()).thenReturn(CacheScheduler.NoCache.CACHE_NOT_INITIALIZED);
    final Response response = (Response) clazz.getMethod("getVersion").invoke(handler);
    Assert.assertEquals(404, response.getStatus());
    verify(entry).getCacheState();
    validateNotFound("getKeys", handler, clazz);
    validateNotFound("getValues", handler, clazz);
    validateNotFound("getMap", handler, clazz);
    verifyNoMoreInteractions(scheduler, entry, versionedCache);
}
Also used : Response(javax.ws.rs.core.Response) ExtractionNamespace(org.apache.druid.query.lookup.namespace.ExtractionNamespace) UriExtractionNamespace(org.apache.druid.query.lookup.namespace.UriExtractionNamespace) Test(org.junit.Test)

Example 2 with ExtractionNamespace

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

the class NamespaceLookupExtractorFactoryTest method testSimpleStartStart.

@Test
public void testSimpleStartStart() throws Exception {
    final ExtractionNamespace extractionNamespace = () -> 0;
    expectScheduleAndWaitOnce(extractionNamespace);
    final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
    Assert.assertTrue(namespaceLookupExtractorFactory.start());
    Assert.assertTrue(namespaceLookupExtractorFactory.start());
    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 3 with ExtractionNamespace

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

the class NamespaceLookupExtractorFactoryTest method testMustBeStarted.

@Test(expected = ISE.class)
public void testMustBeStarted() {
    final ExtractionNamespace extractionNamespace = () -> 0;
    final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
    namespaceLookupExtractorFactory.get();
}
Also used : ExtractionNamespace(org.apache.druid.query.lookup.namespace.ExtractionNamespace) UriExtractionNamespace(org.apache.druid.query.lookup.namespace.UriExtractionNamespace) Test(org.junit.Test)

Example 4 with ExtractionNamespace

use of org.apache.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>, CacheGenerator<?>> factoryMap = ImmutableMap.of(UriExtractionNamespace.class, new UriCacheGenerator(ImmutableMap.of("file", new LocalFileTimestampVersionFinder())), JdbcExtractionNamespace.class, new JdbcCacheGenerator());
    lifecycle = new Lifecycle();
    lifecycle.start();
    NoopServiceEmitter noopServiceEmitter = new NoopServiceEmitter();
    scheduler = new CacheScheduler(noopServiceEmitter, factoryMap, new OnHeapNamespaceExtractionCacheManager(lifecycle, noopServiceEmitter, new NamespaceExtractionConfig()));
}
Also used : CacheGenerator(org.apache.druid.query.lookup.namespace.CacheGenerator) OnHeapNamespaceExtractionCacheManager(org.apache.druid.server.lookup.namespace.cache.OnHeapNamespaceExtractionCacheManager) Lifecycle(org.apache.druid.java.util.common.lifecycle.Lifecycle) ExtractionNamespace(org.apache.druid.query.lookup.namespace.ExtractionNamespace) UriExtractionNamespace(org.apache.druid.query.lookup.namespace.UriExtractionNamespace) JdbcExtractionNamespace(org.apache.druid.query.lookup.namespace.JdbcExtractionNamespace) LocalFileTimestampVersionFinder(org.apache.druid.segment.loading.LocalFileTimestampVersionFinder) NoopServiceEmitter(org.apache.druid.server.metrics.NoopServiceEmitter) CacheScheduler(org.apache.druid.server.lookup.namespace.cache.CacheScheduler) Before(org.junit.Before)

Example 5 with ExtractionNamespace

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

the class JdbcExtractionNamespaceTest method testSerde.

@Test
public void testSerde() throws IOException {
    final JdbcAccessSecurityConfig securityConfig = new JdbcAccessSecurityConfig();
    final JdbcExtractionNamespace extractionNamespace = new JdbcExtractionNamespace(derbyConnectorRule.getMetadataConnectorConfig(), TABLE_NAME, KEY_NAME, VAL_NAME, tsColumn, "some filter", new Period(10), null, securityConfig);
    final ObjectMapper mapper = new DefaultObjectMapper();
    mapper.setInjectableValues(new Std().addValue(JdbcAccessSecurityConfig.class, securityConfig));
    final ExtractionNamespace extractionNamespace2 = mapper.readValue(mapper.writeValueAsBytes(extractionNamespace), ExtractionNamespace.class);
    Assert.assertEquals(extractionNamespace, extractionNamespace2);
}
Also used : Std(com.fasterxml.jackson.databind.InjectableValues.Std) JdbcAccessSecurityConfig(org.apache.druid.server.initialization.JdbcAccessSecurityConfig) Period(org.joda.time.Period) ExtractionNamespace(org.apache.druid.query.lookup.namespace.ExtractionNamespace) JdbcExtractionNamespace(org.apache.druid.query.lookup.namespace.JdbcExtractionNamespace) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) JdbcExtractionNamespace(org.apache.druid.query.lookup.namespace.JdbcExtractionNamespace) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) 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