From ebabe14fbe6bb2142a4ec83b47dc5a3e8ad121ce Mon Sep 17 00:00:00 2001 From: Roman Leventov Date: Fri, 2 Jun 2017 20:09:44 -0500 Subject: [PATCH] Rename ExtractionNamespaceCacheFactory to CachePopulator (the last part of #3667) (#4303) * Renamed ExtractionNamespaceCacheFactory to CachePopulator, and related classes * Rename CachePopulator to CacheGenerator --- ...eCacheFactory.java => CacheGenerator.java} | 10 +-- .../lookup/namespace/ExtractionNamespace.java | 4 +- ...pace.java => JdbcExtractionNamespace.java} | 8 +- ...space.java => UriExtractionNamespace.java} | 8 +- ...heFactory.java => JdbcCacheGenerator.java} | 23 +++--- .../namespace/NamespaceExtractionModule.java | 20 ++--- ...tory.java => StaticMapCacheGenerator.java} | 8 +- ...cheFactory.java => UriCacheGenerator.java} | 16 ++-- .../namespace/cache/CacheScheduler.java | 31 ++++---- .../NamespaceLookupExtractorFactoryTest.java | 8 +- .../namespace/JSONFlatDataParserTest.java | 8 +- ...t.java => UriExtractionNamespaceTest.java} | 72 +++++++++--------- .../NamespacedExtractorModuleTest.java | 46 ++++++------ ....java => StaticMapCacheGeneratorTest.java} | 16 ++-- ...ryTest.java => UriCacheGeneratorTest.java} | 74 +++++++++---------- ...utorsTest.java => CacheSchedulerTest.java} | 48 ++++++------ ....java => JdbcExtractionNamespaceTest.java} | 38 +++++----- .../NamespaceExtractionCacheManagersTest.java | 4 +- 18 files changed, 220 insertions(+), 222 deletions(-) rename extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/{ExtractionNamespaceCacheFactory.java => CacheGenerator.java} (84%) rename extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/{JDBCExtractionNamespace.java => JdbcExtractionNamespace.java} (95%) rename extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/{URIExtractionNamespace.java => UriExtractionNamespace.java} (98%) rename extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/{JDBCExtractionNamespaceCacheFactory.java => JdbcCacheGenerator.java} (85%) rename extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/{StaticMapExtractionNamespaceCacheFactory.java => StaticMapCacheGenerator.java} (84%) rename extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/{URIExtractionNamespaceCacheFactory.java => UriCacheGenerator.java} (91%) rename extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/{URIExtractionNamespaceTest.java => UriExtractionNamespaceTest.java} (85%) rename extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/{StaticMapExtractionNamespaceCacheFactoryTest.java => StaticMapCacheGeneratorTest.java} (80%) rename extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/{URIExtractionNamespaceCacheFactoryTest.java => UriCacheGeneratorTest.java} (86%) rename extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/{NamespaceExtractionCacheManagerExecutorsTest.java => CacheSchedulerTest.java} (89%) rename extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/{JDBCExtractionNamespaceTest.java => JdbcExtractionNamespaceTest.java} (92%) diff --git a/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/ExtractionNamespaceCacheFactory.java b/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/CacheGenerator.java similarity index 84% rename from extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/ExtractionNamespaceCacheFactory.java rename to extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/CacheGenerator.java index 2f423b68fa0..9d76a3d60e7 100644 --- a/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/ExtractionNamespaceCacheFactory.java +++ b/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/CacheGenerator.java @@ -26,25 +26,25 @@ import javax.annotation.Nullable; /** * */ -public interface ExtractionNamespaceCacheFactory +public interface CacheGenerator { /** - * If the lookup source, encapsulated by this {@code ExtractionNamespaceCacheFactory}, has data newer than identified + * If the lookup source, encapsulated by this {@code CacheGenerator}, has data newer than identified * by the given {@code lastVersion} (which is null at the first run of this method, or the version from the previous * run), this method creates a new {@code CacheScheduler.VersionedCache} with {@link * CacheScheduler#createVersionedCache}, called on the given {@code scheduler}, with the version string identifying * the current version of lookup source, populates the created {@code VersionedCache} and returns it. If the lookup * source is up-to-date, this methods returns null. * - * @param namespace The ExtractionNamespace for which to populate data. - * @param id An object uniquely corresponding to the {@link CacheScheduler.Entry}, for which this populateCache() + * @param namespace The ExtractionNamespace for which to generate cache. + * @param id An object uniquely corresponding to the {@link CacheScheduler.Entry}, for which this generateCache() * method is called. Also it has the same toString() representation, that is useful for logging * @param lastVersion The version which was last cached * @param scheduler Should be used only to call {@link CacheScheduler#createVersionedCache}. * @return the new cache along with the new version, or null if the last version is up-to-date. */ @Nullable - CacheScheduler.VersionedCache populateCache( + CacheScheduler.VersionedCache generateCache( T namespace, CacheScheduler.EntryImpl id, String lastVersion, diff --git a/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/ExtractionNamespace.java b/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/ExtractionNamespace.java index 8eb26137295..a6152079248 100644 --- a/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/ExtractionNamespace.java +++ b/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/ExtractionNamespace.java @@ -24,8 +24,8 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonSubTypes(value = { - @JsonSubTypes.Type(name = "jdbc", value = JDBCExtractionNamespace.class), - @JsonSubTypes.Type(name = "uri", value = URIExtractionNamespace.class), + @JsonSubTypes.Type(name = "jdbc", value = JdbcExtractionNamespace.class), + @JsonSubTypes.Type(name = "uri", value = UriExtractionNamespace.class), @JsonSubTypes.Type(name = StaticMapExtractionNamespace.TYPE_NAME, value = StaticMapExtractionNamespace.class) }) /** diff --git a/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/JDBCExtractionNamespace.java b/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/JdbcExtractionNamespace.java similarity index 95% rename from extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/JDBCExtractionNamespace.java rename to extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/JdbcExtractionNamespace.java index 9fb9c3c5de8..f7f24d65cbf 100644 --- a/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/JDBCExtractionNamespace.java +++ b/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/JdbcExtractionNamespace.java @@ -34,7 +34,7 @@ import javax.validation.constraints.NotNull; * */ @JsonTypeName("jdbc") -public class JDBCExtractionNamespace implements ExtractionNamespace +public class JdbcExtractionNamespace implements ExtractionNamespace { @JsonProperty private final MetadataStorageConnectorConfig connectorConfig; @@ -50,7 +50,7 @@ public class JDBCExtractionNamespace implements ExtractionNamespace private final Period pollPeriod; @JsonCreator - public JDBCExtractionNamespace( + public JdbcExtractionNamespace( @NotNull @JsonProperty(value = "connectorConfig", required = true) final MetadataStorageConnectorConfig connectorConfig, @NotNull @JsonProperty(value = "table", required = true) @@ -109,7 +109,7 @@ public class JDBCExtractionNamespace implements ExtractionNamespace public String toString() { return String.format( - "JDBCExtractionNamespace = { connectorConfig = { %s }, table = %s, keyColumn = %s, valueColumn = %s, tsColumn = %s, pollPeriod = %s}", + "JdbcExtractionNamespace = { connectorConfig = { %s }, table = %s, keyColumn = %s, valueColumn = %s, tsColumn = %s, pollPeriod = %s}", connectorConfig.toString(), table, keyColumn, @@ -129,7 +129,7 @@ public class JDBCExtractionNamespace implements ExtractionNamespace return false; } - JDBCExtractionNamespace that = (JDBCExtractionNamespace) o; + JdbcExtractionNamespace that = (JdbcExtractionNamespace) o; if (!connectorConfig.equals(that.connectorConfig)) { return false; diff --git a/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/URIExtractionNamespace.java b/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/UriExtractionNamespace.java similarity index 98% rename from extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/URIExtractionNamespace.java rename to extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/UriExtractionNamespace.java index 0b80c364592..e36275909c4 100644 --- a/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/URIExtractionNamespace.java +++ b/extensions-core/lookups-cached-global/src/main/java/io/druid/query/lookup/namespace/UriExtractionNamespace.java @@ -59,7 +59,7 @@ import java.util.regex.PatternSyntaxException; * */ @JsonTypeName("uri") -public class URIExtractionNamespace implements ExtractionNamespace +public class UriExtractionNamespace implements ExtractionNamespace { @JsonProperty private final URI uri; @@ -73,7 +73,7 @@ public class URIExtractionNamespace implements ExtractionNamespace private final Period pollPeriod; @JsonCreator - public URIExtractionNamespace( + public UriExtractionNamespace( @JsonProperty(value = "uri", required = false) URI uri, @JsonProperty(value = "uriPrefix", required = false) @@ -144,7 +144,7 @@ public class URIExtractionNamespace implements ExtractionNamespace @Override public String toString() { - return "URIExtractionNamespace{" + + return "UriExtractionNamespace{" + "uri=" + uri + ", uriPrefix=" + uriPrefix + ", namespaceParseSpec=" + namespaceParseSpec + @@ -163,7 +163,7 @@ public class URIExtractionNamespace implements ExtractionNamespace return false; } - URIExtractionNamespace that = (URIExtractionNamespace) o; + UriExtractionNamespace that = (UriExtractionNamespace) o; if (getUri() != null ? !getUri().equals(that.getUri()) : that.getUri() != null) { return false; diff --git a/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/JDBCExtractionNamespaceCacheFactory.java b/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/JdbcCacheGenerator.java similarity index 85% rename from extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/JDBCExtractionNamespaceCacheFactory.java rename to extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/JdbcCacheGenerator.java index 403bbaa4112..1a4df7f1db8 100644 --- a/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/JDBCExtractionNamespaceCacheFactory.java +++ b/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/JdbcCacheGenerator.java @@ -22,8 +22,8 @@ package io.druid.server.lookup.namespace; import io.druid.common.utils.JodaUtils; import io.druid.java.util.common.Pair; import io.druid.java.util.common.logger.Logger; -import io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory; -import io.druid.query.lookup.namespace.JDBCExtractionNamespace; +import io.druid.query.lookup.namespace.CacheGenerator; +import io.druid.query.lookup.namespace.JdbcExtractionNamespace; import io.druid.server.lookup.namespace.cache.CacheScheduler; import org.skife.jdbi.v2.DBI; import org.skife.jdbi.v2.Handle; @@ -44,18 +44,17 @@ import java.util.concurrent.ConcurrentMap; /** * */ -public final class JDBCExtractionNamespaceCacheFactory - implements ExtractionNamespaceCacheFactory +public final class JdbcCacheGenerator implements CacheGenerator { - private static final Logger LOG = new Logger(JDBCExtractionNamespaceCacheFactory.class); - private final ConcurrentMap, DBI> dbiCache = + private static final Logger LOG = new Logger(JdbcCacheGenerator.class); + private final ConcurrentMap, DBI> dbiCache = new ConcurrentHashMap<>(); @Override @Nullable - public CacheScheduler.VersionedCache populateCache( - final JDBCExtractionNamespace namespace, - final CacheScheduler.EntryImpl entryId, + public CacheScheduler.VersionedCache generateCache( + final JdbcExtractionNamespace namespace, + final CacheScheduler.EntryImpl entryId, final String lastVersion, final CacheScheduler scheduler ) @@ -132,9 +131,9 @@ public final class JDBCExtractionNamespaceCacheFactory } } - private DBI ensureDBI(CacheScheduler.EntryImpl id, JDBCExtractionNamespace namespace) + private DBI ensureDBI(CacheScheduler.EntryImpl id, JdbcExtractionNamespace namespace) { - final CacheScheduler.EntryImpl key = id; + final CacheScheduler.EntryImpl key = id; DBI dbi = null; if (dbiCache.containsKey(key)) { dbi = dbiCache.get(key); @@ -151,7 +150,7 @@ public final class JDBCExtractionNamespaceCacheFactory return dbi; } - private Long lastUpdates(CacheScheduler.EntryImpl id, JDBCExtractionNamespace namespace) + private Long lastUpdates(CacheScheduler.EntryImpl id, JdbcExtractionNamespace namespace) { final DBI dbi = ensureDBI(id, namespace); final String table = namespace.getTable(); diff --git a/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/NamespaceExtractionModule.java b/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/NamespaceExtractionModule.java index 72dbbd2a9ec..0f92191d523 100644 --- a/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/NamespaceExtractionModule.java +++ b/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/NamespaceExtractionModule.java @@ -30,11 +30,11 @@ import io.druid.guice.LazySingleton; import io.druid.guice.PolyBind; import io.druid.initialization.DruidModule; import io.druid.query.lookup.NamespaceLookupExtractorFactory; -import io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory; +import io.druid.query.lookup.namespace.CacheGenerator; import io.druid.query.lookup.namespace.ExtractionNamespace; -import io.druid.query.lookup.namespace.JDBCExtractionNamespace; +import io.druid.query.lookup.namespace.JdbcExtractionNamespace; import io.druid.query.lookup.namespace.StaticMapExtractionNamespace; -import io.druid.query.lookup.namespace.URIExtractionNamespace; +import io.druid.query.lookup.namespace.UriExtractionNamespace; import io.druid.server.lookup.namespace.cache.NamespaceExtractionCacheManager; import io.druid.server.lookup.namespace.cache.OffHeapNamespaceExtractionCacheManager; import io.druid.server.lookup.namespace.cache.OnHeapNamespaceExtractionCacheManager; @@ -59,7 +59,7 @@ public class NamespaceExtractionModule implements DruidModule ); } - public static MapBinder, ExtractionNamespaceCacheFactory> getNamespaceFactoryMapBinder( + public static MapBinder, CacheGenerator> getNamespaceFactoryMapBinder( final Binder binder ) { @@ -68,7 +68,7 @@ public class NamespaceExtractionModule implements DruidModule new TypeLiteral>() { }, - new TypeLiteral>() + new TypeLiteral>() { } ); @@ -92,16 +92,16 @@ public class NamespaceExtractionModule implements DruidModule .in(LazySingleton.class); getNamespaceFactoryMapBinder(binder) - .addBinding(JDBCExtractionNamespace.class) - .to(JDBCExtractionNamespaceCacheFactory.class) + .addBinding(JdbcExtractionNamespace.class) + .to(JdbcCacheGenerator.class) .in(LazySingleton.class); getNamespaceFactoryMapBinder(binder) - .addBinding(URIExtractionNamespace.class) - .to(URIExtractionNamespaceCacheFactory.class) + .addBinding(UriExtractionNamespace.class) + .to(UriCacheGenerator.class) .in(LazySingleton.class); getNamespaceFactoryMapBinder(binder) .addBinding(StaticMapExtractionNamespace.class) - .to(StaticMapExtractionNamespaceCacheFactory.class) + .to(StaticMapCacheGenerator.class) .in(LazySingleton.class); } } diff --git a/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/StaticMapExtractionNamespaceCacheFactory.java b/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/StaticMapCacheGenerator.java similarity index 84% rename from extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/StaticMapExtractionNamespaceCacheFactory.java rename to extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/StaticMapCacheGenerator.java index c6921dd9396..33d203c390b 100644 --- a/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/StaticMapExtractionNamespaceCacheFactory.java +++ b/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/StaticMapCacheGenerator.java @@ -19,20 +19,20 @@ package io.druid.server.lookup.namespace; -import io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory; +import io.druid.query.lookup.namespace.CacheGenerator; import io.druid.query.lookup.namespace.StaticMapExtractionNamespace; import io.druid.server.lookup.namespace.cache.CacheScheduler; import javax.annotation.Nullable; import java.util.UUID; -public final class StaticMapExtractionNamespaceCacheFactory implements ExtractionNamespaceCacheFactory +public final class StaticMapCacheGenerator implements CacheGenerator { private final String version = UUID.randomUUID().toString(); @Override @Nullable - public CacheScheduler.VersionedCache populateCache( + public CacheScheduler.VersionedCache generateCache( final StaticMapExtractionNamespace namespace, final CacheScheduler.EntryImpl id, final String lastVersion, @@ -43,7 +43,7 @@ public final class StaticMapExtractionNamespaceCacheFactory implements Extractio // Throwing AssertionError, because CacheScheduler doesn't suppress Errors and will stop trying to update // the cache periodically. throw new AssertionError( - "StaticMapExtractionNamespaceCacheFactory could only be configured for a namespace which is scheduled " + "StaticMapCacheGenerator could only be configured for a namespace which is scheduled " + "to be updated once, not periodically. Last version: `" + lastVersion + "`"); } CacheScheduler.VersionedCache versionedCache = scheduler.createVersionedCache(id, version); diff --git a/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/URIExtractionNamespaceCacheFactory.java b/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/UriCacheGenerator.java similarity index 91% rename from extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/URIExtractionNamespaceCacheFactory.java rename to extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/UriCacheGenerator.java index 3778421c173..8d99c561789 100644 --- a/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/URIExtractionNamespaceCacheFactory.java +++ b/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/UriCacheGenerator.java @@ -27,8 +27,8 @@ import io.druid.java.util.common.CompressionUtils; import io.druid.java.util.common.IAE; import io.druid.java.util.common.RetryUtils; import io.druid.java.util.common.logger.Logger; -import io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory; -import io.druid.query.lookup.namespace.URIExtractionNamespace; +import io.druid.query.lookup.namespace.CacheGenerator; +import io.druid.query.lookup.namespace.UriExtractionNamespace; import io.druid.segment.loading.URIDataPuller; import io.druid.server.lookup.namespace.cache.CacheScheduler; @@ -44,14 +44,14 @@ import java.util.regex.Pattern; /** * */ -public final class URIExtractionNamespaceCacheFactory implements ExtractionNamespaceCacheFactory +public final class UriCacheGenerator implements CacheGenerator { private static final int DEFAULT_NUM_RETRIES = 3; - private static final Logger log = new Logger(URIExtractionNamespaceCacheFactory.class); + private static final Logger log = new Logger(UriCacheGenerator.class); private final Map pullers; @Inject - public URIExtractionNamespaceCacheFactory( + public UriCacheGenerator( Map pullers ) { @@ -60,9 +60,9 @@ public final class URIExtractionNamespaceCacheFactory implements ExtractionNames @Override @Nullable - public CacheScheduler.VersionedCache populateCache( - final URIExtractionNamespace extractionNamespace, - final CacheScheduler.EntryImpl entryId, + public CacheScheduler.VersionedCache generateCache( + final UriExtractionNamespace extractionNamespace, + final CacheScheduler.EntryImpl entryId, @Nullable final String lastVersion, final CacheScheduler scheduler ) throws Exception diff --git a/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/cache/CacheScheduler.java b/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/cache/CacheScheduler.java index bc323d781cb..73aad2173d7 100644 --- a/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/cache/CacheScheduler.java +++ b/extensions-core/lookups-cached-global/src/main/java/io/druid/server/lookup/namespace/cache/CacheScheduler.java @@ -27,8 +27,8 @@ import com.metamx.emitter.service.ServiceMetricEvent; import io.druid.guice.LazySingleton; import io.druid.java.util.common.ISE; import io.druid.java.util.common.logger.Logger; +import io.druid.query.lookup.namespace.CacheGenerator; import io.druid.query.lookup.namespace.ExtractionNamespace; -import io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory; import sun.misc.Cleaner; import javax.annotation.Nullable; @@ -70,9 +70,9 @@ public final class CacheScheduler { private final EntryImpl impl; - private Entry(final T namespace, final ExtractionNamespaceCacheFactory cachePopulator) + private Entry(final T namespace, final CacheGenerator cacheGenerator) { - impl = new EntryImpl<>(namespace, this, cachePopulator); + impl = new EntryImpl<>(namespace, this, cacheGenerator); } /** @@ -143,18 +143,18 @@ public final class CacheScheduler private final AtomicReference cacheStateHolder = new AtomicReference(NoCache.CACHE_NOT_INITIALIZED); private final Future updaterFuture; private final Cleaner entryCleaner; - private final ExtractionNamespaceCacheFactory cachePopulator; + private final CacheGenerator cacheGenerator; private final UpdateCounter updateCounter = new UpdateCounter(); private final CountDownLatch startLatch = new CountDownLatch(1); - private EntryImpl(final T namespace, final Entry entry, final ExtractionNamespaceCacheFactory cachePopulator) + private EntryImpl(final T namespace, final Entry entry, final CacheGenerator cacheGenerator) { try { this.namespace = namespace; this.asString = String.format("namespace [%s] : %s", namespace, super.toString()); this.updaterFuture = schedule(namespace); this.entryCleaner = createCleaner(entry); - this.cachePopulator = cachePopulator; + this.cacheGenerator = cacheGenerator; activeEntries.incrementAndGet(); } finally { @@ -221,7 +221,7 @@ public final class CacheScheduler boolean updatedCacheSuccessfully = false; VersionedCache newVersionedCache = null; try { - newVersionedCache = cachePopulator.populateCache(namespace, this, currentVersion, CacheScheduler.this + newVersionedCache = cacheGenerator.generateCache(namespace, this, currentVersion, CacheScheduler.this ); if (newVersionedCache != null) { CacheState previousCacheState = swapCacheState(newVersionedCache); @@ -408,7 +408,7 @@ public final class CacheScheduler } } - private final Map, ExtractionNamespaceCacheFactory> namespacePopulatorMap; + private final Map, CacheGenerator> namespaceGeneratorMap; private final NamespaceExtractionCacheManager cacheManager; private final AtomicLong updatesStarted = new AtomicLong(0); private final AtomicInteger activeEntries = new AtomicInteger(); @@ -416,11 +416,11 @@ public final class CacheScheduler @Inject public CacheScheduler( final ServiceEmitter serviceEmitter, - final Map, ExtractionNamespaceCacheFactory> namespacePopulatorMap, + final Map, CacheGenerator> namespaceGeneratorMap, NamespaceExtractionCacheManager cacheManager ) { - this.namespacePopulatorMap = namespacePopulatorMap; + this.namespaceGeneratorMap = namespaceGeneratorMap; this.cacheManager = cacheManager; cacheManager.scheduledExecutorService().scheduleAtFixedRate( new Runnable() @@ -452,7 +452,7 @@ public final class CacheScheduler } /** - * This method should be used from {@link ExtractionNamespaceCacheFactory#populateCache} implementations, to obtain + * This method should be used from {@link io.druid.query.lookup.namespace.CacheGenerator#generateCache} implementations, to obtain * a {@link VersionedCache} to be returned. * * @param entryId an object uniquely corresponding to the {@link CacheScheduler.Entry}, for which VersionedCache is @@ -502,11 +502,10 @@ public final class CacheScheduler public Entry schedule(final T namespace) { - final ExtractionNamespaceCacheFactory populator = - (ExtractionNamespaceCacheFactory) namespacePopulatorMap.get(namespace.getClass()); - if (populator == null) { - throw new ISE("Cannot find populator for namespace [%s]", namespace); + final CacheGenerator generator = (CacheGenerator) namespaceGeneratorMap.get(namespace.getClass()); + if (generator == null) { + throw new ISE("Cannot find generator for namespace [%s]", namespace); } - return new Entry<>(namespace, populator); + return new Entry<>(namespace, generator); } } diff --git a/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/NamespaceLookupExtractorFactoryTest.java b/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/NamespaceLookupExtractorFactoryTest.java index cea63afab76..463235d6923 100644 --- a/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/NamespaceLookupExtractorFactoryTest.java +++ b/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/NamespaceLookupExtractorFactoryTest.java @@ -39,7 +39,7 @@ import io.druid.initialization.Initialization; import io.druid.jackson.DefaultObjectMapper; import io.druid.java.util.common.ISE; import io.druid.query.lookup.namespace.ExtractionNamespace; -import io.druid.query.lookup.namespace.URIExtractionNamespace; +import io.druid.query.lookup.namespace.UriExtractionNamespace; import io.druid.server.DruidNode; import io.druid.server.lookup.namespace.cache.CacheScheduler; import io.druid.server.lookup.namespace.cache.NamespaceExtractionCacheManager; @@ -109,10 +109,10 @@ public class NamespaceLookupExtractorFactoryTest @Test public void testSimpleSerde() throws Exception { - final URIExtractionNamespace uriExtractionNamespace = new URIExtractionNamespace( + final UriExtractionNamespace uriExtractionNamespace = new UriExtractionNamespace( temporaryFolder.newFolder().toURI(), null, null, - new URIExtractionNamespace.ObjectMapperFlatDataParser(mapper), + new UriExtractionNamespace.ObjectMapperFlatDataParser(mapper), Period.millis(0), null @@ -455,7 +455,7 @@ public class NamespaceLookupExtractorFactoryTest LookupExtractorFactory.class ))); Assert.assertEquals( - URIExtractionNamespace.class, + UriExtractionNamespace.class, namespaceLookupExtractorFactory.getExtractionNamespace().getClass() ); Assert.assertFalse(namespaceLookupExtractorFactory.replaces(mapper.readValue(str, LookupExtractorFactory.class))); diff --git a/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/JSONFlatDataParserTest.java b/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/JSONFlatDataParserTest.java index 590f5819876..e636d66bdc5 100644 --- a/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/JSONFlatDataParserTest.java +++ b/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/JSONFlatDataParserTest.java @@ -92,7 +92,7 @@ public class JSONFlatDataParserTest @Test public void testSimpleParse() throws Exception { - final URIExtractionNamespace.JSONFlatDataParser parser = new URIExtractionNamespace.JSONFlatDataParser( + final UriExtractionNamespace.JSONFlatDataParser parser = new UriExtractionNamespace.JSONFlatDataParser( MAPPER, "key", "val" @@ -106,7 +106,7 @@ public class JSONFlatDataParserTest @Test public void testParseWithNullValues() throws Exception { - final URIExtractionNamespace.JSONFlatDataParser parser = new URIExtractionNamespace.JSONFlatDataParser( + final UriExtractionNamespace.JSONFlatDataParser parser = new UriExtractionNamespace.JSONFlatDataParser( MAPPER, "key", "otherVal" @@ -120,7 +120,7 @@ public class JSONFlatDataParserTest @Test public void testParseWithEmptyValues() throws Exception { - final URIExtractionNamespace.JSONFlatDataParser parser = new URIExtractionNamespace.JSONFlatDataParser( + final UriExtractionNamespace.JSONFlatDataParser parser = new UriExtractionNamespace.JSONFlatDataParser( MAPPER, "key", "canBeEmpty" @@ -134,7 +134,7 @@ public class JSONFlatDataParserTest @Test public void testFailParseOnKeyMissing() throws Exception { - final URIExtractionNamespace.JSONFlatDataParser parser = new URIExtractionNamespace.JSONFlatDataParser( + final UriExtractionNamespace.JSONFlatDataParser parser = new UriExtractionNamespace.JSONFlatDataParser( MAPPER, "keyWHOOPS", "val" diff --git a/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/URIExtractionNamespaceTest.java b/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/UriExtractionNamespaceTest.java similarity index 85% rename from extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/URIExtractionNamespaceTest.java rename to extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/UriExtractionNamespaceTest.java index 6d620b73e0b..460e5caee35 100644 --- a/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/URIExtractionNamespaceTest.java +++ b/extensions-core/lookups-cached-global/src/test/java/io/druid/query/lookup/namespace/UriExtractionNamespaceTest.java @@ -40,7 +40,7 @@ import java.util.Map; /** * */ -public class URIExtractionNamespaceTest +public class UriExtractionNamespaceTest { public static ObjectMapper registerTypes( final ObjectMapper mapper @@ -62,7 +62,7 @@ public class URIExtractionNamespaceTest ) ) ) - ).registerSubtypes(URIExtractionNamespace.class, URIExtractionNamespace.FlatDataParser.class); + ).registerSubtypes(UriExtractionNamespace.class, UriExtractionNamespace.FlatDataParser.class); final GuiceAnnotationIntrospector guiceIntrospector = new GuiceAnnotationIntrospector(); mapper.setAnnotationIntrospectors( @@ -79,7 +79,7 @@ public class URIExtractionNamespaceTest @Test public void testCSV() { - URIExtractionNamespace.CSVFlatDataParser parser = new URIExtractionNamespace.CSVFlatDataParser( + UriExtractionNamespace.CSVFlatDataParser parser = new UriExtractionNamespace.CSVFlatDataParser( ImmutableList.of( "col1", "col2", @@ -92,7 +92,7 @@ public class URIExtractionNamespaceTest @Test(expected = IllegalArgumentException.class) public void testBadCSV() { - URIExtractionNamespace.CSVFlatDataParser parser = new URIExtractionNamespace.CSVFlatDataParser( + UriExtractionNamespace.CSVFlatDataParser parser = new UriExtractionNamespace.CSVFlatDataParser( ImmutableList.of( "col1", "col2", @@ -105,7 +105,7 @@ public class URIExtractionNamespaceTest @Test(expected = NullPointerException.class) public void testBadCSV2() { - URIExtractionNamespace.CSVFlatDataParser parser = new URIExtractionNamespace.CSVFlatDataParser( + UriExtractionNamespace.CSVFlatDataParser parser = new UriExtractionNamespace.CSVFlatDataParser( ImmutableList.of( "col1", "col2", @@ -118,7 +118,7 @@ public class URIExtractionNamespaceTest @Test public void testTSV() { - URIExtractionNamespace.TSVFlatDataParser parser = new URIExtractionNamespace.TSVFlatDataParser( + UriExtractionNamespace.TSVFlatDataParser parser = new UriExtractionNamespace.TSVFlatDataParser( ImmutableList.of("col1", "col2", "col3"), "|", null, "col2", @@ -130,7 +130,7 @@ public class URIExtractionNamespaceTest @Test public void testWithListDelimiterTSV() { - URIExtractionNamespace.TSVFlatDataParser parser = new URIExtractionNamespace.TSVFlatDataParser( + UriExtractionNamespace.TSVFlatDataParser parser = new UriExtractionNamespace.TSVFlatDataParser( ImmutableList.of("col1", "col2", "col3"), "\\u0001", "\\u0002", "col2", @@ -142,7 +142,7 @@ public class URIExtractionNamespaceTest @Test(expected = IllegalArgumentException.class) public void testBadTSV() { - URIExtractionNamespace.TSVFlatDataParser parser = new URIExtractionNamespace.TSVFlatDataParser( + UriExtractionNamespace.TSVFlatDataParser parser = new UriExtractionNamespace.TSVFlatDataParser( ImmutableList.of("col1", "col2", "col3fdsfds"), ",", null, "col2", @@ -156,7 +156,7 @@ public class URIExtractionNamespaceTest @Test(expected = NullPointerException.class) public void testBadTSV2() { - URIExtractionNamespace.TSVFlatDataParser parser = new URIExtractionNamespace.TSVFlatDataParser( + UriExtractionNamespace.TSVFlatDataParser parser = new UriExtractionNamespace.TSVFlatDataParser( ImmutableList.of("col1", "col2", "col3"), ",", null, "col2", @@ -171,7 +171,7 @@ public class URIExtractionNamespaceTest { final String keyField = "keyField"; final String valueField = "valueField"; - URIExtractionNamespace.JSONFlatDataParser parser = new URIExtractionNamespace.JSONFlatDataParser( + UriExtractionNamespace.JSONFlatDataParser parser = new UriExtractionNamespace.JSONFlatDataParser( new ObjectMapper(), keyField, valueField @@ -195,7 +195,7 @@ public class URIExtractionNamespaceTest { final String keyField = "keyField"; final String valueField = "valueField"; - URIExtractionNamespace.JSONFlatDataParser parser = new URIExtractionNamespace.JSONFlatDataParser( + UriExtractionNamespace.JSONFlatDataParser parser = new UriExtractionNamespace.JSONFlatDataParser( new ObjectMapper(), keyField, valueField @@ -218,7 +218,7 @@ public class URIExtractionNamespaceTest { final String keyField = "keyField"; final String valueField = "valueField"; - URIExtractionNamespace.JSONFlatDataParser parser = new URIExtractionNamespace.JSONFlatDataParser( + UriExtractionNamespace.JSONFlatDataParser parser = new UriExtractionNamespace.JSONFlatDataParser( registerTypes(new ObjectMapper()), null, valueField @@ -241,7 +241,7 @@ public class URIExtractionNamespaceTest { final String keyField = "keyField"; final String valueField = "valueField"; - URIExtractionNamespace.JSONFlatDataParser parser = new URIExtractionNamespace.JSONFlatDataParser( + UriExtractionNamespace.JSONFlatDataParser parser = new UriExtractionNamespace.JSONFlatDataParser( registerTypes(new ObjectMapper()), keyField, null @@ -264,7 +264,7 @@ public class URIExtractionNamespaceTest { final String keyField = "keyField"; final String valueField = "valueField"; - URIExtractionNamespace.JSONFlatDataParser parser = new URIExtractionNamespace.JSONFlatDataParser( + UriExtractionNamespace.JSONFlatDataParser parser = new UriExtractionNamespace.JSONFlatDataParser( registerTypes(new ObjectMapper()), "", "" @@ -285,7 +285,7 @@ public class URIExtractionNamespaceTest @Test public void testObjectMapperFlatDataParser() { - URIExtractionNamespace.ObjectMapperFlatDataParser parser = new URIExtractionNamespace.ObjectMapperFlatDataParser( + UriExtractionNamespace.ObjectMapperFlatDataParser parser = new UriExtractionNamespace.ObjectMapperFlatDataParser( registerTypes(new ObjectMapper()) ); Assert.assertEquals(ImmutableMap.of("B", "C"), parser.getParser().parse("{\"B\":\"C\"}")); @@ -295,22 +295,22 @@ public class URIExtractionNamespaceTest public void testSimpleJSONSerDe() throws IOException { final ObjectMapper mapper = registerTypes(new DefaultObjectMapper()); - for (URIExtractionNamespace.FlatDataParser parser : ImmutableList.of( - new URIExtractionNamespace.CSVFlatDataParser( + for (UriExtractionNamespace.FlatDataParser parser : ImmutableList.of( + new UriExtractionNamespace.CSVFlatDataParser( ImmutableList.of( "col1", "col2", "col3" ), "col2", "col3" ), - new URIExtractionNamespace.ObjectMapperFlatDataParser(mapper), - new URIExtractionNamespace.JSONFlatDataParser(mapper, "keyField", "valueField"), - new URIExtractionNamespace.TSVFlatDataParser(ImmutableList.of("A", "B"), ",", null, "A", "B") + new UriExtractionNamespace.ObjectMapperFlatDataParser(mapper), + new UriExtractionNamespace.JSONFlatDataParser(mapper, "keyField", "valueField"), + new UriExtractionNamespace.TSVFlatDataParser(ImmutableList.of("A", "B"), ",", null, "A", "B") )) { final String str = mapper.writeValueAsString(parser); - final URIExtractionNamespace.FlatDataParser parser2 = mapper.readValue( + final UriExtractionNamespace.FlatDataParser parser2 = mapper.readValue( str, - URIExtractionNamespace.FlatDataParser.class + UriExtractionNamespace.FlatDataParser.class ); Assert.assertEquals(str, mapper.writeValueAsString(parser2)); } @@ -320,17 +320,17 @@ public class URIExtractionNamespaceTest public void testSimpleToString() throws IOException { final ObjectMapper mapper = registerTypes(new DefaultObjectMapper()); - for (URIExtractionNamespace.FlatDataParser parser : ImmutableList.of( - new URIExtractionNamespace.CSVFlatDataParser( + for (UriExtractionNamespace.FlatDataParser parser : ImmutableList.of( + new UriExtractionNamespace.CSVFlatDataParser( ImmutableList.of( "col1", "col2", "col3" ), "col2", "col3" ), - new URIExtractionNamespace.ObjectMapperFlatDataParser(mapper), - new URIExtractionNamespace.JSONFlatDataParser(mapper, "keyField", "valueField"), - new URIExtractionNamespace.TSVFlatDataParser(ImmutableList.of("A", "B"), ",", null, "A", "B") + new UriExtractionNamespace.ObjectMapperFlatDataParser(mapper), + new UriExtractionNamespace.JSONFlatDataParser(mapper, "keyField", "valueField"), + new UriExtractionNamespace.TSVFlatDataParser(ImmutableList.of("A", "B"), ",", null, "A", "B") )) { Assert.assertFalse(parser.toString().contains("@")); } @@ -340,13 +340,13 @@ public class URIExtractionNamespaceTest public void testMatchedJson() throws IOException { final ObjectMapper mapper = registerTypes(new DefaultObjectMapper()); - URIExtractionNamespace namespace = mapper.readValue( + UriExtractionNamespace namespace = mapper.readValue( "{\"type\":\"uri\", \"uriPrefix\":\"file:/foo\", \"namespaceParseSpec\":{\"format\":\"simpleJson\"}, \"pollPeriod\":\"PT5M\", \"versionRegex\":\"a.b.c\", \"namespace\":\"testNamespace\"}", - URIExtractionNamespace.class + UriExtractionNamespace.class ); Assert.assertEquals( - URIExtractionNamespace.ObjectMapperFlatDataParser.class.getCanonicalName(), + UriExtractionNamespace.ObjectMapperFlatDataParser.class.getCanonicalName(), namespace.getNamespaceParseSpec().getClass().getCanonicalName() ); Assert.assertEquals("file:/foo", namespace.getUriPrefix().toString()); @@ -358,13 +358,13 @@ public class URIExtractionNamespaceTest public void testExplicitJson() throws IOException { final ObjectMapper mapper = registerTypes(new DefaultObjectMapper()); - URIExtractionNamespace namespace = mapper.readValue( + UriExtractionNamespace namespace = mapper.readValue( "{\"type\":\"uri\", \"uri\":\"file:/foo\", \"namespaceParseSpec\":{\"format\":\"simpleJson\"}, \"pollPeriod\":\"PT5M\"}", - URIExtractionNamespace.class + UriExtractionNamespace.class ); Assert.assertEquals( - URIExtractionNamespace.ObjectMapperFlatDataParser.class.getCanonicalName(), + UriExtractionNamespace.ObjectMapperFlatDataParser.class.getCanonicalName(), namespace.getNamespaceParseSpec().getClass().getCanonicalName() ); Assert.assertEquals("file:/foo", namespace.getUri().toString()); @@ -377,7 +377,7 @@ public class URIExtractionNamespaceTest final ObjectMapper mapper = registerTypes(new DefaultObjectMapper()); mapper.readValue( "{\"type\":\"uri\", \"uri\":\"file:/foo\", \"namespaceParseSpec\":{\"format\":\"simpleJson\"}, \"pollPeriod\":\"PT5M\", \"versionRegex\":\"a.b.c\", \"namespace\":\"testNamespace\"}", - URIExtractionNamespace.class + UriExtractionNamespace.class ); } @@ -388,7 +388,7 @@ public class URIExtractionNamespaceTest final String valueField = "valueField"; final int n = 341879; final String nString = String.format("%d", n); - URIExtractionNamespace.JSONFlatDataParser parser = new URIExtractionNamespace.JSONFlatDataParser( + UriExtractionNamespace.JSONFlatDataParser parser = new UriExtractionNamespace.JSONFlatDataParser( new ObjectMapper(), keyField, valueField @@ -450,7 +450,7 @@ public class URIExtractionNamespaceTest @Test public void testSimpleJsonNumeric() { - final URIExtractionNamespace.ObjectMapperFlatDataParser parser = new URIExtractionNamespace.ObjectMapperFlatDataParser( + final UriExtractionNamespace.ObjectMapperFlatDataParser parser = new UriExtractionNamespace.ObjectMapperFlatDataParser( registerTypes(new DefaultObjectMapper()) ); final int n = 341879; diff --git a/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/NamespacedExtractorModuleTest.java b/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/NamespacedExtractorModuleTest.java index 4dcb409484d..92af1f755c7 100644 --- a/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/NamespacedExtractorModuleTest.java +++ b/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/NamespacedExtractorModuleTest.java @@ -24,11 +24,11 @@ import com.google.common.collect.ImmutableMap; import io.druid.data.SearchableVersionedDataFinder; import io.druid.jackson.DefaultObjectMapper; import io.druid.java.util.common.lifecycle.Lifecycle; -import io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory; +import io.druid.query.lookup.namespace.CacheGenerator; import io.druid.query.lookup.namespace.ExtractionNamespace; -import io.druid.query.lookup.namespace.JDBCExtractionNamespace; -import io.druid.query.lookup.namespace.URIExtractionNamespace; -import io.druid.query.lookup.namespace.URIExtractionNamespaceTest; +import io.druid.query.lookup.namespace.JdbcExtractionNamespace; +import io.druid.query.lookup.namespace.UriExtractionNamespace; +import io.druid.query.lookup.namespace.UriExtractionNamespaceTest; import io.druid.segment.loading.LocalFileTimestampVersionFinder; import io.druid.server.lookup.namespace.cache.CacheScheduler; import io.druid.server.lookup.namespace.cache.OnHeapNamespaceExtractionCacheManager; @@ -51,7 +51,7 @@ import java.util.Map; */ public class NamespacedExtractorModuleTest { - private static final ObjectMapper mapper = URIExtractionNamespaceTest.registerTypes(new DefaultObjectMapper()); + private static final ObjectMapper mapper = UriExtractionNamespaceTest.registerTypes(new DefaultObjectMapper()); private CacheScheduler scheduler; private Lifecycle lifecycle; @@ -61,16 +61,16 @@ public class NamespacedExtractorModuleTest @Before public void setUp() throws Exception { - final Map, ExtractionNamespaceCacheFactory> factoryMap = - ImmutableMap., ExtractionNamespaceCacheFactory>of( - URIExtractionNamespace.class, - new URIExtractionNamespaceCacheFactory( + final Map, CacheGenerator> factoryMap = + ImmutableMap., CacheGenerator>of( + UriExtractionNamespace.class, + new UriCacheGenerator( ImmutableMap.of( "file", new LocalFileTimestampVersionFinder() ) ), - JDBCExtractionNamespace.class, new JDBCExtractionNamespaceCacheFactory() + JdbcExtractionNamespace.class, new JdbcCacheGenerator() ); lifecycle = new Lifecycle(); lifecycle.start(); @@ -95,19 +95,19 @@ public class NamespacedExtractorModuleTest try (OutputStreamWriter out = new FileWriter(tmpFile)) { out.write(mapper.writeValueAsString(ImmutableMap.of("foo", "bar"))); } - final URIExtractionNamespaceCacheFactory factory = new URIExtractionNamespaceCacheFactory( + final UriCacheGenerator factory = new UriCacheGenerator( ImmutableMap.of("file", new LocalFileTimestampVersionFinder()) ); - final URIExtractionNamespace namespace = new URIExtractionNamespace( + final UriExtractionNamespace namespace = new UriExtractionNamespace( tmpFile.toURI(), null, null, - new URIExtractionNamespace.ObjectMapperFlatDataParser( - URIExtractionNamespaceTest.registerTypes(new DefaultObjectMapper()) + new UriExtractionNamespace.ObjectMapperFlatDataParser( + UriExtractionNamespaceTest.registerTypes(new DefaultObjectMapper()) ), new Period(0), null ); - CacheScheduler.VersionedCache versionedCache = factory.populateCache(namespace, null, null, scheduler); + CacheScheduler.VersionedCache versionedCache = factory.generateCache(namespace, null, null, scheduler); Assert.assertNotNull(versionedCache); Map map = versionedCache.getCache(); Assert.assertEquals("bar", map.get("foo")); @@ -121,10 +121,10 @@ public class NamespacedExtractorModuleTest try (OutputStreamWriter out = new FileWriter(tmpFile)) { out.write(mapper.writeValueAsString(ImmutableMap.of("foo", "bar"))); } - final URIExtractionNamespace namespace = new URIExtractionNamespace( + final UriExtractionNamespace namespace = new UriExtractionNamespace( tmpFile.toURI(), null, null, - new URIExtractionNamespace.ObjectMapperFlatDataParser(URIExtractionNamespaceTest.registerTypes(new DefaultObjectMapper())), + new UriExtractionNamespace.ObjectMapperFlatDataParser(UriExtractionNamespaceTest.registerTypes(new DefaultObjectMapper())), new Period(0), null ); @@ -142,11 +142,11 @@ public class NamespacedExtractorModuleTest try (OutputStreamWriter out = new FileWriter(tmpFile)) { out.write(mapper.writeValueAsString(ImmutableMap.of("foo", "bar"))); } - final URIExtractionNamespace namespace = new URIExtractionNamespace( + final UriExtractionNamespace namespace = new UriExtractionNamespace( tmpFile.toURI(), null, null, - new URIExtractionNamespace.ObjectMapperFlatDataParser( - URIExtractionNamespaceTest.registerTypes(new DefaultObjectMapper()) + new UriExtractionNamespace.ObjectMapperFlatDataParser( + UriExtractionNamespaceTest.registerTypes(new DefaultObjectMapper()) ), new Period(0), null @@ -163,11 +163,11 @@ public class NamespacedExtractorModuleTest try (OutputStreamWriter out = new FileWriter(tmpFile)) { out.write(mapper.writeValueAsString(ImmutableMap.of("foo", "bar"))); } - final URIExtractionNamespace namespace = new URIExtractionNamespace( + final UriExtractionNamespace namespace = new UriExtractionNamespace( tmpFile.toURI(), null, null, - new URIExtractionNamespace.ObjectMapperFlatDataParser( - URIExtractionNamespaceTest.registerTypes(new DefaultObjectMapper()) + new UriExtractionNamespace.ObjectMapperFlatDataParser( + UriExtractionNamespaceTest.registerTypes(new DefaultObjectMapper()) ), new Period(0), null diff --git a/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/StaticMapExtractionNamespaceCacheFactoryTest.java b/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/StaticMapCacheGeneratorTest.java similarity index 80% rename from extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/StaticMapExtractionNamespaceCacheFactoryTest.java rename to extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/StaticMapCacheGeneratorTest.java index 50a87f1a190..43792b01f56 100644 --- a/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/StaticMapExtractionNamespaceCacheFactoryTest.java +++ b/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/StaticMapCacheGeneratorTest.java @@ -21,7 +21,7 @@ package io.druid.server.lookup.namespace; import com.google.common.collect.ImmutableMap; import io.druid.java.util.common.lifecycle.Lifecycle; -import io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory; +import io.druid.query.lookup.namespace.CacheGenerator; import io.druid.query.lookup.namespace.ExtractionNamespace; import io.druid.query.lookup.namespace.StaticMapExtractionNamespace; import io.druid.server.lookup.namespace.cache.CacheScheduler; @@ -35,7 +35,7 @@ import org.junit.Test; import java.util.Collections; import java.util.Map; -public class StaticMapExtractionNamespaceCacheFactoryTest +public class StaticMapCacheGeneratorTest { private static final Map MAP = ImmutableMap.builder().put("foo", "bar").build(); @@ -50,7 +50,7 @@ public class StaticMapExtractionNamespaceCacheFactoryTest NoopServiceEmitter noopServiceEmitter = new NoopServiceEmitter(); scheduler = new CacheScheduler( noopServiceEmitter, - Collections., ExtractionNamespaceCacheFactory>emptyMap(), + Collections., CacheGenerator>emptyMap(), new OnHeapNamespaceExtractionCacheManager(lifecycle, noopServiceEmitter) ); } @@ -62,11 +62,11 @@ public class StaticMapExtractionNamespaceCacheFactoryTest } @Test - public void testSimplePopulator() throws Exception + public void testSimpleGenerator() throws Exception { - final StaticMapExtractionNamespaceCacheFactory factory = new StaticMapExtractionNamespaceCacheFactory(); + final StaticMapCacheGenerator factory = new StaticMapCacheGenerator(); final StaticMapExtractionNamespace namespace = new StaticMapExtractionNamespace(MAP); - CacheScheduler.VersionedCache versionedCache = factory.populateCache(namespace, null, null, scheduler); + CacheScheduler.VersionedCache versionedCache = factory.generateCache(namespace, null, null, scheduler); Assert.assertNotNull(versionedCache); Assert.assertEquals(factory.getVersion(), versionedCache.getVersion()); Assert.assertEquals(MAP, versionedCache.getCache()); @@ -76,8 +76,8 @@ public class StaticMapExtractionNamespaceCacheFactoryTest @Test(expected = AssertionError.class) public void testNonNullLastVersionCausesAssertionError() { - final StaticMapExtractionNamespaceCacheFactory factory = new StaticMapExtractionNamespaceCacheFactory(); + final StaticMapCacheGenerator factory = new StaticMapCacheGenerator(); final StaticMapExtractionNamespace namespace = new StaticMapExtractionNamespace(MAP); - factory.populateCache(namespace, null, factory.getVersion(), scheduler); + factory.generateCache(namespace, null, factory.getVersion(), scheduler); } } diff --git a/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/URIExtractionNamespaceCacheFactoryTest.java b/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/UriCacheGeneratorTest.java similarity index 86% rename from extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/URIExtractionNamespaceCacheFactoryTest.java rename to extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/UriCacheGeneratorTest.java index e549815b060..630463de1ad 100644 --- a/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/URIExtractionNamespaceCacheFactoryTest.java +++ b/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/UriCacheGeneratorTest.java @@ -29,14 +29,14 @@ import io.druid.jackson.DefaultObjectMapper; import io.druid.java.util.common.IAE; import io.druid.java.util.common.UOE; import io.druid.java.util.common.lifecycle.Lifecycle; +import io.druid.query.lookup.namespace.CacheGenerator; import io.druid.query.lookup.namespace.ExtractionNamespace; -import io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory; -import io.druid.query.lookup.namespace.URIExtractionNamespace; -import io.druid.query.lookup.namespace.URIExtractionNamespaceTest; +import io.druid.query.lookup.namespace.UriExtractionNamespace; +import io.druid.query.lookup.namespace.UriExtractionNamespaceTest; import io.druid.segment.loading.LocalFileTimestampVersionFinder; import io.druid.server.lookup.namespace.cache.CacheScheduler; import io.druid.server.lookup.namespace.cache.NamespaceExtractionCacheManager; -import io.druid.server.lookup.namespace.cache.NamespaceExtractionCacheManagerExecutorsTest; +import io.druid.server.lookup.namespace.cache.CacheSchedulerTest; import io.druid.server.lookup.namespace.cache.OffHeapNamespaceExtractionCacheManager; import io.druid.server.lookup.namespace.cache.OnHeapNamespaceExtractionCacheManager; import io.druid.server.metrics.NoopServiceEmitter; @@ -76,7 +76,7 @@ import java.util.zip.GZIPOutputStream; * */ @RunWith(Parameterized.class) -public class URIExtractionNamespaceCacheFactoryTest +public class UriCacheGeneratorTest { private static final String FAKE_SCHEME = "wabblywoo"; private static final Map FINDERS = ImmutableMap.of( @@ -232,13 +232,13 @@ public class URIExtractionNamespaceCacheFactoryTest }; } - public URIExtractionNamespaceCacheFactoryTest( + public UriCacheGeneratorTest( String suffix, Function outStreamSupplier, Function cacheManagerCreator ) throws Exception { - final Map, ExtractionNamespaceCacheFactory> namespaceFunctionFactoryMap = new HashMap<>(); + final Map, CacheGenerator> namespaceFunctionFactoryMap = new HashMap<>(); this.suffix = suffix; this.outStreamSupplier = outStreamSupplier; this.lifecycle = new Lifecycle(); @@ -248,9 +248,9 @@ public class URIExtractionNamespaceCacheFactoryTest cacheManagerCreator.apply(lifecycle) ); namespaceFunctionFactoryMap.put( - URIExtractionNamespace.class, + UriExtractionNamespace.class, - new URIExtractionNamespaceCacheFactory(FINDERS) + new UriCacheGenerator(FINDERS) ); } @@ -263,8 +263,8 @@ public class URIExtractionNamespaceCacheFactoryTest private CacheScheduler scheduler; private File tmpFile; private File tmpFileParent; - private URIExtractionNamespaceCacheFactory populator; - private URIExtractionNamespace namespace; + private UriCacheGenerator generator; + private UriExtractionNamespace namespace; @Before public void setUp() throws Exception @@ -288,12 +288,12 @@ public class URIExtractionNamespaceCacheFactoryTest "" ))); } - populator = new URIExtractionNamespaceCacheFactory(FINDERS); - namespace = new URIExtractionNamespace( + generator = new UriCacheGenerator(FINDERS); + namespace = new UriExtractionNamespace( tmpFile.toURI(), null, null, - new URIExtractionNamespace.ObjectMapperFlatDataParser( - URIExtractionNamespaceTest.registerTypes(new ObjectMapper()) + new UriExtractionNamespace.ObjectMapperFlatDataParser( + UriExtractionNamespaceTest.registerTypes(new ObjectMapper()) ), new Period(0), null @@ -311,7 +311,7 @@ public class URIExtractionNamespaceCacheFactoryTest { Assert.assertEquals(0, scheduler.getActiveEntries()); CacheScheduler.Entry entry = scheduler.schedule(namespace); - NamespaceExtractionCacheManagerExecutorsTest.waitFor(entry); + CacheSchedulerTest.waitFor(entry); Map map = entry.getCache(); Assert.assertEquals("bar", map.get("foo")); Assert.assertEquals(null, map.get("baz")); @@ -320,7 +320,7 @@ public class URIExtractionNamespaceCacheFactoryTest @Test public void simpleTestRegex() throws IOException, ExecutionException, InterruptedException { - final URIExtractionNamespace namespace = new URIExtractionNamespace( + final UriExtractionNamespace namespace = new UriExtractionNamespace( null, Paths.get(this.namespace.getUri()).getParent().toUri(), Pattern.quote(Paths.get(this.namespace.getUri()).getFileName().toString()), @@ -329,7 +329,7 @@ public class URIExtractionNamespaceCacheFactoryTest null ); CacheScheduler.Entry entry = scheduler.schedule(namespace); - NamespaceExtractionCacheManagerExecutorsTest.waitFor(entry); + CacheSchedulerTest.waitFor(entry); Map map = entry.getCache(); Assert.assertNotNull(map); Assert.assertEquals("bar", map.get("foo")); @@ -342,11 +342,11 @@ public class URIExtractionNamespaceCacheFactoryTest final int size = 128; List entries = new ArrayList<>(size); for (int i = 0; i < size; ++i) { - URIExtractionNamespace namespace = new URIExtractionNamespace( + UriExtractionNamespace namespace = new UriExtractionNamespace( tmpFile.toURI(), null, null, - new URIExtractionNamespace.ObjectMapperFlatDataParser( - URIExtractionNamespaceTest.registerTypes(new ObjectMapper()) + new UriExtractionNamespace.ObjectMapperFlatDataParser( + UriExtractionNamespaceTest.registerTypes(new ObjectMapper()) ), new Period(0), null @@ -354,7 +354,7 @@ public class URIExtractionNamespaceCacheFactoryTest CacheScheduler.Entry entry = scheduler.schedule(namespace); entries.add(entry); - NamespaceExtractionCacheManagerExecutorsTest.waitFor(entry); + CacheSchedulerTest.waitFor(entry); } for (CacheScheduler.Entry entry : entries) { @@ -371,7 +371,7 @@ public class URIExtractionNamespaceCacheFactoryTest { Assert.assertEquals(0, scheduler.getActiveEntries()); - CacheScheduler.VersionedCache versionedCache = populator.populateCache(namespace, null, null, scheduler); + CacheScheduler.VersionedCache versionedCache = generator.generateCache(namespace, null, null, scheduler); Assert.assertNotNull(versionedCache); Map map = versionedCache.getCache(); Assert.assertEquals("bar", map.get("foo")); @@ -379,13 +379,13 @@ public class URIExtractionNamespaceCacheFactoryTest String version = versionedCache.getVersion(); Assert.assertNotNull(version); - Assert.assertNull(populator.populateCache(namespace, null, version, scheduler)); + Assert.assertNull(generator.generateCache(namespace, null, version, scheduler)); } @Test(expected = FileNotFoundException.class) public void testMissing() throws Exception { - URIExtractionNamespace badNamespace = new URIExtractionNamespace( + UriExtractionNamespace badNamespace = new UriExtractionNamespace( namespace.getUri(), null, null, namespace.getNamespaceParseSpec(), @@ -393,13 +393,13 @@ public class URIExtractionNamespaceCacheFactoryTest null ); Assert.assertTrue(new File(namespace.getUri()).delete()); - populator.populateCache(badNamespace, null, null, scheduler); + generator.generateCache(badNamespace, null, null, scheduler); } @Test(expected = FileNotFoundException.class) public void testMissingRegex() throws Exception { - URIExtractionNamespace badNamespace = new URIExtractionNamespace( + UriExtractionNamespace badNamespace = new UriExtractionNamespace( null, Paths.get(namespace.getUri()).getParent().toUri(), Pattern.quote(Paths.get(namespace.getUri()).getFileName().toString()), @@ -408,13 +408,13 @@ public class URIExtractionNamespaceCacheFactoryTest null ); Assert.assertTrue(new File(namespace.getUri()).delete()); - populator.populateCache(badNamespace, null, null, scheduler); + generator.generateCache(badNamespace, null, null, scheduler); } @Test(expected = IAE.class) public void testExceptionalCreationDoubleURI() { - new URIExtractionNamespace( + new UriExtractionNamespace( namespace.getUri(), namespace.getUri(), null, @@ -427,7 +427,7 @@ public class URIExtractionNamespaceCacheFactoryTest @Test(expected = IAE.class) public void testExceptionalCreationURIWithPattern() { - new URIExtractionNamespace( + new UriExtractionNamespace( namespace.getUri(), null, "", @@ -440,7 +440,7 @@ public class URIExtractionNamespaceCacheFactoryTest @Test(expected = IAE.class) public void testExceptionalCreationURIWithLegacyPattern() { - new URIExtractionNamespace( + new UriExtractionNamespace( namespace.getUri(), null, null, @@ -453,7 +453,7 @@ public class URIExtractionNamespaceCacheFactoryTest @Test(expected = IAE.class) public void testLegacyMix() { - new URIExtractionNamespace( + new UriExtractionNamespace( null, namespace.getUri(), "", @@ -467,7 +467,7 @@ public class URIExtractionNamespaceCacheFactoryTest @Test(expected = IAE.class) public void testBadPattern() { - new URIExtractionNamespace( + new UriExtractionNamespace( null, namespace.getUri(), "[", @@ -480,7 +480,7 @@ public class URIExtractionNamespaceCacheFactoryTest @Test public void testWeirdSchemaOnExactURI() throws Exception { - final URIExtractionNamespace extractionNamespace = new URIExtractionNamespace( + final UriExtractionNamespace extractionNamespace = new UriExtractionNamespace( new URI( FAKE_SCHEME, namespace.getUri().getUserInfo(), @@ -496,19 +496,19 @@ public class URIExtractionNamespaceCacheFactoryTest Period.millis((int) namespace.getPollMs()), null ); - Assert.assertNotNull(populator.populateCache(extractionNamespace, null, null, scheduler)); + Assert.assertNotNull(generator.generateCache(extractionNamespace, null, null, scheduler)); } @Test(timeout = 10_000) public void testDeleteOnScheduleFail() throws Exception { Assert.assertNull(scheduler.scheduleAndWait( - new URIExtractionNamespace( + new UriExtractionNamespace( new URI("file://tmp/I_DONT_REALLY_EXIST" + UUID.randomUUID().toString()), null, null, - new URIExtractionNamespace.JSONFlatDataParser( + new UriExtractionNamespace.JSONFlatDataParser( new DefaultObjectMapper(), "key", "val" diff --git a/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/NamespaceExtractionCacheManagerExecutorsTest.java b/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/CacheSchedulerTest.java similarity index 89% rename from extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/NamespaceExtractionCacheManagerExecutorsTest.java rename to extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/CacheSchedulerTest.java index f3904d9570b..7d92692b195 100644 --- a/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/NamespaceExtractionCacheManagerExecutorsTest.java +++ b/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/CacheSchedulerTest.java @@ -28,10 +28,10 @@ import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import io.druid.concurrent.Execs; import io.druid.java.util.common.lifecycle.Lifecycle; +import io.druid.query.lookup.namespace.CacheGenerator; import io.druid.query.lookup.namespace.ExtractionNamespace; -import io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory; -import io.druid.query.lookup.namespace.URIExtractionNamespace; -import io.druid.query.lookup.namespace.URIExtractionNamespaceTest; +import io.druid.query.lookup.namespace.UriExtractionNamespace; +import io.druid.query.lookup.namespace.UriExtractionNamespaceTest; import io.druid.server.metrics.NoopServiceEmitter; import org.joda.time.Period; import org.junit.After; @@ -65,7 +65,7 @@ import java.util.concurrent.TimeoutException; * */ @RunWith(Parameterized.class) -public class NamespaceExtractionCacheManagerExecutorsTest +public class CacheSchedulerTest { public static final Function CREATE_ON_HEAP_CACHE_MANAGER = new Function() @@ -111,7 +111,7 @@ public class NamespaceExtractionCacheManagerExecutorsTest private CacheScheduler scheduler; private File tmpFile; - public NamespaceExtractionCacheManagerExecutorsTest( + public CacheSchedulerTest( Function createCacheManager ) { @@ -125,13 +125,13 @@ public class NamespaceExtractionCacheManagerExecutorsTest lifecycle.start(); cacheManager = createCacheManager.apply(lifecycle); final Path tmpDir = temporaryFolder.newFolder().toPath(); - final ExtractionNamespaceCacheFactory cachePopulator = new - ExtractionNamespaceCacheFactory() + final CacheGenerator cacheGenerator = new + CacheGenerator() { @Override - public CacheScheduler.VersionedCache populateCache( - final URIExtractionNamespace extractionNamespace, - final CacheScheduler.EntryImpl id, + public CacheScheduler.VersionedCache generateCache( + final UriExtractionNamespace extractionNamespace, + final CacheScheduler.EntryImpl id, final String lastVersion, final CacheScheduler scheduler ) throws InterruptedException @@ -146,9 +146,9 @@ public class NamespaceExtractionCacheManagerExecutorsTest }; scheduler = new CacheScheduler( new NoopServiceEmitter(), - ImmutableMap., ExtractionNamespaceCacheFactory>of( - URIExtractionNamespace.class, - cachePopulator + ImmutableMap., CacheGenerator>of( + UriExtractionNamespace.class, + cacheGenerator ), cacheManager ); @@ -172,11 +172,11 @@ public class NamespaceExtractionCacheManagerExecutorsTest @Test(timeout = 10_000) public void testSimpleSubmission() throws ExecutionException, InterruptedException { - URIExtractionNamespace namespace = new URIExtractionNamespace( + UriExtractionNamespace namespace = new UriExtractionNamespace( tmpFile.toURI(), null, null, - new URIExtractionNamespace.ObjectMapperFlatDataParser( - URIExtractionNamespaceTest.registerTypes(new ObjectMapper()) + new UriExtractionNamespace.ObjectMapperFlatDataParser( + UriExtractionNamespaceTest.registerTypes(new ObjectMapper()) ), new Period(0), null @@ -194,7 +194,7 @@ public class NamespaceExtractionCacheManagerExecutorsTest final int repeatCount = 5; final long delay = 5; try { - final URIExtractionNamespace namespace = getUriExtractionNamespace(delay); + final UriExtractionNamespace namespace = getUriExtractionNamespace(delay); final long start = System.currentTimeMillis(); try (CacheScheduler.Entry entry = scheduler.schedule(namespace)) { @@ -305,7 +305,7 @@ public class NamespaceExtractionCacheManagerExecutorsTest throws InterruptedException, TimeoutException, ExecutionException { final long period = 1_000L;// Give it some time between attempts to update - final URIExtractionNamespace namespace = getUriExtractionNamespace(period); + final UriExtractionNamespace namespace = getUriExtractionNamespace(period); CacheScheduler.Entry entry = scheduler.scheduleAndWait(namespace, 10_000); Assert.assertNotNull(entry); final Future future = entry.getUpdaterFuture(); @@ -332,13 +332,13 @@ public class NamespaceExtractionCacheManagerExecutorsTest Assert.assertTrue(future.isDone()); } - private URIExtractionNamespace getUriExtractionNamespace(long period) + private UriExtractionNamespace getUriExtractionNamespace(long period) { - return new URIExtractionNamespace( + return new UriExtractionNamespace( tmpFile.toURI(), null, null, - new URIExtractionNamespace.ObjectMapperFlatDataParser( - URIExtractionNamespaceTest.registerTypes(new ObjectMapper()) + new UriExtractionNamespace.ObjectMapperFlatDataParser( + UriExtractionNamespaceTest.registerTypes(new ObjectMapper()) ), new Period(period), null @@ -352,7 +352,7 @@ public class NamespaceExtractionCacheManagerExecutorsTest final long period = 5L; try { - final URIExtractionNamespace namespace = getUriExtractionNamespace(period); + final UriExtractionNamespace namespace = getUriExtractionNamespace(period); try (CacheScheduler.Entry entry = scheduler.schedule(namespace)) { final Future future = entry.getUpdaterFuture(); @@ -383,7 +383,7 @@ public class NamespaceExtractionCacheManagerExecutorsTest { final int numWaits = 5; try { - final URIExtractionNamespace namespace = getUriExtractionNamespace((long) 5); + final UriExtractionNamespace namespace = getUriExtractionNamespace((long) 5); try (CacheScheduler.Entry entry = scheduler.schedule(namespace)) { final Future future = entry.getUpdaterFuture(); entry.awaitNextUpdates(numWaits); diff --git a/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/JDBCExtractionNamespaceTest.java b/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/JdbcExtractionNamespaceTest.java similarity index 92% rename from extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/JDBCExtractionNamespaceTest.java rename to extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/JdbcExtractionNamespaceTest.java index 03be4b4637a..da5099e5dbf 100644 --- a/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/JDBCExtractionNamespaceTest.java +++ b/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/JdbcExtractionNamespaceTest.java @@ -31,10 +31,10 @@ import io.druid.java.util.common.io.Closer; import io.druid.java.util.common.lifecycle.Lifecycle; import io.druid.java.util.common.logger.Logger; import io.druid.metadata.TestDerbyConnector; +import io.druid.query.lookup.namespace.CacheGenerator; import io.druid.query.lookup.namespace.ExtractionNamespace; -import io.druid.query.lookup.namespace.ExtractionNamespaceCacheFactory; -import io.druid.query.lookup.namespace.JDBCExtractionNamespace; -import io.druid.server.lookup.namespace.JDBCExtractionNamespaceCacheFactory; +import io.druid.query.lookup.namespace.JdbcExtractionNamespace; +import io.druid.server.lookup.namespace.JdbcCacheGenerator; import io.druid.server.metrics.NoopServiceEmitter; import org.joda.time.Period; import org.junit.After; @@ -62,11 +62,11 @@ import java.util.concurrent.locks.ReentrantLock; * */ @RunWith(Parameterized.class) -public class JDBCExtractionNamespaceTest +public class JdbcExtractionNamespaceTest { @Rule public final TestDerbyConnector.DerbyConnectorRule derbyConnectorRule = new TestDerbyConnector.DerbyConnectorRule(); - private static final Logger log = new Logger(JDBCExtractionNamespaceTest.class); + private static final Logger log = new Logger(JdbcExtractionNamespaceTest.class); private static final String tableName = "abstractDbRenameTest"; private static final String keyName = "keyName"; private static final String valName = "valName"; @@ -87,7 +87,7 @@ public class JDBCExtractionNamespaceTest ); } - public JDBCExtractionNamespaceTest( + public JdbcExtractionNamespaceTest( String tsColumn ) { @@ -186,25 +186,25 @@ public class JDBCExtractionNamespaceTest NoopServiceEmitter noopServiceEmitter = new NoopServiceEmitter(); scheduler = new CacheScheduler( noopServiceEmitter, - ImmutableMap., ExtractionNamespaceCacheFactory>of( - JDBCExtractionNamespace.class, - new ExtractionNamespaceCacheFactory() + ImmutableMap., CacheGenerator>of( + JdbcExtractionNamespace.class, + new CacheGenerator() { - private final JDBCExtractionNamespaceCacheFactory delegate = - new JDBCExtractionNamespaceCacheFactory(); + private final JdbcCacheGenerator delegate = + new JdbcCacheGenerator(); @Override - public CacheScheduler.VersionedCache populateCache( - final JDBCExtractionNamespace namespace, - final CacheScheduler.EntryImpl id, + public CacheScheduler.VersionedCache generateCache( + final JdbcExtractionNamespace namespace, + final CacheScheduler.EntryImpl id, final String lastVersion, final CacheScheduler scheduler ) throws InterruptedException { updateLock.lockInterruptibly(); try { - log.debug("Running cache populator"); + log.debug("Running cache generator"); try { - return delegate.populateCache(namespace, id, lastVersion, scheduler); + return delegate.generateCache(namespace, id, lastVersion, scheduler); } finally { updates.incrementAndGet(); @@ -355,7 +355,7 @@ public class JDBCExtractionNamespaceTest throws ClassNotFoundException, NoSuchFieldException, IllegalAccessException, ExecutionException, InterruptedException, TimeoutException { - final JDBCExtractionNamespace extractionNamespace = new JDBCExtractionNamespace( + final JdbcExtractionNamespace extractionNamespace = new JdbcExtractionNamespace( derbyConnectorRule.getMetadataConnectorConfig(), tableName, keyName, @@ -364,7 +364,7 @@ public class JDBCExtractionNamespaceTest new Period(0) ); try (CacheScheduler.Entry entry = scheduler.schedule(extractionNamespace)) { - NamespaceExtractionCacheManagerExecutorsTest.waitFor(entry); + CacheSchedulerTest.waitFor(entry); final Map map = entry.getCache(); for (Map.Entry e : renames.entrySet()) { @@ -403,7 +403,7 @@ public class JDBCExtractionNamespaceTest private CacheScheduler.Entry ensureEntry() throws NoSuchFieldException, IllegalAccessException, InterruptedException { - final JDBCExtractionNamespace extractionNamespace = new JDBCExtractionNamespace( + final JdbcExtractionNamespace extractionNamespace = new JdbcExtractionNamespace( derbyConnectorRule.getMetadataConnectorConfig(), tableName, keyName, diff --git a/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/NamespaceExtractionCacheManagersTest.java b/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/NamespaceExtractionCacheManagersTest.java index 472bb437b24..7c7013c1f59 100644 --- a/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/NamespaceExtractionCacheManagersTest.java +++ b/extensions-core/lookups-cached-global/src/test/java/io/druid/server/lookup/namespace/cache/NamespaceExtractionCacheManagersTest.java @@ -47,8 +47,8 @@ public class NamespaceExtractionCacheManagersTest public static Collection data() { return Arrays.asList(new Object[][]{ - {NamespaceExtractionCacheManagerExecutorsTest.CREATE_ON_HEAP_CACHE_MANAGER}, - {NamespaceExtractionCacheManagerExecutorsTest.CREATE_OFF_HEAP_CACHE_MANAGER} + {CacheSchedulerTest.CREATE_ON_HEAP_CACHE_MANAGER}, + {CacheSchedulerTest.CREATE_OFF_HEAP_CACHE_MANAGER} }); }