Search in sources :

Example 1 with LocalFileTimestampVersionFinder

use of io.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>, 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 LocalFileTimestampVersionFinder

use of io.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 (OutputStreamWriter out = new FileWriter(tmpFile)) {
        out.write(mapper.writeValueAsString(ImmutableMap.<String, String>of("foo", "bar")));
    }
    final URIExtractionNamespaceCacheFactory factory = new URIExtractionNamespaceCacheFactory(ImmutableMap.<String, SearchableVersionedDataFinder>of("file", new LocalFileTimestampVersionFinder()));
    final URIExtractionNamespace namespace = new URIExtractionNamespace(tmpFile.toURI(), null, null, new URIExtractionNamespace.ObjectMapperFlatDataParser(URIExtractionNamespaceTest.registerTypes(new DefaultObjectMapper())), new Period(0), null);
    CacheScheduler.VersionedCache versionedCache = factory.populateCache(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 : FileWriter(java.io.FileWriter) Period(org.joda.time.Period) URIExtractionNamespace(io.druid.query.lookup.namespace.URIExtractionNamespace) OutputStreamWriter(java.io.OutputStreamWriter) LocalFileTimestampVersionFinder(io.druid.segment.loading.LocalFileTimestampVersionFinder) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) File(java.io.File) CacheScheduler(io.druid.server.lookup.namespace.cache.CacheScheduler) URIExtractionNamespaceTest(io.druid.query.lookup.namespace.URIExtractionNamespaceTest) Test(org.junit.Test)

Aggregations

URIExtractionNamespace (io.druid.query.lookup.namespace.URIExtractionNamespace)2 LocalFileTimestampVersionFinder (io.druid.segment.loading.LocalFileTimestampVersionFinder)2 CacheScheduler (io.druid.server.lookup.namespace.cache.CacheScheduler)2 SearchableVersionedDataFinder (io.druid.data.SearchableVersionedDataFinder)1 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)1 Lifecycle (io.druid.java.util.common.lifecycle.Lifecycle)1 ExtractionNamespace (io.druid.query.lookup.namespace.ExtractionNamespace)1 ExtractionNamespaceCacheFactory (io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory)1 JDBCExtractionNamespace (io.druid.query.lookup.namespace.JDBCExtractionNamespace)1 URIExtractionNamespaceTest (io.druid.query.lookup.namespace.URIExtractionNamespaceTest)1 OnHeapNamespaceExtractionCacheManager (io.druid.server.lookup.namespace.cache.OnHeapNamespaceExtractionCacheManager)1 NoopServiceEmitter (io.druid.server.metrics.NoopServiceEmitter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Period (org.joda.time.Period)1 Before (org.junit.Before)1 Test (org.junit.Test)1