summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-12-13 14:20:26 +0100
committerHarald Musum <musum@oath.com>2018-12-13 14:20:26 +0100
commit32ab659d7979cd1f61115130a3ea7d471abace9f (patch)
tree691667f9db4cc2f64324009308da758c59ec9cf9 /configserver
parent11f29b067df1a074e0e9c5ebeae9cf9201cd5901 (diff)
Inject FlagSource through component registry
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java9
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java10
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java5
6 files changed, 30 insertions, 5 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java b/configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java
index 5987532c004..ad12c5c9e24 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java
@@ -13,6 +13,7 @@ import com.yahoo.vespa.config.server.session.SessionPreparer;
import com.yahoo.vespa.config.server.tenant.TenantListener;
import com.yahoo.vespa.config.server.zookeeper.ConfigCurator;
import com.yahoo.vespa.curator.Curator;
+import com.yahoo.vespa.flags.FlagSource;
import java.time.Clock;
import java.util.Optional;
@@ -40,5 +41,6 @@ public interface GlobalComponentRegistry {
Zone getZone();
Clock getClock();
ConfigServerDB getConfigServerDB();
+ FlagSource getFlagSource();
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java b/configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java
index 587eb5857bf..e9ebe954799 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java
@@ -16,6 +16,7 @@ import com.yahoo.vespa.config.server.session.SessionPreparer;
import com.yahoo.vespa.config.server.tenant.TenantListener;
import com.yahoo.vespa.config.server.zookeeper.ConfigCurator;
import com.yahoo.vespa.curator.Curator;
+import com.yahoo.vespa.flags.FlagSource;
import java.time.Clock;
import java.util.Optional;
@@ -41,6 +42,7 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry
private final Optional<Provisioner> hostProvisioner;
private final Zone zone;
private final ConfigServerDB configServerDB;
+ private final FlagSource flagSource;
@SuppressWarnings("WeakerAccess")
@Inject
@@ -57,7 +59,8 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry
HostRegistries hostRegistries,
HostProvisionerProvider hostProvisionerProvider,
Zone zone,
- ConfigServerDB configServerDB) {
+ ConfigServerDB configServerDB,
+ FlagSource flagSource) {
this.curator = curator;
this.configCurator = configCurator;
this.metrics = metrics;
@@ -72,6 +75,7 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry
this.hostProvisioner = hostProvisionerProvider.getHostProvisioner();
this.zone = zone;
this.configServerDB = configServerDB;
+ this.flagSource = flagSource;
}
@Override
@@ -114,4 +118,7 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry
@Override
public ConfigServerDB getConfigServerDB() { return configServerDB; }
+
+ @Override
+ public FlagSource getFlagSource() { return flagSource; }
}
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 f72ab1b07ac..032bb88eaaa 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
@@ -25,6 +25,7 @@ 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 com.yahoo.vespa.flags.FlagSource;
import java.util.Objects;
import java.util.Set;
@@ -46,9 +47,15 @@ public class Application implements ModelResult {
private final ServerCache cache;
private final MetricUpdater metricUpdater;
private final ApplicationId app;
+ private final FeatureFlag useConfigServerCache;
public Application(Model model, ServerCache cache, long appGeneration, boolean internalRedeploy,
Version vespaVersion, MetricUpdater metricUpdater, ApplicationId app) {
+ this(model, cache, appGeneration, internalRedeploy, vespaVersion, metricUpdater, app, new FileFlagSource());
+ }
+
+ public Application(Model model, ServerCache cache, long appGeneration, boolean internalRedeploy,
+ Version vespaVersion, MetricUpdater metricUpdater, ApplicationId app, FlagSource flagSource) {
Objects.requireNonNull(model, "The model cannot be null");
this.model = model;
this.cache = cache;
@@ -57,6 +64,7 @@ public class Application implements ModelResult {
this.vespaVersion = vespaVersion;
this.metricUpdater = metricUpdater;
this.app = app;
+ this.useConfigServerCache = new FeatureFlag("use-config-server-cache", true, flagSource);
}
/**
@@ -150,7 +158,7 @@ public class Application implements ModelResult {
if (request.noCache())
return false;
else
- return new FeatureFlag("use-config-server-cache", true, new FileFlagSource()).value();
+ return useConfigServerCache.value();
}
private boolean logDebug() {
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java
index 89c5cedb05c..103eec14b36 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java
@@ -27,6 +27,7 @@ import com.yahoo.vespa.config.server.monitoring.Metrics;
import com.yahoo.vespa.config.server.session.SessionZooKeeperClient;
import com.yahoo.vespa.config.server.session.SilentDeployLogger;
import com.yahoo.vespa.curator.Curator;
+import com.yahoo.vespa.flags.FlagSource;
import java.net.URI;
import java.time.Instant;
@@ -51,6 +52,7 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> {
private final Metrics metrics;
private final Curator curator;
private final DeployLogger logger;
+ private final FlagSource flagSource;
public ActivatedModelsBuilder(TenantName tenant,
long appGeneration,
@@ -68,6 +70,7 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> {
this.metrics = globalComponentRegistry.getMetrics();
this.curator = globalComponentRegistry.getCurator();
this.logger = new SilentDeployLogger();
+ this.flagSource = globalComponentRegistry.getFlagSource();
}
@Override
@@ -100,7 +103,8 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> {
applicationPackage.getMetaData().isInternalRedeploy(),
modelFactory.version(),
applicationMetricUpdater,
- applicationId);
+ applicationId,
+ flagSource);
}
private static <T> Optional<T> getForVersionOrLatest(Map<Version, T> map, Version version) {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java
index 324f7c5de00..b2e911c47a4 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java
@@ -18,6 +18,7 @@ import com.yahoo.vespa.config.server.session.*;
import com.yahoo.vespa.curator.mock.MockCurator;
import com.yahoo.vespa.config.server.zookeeper.ConfigCurator;
import com.yahoo.vespa.curator.Curator;
+import com.yahoo.vespa.flags.FileFlagSource;
import com.yahoo.vespa.model.VespaModelFactory;
import org.junit.Before;
import org.junit.Rule;
@@ -74,7 +75,7 @@ public class InjectedGlobalComponentRegistryTest {
globalComponentRegistry =
new InjectedGlobalComponentRegistry(curator, configCurator, metrics, modelFactoryRegistry, sessionPreparer, rpcServer, configserverConfig,
generationCounter, defRepo, permanentApplicationPackage, hostRegistries, hostProvisionerProvider, zone,
- new ConfigServerDB(configserverConfig));
+ new ConfigServerDB(configserverConfig), new FileFlagSource());
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java b/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java
index 2c89678c90f..65c83633bbb 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java
@@ -21,6 +21,8 @@ import com.yahoo.vespa.config.server.tenant.TenantRequestHandlerTest;
import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.mock.MockCurator;
import com.yahoo.vespa.config.server.zookeeper.ConfigCurator;
+import com.yahoo.vespa.flags.FileFlagSource;
+import com.yahoo.vespa.flags.FlagSource;
import com.yahoo.vespa.model.VespaModelFactory;
import java.time.Clock;
@@ -196,7 +198,8 @@ public class TestComponentRegistry implements GlobalComponentRegistry {
public Clock getClock() { return clock;}
@Override
public ConfigServerDB getConfigServerDB() { return configServerDB;}
-
+ @Override
+ public FlagSource getFlagSource() { return new FileFlagSource(); }
public FileDistributionFactory getFileDistributionFactory() { return fileDistributionFactory; }