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);
}
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);
}
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();
}
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()));
}
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);
}
Aggregations