From 8faeeb42323c95b0efddcf492ead1d5947f352ac Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 4 Mar 2024 15:39:22 +0100 Subject: [PATCH 1/3] Simplify MultipleDocumentDatabasesConfigProducer according to doc. --- .../validation/RankSetupValidator.java | 15 ++-- .../model/search/IndexedSearchCluster.java | 73 +++++++------------ 2 files changed, 34 insertions(+), 54 deletions(-) diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java index 98adde7b547c..03076b64d0cf 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RankSetupValidator.java @@ -22,7 +22,6 @@ import com.yahoo.vespa.defaults.Defaults; import com.yahoo.vespa.model.application.validation.Validation.Context; import com.yahoo.vespa.model.search.DocumentDatabase; -import com.yahoo.vespa.model.search.IndexedSearchCluster; import com.yahoo.vespa.model.search.SearchCluster; import com.yahoo.yolean.Exceptions; @@ -111,31 +110,31 @@ private void writeConfigs(String dir, DocumentDatabase producer) throws IOExcept writeConfig(dir, VsmfieldsConfig.getDefName() + ".cfg", vsmFB.build()); RankProfilesConfig.Builder rpcb = new RankProfilesConfig.Builder(); - ((RankProfilesConfig.Producer) producer).getConfig(rpcb); + producer.getConfig(rpcb); writeConfig(dir, RankProfilesConfig.getDefName() + ".cfg", rpcb.build()); IndexschemaConfig.Builder iscb = new IndexschemaConfig.Builder(); - ((IndexschemaConfig.Producer) producer).getConfig(iscb); + producer.getConfig(iscb); writeConfig(dir, IndexschemaConfig.getDefName() + ".cfg", iscb.build()); AttributesConfig.Builder acb = new AttributesConfig.Builder(); - ((AttributesConfig.Producer) producer).getConfig(acb); + producer.getConfig(acb); writeConfig(dir, AttributesConfig.getDefName() + ".cfg", acb.build()); RankingConstantsConfig.Builder rccb = new RankingConstantsConfig.Builder(); - ((RankingConstantsConfig.Producer) producer).getConfig(rccb); + producer.getConfig(rccb); writeConfig(dir, RankingConstantsConfig.getDefName() + ".cfg", rccb.build()); RankingExpressionsConfig.Builder recb = new RankingExpressionsConfig.Builder(); - ((RankingExpressionsConfig.Producer) producer).getConfig(recb); + producer.getConfig(recb); writeConfig(dir, RankingExpressionsConfig.getDefName() + ".cfg", recb.build()); OnnxModelsConfig.Builder omcb = new OnnxModelsConfig.Builder(); - ((OnnxModelsConfig.Producer) producer).getConfig(omcb); + producer.getConfig(omcb); writeConfig(dir, OnnxModelsConfig.getDefName() + ".cfg", omcb.build()); ImportedFieldsConfig.Builder ifcb = new ImportedFieldsConfig.Builder(); - ((ImportedFieldsConfig.Producer) producer).getConfig(ifcb); + producer.getConfig(ifcb); writeConfig(dir, ImportedFieldsConfig.getDefName() + ".cfg", ifcb.build()); } 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 885cb53a148b..a55eb0fefe89 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 @@ -45,7 +45,6 @@ public class IndexedSearchCluster extends SearchCluster private SearchCoverage searchCoverage; private final List documentDbs = new LinkedList<>(); - private final MultipleDocumentDatabasesConfigProducer documentDbsConfigProducer; private final Redundancy.Provider redundancyProvider; @@ -57,7 +56,6 @@ public class IndexedSearchCluster extends SearchCluster public IndexedSearchCluster(TreeConfigProducer parent, String clusterName, int index, Redundancy.Provider redundancyProvider, ModelContext.FeatureFlags featureFlags) { super(parent, clusterName, index); - documentDbsConfigProducer = new MultipleDocumentDatabasesConfigProducer(this, documentDbs); this.redundancyProvider = redundancyProvider; defaultDispatchPolicy = DispatchTuning.Builder.toDispatchPolicy(featureFlags.queryDispatchPolicy()); dispatchWarmup = featureFlags.queryDispatchWarmup(); @@ -132,25 +130,25 @@ public void getConfig(DocumentdbInfoConfig.Builder builder) { @Override public void getConfig(IndexInfoConfig.Builder builder) { - documentDbsConfigProducer.getConfig(builder); + new Join(documentDbs).getConfig(builder); } @Override public void getConfig(SchemaInfoConfig.Builder builder) { - documentDbsConfigProducer.getConfig(builder); + new Join(documentDbs).getConfig(builder); } @Override public void getConfig(IlscriptsConfig.Builder builder) { - documentDbsConfigProducer.getConfig(builder); + new Join(documentDbs).getConfig(builder); } public void getConfig(AttributesConfig.Builder builder) { - documentDbsConfigProducer.getConfig(builder); + new Join(documentDbs).getConfig(builder); } public void getConfig(RankProfilesConfig.Builder builder) { - documentDbsConfigProducer.getConfig(builder); + new Join(documentDbs).getConfig(builder); } private static DistributionPolicy.Enum toDistributionPolicy(DispatchTuning.DispatchPolicy tuning) { @@ -216,59 +214,42 @@ public String toString() { /** * Class used to retrieve combined configuration from multiple document databases. - * It is not a direct {@link com.yahoo.config.ConfigInstance.Producer} of those configs, + * It is not a direct {@link ConfigInstance.Producer} of those configs, * that is handled (by delegating to this) by the {@link IndexedSearchCluster} * which is the parent to this. This avoids building the config multiple times. */ - public static class MultipleDocumentDatabasesConfigProducer - extends TreeConfigProducer - implements AttributesConfig.Producer, - IndexInfoConfig.Producer, - IlscriptsConfig.Producer, - SchemaInfoConfig.Producer, - RankProfilesConfig.Producer { - private final List docDbs; - - private MultipleDocumentDatabasesConfigProducer(TreeConfigProducer parent, List docDbs) { - super(parent, "union"); - this.docDbs = docDbs; - } + private record Join(List docDbs) { - @Override public void getConfig(IndexInfoConfig.Builder builder) { - for (DocumentDatabase docDb : docDbs) { - docDb.getConfig(builder); + for (DocumentDatabase docDb : docDbs) { + docDb.getConfig(builder); + } } - } - @Override - public void getConfig(SchemaInfoConfig.Builder builder) { - for (DocumentDatabase docDb : docDbs) { - docDb.getConfig(builder); + public void getConfig(SchemaInfoConfig.Builder builder) { + for (DocumentDatabase docDb : docDbs) { + docDb.getConfig(builder); + } } - } - @Override - public void getConfig(IlscriptsConfig.Builder builder) { - for (DocumentDatabase docDb : docDbs) { - docDb.getConfig(builder); + public void getConfig(IlscriptsConfig.Builder builder) { + for (DocumentDatabase docDb : docDbs) { + docDb.getConfig(builder); + } } - } - @Override - public void getConfig(AttributesConfig.Builder builder) { - for (DocumentDatabase docDb : docDbs) { - docDb.getConfig(builder); + public void getConfig(AttributesConfig.Builder builder) { + for (DocumentDatabase docDb : docDbs) { + docDb.getConfig(builder); + } } - } - @Override - public void getConfig(RankProfilesConfig.Builder builder) { - for (DocumentDatabase docDb : docDbs) { - docDb.getConfig(builder); + public void getConfig(RankProfilesConfig.Builder builder) { + for (DocumentDatabase docDb : docDbs) { + docDb.getConfig(builder); + } } - } - } + } } From 01010e991dd06fc207a01e5ae23376b87e5202b4 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 4 Mar 2024 16:26:02 +0100 Subject: [PATCH 2/3] - Unify the amount of null checking. - No need to be a an attributes config producer. --- .../config/model/producer/AnyConfigProducer.java | 1 - .../config/model/producer/TreeConfigProducer.java | 1 - .../yahoo/schema/derived/DerivedConfiguration.java | 5 +---- .../vespa/model/search/IndexedSearchCluster.java | 11 +++-------- .../vespa/model/search/StreamingSearchCluster.java | 13 +++++-------- 5 files changed, 9 insertions(+), 22 deletions(-) diff --git a/config-model/src/main/java/com/yahoo/config/model/producer/AnyConfigProducer.java b/config-model/src/main/java/com/yahoo/config/model/producer/AnyConfigProducer.java index 2327615cbe43..539447b41e9f 100644 --- a/config-model/src/main/java/com/yahoo/config/model/producer/AnyConfigProducer.java +++ b/config-model/src/main/java/com/yahoo/config/model/producer/AnyConfigProducer.java @@ -30,7 +30,6 @@ public abstract class AnyConfigProducer implements ConfigProducer, ConfigInstance.Producer, Serializable { - private static final long serialVersionUID = 1L; public static final Logger log = Logger.getLogger(AnyConfigProducer.class.getPackage().toString()); private final String subId; private String configId = null; diff --git a/config-model/src/main/java/com/yahoo/config/model/producer/TreeConfigProducer.java b/config-model/src/main/java/com/yahoo/config/model/producer/TreeConfigProducer.java index 094a43696ccd..b10bd29aee2c 100644 --- a/config-model/src/main/java/com/yahoo/config/model/producer/TreeConfigProducer.java +++ b/config-model/src/main/java/com/yahoo/config/model/producer/TreeConfigProducer.java @@ -23,7 +23,6 @@ public abstract class TreeConfigProducer extends AnyConfigProducer { - private static final long serialVersionUID = 1L; private final List descendantServices = new ArrayList<>(); private final FreezableMap childrenBySubId = new FreezableMap<>(LinkedHashMap.class); diff --git a/config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java b/config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java index 575b7264628f..bc1c097ea4b9 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/DerivedConfiguration.java @@ -24,7 +24,7 @@ * * @author bratseth */ -public class DerivedConfiguration implements AttributesConfig.Producer { +public class DerivedConfiguration { private final Schema schema; private Summaries summaries; @@ -74,8 +74,6 @@ public DerivedConfiguration(Schema schema, DeployState deployState, boolean isSt 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()); juniperrc = new Juniperrc(schema); @@ -154,7 +152,6 @@ public AttributeFields getAttributeFields() { return attributeFields; } - @Override public void getConfig(AttributesConfig.Builder builder) { getConfig(builder, AttributeFields.FieldSet.ALL); } 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 a55eb0fefe89..6f5390fdeaac 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 @@ -31,15 +31,10 @@ /** * @author baldersheim */ -public class IndexedSearchCluster extends SearchCluster - implements - DocumentdbInfoConfig.Producer, - IndexInfoConfig.Producer, - SchemaInfoConfig.Producer, - IlscriptsConfig.Producer, +public class IndexedSearchCluster extends SearchCluster implements DispatchConfig.Producer, - DispatchNodesConfig.Producer, - ConfigInstance.Producer { + DispatchNodesConfig.Producer +{ private Tuning tuning; private SearchCoverage searchCoverage; 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 f3ae7e2a312c..90f74af868b1 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 @@ -29,14 +29,14 @@ * @author vegardh */ public class StreamingSearchCluster extends SearchCluster implements - DocumentdbInfoConfig.Producer, RankProfilesConfig.Producer, RankingConstantsConfig.Producer, RankingExpressionsConfig.Producer, OnnxModelsConfig.Producer, VsmsummaryConfig.Producer, VsmfieldsConfig.Producer, - SummaryConfig.Producer { + SummaryConfig.Producer +{ private final String storageRouteSpec; private final AttributesProducer attributesConfig; @@ -129,20 +129,17 @@ public void getConfig(RankProfilesConfig.Builder builder) { @Override public void getConfig(VsmsummaryConfig.Builder builder) { - if (derivedConfig.getVsmSummary() != null) - derivedConfig.getVsmSummary().getConfig(builder); + derivedConfig.getVsmSummary().getConfig(builder); } @Override public void getConfig(VsmfieldsConfig.Builder builder) { - if (derivedConfig.getVsmFields() != null) - derivedConfig.getVsmFields().getConfig(builder); + derivedConfig.getVsmFields().getConfig(builder); } @Override public void getConfig(SummaryConfig.Builder builder) { - if (derivedConfig.getSummaries() != null) - derivedConfig.getSummaries().getConfig(builder); + derivedConfig.getSummaries().getConfig(builder); } private class AttributesProducer extends AnyConfigProducer implements AttributesConfig.Producer { From 94d01c8e7945c446687aaf486217d39d2cd75fe7 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 4 Mar 2024 16:33:42 +0100 Subject: [PATCH 3/3] Reindent --- .../model/search/IndexedSearchCluster.java | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) 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 6f5390fdeaac..e20c294d135e 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 @@ -216,35 +216,35 @@ public String toString() { private record Join(List docDbs) { public void getConfig(IndexInfoConfig.Builder builder) { - for (DocumentDatabase docDb : docDbs) { - docDb.getConfig(builder); - } + for (DocumentDatabase docDb : docDbs) { + docDb.getConfig(builder); } + } - public void getConfig(SchemaInfoConfig.Builder builder) { - for (DocumentDatabase docDb : docDbs) { - docDb.getConfig(builder); - } + public void getConfig(SchemaInfoConfig.Builder builder) { + for (DocumentDatabase docDb : docDbs) { + docDb.getConfig(builder); } + } - public void getConfig(IlscriptsConfig.Builder builder) { - for (DocumentDatabase docDb : docDbs) { - docDb.getConfig(builder); - } + public void getConfig(IlscriptsConfig.Builder builder) { + for (DocumentDatabase docDb : docDbs) { + docDb.getConfig(builder); } + } - public void getConfig(AttributesConfig.Builder builder) { - for (DocumentDatabase docDb : docDbs) { - docDb.getConfig(builder); - } + public void getConfig(AttributesConfig.Builder builder) { + for (DocumentDatabase docDb : docDbs) { + docDb.getConfig(builder); } + } - public void getConfig(RankProfilesConfig.Builder builder) { - for (DocumentDatabase docDb : docDbs) { - docDb.getConfig(builder); - } + public void getConfig(RankProfilesConfig.Builder builder) { + for (DocumentDatabase docDb : docDbs) { + docDb.getConfig(builder); } - } + } + }