Search in sources :

Example 1 with LocalFileTimestampVersionFinder

use of org.apache.druid.segment.loading.LocalFileTimestampVersionFinder 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 2 with LocalFileTimestampVersionFinder

use of org.apache.druid.segment.loading.LocalFileTimestampVersionFinder in project druid by druid-io.

the class NamespacedExtractorModuleTest method testNewTask.

@Test
public void testNewTask() throws Exception {
    final File tmpFile = temporaryFolder.newFile();
    try (Writer out = Files.newWriter(tmpFile, StandardCharsets.UTF_8)) {
        out.write(MAPPER.writeValueAsString(ImmutableMap.of("foo", "bar")));
    }
    final UriCacheGenerator factory = new UriCacheGenerator(ImmutableMap.of("file", new LocalFileTimestampVersionFinder()));
    final UriExtractionNamespace namespace = new UriExtractionNamespace(tmpFile.toURI(), null, null, new UriExtractionNamespace.ObjectMapperFlatDataParser(UriExtractionNamespaceTest.registerTypes(new DefaultObjectMapper())), new Period(0), null, null);
    CacheScheduler.VersionedCache versionedCache = factory.generateCache(namespace, null, null, scheduler);
    Assert.assertNotNull(versionedCache);
    Map<String, String> map = versionedCache.getCache();
    Assert.assertEquals("bar", map.get("foo"));
    Assert.assertEquals(null, map.get("baz"));
}
Also used : Period(org.joda.time.Period) LocalFileTimestampVersionFinder(org.apache.druid.segment.loading.LocalFileTimestampVersionFinder) UriExtractionNamespace(org.apache.druid.query.lookup.namespace.UriExtractionNamespace) DefaultObjectMapper(org.apache.druid.jackson.DefaultObjectMapper) File(java.io.File) CacheScheduler(org.apache.druid.server.lookup.namespace.cache.CacheScheduler) Writer(java.io.Writer) UriExtractionNamespaceTest(org.apache.druid.query.lookup.namespace.UriExtractionNamespaceTest) Test(org.junit.Test)

Aggregations

UriExtractionNamespace (org.apache.druid.query.lookup.namespace.UriExtractionNamespace)2 LocalFileTimestampVersionFinder (org.apache.druid.segment.loading.LocalFileTimestampVersionFinder)2 CacheScheduler (org.apache.druid.server.lookup.namespace.cache.CacheScheduler)2 File (java.io.File)1 Writer (java.io.Writer)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 ExtractionNamespace (org.apache.druid.query.lookup.namespace.ExtractionNamespace)1 JdbcExtractionNamespace (org.apache.druid.query.lookup.namespace.JdbcExtractionNamespace)1 UriExtractionNamespaceTest (org.apache.druid.query.lookup.namespace.UriExtractionNamespaceTest)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 Test (org.junit.Test)1