diff options
author | Harald Musum <musum@yahoo-inc.com> | 2017-02-14 22:17:35 +0100 |
---|---|---|
committer | Harald Musum <musum@yahoo-inc.com> | 2017-02-14 22:17:35 +0100 |
commit | 58474e77ccd2a0f495a69c77cabe41e40d94bcfa (patch) | |
tree | 58e3aca49204f9e1559506bd40b25f4dfbab93aa /config-proxy | |
parent | 7c6ae7d45e6c53c70b9033973061ddebf95e8a98 (diff) |
Refactoring
* Remove traces of diskcache mode and simplify startup now that
only default mode is supported when starting config proxy
* Remove CacheManager now that we have only one type of cache
* Rename some classes
Diffstat (limited to 'config-proxy')
20 files changed, 197 insertions, 282 deletions
diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/CacheManager.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/CacheManager.java deleted file mode 100644 index 680bb6b43ac..00000000000 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/CacheManager.java +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.config.proxy; - -import com.yahoo.vespa.config.RawConfig; - -/** - * Manages memory and disk caches. - * - * @author hmusum - */ -public class CacheManager { - - private final MemoryCache memoryCache; - - public CacheManager(MemoryCache memoryCache) { - this.memoryCache = memoryCache; - } - - static CacheManager createTestCacheManager() { - return CacheManager.createTestCacheManager(new MemoryCache()); - } - - static CacheManager createTestCacheManager(MemoryCache memoryCache) { - return new CacheManager(memoryCache); - } - - void putInCache(RawConfig config) { - putInMemoryCache(config); - } - - private void putInMemoryCache(RawConfig config) { - if (!config.isError()) { - memoryCache.put(config); - } - } - - public MemoryCache getMemoryCache() { - return memoryCache; - } - - // Only for testing. - int getCacheSize() { - return getMemoryCache().size(); - } - -} diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ClientUpdater.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ClientUpdater.java index fbbc2071d30..28fc22538b6 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ClientUpdater.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ClientUpdater.java @@ -14,21 +14,21 @@ import java.util.logging.Logger; * * @author hmusum */ -public class ClientUpdater { - final static Logger log = Logger.getLogger(ClientUpdater.class.getName()); +class ClientUpdater { + private final static Logger log = Logger.getLogger(ClientUpdater.class.getName()); - private final CacheManager cacheManager; + private final MemoryCache memoryCache; private final ConfigProxyStatistics statistics; private final RpcServer rpcServer; private final DelayedResponses delayedResponses; private final Mode mode; - public ClientUpdater(CacheManager cacheManager, - RpcServer rpcServer, - ConfigProxyStatistics statistics, - DelayedResponses delayedResponses, - Mode mode) { - this.cacheManager = cacheManager; + ClientUpdater(MemoryCache memoryCache, + RpcServer rpcServer, + ConfigProxyStatistics statistics, + DelayedResponses delayedResponses, + Mode mode) { + this.memoryCache = memoryCache; this.rpcServer = rpcServer; this.statistics = statistics; this.delayedResponses = delayedResponses; @@ -54,11 +54,11 @@ public class ClientUpdater { if (log.isLoggable(LogLevel.DEBUG)) { log.log(LogLevel.DEBUG, "Config updated for " + config.getKey() + "," + config.getGeneration()); } - cacheManager.putInCache(config); + memoryCache.put(config); sendResponse(config); } - void sendResponse(RawConfig config) { + private void sendResponse(RawConfig config) { if (config.isError()) { statistics.incErrorCount(); } if (log.isLoggable(LogLevel.DEBUG)) { log.log(LogLevel.DEBUG, "Sending response for " + config.getKey() + "," + config.getGeneration()); diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServer.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServer.java index 7104ed5a24b..eff25aa9191 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServer.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServer.java @@ -25,13 +25,13 @@ import java.util.logging.Logger; public class ConfigProxyRpcServer implements Runnable, TargetWatcher, RpcServer { private final static Logger log = Logger.getLogger(ConfigProxyRpcServer.class.getName()); - static final int TRACELEVEL = 6; + private static final int TRACELEVEL = 6; private final Spec spec; private final Supervisor supervisor = new Supervisor(new Transport()); private final ProxyServer proxyServer; - public ConfigProxyRpcServer(ProxyServer proxyServer, Spec spec) { + ConfigProxyRpcServer(ProxyServer proxyServer, Spec spec) { this.proxyServer = proxyServer; this.spec = spec; setUp(); @@ -53,11 +53,11 @@ public class ConfigProxyRpcServer implements Runnable, TargetWatcher, RpcServer supervisor.transport().shutdown(); } - public Spec getSpec() { + Spec getSpec() { return spec; } - void setUp() { + private void setUp() { // The getConfig method in this class will handle RPC calls for getting config supervisor.addMethod(JRTMethods.createConfigV3GetConfigMethod(this, "getConfigV3")); supervisor.addMethod(new Method("ping", "", "i", @@ -157,13 +157,13 @@ public class ConfigProxyRpcServer implements Runnable, TargetWatcher, RpcServer RawConfig config = proxyServer.resolveConfig(request); if (config == null) { if (log.isLoggable(LogLevel.DEBUG)) { - log.log(LogLevel.DEBUG, "No config received yet for " + request.getShortDescription() + ",not sending response"); + log.log(LogLevel.DEBUG, "No config received yet for " + request.getShortDescription() + ", not sending response"); } } else if (ProxyServer.configOrGenerationHasChanged(config, request)) { returnOkResponse(request, config); } else { if (log.isLoggable(LogLevel.DEBUG)) { - log.log(LogLevel.DEBUG, "No new config for " + request.getShortDescription() + ",not sending response"); + log.log(LogLevel.DEBUG, "No new config for " + request.getShortDescription() + ", not sending response"); } } } catch (Exception e) { @@ -236,7 +236,7 @@ public class ConfigProxyRpcServer implements Runnable, TargetWatcher, RpcServer } public final void invalidateCache(Request req) { - proxyServer.getCacheManager().getMemoryCache().clear(); + proxyServer.getMemoryCache().clear(); String[] s = new String[2]; s[0] = "0"; s[1] = "success"; @@ -265,13 +265,13 @@ public class ConfigProxyRpcServer implements Runnable, TargetWatcher, RpcServer @SuppressWarnings({"UnusedDeclaration"}) public final void dumpCache(Request req) { - final CacheManager cacheManager = proxyServer.getCacheManager(); - req.returnValues().add(new StringValue(cacheManager.getMemoryCache().dumpCacheToDisk(req.parameters().get(0).asString(), cacheManager.getMemoryCache()))); + final MemoryCache memoryCache = proxyServer.getMemoryCache(); + req.returnValues().add(new StringValue(memoryCache.dumpCacheToDisk(req.parameters().get(0).asString(), memoryCache))); } final void listCachedConfig(Request req, boolean full) { String[] ret; - MemoryCache cache = proxyServer.getCacheManager().getMemoryCache(); + MemoryCache cache = proxyServer.getMemoryCache(); ret = new String[cache.size()]; int i = 0; for (RawConfig config : cache.values()) { diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigProxyStatistics.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigProxyStatistics.java index 5ad521ef5f6..ce123b219a9 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigProxyStatistics.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigProxyStatistics.java @@ -59,11 +59,11 @@ class ConfigProxyStatistics implements Runnable { Event.value("delayed_responses", delayedResponses()); } - public void stop() { + void stop() { stopped = true; } - public Long getEventInterval() { + Long getEventInterval() { return eventInterval; } diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigSourceClient.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigSourceClient.java index 5bbb6d40cc7..f8b2cafa50f 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigSourceClient.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ConfigSourceClient.java @@ -19,12 +19,11 @@ import java.util.List; public abstract class ConfigSourceClient { static ConfigSourceClient createClient(ConfigSource source, ClientUpdater clientUpdater, - CacheManager cacheManager, + MemoryCache memoryCache, TimingValues timingValues, - ConfigProxyStatistics statistics, DelayedResponses delayedResponses) { if (source instanceof ConfigSourceSet) { - return new RpcConfigSourceClient((ConfigSourceSet) source, clientUpdater, cacheManager, timingValues, delayedResponses); + return new RpcConfigSourceClient((ConfigSourceSet) source, clientUpdater, memoryCache, timingValues, delayedResponses); } else if (source instanceof MapBackedConfigSource) { return (ConfigSourceClient) source; } else { diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/DelayedResponse.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/DelayedResponse.java index 257b94038b6..2a89dc224c5 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/DelayedResponse.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/DelayedResponse.java @@ -12,7 +12,7 @@ import java.util.concurrent.TimeUnit; * delayed responses and returning requests that are about to time out, in cases where no new * config has been returned from upstream) * - * @see com.yahoo.vespa.config.proxy.CheckDelayedResponses + * @see DelayedResponseHandler */ public class DelayedResponse implements Delayed { private final JRTServerConfigRequest request; diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/CheckDelayedResponses.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/DelayedResponseHandler.java index c6a5d90fd2b..21909a5e371 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/CheckDelayedResponses.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/DelayedResponseHandler.java @@ -11,20 +11,20 @@ import java.util.Date; import java.util.logging.Logger; /** - * The run method of this class is executed periodically to - * return requests that are about to time out. + * The run method of this class is executed periodically to return delayed responses + * (long polling requests that are about to time out and needs to be returned). * * @author hmusum */ -public class CheckDelayedResponses implements Runnable { +public class DelayedResponseHandler implements Runnable { - final static Logger log = Logger.getLogger(CheckDelayedResponses.class.getName()); + private final static Logger log = Logger.getLogger(DelayedResponseHandler.class.getName()); private final DelayedResponses delayedResponses; private final MemoryCache memoryCache; private final RpcServer rpcServer; - public CheckDelayedResponses(DelayedResponses delayedResponses, MemoryCache memoryCache, RpcServer rpcServer) { + DelayedResponseHandler(DelayedResponses delayedResponses, MemoryCache memoryCache, RpcServer rpcServer) { this.delayedResponses = delayedResponses; this.memoryCache = memoryCache; this.rpcServer = rpcServer; @@ -39,7 +39,7 @@ public class CheckDelayedResponses implements Runnable { try { long start = System.currentTimeMillis(); if (log.isLoggable(LogLevel.SPAM)) { - log.log(LogLevel.SPAM, "Running CheckDelayedResponses. There are " + delayedResponses.size() + " delayed responses. First one is " + delayedResponses.responses().peek()); + log.log(LogLevel.SPAM, "Running DelayedResponseHandler. There are " + delayedResponses.size() + " delayed responses. First one is " + delayedResponses.responses().peek()); } DelayedResponse response; int i = 0; @@ -59,13 +59,13 @@ public class CheckDelayedResponses implements Runnable { } } if (log.isLoggable(LogLevel.SPAM)) { - log.log(LogLevel.SPAM, "Finished running CheckDelayedResponses. " + i + " delayed responses sent in " + + log.log(LogLevel.SPAM, "Finished running DelayedResponseHandler. " + i + " delayed responses sent in " + (System.currentTimeMillis() - start) + " ms"); } } catch (Exception e) { // To avoid thread throwing exception and executor never running this again - log.log(LogLevel.WARNING, "Got exception in CheckDelayedResponses: " + Exceptions.toMessageString(e)); + log.log(LogLevel.WARNING, "Got exception in DelayedResponseHandler: " + Exceptions.toMessageString(e)); } catch (Throwable e) { - com.yahoo.protect.Process.logAndDie("Got error in CheckDelayedResponses, exiting: " + Exceptions.toMessageString(e)); + com.yahoo.protect.Process.logAndDie("Got error in DelayedResponseHandler, exiting: " + Exceptions.toMessageString(e)); } } } diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/MemoryCache.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/MemoryCache.java index e5ef69cbe7a..a3ed15405da 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/MemoryCache.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/MemoryCache.java @@ -27,30 +27,31 @@ public class MemoryCache { // Separator in file names between different fields of config key private final static String separator = ":"; private static final String DEFAULT_DUMP_DIR = Defaults.getDefaults().vespaHome() + "var/vespa/cache/config"; - private final String dumpDir; private final ConcurrentHashMap<ConfigCacheKey, RawConfig> cache = new ConcurrentHashMap<>(500, 0.75f); - public MemoryCache() { - dumpDir = DEFAULT_DUMP_DIR; - } - public RawConfig get(ConfigCacheKey key) { return cache.get(key); } - public RawConfig put(RawConfig config) { + /** + * Put in cache, except when config has an error + * @param config config to put in cache + */ + public void put(RawConfig config) { + if (config.isError()) return; + if (log.isLoggable(LogLevel.DEBUG)) { log.log(LogLevel.DEBUG, "Putting '" + config + "' into memory cache"); } - return cache.put(new ConfigCacheKey(config.getKey(), config.getDefMd5()), config); + cache.put(new ConfigCacheKey(config.getKey(), config.getDefMd5()), config); } boolean containsKey(ConfigCacheKey key) { return cache.containsKey(key); } - public Collection<RawConfig> values() { + Collection<RawConfig> values() { return cache.values(); } @@ -69,7 +70,7 @@ public class MemoryCache { String dumpCacheToDisk(String path, MemoryCache cache) { if (path == null || path.isEmpty()) { - path = dumpDir; + path = DEFAULT_DUMP_DIR; log.log(LogLevel.DEBUG, "dumpCache. No path or empty path. Using dir '" + path + "'"); } if (path.endsWith("/")) { @@ -83,19 +84,19 @@ public class MemoryCache { return "Not a dir or not able to write to '" + dir + "'"; } for (RawConfig config : cache.values()) { - put(config, path); + writeConfigToFile(config, path); } return "success"; } - void put(RawConfig config, String path) { - if (log.isLoggable(LogLevel.DEBUG)) { - log.log(LogLevel.DEBUG, "Putting '" + config.getKey() + "' into disk cache"); - } + private void writeConfigToFile(RawConfig config, String path) { String filename = null; Writer writer = null; try { filename = path + File.separator + createCacheFileName(config); + if (log.isLoggable(LogLevel.DEBUG)) { + log.log(LogLevel.DEBUG, "Writing '" + config.getKey() + "' to '" + filename + "'"); + } final Payload payload = config.getPayload(); long protocolVersion = 3; log.log(LogLevel.DEBUG, "Writing config '" + config + "' to file '" + filename + "' with protocol version " + protocolVersion); @@ -127,7 +128,7 @@ public class MemoryCache { return createCacheFileName(new ConfigCacheKey(config.getKey(), config.getDefMd5())); } - static String createCacheFileName(ConfigCacheKey key) { + private static String createCacheFileName(ConfigCacheKey key) { final ConfigKey<?> configKey = key.getKey(); return configKey.getNamespace() + "." + configKey.getName() + separator + configKey.getConfigId().replaceAll("/", "_") + separator + key.getDefMd5(); diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClient.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClient.java index cfe3836faa7..f1980b05817 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClient.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/MemoryCacheConfigClient.java @@ -13,7 +13,7 @@ import java.util.logging.Logger; * @author hmusum * @since 5.1.10 */ -public class MemoryCacheConfigClient extends ConfigSourceClient { +class MemoryCacheConfigClient extends ConfigSourceClient { private final static Logger log = Logger.getLogger(MemoryCacheConfigClient.class.getName()); private final MemoryCache cache; @@ -22,13 +22,13 @@ public class MemoryCacheConfigClient extends ConfigSourceClient { this.cache = cache; } - @Override /** - * Retrieves the requested config from the cache. Used when in 'memorycache' mode</p> + * Retrieves the requested config from the cache. Used when in 'memorycache' mode. * * @param request The config to retrieve - can be empty (no payload), or have a valid payload. * @return A Config with a payload. */ + @Override RawConfig getConfig(RawConfig input, JRTServerConfigRequest request) { log.log(LogLevel.DEBUG, "Getting config from cache"); ConfigKey<?> key = input.getKey(); diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/Mode.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/Mode.java index 38ba9d646b4..ecec8aca3a9 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/Mode.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/Mode.java @@ -22,7 +22,11 @@ class Mode { } public Mode() { - this(ModeName.DEFAULT.name()); + this(ModeName.DEFAULT); + } + + public Mode(ModeName modeName) { + mode = modeName; } public Mode(String modeString) { diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java index 131d292ce5a..a0ce5853768 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/ProxyServer.java @@ -20,6 +20,7 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Logger; +import static com.yahoo.vespa.config.proxy.Mode.ModeName.DEFAULT; import static java.util.concurrent.TimeUnit.SECONDS; /** @@ -40,7 +41,7 @@ public class ProxyServer implements Runnable { // Scheduled executor that periodically checks for requests that have timed out and response should be returned to clients private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1, new DaemonThreadFactory()); private final ClientUpdater clientUpdater; - private ScheduledFuture<?> checkerHandle; + private ScheduledFuture<?> delayedResponseScheduler; private final ConfigProxyRpcServer rpcServer; final DelayedResponses delayedResponses; @@ -50,57 +51,56 @@ public class ProxyServer implements Runnable { private final ConfigProxyStatistics statistics; private final TimingValues timingValues; - private final CacheManager cacheManager; - private static final double timingvaluesRatio = 0.8; + private final MemoryCache memoryCache; + private static final double timingValuesRatio = 0.8; private final static TimingValues defaultTimingValues; private final boolean delayedResponseHandling; private volatile Mode mode; - static { // Proxy should time out before clients upon subscription. TimingValues tv = new TimingValues(); - tv.setUnconfiguredDelay((long)(tv.getUnconfiguredDelay()* timingvaluesRatio)). - setConfiguredErrorDelay((long)(tv.getConfiguredErrorDelay()* timingvaluesRatio)). - setSubscribeTimeout((long)(tv.getSubscribeTimeout()* timingvaluesRatio)). + tv.setUnconfiguredDelay((long)(tv.getUnconfiguredDelay()* timingValuesRatio)). + setConfiguredErrorDelay((long)(tv.getConfiguredErrorDelay()* timingValuesRatio)). + setSubscribeTimeout((long)(tv.getSubscribeTimeout()* timingValuesRatio)). setConfiguredErrorTimeout(-1); // Never cache errors defaultTimingValues = tv; } private ProxyServer(Spec spec, DelayedResponses delayedResponses, ConfigSource source, ConfigProxyStatistics statistics, TimingValues timingValues, Mode mode, boolean delayedResponseHandling, - CacheManager cacheManager) { + MemoryCache memoryCache) { this.delayedResponses = delayedResponses; this.configSource = source; - log.log(LogLevel.DEBUG, "Using config sources: " + source); + log.log(LogLevel.DEBUG, "Using config source '" + source); this.statistics = statistics; this.timingValues = timingValues; this.mode = mode; this.delayedResponseHandling = delayedResponseHandling; - this.cacheManager = cacheManager; + this.memoryCache = memoryCache; if (spec == null) { rpcServer = null; } else { rpcServer = new ConfigProxyRpcServer(this, spec); } - clientUpdater = new ClientUpdater(cacheManager, rpcServer, statistics, delayedResponses, mode); - this.configSourceClient = ConfigSourceClient.createClient(source, clientUpdater, cacheManager, timingValues, statistics, delayedResponses); + clientUpdater = new ClientUpdater(memoryCache, rpcServer, statistics, delayedResponses, mode); + this.configSourceClient = ConfigSourceClient.createClient(source, clientUpdater, memoryCache, timingValues, delayedResponses); } - static ProxyServer create(int port, DelayedResponses delayedResponses, ConfigSource source, - ConfigProxyStatistics statistics, Mode mode) { - return new ProxyServer(new Spec(null, port), delayedResponses, source, statistics, defaultTimingValues(), mode, true, new CacheManager(new MemoryCache())); + private static ProxyServer create(int port, DelayedResponses delayedResponses, ConfigSource source, + ConfigProxyStatistics statistics, Mode mode) { + return new ProxyServer(new Spec(null, port), delayedResponses, source, statistics, defaultTimingValues(), mode, true, new MemoryCache()); } - static ProxyServer createTestServer(ConfigSource source) { - final Mode mode = new Mode(Mode.ModeName.DEFAULT.name()); - return ProxyServer.createTestServer(source, false, mode, CacheManager.createTestCacheManager()); - } - static ProxyServer createTestServer(ConfigSource source, boolean delayedResponseHandling, Mode mode, CacheManager cacheManager) { + static ProxyServer createTestServer(ConfigSource source) { + final Mode mode = new Mode(DEFAULT); final ConfigProxyStatistics statistics = new ConfigProxyStatistics(); - return new ProxyServer(null, new DelayedResponses(statistics), source, statistics, defaultTimingValues(), mode, delayedResponseHandling, cacheManager); + final boolean delayedResponseHandling = false; + return new ProxyServer(null, new DelayedResponses(statistics), + source, statistics, defaultTimingValues(), mode, delayedResponseHandling, + new MemoryCache()); } public void run() { @@ -111,7 +111,10 @@ public class ProxyServer implements Runnable { } if (delayedResponseHandling) { // Wait for 5 seconds initially, then run every second - checkerHandle = scheduler.scheduleAtFixedRate(new CheckDelayedResponses(delayedResponses, cacheManager.getMemoryCache(), rpcServer), 5, 1, SECONDS); + delayedResponseScheduler = scheduler.scheduleAtFixedRate(new DelayedResponseHandler(delayedResponses, + memoryCache, + rpcServer), + 5, 1, SECONDS); } else { log.log(LogLevel.INFO, "Running without delayed response handling"); } @@ -125,7 +128,7 @@ public class ProxyServer implements Runnable { // In the last case the method below will return null. RawConfig config = configSourceClient.getConfig(RawConfig.createFromServerRequest(req), req); if (configOrGenerationHasChanged(config, req)) { - cacheManager.putInCache(config); + memoryCache.put(config); } return config; } @@ -143,19 +146,22 @@ public class ProxyServer implements Runnable { log.log(LogLevel.INFO, "Switching from " + this.mode + " mode to " + modeName.toLowerCase() + " mode"); this.mode = new Mode(modeName); - if (mode.isMemoryCache()) { - configSourceClient.shutdownSourceConnections(); - configSourceClient = new MemoryCacheConfigClient(cacheManager.getMemoryCache()); - } else if (mode.isDefault()) { - flush(); - configSourceClient = createRpcClient(); - } else { - throw new IllegalArgumentException("Not able to handle mode '" + modeName + "'"); + switch (mode.getMode()) { + case MEMORYCACHE: + configSourceClient.shutdownSourceConnections(); + configSourceClient = new MemoryCacheConfigClient(memoryCache); + break; + case DEFAULT: + flush(); + configSourceClient = createRpcClient(); + break; + default: + throw new IllegalArgumentException("Not able to handle mode '" + modeName + "'"); } } private RpcConfigSourceClient createRpcClient() { - return new RpcConfigSourceClient((ConfigSourceSet) configSource, clientUpdater, cacheManager, timingValues, delayedResponses); + return new RpcConfigSourceClient((ConfigSourceSet) configSource, clientUpdater, memoryCache, timingValues, delayedResponses); } private void setupSigTermHandler() { @@ -194,20 +200,9 @@ public class ProxyServer implements Runnable { t.setDaemon(true); t.start(); - Mode startupMode = new Mode(properties.mode); - if (!startupMode.isDefault()) log.log(LogLevel.INFO, "Starting config proxy in '" + startupMode + "' mode"); - - if (startupMode.isMemoryCache()) { - log.log(LogLevel.ERROR, "Starting config proxy in '" + startupMode + "' mode is not allowed"); - System.exit(1); - } - - ConfigSourceSet configSources = new ConfigSourceSet(); - if (startupMode.requiresConfigSource()) { - configSources = new ConfigSourceSet(properties.configSources); - } + ConfigSourceSet configSources = new ConfigSourceSet(properties.configSources); DelayedResponses delayedResponses = new DelayedResponses(statistics); - ProxyServer proxyServer = ProxyServer.create(port, delayedResponses, configSources, statistics, startupMode); + ProxyServer proxyServer = ProxyServer.create(port, delayedResponses, configSources, statistics, new Mode(DEFAULT)); // catch termination signal proxyServer.setupSigTermHandler(); Thread proxyserverThread = new Thread(proxyServer); @@ -219,19 +214,16 @@ public class ProxyServer implements Runnable { static Properties getSystemProperties() { // Read system properties long eventInterval = Long.getLong("eventinterval", ConfigProxyStatistics.defaultEventInterval); - String mode = System.getProperty("mode", Mode.ModeName.DEFAULT.name()); final String[] inputConfigSources = System.getProperty("proxyconfigsources", DEFAULT_PROXY_CONFIG_SOURCES).split(","); - return new Properties(eventInterval, mode, inputConfigSources); + return new Properties(eventInterval, inputConfigSources); } static class Properties { final long eventInterval; - final String mode; final String[] configSources; - Properties(long eventInterval, String mode, String[] configSources) { + Properties(long eventInterval, String[] configSources) { this.eventInterval = eventInterval; - this.mode = mode; this.configSources = configSources; } } @@ -251,22 +243,22 @@ public class ProxyServer implements Runnable { // Cancels all config instances and flushes the cache. When this method returns, // the cache will not be updated again before someone calls getConfig(). synchronized void flush() { - cacheManager.getMemoryCache().clear(); + memoryCache.clear(); configSourceClient.cancel(); } public void stop() { Event.stopping("configproxy", "shutdown"); if (rpcServer != null) rpcServer.shutdown(); - if (checkerHandle != null) checkerHandle.cancel(true); + if (delayedResponseScheduler != null) delayedResponseScheduler.cancel(true); flush(); if (statistics != null) { statistics.stop(); } } - public CacheManager getCacheManager() { - return cacheManager; + public MemoryCache getMemoryCache() { + return memoryCache; } String getActiveSourceConnection() { diff --git a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClient.java b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClient.java index 30c85efe93b..1f5d49270ed 100644 --- a/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClient.java +++ b/config-proxy/src/main/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClient.java @@ -43,12 +43,12 @@ public class RpcConfigSourceClient extends ConfigSourceClient { RpcConfigSourceClient(ConfigSourceSet configSourceSet, ClientUpdater clientUpdater, - CacheManager cacheManager, + MemoryCache memoryCache, TimingValues timingValues, DelayedResponses delayedResponses) { this.configSourceSet = configSourceSet; this.clientUpdater = clientUpdater; - this.memoryCache = cacheManager.getMemoryCache(); + this.memoryCache = memoryCache; this.delayedResponses = delayedResponses; this.timingValues = timingValues; checkConfigSources(); diff --git a/config-proxy/src/main/sh/config-ctl b/config-proxy/src/main/sh/config-ctl index 3264a18ddec..4618cb24cbc 100755 --- a/config-proxy/src/main/sh/config-ctl +++ b/config-proxy/src/main/sh/config-ctl @@ -107,19 +107,15 @@ case $1 in if [ "$userargs" == "" ]; then userargs=$services__jvmargs_configproxy fi - proxymode=$services__configproxy_mode jvmopts="-Xms32M -Xmx256M -XX:ThreadStackSize=256 -XX:MaxJavaStackTraceDepth=-1" VESPA_SERVICE_NAME=configproxy export VESPA_SERVICE_NAME - if [ "$proxymode" ]; then - echo "Will start config proxy in mode $proxymode" - fi echo "Starting config proxy using $configsources as config source(s)" vespa-runserver -r 10 -s configproxy -p $P_CONFIG_PROXY -- \ java ${jvmopts} \ -XX:OnOutOfMemoryError="kill -9 %p" $(getJavaOptionsIPV46) \ - -Dproxyconfigsources="${configsources}" -Dmode="${proxymode}" ${userargs} \ + -Dproxyconfigsources="${configsources}" ${userargs} \ -cp $cp com.yahoo.vespa.config.proxy.ProxyServer 19090 echo "Waiting for config proxy to start" diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/CacheTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/CacheTest.java deleted file mode 100644 index ffeb6a02e59..00000000000 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/CacheTest.java +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.config.proxy; - -import com.yahoo.slime.Slime; -import com.yahoo.vespa.config.ConfigCacheKey; -import com.yahoo.vespa.config.ConfigKey; -import com.yahoo.vespa.config.ConfigPayload; -import com.yahoo.vespa.config.RawConfig; -import com.yahoo.vespa.config.protocol.Payload; -import org.junit.Before; - -import java.util.ArrayList; -import java.util.Optional; - -/** - * Helper class for memory and disk cache unit tests - * - * @author hmusum - * @since 5.1.10 - */ -public class CacheTest { - String defName = "foo"; - String configId = "id"; - String namespace = "bar"; - String defMd5 = "a"; - - long generation = 1L; - String defName2 = "baz-quux"; - String namespace2 = "search.config"; - // Test with a config id with / in it - String configId2 = "clients/gateways/gateway/component/com.yahoo.feedhandler.VespaFeedHandlerRemoveLocation"; - String defMd52 = "a2"; - String differentDefMd5 = "09ef"; - String configMd5 = "b"; - ConfigKey<?> configKey = new ConfigKey<>(defName, configId, namespace); - ConfigKey<?> configKey2 = new ConfigKey<>(defName2, configId2, namespace2); - ConfigCacheKey cacheKey; - ConfigCacheKey cacheKeyDifferentMd5; - ConfigCacheKey cacheKey2; - RawConfig config; - RawConfig config2; - RawConfig configDifferentMd5; - RawConfig unknown; - Payload payload; - Payload payload2; - Payload payloadDifferentMd5; - - public CacheTest() { - } - - @Before - public void setup() { - ArrayList<String> defContent = new ArrayList<>(); - defContent.add("bar string"); - - Slime slime = new Slime(); - slime.setString("bar \"value\""); - payload = Payload.from(new ConfigPayload(slime)); - - slime = new Slime(); - slime.setString("bar \"baz\""); - payload2 = Payload.from(new ConfigPayload(slime)); - - slime = new Slime(); - slime.setString("bar \"value2\""); - payloadDifferentMd5 = Payload.from(new ConfigPayload(slime)); - - config = new RawConfig(configKey, defMd5, payload, configMd5, generation, defContent, Optional.empty()); - config2 = new RawConfig(configKey2, defMd52, payload2, configMd5, generation, defContent, Optional.empty()); - unknown = new RawConfig(new ConfigKey<>("unknown", configId, namespace), defMd5, payload, configMd5, generation, defContent, Optional.empty()); - configDifferentMd5 = new RawConfig(configKey, differentDefMd5, payloadDifferentMd5, configMd5, generation, defContent, Optional.empty()); - - cacheKey = new ConfigCacheKey(configKey, config.getDefMd5()); - cacheKey2 = new ConfigCacheKey(configKey2, config2.getDefMd5()); - cacheKeyDifferentMd5 = new ConfigCacheKey(configKey, differentDefMd5); - } -}
\ No newline at end of file diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ClientUpdaterTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ClientUpdaterTest.java index 2b429ad9729..da691981d01 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ClientUpdaterTest.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ClientUpdaterTest.java @@ -37,11 +37,7 @@ public class ClientUpdaterTest { delayedResponses = new DelayedResponses(statistics); mode = new Mode(); memoryCache = new MemoryCache(); - clientUpdater = new ClientUpdater(CacheManager.createTestCacheManager(memoryCache), - rpcServer, - statistics, - delayedResponses, - mode); + clientUpdater = new ClientUpdater(memoryCache, rpcServer, statistics, delayedResponses, mode); } @Test @@ -64,7 +60,7 @@ public class ClientUpdaterTest { assertResponseAndCache(rpcServer, memoryCache, barConfig, 1, 2); - mode = new Mode(Mode.ModeName.MEMORYCACHE.name()); + mode = new Mode(Mode.ModeName.MEMORYCACHE); // Nothing should be returned, so still 1 response assertResponseAndCache(rpcServer, memoryCache, fooConfig, 1, 2); assertThat(statistics.errors(), is(0L)); @@ -73,12 +69,8 @@ public class ClientUpdaterTest { @Test public void memoryCacheMode() { final RawConfig fooConfig = ProxyServerTest.fooConfig; - mode = new Mode(Mode.ModeName.MEMORYCACHE.name()); - clientUpdater = new ClientUpdater(CacheManager.createTestCacheManager(memoryCache), - rpcServer, - statistics, - delayedResponses, - mode); + mode = new Mode(Mode.ModeName.MEMORYCACHE); + clientUpdater = new ClientUpdater(memoryCache, rpcServer, statistics,delayedResponses, mode); memoryCache.clear(); assertThat(rpcServer.responses, is(0L)); diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java index 0b5df24b09e..8e96d32329b 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java @@ -72,7 +72,7 @@ public class ConfigProxyRpcServerTest { assertThat(ret.length, is(0)); final RawConfig config = ProxyServerTest.fooConfig; - proxyServer.getCacheManager().putInCache(config); + proxyServer.getMemoryCache().put(config); req = new Request("listCachedConfig"); rpcServer.listCachedConfig(req); assertFalse(req.errorMessage(), req.isError()); @@ -99,7 +99,7 @@ public class ConfigProxyRpcServerTest { assertThat(ret.length, is(0)); final RawConfig config = ProxyServerTest.fooConfig; - proxyServer.getCacheManager().putInCache(config); + proxyServer.getMemoryCache().put(config); req = new Request("listCachedConfigFull"); rpcServer.listCachedConfigFull(req); assertFalse(req.errorMessage(), req.isError()); diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/CheckDelayedResponsesTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java index a14f0a5954a..f063427d808 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/CheckDelayedResponsesTest.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java @@ -12,7 +12,7 @@ import static org.junit.Assert.assertThat; /** * @author hmusum */ -public class CheckDelayedResponsesTest { +public class DelayedResponseHandlerTest { private final MapBackedConfigSource source = new MapBackedConfigSource(UpstreamConfigSubscriberTest.MockClientUpdater.create()); @@ -33,11 +33,11 @@ public class CheckDelayedResponsesTest { final MockRpcServer mockRpcServer = new MockRpcServer(); final MemoryCache memoryCache = new MemoryCache(); memoryCache.put(ProxyServerTest.fooConfig); - final CheckDelayedResponses checkDelayedResponses = new CheckDelayedResponses(delayedResponses, memoryCache, mockRpcServer); + final DelayedResponseHandler delayedResponseHandler = new DelayedResponseHandler(delayedResponses, memoryCache, mockRpcServer); delayedResponses.add(new DelayedResponse(tester.createRequest(ProxyServerTest.fooConfig, 0))); delayedResponses.add(new DelayedResponse(tester.createRequest(ProxyServerTest.fooConfig, 1200000))); // should not be returned yet delayedResponses.add(new DelayedResponse(tester.createRequest(ProxyServerTest.errorConfig, 0))); // will not give a config when resolving - checkDelayedResponses.checkDelayedResponses(); + delayedResponseHandler.checkDelayedResponses(); assertThat(mockRpcServer.responses, is(1L)); } diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java index 9ab96cc3535..2da0f629b6f 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MemoryCacheTest.java @@ -1,9 +1,18 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.proxy; +import com.yahoo.slime.Slime; +import com.yahoo.vespa.config.ConfigCacheKey; +import com.yahoo.vespa.config.ConfigKey; +import com.yahoo.vespa.config.ConfigPayload; import com.yahoo.vespa.config.RawConfig; +import com.yahoo.vespa.config.protocol.Payload; +import org.junit.Before; import org.junit.Test; +import java.util.ArrayList; +import java.util.Optional; + import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.*; @@ -11,7 +20,57 @@ import static org.junit.Assert.*; * @author hmusum * @since 5.1.9 */ -public class MemoryCacheTest extends CacheTest { +public class MemoryCacheTest { + private String defName = "foo"; + private String configId = "id"; + private String namespace = "bar"; + private static final String defMd5 = "a"; + + private long generation = 1L; + private String defName2 = "baz-quux"; + private String namespace2 = "search.config"; + // Test with a config id with / in it + private String configId2 = "clients/gateways/gateway/component/com.yahoo.feedhandler.VespaFeedHandlerRemoveLocation"; + private static final String defMd52 = "a2"; + private static final String differentDefMd5 = "09ef"; + private static final String configMd5 = "b"; + private ConfigKey<?> configKey = new ConfigKey<>(defName, configId, namespace); + private ConfigKey<?> configKey2 = new ConfigKey<>(defName2, configId2, namespace2); + private ConfigCacheKey cacheKey; + private ConfigCacheKey cacheKeyDifferentMd5; + private ConfigCacheKey cacheKey2; + private RawConfig config; + private RawConfig config2; + private RawConfig configDifferentMd5; + private Payload payload; + private Payload payload2; + private Payload payloadDifferentMd5; + + @Before + public void setup() { + ArrayList<String> defContent = new ArrayList<>(); + defContent.add("bar string"); + + Slime slime = new Slime(); + slime.setString("bar \"value\""); + payload = Payload.from(new ConfigPayload(slime)); + + slime = new Slime(); + slime.setString("bar \"baz\""); + payload2 = Payload.from(new ConfigPayload(slime)); + + slime = new Slime(); + slime.setString("bar \"value2\""); + payloadDifferentMd5 = Payload.from(new ConfigPayload(slime)); + + config = new RawConfig(configKey, defMd5, payload, configMd5, generation, defContent, Optional.empty()); + config2 = new RawConfig(configKey2, defMd52, payload2, configMd5, generation, defContent, Optional.empty()); + configDifferentMd5 = new RawConfig(configKey, differentDefMd5, payloadDifferentMd5, configMd5, generation, defContent, Optional.empty()); + + cacheKey = new ConfigCacheKey(configKey, config.getDefMd5()); + cacheKey2 = new ConfigCacheKey(configKey2, config2.getDefMd5()); + cacheKeyDifferentMd5 = new ConfigCacheKey(configKey, differentDefMd5); + } @Test public void basic() { diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java index 1c2195cec51..bdeedba7b78 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java @@ -28,7 +28,7 @@ public class ProxyServerTest { static final RawConfig fooConfig = Helper.fooConfigV2; // errorConfig based on fooConfig - static final ConfigKey<?> errorConfigKey = new ConfigKey<>("error", fooConfig.getConfigId(), fooConfig.getNamespace()); + private static final ConfigKey<?> errorConfigKey = new ConfigKey<>("error", fooConfig.getConfigId(), fooConfig.getNamespace()); static final RawConfig errorConfig = new RawConfig(errorConfigKey, fooConfig.getDefMd5(), fooConfig.getPayload(), fooConfig.getConfigMd5(), fooConfig.getGeneration(), ErrorCode.UNKNOWN_DEFINITION, fooConfig.getDefContent(), Optional.empty()); @@ -52,7 +52,7 @@ public class ProxyServerTest { @Test public void basic() { assertTrue(proxy.getMode().isDefault()); - assertThat(proxy.getCacheManager().getMemoryCache().size(), is(0)); + assertThat(proxy.getMemoryCache().size(), is(0)); assertThat(proxy.getTimingValues(), is(ProxyServer.defaultTimingValues())); } @@ -109,19 +109,19 @@ public class ProxyServerTest { @Test public void testGetConfigAndCaching() { ConfigTester tester = new ConfigTester(); - final CacheManager cacheManager = proxy.getCacheManager(); - assertEquals(0, cacheManager.getCacheSize()); + final MemoryCache memoryCache = proxy.getMemoryCache(); + assertEquals(0, memoryCache.size()); RawConfig res = proxy.resolveConfig(tester.createRequest(fooConfig)); assertNotNull(res); assertThat(res.getPayload().toString(), is(Helper.fooConfigPayload.toString())); - assertEquals(1, cacheManager.getCacheSize()); - assertThat(cacheManager.getMemoryCache().get(new ConfigCacheKey(fooConfig.getKey(), fooConfig.getDefMd5())), is(res)); + assertEquals(1, memoryCache.size()); + assertThat(memoryCache.get(new ConfigCacheKey(fooConfig.getKey(), fooConfig.getDefMd5())), is(res)); // Trying same config again JRTServerConfigRequest newRequestBasedOnResponse = tester.createRequest(res); RawConfig res2 = proxy.resolveConfig(newRequestBasedOnResponse); assertFalse(ProxyServer.configOrGenerationHasChanged(res2, newRequestBasedOnResponse)); - assertEquals(1, cacheManager.getCacheSize()); + assertEquals(1, memoryCache.size()); } /** @@ -134,14 +134,14 @@ public class ProxyServerTest { // Simulate an error response source.put(fooConfig.getKey(), createConfigWithNextConfigGeneration(fooConfig, ErrorCode.INTERNAL_ERROR)); - final CacheManager cacheManager = proxy.getCacheManager(); - assertEquals(0, cacheManager.getCacheSize()); + final MemoryCache cacheManager = proxy.getMemoryCache(); + assertEquals(0, cacheManager.size()); RawConfig res = proxy.resolveConfig(tester.createRequest(fooConfig)); assertNotNull(res); assertNotNull(res.getPayload()); assertTrue(res.isError()); - assertEquals(0, cacheManager.getCacheSize()); + assertEquals(0, cacheManager.size()); // Put a version of the same config into backend without error and see that it now works (i.e. we are // not getting a cached response (of the error in the previous request) @@ -152,19 +152,18 @@ public class ProxyServerTest { assertNotNull(res); assertNotNull(res.getPayload().getData()); assertThat(res.getPayload().toString(), is(Helper.fooConfigPayload.toString())); - assertEquals(1, cacheManager.getCacheSize()); + assertEquals(1, cacheManager.size()); JRTServerConfigRequest newRequestBasedOnResponse = tester.createRequest(res); RawConfig res2 = proxy.resolveConfig(newRequestBasedOnResponse); assertFalse(ProxyServer.configOrGenerationHasChanged(res2, newRequestBasedOnResponse)); - assertEquals(1, cacheManager.getCacheSize()); + assertEquals(1, cacheManager.size()); } @Test public void testReadingSystemProperties() { - ProxyServer.Properties properties = ProxyServer.getSystemProperties(); + ProxyServer.Properties properties = ProxyServer.getSystemProperties(); assertThat(properties.eventInterval, is(ConfigProxyStatistics.defaultEventInterval)); - assertThat(properties.mode, is(Mode.ModeName.DEFAULT.name())); assertThat(properties.configSources.length, is(1)); assertThat(properties.configSources[0], is(ProxyServer.DEFAULT_PROXY_CONFIG_SOURCES)); } diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/UpstreamConfigSubscriberTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/UpstreamConfigSubscriberTest.java index 15c7216bb70..27ee550d956 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/UpstreamConfigSubscriberTest.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/UpstreamConfigSubscriberTest.java @@ -30,12 +30,12 @@ public class UpstreamConfigSubscriberTest { private MapBackedConfigSource sourceResponses; private MockClientUpdater clientUpdater; private MockConnection mockConnection; - static RawConfig fooConfig; - static RawConfig errorConfig; - static ConfigKey<?> errorConfigKey; - static Payload fooPayload; - static Payload errorPayload; - long generation = 1; + private static RawConfig fooConfig; + private static RawConfig errorConfig; + private static ConfigKey<?> errorConfigKey; + private static Payload fooPayload; + private static Payload errorPayload; + private long generation = 1; @Rule @@ -148,11 +148,7 @@ public class UpstreamConfigSubscriberTest { private RawConfig lastConfig; private MockClientUpdater(ConfigProxyStatistics statistics, Mode mode) { - super(CacheManager.createTestCacheManager(), - new MockRpcServer(), - statistics, - new DelayedResponses(statistics), - mode); + super(new MemoryCache(), new MockRpcServer(), statistics, new DelayedResponses(statistics), mode); } public static MockClientUpdater create() { |