summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-05-11 23:49:45 +0200
committerGitHub <noreply@github.com>2022-05-11 23:49:45 +0200
commitcd75d7bd21d5e5d084c17d2831c43a14dbff8efa (patch)
treeed0ef6db7f9b348da7279dfb93234f19ec6d73e5
parentf055594f402631c216241a123144bbe171c61e4b (diff)
Revert "Pass DeployState"
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java22
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java45
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java37
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/VespaModel.java6
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java8
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java8
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java16
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileRegistry.java24
8 files changed, 89 insertions, 77 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java
index 74d92bcfd02..9eef1dc2447 100644
--- a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java
+++ b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java
@@ -28,7 +28,6 @@ import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.config.provision.DockerImage;
import com.yahoo.config.provision.Zone;
import com.yahoo.io.IOUtils;
-import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.Application;
import com.yahoo.searchdefinition.RankProfileRegistry;
import com.yahoo.searchdefinition.Schema;
@@ -335,8 +334,6 @@ public class DeployState implements ConfigDefinitionStore {
private boolean accessLoggingEnabledByDefault = true;
private Optional<DockerImage> wantedDockerImageRepo = Optional.empty();
private Reindexing reindexing = null;
- private RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
- private QueryProfiles queryProfiles = null;
public Builder() {}
@@ -434,21 +431,6 @@ public class DeployState implements ConfigDefinitionStore {
return this;
}
- public Builder rankProfileRegistry(RankProfileRegistry rankProfileRegistry) {
- this.rankProfileRegistry = rankProfileRegistry;
- return this;
- }
-
- public Builder queryProfiles(QueryProfiles queryProfiles) {
- this.queryProfiles = queryProfiles;
- return this;
- }
-
- public Builder queryProfiles(QueryProfileRegistry queryProfileRegistry) {
- this.queryProfiles = new QueryProfiles(queryProfileRegistry, logger);
- return this;
- }
-
public Builder reindexing(Reindexing reindexing) { this.reindexing = Objects.requireNonNull(reindexing); return this; }
public DeployState build() {
@@ -456,8 +438,8 @@ public class DeployState implements ConfigDefinitionStore {
}
public DeployState build(ValidationParameters validationParameters) {
- if (queryProfiles == null)
- queryProfiles = new QueryProfilesBuilder().build(applicationPackage, logger);
+ RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
+ QueryProfiles queryProfiles = new QueryProfilesBuilder().build(applicationPackage, logger);
SemanticRules semanticRules = new SemanticRuleBuilder().build(applicationPackage);
Application application = new ApplicationBuilder(applicationPackage, fileRegistry, logger, properties,
rankProfileRegistry, queryProfiles.getRegistry())
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java
index 8dec0e8339a..0c7c507f32d 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/DerivedConfiguration.java
@@ -1,8 +1,13 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.derived;
+import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels;
+import com.yahoo.concurrent.InThreadExecutorService;
import com.yahoo.config.ConfigInstance;
-import com.yahoo.config.model.deploy.DeployState;
+import com.yahoo.config.model.api.ModelContext;
+import com.yahoo.config.model.application.provider.BaseDeployLogger;
+import com.yahoo.config.application.api.DeployLogger;
+import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.document.config.DocumenttypesConfig;
import com.yahoo.document.config.DocumentmanagerConfig;
import com.yahoo.io.IOUtils;
@@ -16,6 +21,7 @@ import com.yahoo.vespa.model.container.search.QueryProfiles;
import java.io.IOException;
import java.io.Writer;
+import java.util.concurrent.ExecutorService;
/**
* A set of all derived configuration of a schema. Use this as a facade to individual configurations when
@@ -56,36 +62,47 @@ public class DerivedConfiguration implements AttributesConfig.Producer {
}
DerivedConfiguration(Schema schema, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfiles) {
- this(schema, new DeployState.Builder().rankProfileRegistry(rankProfileRegistry).queryProfiles(queryProfiles).build());
+ this(schema, new BaseDeployLogger(), new TestProperties(), rankProfileRegistry, queryProfiles, new ImportedMlModels(), new InThreadExecutorService());
}
/**
- * Creates a complete derived configuration snapshot from a schema.
+ * Creates a complete derived configuration snapshot from a search definition.
*
- * @param schema the schema to derive a configuration from. Derived objects will be snapshots, but this
- * argument is live. Which means that this object will be inconsistent if the given
- * schema is later modified.
+ * @param schema the search to derive a configuration from. Derived objects will be snapshots, but this
+ * argument is live. Which means that this object will be inconsistent when the given
+ * search definition is later modified.
+ * @param deployLogger a {@link DeployLogger} for logging when doing operations on this
+ * @param deployProperties properties set on deploy
+ * @param rankProfileRegistry a {@link com.yahoo.searchdefinition.RankProfileRegistry}
+ * @param queryProfiles the query profiles of this application
*/
- public DerivedConfiguration(Schema schema, DeployState deployState) {
- Validator.ensureNotNull("Schema", schema);
+ public DerivedConfiguration(Schema schema,
+ DeployLogger deployLogger,
+ ModelContext.Properties deployProperties,
+ RankProfileRegistry rankProfileRegistry,
+ QueryProfileRegistry queryProfiles,
+ ImportedMlModels importedModels,
+ ExecutorService executor) {
+ Validator.ensureNotNull("Search definition", schema);
this.schema = schema;
- this.queryProfiles = deployState.getQueryProfiles().getRegistry();
- this.maxUncommittedMemory = deployState.getProperties().featureFlags().maxUnCommittedMemory();
- this.enableBitVectors = deployState.getProperties().featureFlags().enableBitVectors();
+ this.queryProfiles = queryProfiles;
+ this.maxUncommittedMemory = deployProperties.featureFlags().maxUnCommittedMemory();
+ this.enableBitVectors = deployProperties.featureFlags().enableBitVectors();
if ( ! schema.isDocumentsOnly()) {
streamingFields = new VsmFields(schema);
streamingSummary = new VsmSummary(schema);
}
if ( ! schema.isDocumentsOnly()) {
attributeFields = new AttributeFields(schema);
- summaries = new Summaries(schema, deployState.getDeployLogger(), deployState.getProperties().featureFlags());
+ summaries = new Summaries(schema, deployLogger, deployProperties.featureFlags());
summaryMap = new SummaryMap(schema);
juniperrc = new Juniperrc(schema);
rankProfileList = new RankProfileList(schema, schema.rankingConstants(), schema.rankExpressionFiles(),
- schema.onnxModels(), attributeFields, deployState);
+ schema.onnxModels(), attributeFields, rankProfileRegistry,
+ queryProfiles, importedModels, deployProperties, executor);
indexingScript = new IndexingScript(schema);
indexInfo = new IndexInfo(schema);
- schemaInfo = new SchemaInfo(schema, deployState.rankProfileRegistry(), summaries, summaryMap);
+ schemaInfo = new SchemaInfo(schema, rankProfileRegistry, summaries, summaryMap);
indexSchema = new IndexSchema(schema);
importedFields = new ImportedFields(schema);
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
index a55c97f4ebb..c36bd96d309 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/RankProfileList.java
@@ -3,7 +3,6 @@ package com.yahoo.searchdefinition.derived;
import ai.vespa.rankingexpression.importer.configmodelview.ImportedMlModels;
import com.yahoo.config.model.api.ModelContext;
-import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.search.query.profile.QueryProfileRegistry;
import com.yahoo.searchdefinition.OnnxModel;
import com.yahoo.searchdefinition.OnnxModels;
@@ -61,12 +60,16 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
LargeRankExpressions largeRankExpressions,
OnnxModels onnxModels,
AttributeFields attributeFields,
- DeployState deployState) {
+ RankProfileRegistry rankProfileRegistry,
+ QueryProfileRegistry queryProfiles,
+ ImportedMlModels importedModels,
+ ModelContext.Properties deployProperties,
+ ExecutorService executor) {
setName(schema == null ? "default" : schema.getName());
this.rankingConstants = rankingConstants;
this.largeRankExpressions = largeRankExpressions;
this.onnxModels = onnxModels; // as ONNX models come from parsing rank expressions
- deriveRankProfiles(schema, attributeFields, deployState);
+ deriveRankProfiles(rankProfileRegistry, queryProfiles, importedModels, schema, attributeFields, deployProperties, executor);
}
private boolean areDependenciesReady(RankProfile rank, RankProfileRegistry registry) {
@@ -75,34 +78,28 @@ public class RankProfileList extends Derived implements RankProfilesConfig.Produ
(rank.schema() != null && rank.inheritedNames().stream().allMatch(name -> registry.resolve(rank.schema().getDocument(), name) != null));
}
- private void deriveRankProfiles(Schema schema,
+ private void deriveRankProfiles(RankProfileRegistry rankProfileRegistry,
+ QueryProfileRegistry queryProfiles,
+ ImportedMlModels importedModels,
+ Schema schema,
AttributeFields attributeFields,
- DeployState deployState) {
+ ModelContext.Properties deployProperties,
+ ExecutorService executor) {
if (schema != null) { // profiles belonging to a search have a default profile
- RawRankProfile rawRank = new RawRankProfile(deployState.rankProfileRegistry().get(schema, "default"),
- largeRankExpressions,
- deployState.getQueryProfiles().getRegistry(),
- deployState.getImportedModels(),
- attributeFields,
- deployState.getProperties());
+ RawRankProfile rawRank = new RawRankProfile(rankProfileRegistry.get(schema, "default"),
+ largeRankExpressions, queryProfiles, importedModels, attributeFields, deployProperties);
rankProfiles.put(rawRank.getName(), rawRank);
}
Map<String, RankProfile> remaining = new LinkedHashMap<>();
- deployState.rankProfileRegistry().rankProfilesOf(schema).forEach(rank -> remaining.put(rank.name(), rank));
+ rankProfileRegistry.rankProfilesOf(schema).forEach(rank -> remaining.put(rank.name(), rank));
remaining.remove("default");
while (!remaining.isEmpty()) {
List<RankProfile> ready = new ArrayList<>();
remaining.forEach((name, rank) -> {
- if (areDependenciesReady(rank, deployState.rankProfileRegistry())) ready.add(rank);
+ if (areDependenciesReady(rank, rankProfileRegistry)) ready.add(rank);
});
- processRankProfiles(ready,
- deployState.getQueryProfiles().getRegistry(),
- deployState.getImportedModels(),
- schema,
- attributeFields,
- deployState.getProperties(),
- deployState.getExecutor());
+ processRankProfiles(ready, queryProfiles, importedModels, schema, attributeFields, deployProperties, executor);
ready.forEach(rank -> remaining.remove(rank.name()));
}
}
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 6c04ebbc31e..c671ad5bd17 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
@@ -186,7 +186,11 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Seri
new LargeRankExpressions(deployState.getFileRegistry()),
new OnnxModels(deployState.getFileRegistry(), Optional.empty()),
AttributeFields.empty,
- deployState);
+ deployState.rankProfileRegistry(),
+ deployState.getQueryProfiles().getRegistry(),
+ deployState.getImportedModels(),
+ deployState.getProperties(),
+ deployState.getExecutor());
HostSystem hostSystem = root.hostSystem();
if (complete) { // create a completed, frozen model
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 44e574199ea..d5bf12df559 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
@@ -189,7 +189,13 @@ public class IndexedSearchCluster extends SearchCluster
for (SchemaInfo spec : schemas().values()) {
if (spec.fullSchema() instanceof DocumentOnlySchema) continue;
DocumentDatabase db = new DocumentDatabase(this, spec.fullSchema().getName(),
- new DerivedConfiguration(spec.fullSchema(), deployState));
+ new DerivedConfiguration(spec.fullSchema(),
+ deployState.getDeployLogger(),
+ deployState.getProperties(),
+ deployState.rankProfileRegistry(),
+ deployState.getQueryProfiles().getRegistry(),
+ deployState.getImportedModels(),
+ deployState.getExecutor()));
documentDbs.add(db);
}
}
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 09ed8bad403..df266ab77dd 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
@@ -77,7 +77,13 @@ public class StreamingSearchCluster extends SearchCluster implements
if ( ! schema.getName().equals(docTypeName))
throw new IllegalArgumentException("Document type name '" + docTypeName +
"' must be the same as the schema name '" + schema.getName() + "'");
- this.schemaConfig = new DerivedConfiguration(schema, deployState);
+ this.schemaConfig = new DerivedConfiguration(schema,
+ deployState.getDeployLogger(),
+ deployState.getProperties(),
+ deployState.rankProfileRegistry(),
+ deployState.getQueryProfiles().getRegistry(),
+ deployState.getImportedModels(),
+ deployState.getExecutor());
}
@Override
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java
index 992d770d851..8548e50d4bc 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java
@@ -4,7 +4,6 @@ package com.yahoo.searchdefinition.derived;
import com.yahoo.concurrent.InThreadExecutorService;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.config.model.application.provider.MockFileRegistry;
-import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.document.config.DocumenttypesConfig;
import com.yahoo.document.config.DocumentmanagerConfig;
@@ -50,11 +49,12 @@ public abstract class AbstractExportingTestCase extends AbstractSchemaTestCase {
ApplicationBuilder builder,
DeployLogger logger) throws IOException {
DerivedConfiguration config = new DerivedConfiguration(builder.getSchema(schemaName),
- new DeployState.Builder().properties(properties)
- .deployLogger(logger)
- .rankProfileRegistry(builder.getRankProfileRegistry())
- .queryProfiles(builder.getQueryProfileRegistry())
- .build());
+ logger,
+ properties,
+ builder.getRankProfileRegistry(),
+ builder.getQueryProfileRegistry(),
+ new ImportedMlModels(),
+ new InThreadExecutorService());
return export(dirName, builder, config);
}
@@ -108,10 +108,10 @@ public abstract class AbstractExportingTestCase extends AbstractSchemaTestCase {
}
protected DerivedConfiguration assertCorrectDeriving(String dirName,
- String schemaName,
+ String searchDefinitionName,
TestProperties properties,
DeployLogger logger) throws IOException, ParseException {
- DerivedConfiguration derived = derive(dirName, schemaName, properties, logger);
+ DerivedConfiguration derived = derive(dirName, searchDefinitionName, properties, logger);
assertCorrectConfigFiles(dirName);
return derived;
}
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileRegistry.java b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileRegistry.java
index e942d5dbdef..1910078058a 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileRegistry.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/QueryProfileRegistry.java
@@ -49,30 +49,30 @@ public class QueryProfileRegistry extends ComponentRegistry<QueryProfile> {
* which has a type which allows path mahting is used. If there is no such profile, null is returned.
*/
public QueryProfile findQueryProfile(String idString) {
- if (idString == null) return getComponent("default");
- ComponentSpecification id = new ComponentSpecification(idString);
- QueryProfile profile = getComponent(id);
- if (profile != null) return profile;
+ if (idString==null) return getComponent("default");
+ ComponentSpecification id=new ComponentSpecification(idString);
+ QueryProfile profile=getComponent(id);
+ if (profile!=null) return profile;
return findPathParentQueryProfile(new ComponentSpecification(idString));
}
private QueryProfile findPathParentQueryProfile(ComponentSpecification id) {
// Try the name with "/" appended - should have the same semantics with path matching
- QueryProfile slashedProfile = getComponent(new ComponentSpecification(id.getName() + "/", id.getVersionSpecification()));
- if (slashedProfile != null && slashedProfile.getType() != null && slashedProfile.getType().getMatchAsPath())
+ QueryProfile slashedProfile=getComponent(new ComponentSpecification(id.getName() + "/",id.getVersionSpecification()));
+ if (slashedProfile!=null && slashedProfile.getType()!=null && slashedProfile.getType().getMatchAsPath())
return slashedProfile;
// Extract the parent (if any)
- int slashIndex = id.getName().lastIndexOf("/");
- if (slashIndex < 1) return null;
- String parentName = id.getName().substring(0,slashIndex);
+ int slashIndex=id.getName().lastIndexOf("/");
+ if (slashIndex<1) return null;
+ String parentName=id.getName().substring(0,slashIndex);
- ComponentSpecification parentId = new ComponentSpecification(parentName, id.getVersionSpecification());
+ ComponentSpecification parentId=new ComponentSpecification(parentName,id.getVersionSpecification());
- QueryProfile pathParentProfile = getComponent(parentId);
+ QueryProfile pathParentProfile=getComponent(parentId);
- if (pathParentProfile != null && pathParentProfile.getType() != null && pathParentProfile.getType().getMatchAsPath())
+ if (pathParentProfile!=null && pathParentProfile.getType()!=null && pathParentProfile.getType().getMatchAsPath())
return pathParentProfile;
return findPathParentQueryProfile(parentId);
}