use of org.apache.druid.query.lookup.namespace.UriExtractionNamespace in project druid by druid-io.
the class NamespaceLookupExtractorFactoryTest method testSimpleSerde.
@Test
public void testSimpleSerde() throws Exception {
final UriExtractionNamespace uriExtractionNamespace = new UriExtractionNamespace(temporaryFolder.newFolder().toURI(), null, null, new UriExtractionNamespace.ObjectMapperFlatDataParser(mapper), Period.millis(0), null, null);
final NamespaceLookupExtractorFactory namespaceLookupExtractorFactory = new NamespaceLookupExtractorFactory(uriExtractionNamespace, scheduler);
Assert.assertEquals(uriExtractionNamespace, mapper.readValue(mapper.writeValueAsString(namespaceLookupExtractorFactory), NamespaceLookupExtractorFactory.class).getExtractionNamespace());
}
use of org.apache.druid.query.lookup.namespace.UriExtractionNamespace in project druid by druid-io.
the class CacheSchedulerTest method testPeriodicUpdatesScheduled.
@Test(timeout = 60_000L)
public void testPeriodicUpdatesScheduled() throws InterruptedException {
final int repeatCount = 5;
final long delay = 5;
try {
final UriExtractionNamespace namespace = getUriExtractionNamespace(delay);
final long start = System.currentTimeMillis();
try (CacheScheduler.Entry entry = scheduler.schedule(namespace)) {
Assert.assertFalse(entry.getUpdaterFuture().isDone());
Assert.assertFalse(entry.getUpdaterFuture().isCancelled());
entry.awaitTotalUpdates(repeatCount);
long minEnd = start + ((repeatCount - 1) * delay);
long end = System.currentTimeMillis();
Assert.assertTrue(StringUtils.format("Didn't wait long enough between runs. Expected more than %d was %d", minEnd - start, end - start), minEnd <= end);
}
} finally {
lifecycle.stop();
cacheManager.waitForServiceToEnd(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
}
checkNoMoreRunning();
}
use of org.apache.druid.query.lookup.namespace.UriExtractionNamespace in project druid by druid-io.
the class CacheSchedulerTest method testSimpleSubmission.
@Test(timeout = 60_000L)
public void testSimpleSubmission() throws InterruptedException {
UriExtractionNamespace namespace = new UriExtractionNamespace(tmpFile.toURI(), null, null, new UriExtractionNamespace.ObjectMapperFlatDataParser(UriExtractionNamespaceTest.registerTypes(new ObjectMapper())), new Period(0), null, null);
CacheScheduler.Entry entry = scheduler.schedule(namespace);
waitFor(entry);
Map<String, String> cache = entry.getCache();
Assert.assertNull(cache.put("key", "val"));
Assert.assertEquals("val", cache.get("key"));
}
use of org.apache.druid.query.lookup.namespace.UriExtractionNamespace in project druid by druid-io.
the class NamespacedExtractorModuleTest method testListNamespaces.
@Test
public void testListNamespaces() 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 UriExtractionNamespace namespace = new UriExtractionNamespace(tmpFile.toURI(), null, null, new UriExtractionNamespace.ObjectMapperFlatDataParser(UriExtractionNamespaceTest.registerTypes(new DefaultObjectMapper())), new Period(0), null, null);
try (CacheScheduler.Entry entry = scheduler.scheduleAndWait(namespace, 1_000)) {
Assert.assertNotNull(entry);
entry.awaitTotalUpdates(1);
Assert.assertEquals(1, scheduler.getActiveEntries());
}
}
use of org.apache.druid.query.lookup.namespace.UriExtractionNamespace in project druid by druid-io.
the class NamespacedExtractorModuleTest method testDeleteNamespaces.
// (timeout = 60_000L)
@Test
public void testDeleteNamespaces() 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 UriExtractionNamespace namespace = new UriExtractionNamespace(tmpFile.toURI(), null, null, new UriExtractionNamespace.ObjectMapperFlatDataParser(UriExtractionNamespaceTest.registerTypes(new DefaultObjectMapper())), new Period(0), null, null);
try (CacheScheduler.Entry entry = scheduler.scheduleAndWait(namespace, 1_000)) {
Assert.assertNotNull(entry);
}
}
Aggregations