summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-10-03 22:45:09 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2018-10-03 22:45:09 +0200
commit6520467f1afb87f0f97f87048a17ac1d4c5795da (patch)
treef574923eaa01a270cce4c4b046aa8ad001b3eda6
parent488a0b5e5c69999b15fb47b14ed534cce2276d70 (diff)
Further reduce complicated and magic use of getDeployState callback
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/ApplicationConfigProducerRoot.java5
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/ConfigModel.java4
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/ConfigModelRepo.java4
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java7
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/Host.java4
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java18
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilder.java18
-rwxr-xr-xconfig-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java24
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/ContainerModel.java5
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java3
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/Content.java18
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java35
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java5
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java4
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java7
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java14
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/jersey/xml/RestApiTest.java2
17 files changed, 101 insertions, 76 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/ApplicationConfigProducerRoot.java b/config-model/src/main/java/com/yahoo/config/model/ApplicationConfigProducerRoot.java
index 7a5969585e9..da79e34b3ad 100644
--- a/config-model/src/main/java/com/yahoo/config/model/ApplicationConfigProducerRoot.java
+++ b/config-model/src/main/java/com/yahoo/config/model/ApplicationConfigProducerRoot.java
@@ -2,6 +2,7 @@
package com.yahoo.config.model;
import com.yahoo.cloud.config.*;
+import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.Version;
import com.yahoo.vespa.config.content.LoadTypeConfig;
@@ -125,11 +126,11 @@ public class ApplicationConfigProducerRoot extends AbstractConfigProducer<Abstra
}
// TODO: Do this as another config model depending on the other models
- public void setupRouting(VespaModel vespaModel, ConfigModelRepo configModels) {
+ public void setupRouting(DeployState deployState, VespaModel vespaModel, ConfigModelRepo configModels) {
if (admin != null) {
Routing routing = configModels.getRouting();
if (routing == null) {
- routing = new Routing(ConfigModelContext.create(vespaModel, configModels, this, "routing"));
+ routing = new Routing(ConfigModelContext.create(deployState, vespaModel, configModels, this, "routing"));
configModels.add(routing);
}
this.routing = routing;
diff --git a/config-model/src/main/java/com/yahoo/config/model/ConfigModel.java b/config-model/src/main/java/com/yahoo/config/model/ConfigModel.java
index 385cd883da4..b4a5a865b9e 100644
--- a/config-model/src/main/java/com/yahoo/config/model/ConfigModel.java
+++ b/config-model/src/main/java/com/yahoo/config/model/ConfigModel.java
@@ -1,6 +1,8 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.model;
+import com.yahoo.config.model.deploy.DeployState;
+
/**
* A config model is an abstract representation of a subsystem, which is used
* by the builder of that subsystem to derive a config producer tree for the subsystem, and by other
@@ -52,7 +54,7 @@ public abstract class ConfigModel {
*
* @param configModelRepo The ConfigModelRepo of the system model
*/
- public void prepare(ConfigModelRepo configModelRepo) { return; }
+ public void prepare(ConfigModelRepo configModelRepo, DeployState deployState) { return; }
/**
* <p>Returns whether this model must be maintained in memory for serving config requests.
diff --git a/config-model/src/main/java/com/yahoo/config/model/ConfigModelRepo.java b/config-model/src/main/java/com/yahoo/config/model/ConfigModelRepo.java
index 60089f04572..f14a1ea3c2c 100644
--- a/config-model/src/main/java/com/yahoo/config/model/ConfigModelRepo.java
+++ b/config-model/src/main/java/com/yahoo/config/model/ConfigModelRepo.java
@@ -215,9 +215,9 @@ public class ConfigModelRepo implements ConfigModelRepoAdder, Serializable, Iter
* Initialize part 2.:
* Prepare all config models for starting. Must be called after plugins are loaded and frozen.
*/
- public void prepareConfigModels() {
+ public void prepareConfigModels(DeployState deployState) {
for (ConfigModel model : configModels) {
- model.prepare(ConfigModelRepo.this);
+ model.prepare(this, deployState);
}
}
diff --git a/config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java b/config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java
index 8fff69e11a6..113262d0734 100644
--- a/config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java
+++ b/config-model/src/main/java/com/yahoo/config/model/admin/AdminModel.java
@@ -9,6 +9,7 @@ import com.yahoo.config.model.ApplicationConfigProducerRoot;
import com.yahoo.config.model.deploy.DeployProperties;
import com.yahoo.config.model.builder.xml.ConfigModelBuilder;
import com.yahoo.config.model.builder.xml.ConfigModelId;
+import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.model.admin.Admin;
import com.yahoo.vespa.model.builder.xml.dom.DomAdminV2Builder;
@@ -44,12 +45,12 @@ public class AdminModel extends ConfigModel {
private Collection<ContainerModel> getContainerModels() { return containerModels; }
@Override
- public void prepare(ConfigModelRepo configModelRepo) {
+ public void prepare(ConfigModelRepo configModelRepo, DeployState deployState) {
verifyClusterControllersOnlyDefinedForContent(configModelRepo);
if (admin == null) return;
if (admin.getClusterControllers() != null)
- admin.getClusterControllers().prepare();
- admin.getLogServerContainerCluster().ifPresent(ContainerCluster::prepare);
+ admin.getClusterControllers().prepare(deployState);
+ admin.getLogServerContainerCluster().ifPresent((ContainerCluster cc) -> cc.prepare(deployState));
}
private void verifyClusterControllersOnlyDefinedForContent(ConfigModelRepo configModelRepo) {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/Host.java b/config-model/src/main/java/com/yahoo/vespa/model/Host.java
index 624a9fd4da7..ac56875270d 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/Host.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/Host.java
@@ -37,10 +37,10 @@ public final class Host extends AbstractConfigProducer<AbstractConfigProducer<?>
this.runsConfigServer = runsConfigServer;
this.hostname = hostname;
if (parent instanceof HostSystem)
- checkName((HostSystem) parent, hostname);
+ checkName(hostname);
}
- private void checkName(HostSystem parent, String hostname) {
+ private void checkName(String hostname) {
// Give a warning if the host does not exist
try {
Object address = java.net.InetAddress.getByName(hostname);
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java
index 9bd3a359c1a..a8e55e99e3b 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java
@@ -164,8 +164,6 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri
configModelRegistry = new VespaConfigModelRegistry(configModelRegistry);
VespaModelBuilder builder = new VespaDomBuilder();
this.applicationPackage = deployState.getApplicationPackage();
- this.deployState = deployState;
- this.deployLogger = deployState.getDeployLogger();
root = builder.getRoot(VespaModel.ROOT_CONFIGID, deployState, this);
HostSystem hostSystem = root.getHostSystem();
@@ -179,25 +177,25 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri
deployState.getImportedModels());
if (complete) { // create a a completed, frozen model
+ this.deployLogger = deployState.getDeployLogger();
+ this.deployState = deployState;
configModelRepo.readConfigModels(deployState, this, builder, root, configModelRegistry);
+ this.deployState = null;
addServiceClusters(deployState.getApplicationPackage(), builder);
this.allocatedHosts = AllocatedHosts.withHosts(hostSystem.getHostSpecs()); // must happen after the two lines above
-
- setupRouting();
+ setupRouting(deployState);
this.fileDistributor = root.getFileDistributionConfigProducer().getFileDistributor();
getAdmin().addPerHostServices(hostSystem.getHosts(), deployState);
+ this.deployLogger = null;
freezeModelTopology();
root.prepare(configModelRepo);
- configModelRepo.prepareConfigModels();
- this.deployState = null;
+ configModelRepo.prepareConfigModels(deployState);
validateWrapExceptions();
- this.deployLogger = null;
}
else { // create a model with no services instantiated and the given file distributor
this.allocatedHosts = AllocatedHosts.withHosts(hostSystem.getHostSpecs());
this.fileDistributor = fileDistributor;
}
- this.deployState = null;
}
/** Returns the application package owning this */
@@ -259,8 +257,8 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri
/** Returns the global rank profiles as a rank profile list */
public RankProfileList rankProfileList() { return rankProfileList; }
- private void setupRouting() {
- root.setupRouting(this, configModelRepo);
+ private void setupRouting(DeployState deployState) {
+ root.setupRouting(deployState, this, configModelRepo);
}
/** Returns the one and only HostSystem of this VespaModel */
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilder.java
index 5b7d1fe010c..0e29c69c53e 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/VespaDomBuilder.java
@@ -95,7 +95,7 @@ public class VespaDomBuilder extends VespaModelBuilder {
public ApplicationConfigProducerRoot getRoot(String name, DeployState deployState, AbstractConfigProducer parent) {
try {
return new DomRootBuilder(name, deployState).
- build(parent, XmlHelper.getDocument(deployState.getApplicationPackage().getServices()).getDocumentElement());
+ build(deployState, parent, XmlHelper.getDocument(deployState.getApplicationPackage().getServices()).getDocumentElement());
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
@@ -120,12 +120,16 @@ public class VespaDomBuilder extends VespaModelBuilder {
// TODO: find good way to provide access to app package
public final T build(AbstractConfigProducer ancestor, Element producerSpec) {
+ return build(ancestor.getRoot().getDeployState(), ancestor, producerSpec);
+ }
+
+ public final T build(DeployState deployState, AbstractConfigProducer ancestor, Element producerSpec) {
T t = doBuild(ancestor, producerSpec);
if (t instanceof AbstractService) {
- initializeService((AbstractService)t, ancestor.getRoot(), ancestor.getHostSystem(), producerSpec);
+ initializeService((AbstractService)t, deployState, ancestor.getHostSystem(), producerSpec);
} else {
- initializeProducer(t, ancestor.getRoot(), producerSpec);
+ initializeProducer(t, deployState, producerSpec);
}
return t;
@@ -134,9 +138,9 @@ public class VespaDomBuilder extends VespaModelBuilder {
protected abstract T doBuild(AbstractConfigProducer ancestor, Element producerSpec);
private void initializeProducer(AbstractConfigProducer child,
- AbstractConfigProducerRoot ancestorRoot,
+ DeployState deployState,
Element producerSpec) {
- UserConfigRepo userConfigs = UserConfigBuilder.build(producerSpec, ancestorRoot.getDeployState(), ancestorRoot.deployLogger());
+ UserConfigRepo userConfigs = UserConfigBuilder.build(producerSpec, deployState, deployState.getDeployLogger());
// TODO: must be made to work:
//userConfigs.applyWarnings(child);
log.log(LogLevel.DEBUG, "Adding user configs " + userConfigs + " for " + producerSpec);
@@ -144,10 +148,10 @@ public class VespaDomBuilder extends VespaModelBuilder {
}
private void initializeService(AbstractService t,
- AbstractConfigProducerRoot ancestorRoot,
+ DeployState deployState,
HostSystem hostSystem,
Element producerSpec) {
- initializeProducer(t, ancestorRoot, producerSpec);
+ initializeProducer(t, deployState, producerSpec);
if (producerSpec != null) {
if (producerSpec.hasAttribute(JVMARGS_ATTRIB_NAME)) {
t.appendJvmArgs(producerSpec.getAttribute(JVMARGS_ATTRIB_NAME));
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java
index 19fb2c61e10..18c5bfdcd60 100755
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java
@@ -200,16 +200,20 @@ public final class ContainerCluster
public ContainerCluster(AbstractConfigProducer<?> parent, String subId, String name) {
this(parent, subId, name, new AcceptAllVerifier());
}
+ public ContainerCluster(AbstractConfigProducer<?> parent, String subId, String name, DeployState deployState) {
+ this(parent, subId, name, new AcceptAllVerifier(), deployState);
+ }
+
+ public ContainerCluster(AbstractConfigProducer<?> parent, String subId, String name, ContainerClusterVerifier verifier) {
+ this(parent, subId, name, verifier, deployStateFrom(parent));
+ }
/** Creates a container cluster */
- public ContainerCluster(AbstractConfigProducer<?> parent,
- String subId,
- String name,
- ContainerClusterVerifier verifier) {
+ public ContainerCluster(AbstractConfigProducer<?> parent, String subId, String name,
+ ContainerClusterVerifier verifier, DeployState deployState) {
super(parent, subId);
this.clusterVerifier = verifier;
this.name = name;
- DeployState deployState = deployStateFrom(parent);
this.isHostedVespa = stateIsHosted(deployState);
this.zone = (deployState != null) ? deployState.zone() : Zone.defaultZone();
componentGroup = new ComponentGroup<>(this, "component");
@@ -338,18 +342,18 @@ public final class ContainerCluster
addComponent(new SimpleComponent(className));
}
- public void prepare() {
- addAndSendApplicationBundles(getRoot().getDeployState());
+ public void prepare(DeployState deployState) {
+ addAndSendApplicationBundles(deployState);
if (modelEvaluation != null)
modelEvaluation.prepare(containers);
sendUserConfiguredFiles();
- setApplicationMetaData();
+ setApplicationMetaData(deployState);
for (RestApi restApi : restApiGroup.getComponents())
restApi.prepare();
}
- private void setApplicationMetaData() {
- applicationMetaData = getRoot().getDeployState().getApplicationPackage().getMetaData();
+ private void setApplicationMetaData(DeployState deployState) {
+ applicationMetaData = deployState.getApplicationPackage().getMetaData();
}
public void addMbusServer(ComponentId chainId) {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerModel.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerModel.java
index 83d749067b4..cefccca5ec8 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerModel.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerModel.java
@@ -4,6 +4,7 @@ package com.yahoo.vespa.model.container;
import com.yahoo.config.model.ConfigModel;
import com.yahoo.config.model.ConfigModelContext;
import com.yahoo.config.model.ConfigModelRepo;
+import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.vespa.model.content.Content;
import com.yahoo.vespa.model.search.AbstractSearchCluster;
@@ -35,9 +36,9 @@ public class ContainerModel extends ConfigModel {
public ContainerCluster getCluster() { return containerCluster; }
@Override
- public void prepare(ConfigModelRepo plugins) {
+ public void prepare(ConfigModelRepo plugins, DeployState deployState) {
assert (getCluster() != null) : "Null container cluster!";
- getCluster().prepare();
+ getCluster().prepare(deployState);
}
@Override
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
index 2d3f3036ccc..570ab06f4fa 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
@@ -149,7 +149,8 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
return new VespaDomBuilder.DomConfigProducerBuilder<ContainerCluster>() {
@Override
protected ContainerCluster doBuild(AbstractConfigProducer ancestor, Element producerSpec) {
- return new ContainerCluster(ancestor, modelContext.getProducerId(), modelContext.getProducerId());
+ return new ContainerCluster(ancestor, modelContext.getProducerId(),
+ modelContext.getProducerId(), modelContext.getDeployState());
}
}.build(modelContext.getParentProducer(), spec);
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java b/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java
index ec68243ec9d..d268089e9c4 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/Content.java
@@ -12,10 +12,12 @@ import com.yahoo.config.model.ConfigModelRepo;
import com.yahoo.config.model.admin.AdminModel;
import com.yahoo.config.model.builder.xml.ConfigModelBuilder;
import com.yahoo.config.model.builder.xml.ConfigModelId;
+import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.log.LogLevel;
-import com.yahoo.searchdefinition.derived.RankProfileList;
-import com.yahoo.vespa.model.*;
+import com.yahoo.vespa.model.AbstractService;
+import com.yahoo.vespa.model.HostResource;
+import com.yahoo.vespa.model.SimpleConfigProducer;
import com.yahoo.vespa.model.admin.Admin;
import com.yahoo.vespa.model.container.Container;
import com.yahoo.vespa.model.container.ContainerCluster;
@@ -31,7 +33,13 @@ import com.yahoo.vespa.model.search.IndexingDocprocChain;
import com.yahoo.vespa.model.search.SearchNode;
import org.w3c.dom.Element;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
import java.util.logging.Logger;
/**
@@ -158,7 +166,7 @@ public class Content extends ConfigModel {
}
@Override
- public void prepare(ConfigModelRepo models) {
+ public void prepare(ConfigModelRepo models, DeployState deployState) {
if (cluster.getRootGroup().useCpuSocketAffinity()) {
setCpuSocketAffinity();
}
@@ -192,7 +200,7 @@ public class Content extends ConfigModel {
s.setVespaMallocDebugStackTrace(cluster.getRootGroup().getVespaMallocDebugStackTrace().get());
}
}
- cluster.prepare();
+ cluster.prepare(deployState);
}
private void setCpuSocketAffinity() {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java
index cc392c24cf1..708c4930de1 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java
@@ -67,9 +67,10 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot
ModelElement clusterElem = new ModelElement(producerSpec);
String clusterName = ContentCluster.getClusterName(clusterElem);
Boolean flushOnShutdownElem = clusterElem.childAsBoolean("engine.proton.flush-on-shutdown");
+ DeployState deployState = AbstractConfigProducer.deployStateFrom(ancestor);
ContentSearchCluster search = new ContentSearchCluster(ancestor, clusterName, documentDefinitions, globallyDistributedDocuments,
- getFlushOnShutdown(flushOnShutdownElem, AbstractConfigProducer.deployStateFrom(ancestor)));
+ getFlushOnShutdown(flushOnShutdownElem, deployState));
ModelElement tuning = clusterElem.getChildByPath("engine.proton.tuning");
if (tuning != null) {
@@ -80,8 +81,8 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot
search.setResourceLimits(DomResourceLimitsBuilder.build(protonElem));
}
- buildAllStreamingSearchClusters(clusterElem, clusterName, search);
- buildIndexedSearchCluster(clusterElem, clusterName, search);
+ buildAllStreamingSearchClusters(deployState, clusterElem, clusterName, search);
+ buildIndexedSearchCluster(deployState, clusterElem, clusterName, search);
return search;
}
@@ -96,7 +97,7 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot
return clusterElem.childAsDouble("engine.proton.query-timeout");
}
- private void buildAllStreamingSearchClusters(ModelElement clusterElem, String clusterName, ContentSearchCluster search) {
+ private void buildAllStreamingSearchClusters(DeployState deployState, ModelElement clusterElem, String clusterName, ContentSearchCluster search) {
ModelElement docElem = clusterElem.getChild("documents");
if (docElem == null) {
@@ -106,20 +107,20 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot
for (ModelElement docType : docElem.subElements("document")) {
String mode = docType.getStringAttribute("mode");
if ("streaming".equals(mode)) {
- buildStreamingSearchCluster(clusterElem, clusterName, search, docType);
+ buildStreamingSearchCluster(deployState, clusterElem, clusterName, search, docType);
}
}
}
- private void buildStreamingSearchCluster(ModelElement clusterElem, String clusterName, ContentSearchCluster search, ModelElement docType) {
+ private void buildStreamingSearchCluster(DeployState deployState, ModelElement clusterElem, String clusterName,
+ ContentSearchCluster search, ModelElement docType) {
String docTypeName = docType.getStringAttribute("type");
StreamingSearchCluster cluster = new StreamingSearchCluster(search, clusterName + "." + docTypeName, 0, docTypeName, clusterName);
- search.addSearchCluster(cluster, getQueryTimeout(clusterElem), Arrays.asList(docType));
+ search.addSearchCluster(deployState, cluster, getQueryTimeout(clusterElem), Arrays.asList(docType));
}
- private void buildIndexedSearchCluster(ModelElement clusterElem,
- String clusterName,
- ContentSearchCluster search) {
+ private void buildIndexedSearchCluster(DeployState deployState, ModelElement clusterElem,
+ String clusterName, ContentSearchCluster search) {
List<ModelElement> indexedDefs = getIndexedSearchDefinitions(clusterElem);
if (!indexedDefs.isEmpty()) {
IndexedSearchCluster isc = new IndexedSearchCluster(search, clusterName, 0);
@@ -130,7 +131,7 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot
isc.setVisibilityDelay(visibilityDelay);
}
- search.addSearchCluster(isc, getQueryTimeout(clusterElem), indexedDefs);
+ search.addSearchCluster(deployState, isc, getQueryTimeout(clusterElem), indexedDefs);
}
}
@@ -164,29 +165,29 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot
this.flushOnShutdown = flushOnShutdown;
}
- void addSearchCluster(SearchCluster cluster, Double queryTimeout, List<ModelElement> documentDefs) {
- addSearchDefinitions(documentDefs, cluster);
+ void addSearchCluster(DeployState deployState, SearchCluster cluster, Double queryTimeout, List<ModelElement> documentDefs) {
+ addSearchDefinitions(deployState, documentDefs, cluster);
if (queryTimeout != null) {
cluster.setQueryTimeout(queryTimeout);
}
cluster.defaultDocumentsConfig();
- cluster.deriveSearchDefinitions();
+ cluster.deriveSearchDefinitions(deployState);
addCluster(cluster);
}
- private void addSearchDefinitions(List<ModelElement> searchDefs, AbstractSearchCluster sc) {
+ private void addSearchDefinitions(DeployState deployState, List<ModelElement> searchDefs, AbstractSearchCluster sc) {
for (ModelElement e : searchDefs) {
SearchDefinitionXMLHandler searchDefinitionXMLHandler = new SearchDefinitionXMLHandler(e);
SearchDefinition searchDefinition =
- searchDefinitionXMLHandler.getResponsibleSearchDefinition(sc.getRoot().getDeployState().getSearchDefinitions());
+ searchDefinitionXMLHandler.getResponsibleSearchDefinition(deployState.getSearchDefinitions());
if (searchDefinition == null)
throw new RuntimeException("Search definition parsing error or file does not exist: '" +
searchDefinitionXMLHandler.getName() + "'");
// TODO: remove explicit building of user configs when the complete content model is built using builders.
sc.getLocalSDS().add(new AbstractSearchCluster.SearchDefinitionSpec(searchDefinition,
- UserConfigBuilder.build(e.getXml(), sc.getRoot().getDeployState(), sc.getRoot().deployLogger())));
+ UserConfigBuilder.build(e.getXml(), deployState, sc.getRoot().deployLogger())));
//need to get the document names from this sdfile
sc.addDocumentNames(searchDefinition);
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
index f15ba547894..699da07f159 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
@@ -4,6 +4,7 @@ package com.yahoo.vespa.model.content.cluster;
import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
import com.yahoo.config.model.ConfigModelContext;
+import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.producer.AbstractConfigProducerRoot;
import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.Environment;
@@ -499,11 +500,11 @@ public class ContentCluster extends AbstractConfigProducer implements
this.zone = zone;
}
- public void prepare() {
+ public void prepare(DeployState deployState) {
search.prepare();
if (clusterControllers != null) {
- clusterControllers.prepare();
+ clusterControllers.prepare(deployState);
}
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java
index 699b5449f1a..e0dffcbc537 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java
@@ -283,11 +283,11 @@ public class IndexedSearchCluster extends SearchCluster
}
}
}
- protected void deriveAllSearchDefinitions(List<SearchDefinitionSpec> localSearches) {
+ @Override
+ protected void deriveAllSearchDefinitions(List<SearchDefinitionSpec> localSearches, DeployState deployState) {
for (SearchDefinitionSpec spec : localSearches) {
com.yahoo.searchdefinition.Search search = spec.getSearchDefinition().getSearch();
if ( ! (search instanceof DocumentOnlySearch)) {
- DeployState deployState = getRoot().getDeployState();
DocumentDatabase db = new DocumentDatabase(this, search.getName(),
new DerivedConfiguration(search, deployLogger(),
deployState.rankProfileRegistry(),
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java
index 096cc2e2ede..34a2fc7ab0e 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.search;
+import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.searchdefinition.derived.RawRankProfile;
import com.yahoo.searchdefinition.derived.SummaryMap;
import com.yahoo.vespa.config.search.RankProfilesConfig;
@@ -48,8 +49,8 @@ public abstract class SearchCluster extends AbstractSearchCluster
* Also stores the document names contained in the search
* definitions.
*/
- public void deriveSearchDefinitions() {
- deriveAllSearchDefinitions(getLocalSDS());
+ public void deriveSearchDefinitions(DeployState deployState) {
+ deriveAllSearchDefinitions(getLocalSDS(), deployState);
}
@Override
@@ -139,7 +140,7 @@ public abstract class SearchCluster extends AbstractSearchCluster
return false;
}
- protected abstract void deriveAllSearchDefinitions(List<SearchDefinitionSpec> localSearches);
+ protected abstract void deriveAllSearchDefinitions(List<SearchDefinitionSpec> localSearches, DeployState deployState);
public abstract void defaultDocumentsConfig();
public abstract DerivedConfiguration getSdConfig();
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java
index 69113da42e2..7f177babf26 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java
@@ -1,6 +1,7 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.search;
+import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
import com.yahoo.searchdefinition.derived.AttributeFields;
@@ -89,21 +90,22 @@ public class StreamingSearchCluster extends SearchCluster implements
}
}
- protected void deriveAllSearchDefinitions(List<SearchDefinitionSpec> local) {
+ @Override
+ protected void deriveAllSearchDefinitions(List<SearchDefinitionSpec> local, DeployState deployState) {
if (local.size() == 1) {
- deriveSingleSearchDefinition(local.get(0).getSearchDefinition().getSearch());
+ deriveSingleSearchDefinition(local.get(0).getSearchDefinition().getSearch(), deployState);
} else if (local.size() > 1){
throw new IllegalStateException("Logical indexes are not supported: Got " + local.size() + " search definitions, expected 1");
}
}
- private void deriveSingleSearchDefinition(com.yahoo.searchdefinition.Search localSearch) {
+ private void deriveSingleSearchDefinition(com.yahoo.searchdefinition.Search localSearch, DeployState deployState) {
if (!localSearch.getName().equals(docTypeName)) {
throw new IllegalStateException("Mismatch between document type name (" + docTypeName + ") and name of search definition (" + localSearch.getName() + ")");
}
this.sdConfig = new DerivedConfiguration(localSearch, deployLogger(),
- getRoot().getDeployState().rankProfileRegistry(),
- getRoot().getDeployState().getQueryProfiles().getRegistry(),
- getRoot().getDeployState().getImportedModels());
+ deployState.rankProfileRegistry(),
+ deployState.getQueryProfiles().getRegistry(),
+ deployState.getImportedModels());
}
@Override
public DerivedConfiguration getSdConfig() {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/jersey/xml/RestApiTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/jersey/xml/RestApiTest.java
index 503b38b79b4..e954e6343de 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/jersey/xml/RestApiTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/jersey/xml/RestApiTest.java
@@ -55,7 +55,7 @@ public class RestApiTest extends ContainerModelBuilderTestBase {
public void setup() throws Exception {
createModel(root, restApiXml);
root.validate();
- getContainerCluster(CLUSTER_ID).prepare();
+ getContainerCluster(CLUSTER_ID).prepare(root.getDeployState());
restApi = getContainerCluster(CLUSTER_ID).getRestApiMap().values().iterator().next();
servlet = restApi.getJersey2Servlet();
context = restApi.getContext();