diff options
author | Harald Musum <musum@oath.com> | 2018-12-13 13:05:58 +0100 |
---|---|---|
committer | Harald Musum <musum@oath.com> | 2018-12-13 13:23:19 +0100 |
commit | 11f29b067df1a074e0e9c5ebeae9cf9201cd5901 (patch) | |
tree | f9dadc18e31e206d654759c374adc841dd197a89 | |
parent | 6e9384c64f0325f45619ba9ac9e057afdf18794e (diff) |
Use feature flag for when to use server cache
-rw-r--r-- | configserver/pom.xml | 6 | ||||
-rw-r--r-- | configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java | 13 |
2 files changed, 17 insertions, 2 deletions
diff --git a/configserver/pom.xml b/configserver/pom.xml index a9cade47446..f932a963d14 100644 --- a/configserver/pom.xml +++ b/configserver/pom.xml @@ -168,6 +168,12 @@ </dependency> <dependency> <groupId>com.yahoo.vespa</groupId> + <artifactId>flags</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>com.yahoo.vespa</groupId> <artifactId>serviceview</artifactId> <version>${project.version}</version> <scope>compile</scope> diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java index 06a4c12fb32..f72ab1b07ac 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java @@ -23,6 +23,8 @@ import com.yahoo.vespa.config.server.UnknownConfigDefinitionException; import com.yahoo.vespa.config.server.modelfactory.ModelResult; import com.yahoo.vespa.config.server.monitoring.MetricUpdater; import com.yahoo.vespa.config.util.ConfigUtils; +import com.yahoo.vespa.flags.FeatureFlag; +import com.yahoo.vespa.flags.FileFlagSource; import java.util.Objects; import java.util.Set; @@ -109,7 +111,7 @@ public class Application implements ModelResult { debug("Resolving config " + cacheKey); } - if ( ! req.noCache()) { + if (useCache(req)) { ConfigResponse config = cache.get(cacheKey); if (config != null) { if (logDebug()) { @@ -136,7 +138,7 @@ public class Application implements ModelResult { ConfigResponse configResponse = responseFactory.createResponse(payload, def.getCNode(), appGeneration, internalRedeploy); metricUpdater.incrementProcTime(System.currentTimeMillis() - start); - if ( ! req.noCache()) { + if (useCache(req)) { cache.put(cacheKey, configResponse, configResponse.getConfigMd5()); metricUpdater.setCacheConfigElems(cache.configElems()); metricUpdater.setCacheChecksumElems(cache.checkSumElems()); @@ -144,6 +146,13 @@ public class Application implements ModelResult { return configResponse; } + private boolean useCache(GetConfigRequest request) { + if (request.noCache()) + return false; + else + return new FeatureFlag("use-config-server-cache", true, new FileFlagSource()).value(); + } + private boolean logDebug() { return log.isLoggable(LogLevel.DEBUG); } |