use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.
the class StaticMapExtractionNamespaceCacheFactoryTest method setup.
@Before
public void setup() throws Exception {
lifecycle = new Lifecycle();
lifecycle.start();
NoopServiceEmitter noopServiceEmitter = new NoopServiceEmitter();
scheduler = new CacheScheduler(noopServiceEmitter, Collections.<Class<? extends ExtractionNamespace>, ExtractionNamespaceCacheFactory<?>>emptyMap(), new OnHeapNamespaceExtractionCacheManager(lifecycle, noopServiceEmitter));
}
use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.
the class NamespaceLookupExtractorFactoryTest method testSimpleStartGetStop.
@Test
public void testSimpleStartGetStop() {
final ExtractionNamespace extractionNamespace = new ExtractionNamespace() {
@Override
public long getPollMs() {
return 0;
}
};
expectScheduleAndWaitOnce(extractionNamespace);
expectEntryGetCacheStateOnce(versionedCache);
expectEmptyCache();
expectVersionOnce("0");
expectEntryCloseOnce();
mockReplay();
final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
Assert.assertTrue(namespaceLookupExtractorFactory.start());
final LookupExtractor extractor = namespaceLookupExtractorFactory.get();
Assert.assertNull(extractor.apply("foo"));
Assert.assertTrue(namespaceLookupExtractorFactory.close());
mockVerify();
}
use of io.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 = new ExtractionNamespace() {
@Override
public long getPollMs() {
return 0;
}
};
final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(extractionNamespace, scheduler);
namespaceLookupExtractorFactory.get();
}
use of io.druid.query.lookup.namespace.ExtractionNamespace in project druid by druid-io.
the class NamespaceExtractionCacheManagerExecutorsTest method setUp.
@Before
public void setUp() throws Exception {
lifecycle = new Lifecycle();
lifecycle.start();
cacheManager = createCacheManager.apply(lifecycle);
final Path tmpDir = temporaryFolder.newFolder().toPath();
final ExtractionNamespaceCacheFactory<URIExtractionNamespace> cachePopulator = new ExtractionNamespaceCacheFactory<URIExtractionNamespace>() {
@Override
public CacheScheduler.VersionedCache populateCache(final URIExtractionNamespace extractionNamespace, final CacheScheduler.EntryImpl<URIExtractionNamespace> id, final String lastVersion, final CacheScheduler scheduler) throws InterruptedException {
// To make absolutely sure there is a unique currentTimeMillis
Thread.sleep(2);
String version = Long.toString(System.currentTimeMillis());
CacheScheduler.VersionedCache versionedCache = scheduler.createVersionedCache(id, version);
// Don't actually read off disk because TravisCI doesn't like that
versionedCache.getCache().put(KEY, VALUE);
return versionedCache;
}
};
scheduler = new CacheScheduler(new NoopServiceEmitter(), ImmutableMap.<Class<? extends ExtractionNamespace>, ExtractionNamespaceCacheFactory<?>>of(URIExtractionNamespace.class, cachePopulator), cacheManager);
tmpFile = Files.createTempFile(tmpDir, "druidTestURIExtractionNS", ".dat").toFile();
try (OutputStream ostream = new FileOutputStream(tmpFile)) {
try (OutputStreamWriter out = new OutputStreamWriter(ostream)) {
// Since Travis sucks with disk related stuff, we override the disk reading part above.
// This is safe and should shake out any problem areas that accidentally read the file.
out.write("SHOULDN'T TRY TO PARSE");
out.flush();
}
}
}
Aggregations