From ebfc7be5f5b6383e02c142b7e38bc4cc57b26324 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 15 Mar 2024 15:54:10 +0100 Subject: Add necessary config to ClusterConfig to avoid hidden relation via clusterId to QrSearchersConfig --- .../com/yahoo/prelude/cluster/ClusterSearcher.java | 30 +++++----------------- .../prelude/searcher/ValidateSortingSearcher.java | 21 ++++++--------- .../yahoo/search/grouping/GroupingValidator.java | 12 +++------ .../searchers/ValidateMatchPhaseSearcher.java | 1 - .../configdefinitions/search.config.cluster.def | 15 ++++++----- 5 files changed, 27 insertions(+), 52 deletions(-) (limited to 'container-search/src/main') diff --git a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java index 855a524473d..cb5ac7a6a4f 100644 --- a/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/cluster/ClusterSearcher.java @@ -6,7 +6,6 @@ import com.yahoo.component.annotation.Inject; import com.yahoo.component.ComponentId; import com.yahoo.component.chain.dependencies.After; import com.yahoo.component.provider.ComponentRegistry; -import com.yahoo.container.QrSearchersConfig; import com.yahoo.container.core.documentapi.VespaDocumentAccess; import com.yahoo.container.handler.VipStatus; import com.yahoo.prelude.fastsearch.ClusterParams; @@ -71,7 +70,6 @@ public class ClusterSearcher extends Searcher { @Inject public ClusterSearcher(ComponentId id, Executor executor, - QrSearchersConfig qrsConfig, ClusterConfig clusterConfig, DocumentdbInfoConfig documentDbConfig, SchemaInfo schemaInfo, @@ -84,7 +82,6 @@ public class ClusterSearcher extends Searcher { this.schemaInfo = schemaInfo; int searchClusterIndex = clusterConfig.clusterId(); searchClusterName = clusterConfig.clusterName(); - QrSearchersConfig.Searchcluster searchClusterConfig = getSearchClusterConfigFromClusterName(qrsConfig, searchClusterName); this.globalPhaseRanker = globalPhaseRanker; schema2Searcher = new LinkedHashMap<>(); @@ -92,9 +89,7 @@ public class ClusterSearcher extends Searcher { maxQueryCacheTimeout = ParameterParser.asMilliSeconds(clusterConfig.maxQueryCacheTimeout(), DEFAULT_MAX_QUERY_CACHE_TIMEOUT); VespaBackend streaming = null, indexed = null; - ClusterParams clusterParams = makeClusterParams(searchClusterIndex, qrsConfig - .com().yahoo().prelude().fastsearch().IndexedBackend().docsum() - .defaultclass(), documentDbConfig, schemaInfo); + ClusterParams clusterParams = makeClusterParams(searchClusterIndex, documentDbConfig, schemaInfo); for (DocumentdbInfoConfig.Documentdb docDb : documentDbConfig.documentdb()) { if (docDb.mode() == DocumentdbInfoConfig.Documentdb.Mode.Enum.INDEX) { if (indexed == null) { @@ -103,7 +98,7 @@ public class ClusterSearcher extends Searcher { schema2Searcher.put(docDb.name(), indexed); } else if (docDb.mode() == DocumentdbInfoConfig.Documentdb.Mode.Enum.STREAMING) { if (streaming == null) { - streaming = streamingCluster(clusterParams, searchClusterConfig, access); + streaming = streamingCluster(clusterParams, clusterConfig, access); vipStatus.addToRotation(streaming.getName()); } schema2Searcher.put(docDb.name(), streaming); @@ -111,21 +106,10 @@ public class ClusterSearcher extends Searcher { } } - private static QrSearchersConfig.Searchcluster getSearchClusterConfigFromClusterName(QrSearchersConfig config, String name) { - for (QrSearchersConfig.Searchcluster searchCluster : config.searchcluster()) { - if (searchCluster.name().equals(name)) { - return searchCluster; - } - } - throw new IllegalStateException("No configured search cluster '" + name + "' among : " + - config.searchcluster().stream().map(QrSearchersConfig.Searchcluster::name).toList()); - } - - private static ClusterParams makeClusterParams(int searchclusterIndex, String defaultSummary, - DocumentdbInfoConfig documentDbConfig, SchemaInfo schemaInfo) + private static ClusterParams makeClusterParams(int searchclusterIndex, DocumentdbInfoConfig documentDbConfig, SchemaInfo schemaInfo) { return new ClusterParams("sc" + searchclusterIndex + ".num" + 0, UUID.randomUUID().toString(), - defaultSummary, documentDbConfig, schemaInfo); + null, documentDbConfig, schemaInfo); } private static IndexedBackend searchDispatch(ClusterParams clusterParams, @@ -140,11 +124,11 @@ public class ClusterSearcher extends Searcher { } private static StreamingBackend streamingCluster(ClusterParams clusterParams, - QrSearchersConfig.Searchcluster searchClusterConfig, + ClusterConfig clusterConfig, VespaDocumentAccess access) { - return new StreamingBackend(clusterParams, searchClusterConfig.rankprofiles_configid(), - access, searchClusterConfig.storagecluster().routespec()); + return new StreamingBackend(clusterParams, clusterConfig.configid(), + access, clusterConfig.storageRoute()); } /** Do not use, for internal testing purposes only. **/ diff --git a/container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java b/container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java index a25cc30955e..96bf40195e9 100644 --- a/container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java +++ b/container-search/src/main/java/com/yahoo/prelude/searcher/ValidateSortingSearcher.java @@ -3,7 +3,6 @@ package com.yahoo.prelude.searcher; import com.yahoo.component.chain.dependencies.After; import com.yahoo.component.chain.dependencies.Before; -import com.yahoo.container.QrSearchersConfig; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.Searcher; @@ -32,14 +31,12 @@ public class ValidateSortingSearcher extends Searcher { private Map attributeNames = null; private String clusterName = ""; - private final QrSearchersConfig.Searchcluster.Indexingmode.Enum indexingMode; + private final boolean enabled; - public ValidateSortingSearcher(QrSearchersConfig qrsConfig, ClusterConfig clusterConfig, - AttributesConfig attributesConfig) { + public ValidateSortingSearcher(ClusterConfig clusterConfig, AttributesConfig attributesConfig) { initAttributeNames(attributesConfig); - var searchCluster = qrsConfig.searchcluster(clusterConfig.clusterId()); - setClusterName(searchCluster.name()); - indexingMode = searchCluster.indexingmode(); + setClusterName(clusterConfig.clusterName()); + enabled = clusterConfig.indexMode() != ClusterConfig.IndexMode.Enum.STREAMING; } public String getClusterName() { @@ -70,12 +67,10 @@ public class ValidateSortingSearcher extends Searcher { @Override public Result search(Query query, Execution execution) { ErrorMessage e = validate(query); - if (indexingMode != QrSearchersConfig.Searchcluster.Indexingmode.STREAMING) { - if (e != null) { - Result r = new Result(query); - r.hits().addError(e); - return r; - } + if (enabled && e != null) { + Result r = new Result(query); + r.hits().addError(e); + return r; } return execution.search(query); } diff --git a/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java b/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java index d4e295fb51f..165469d59ee 100644 --- a/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java +++ b/container-search/src/main/java/com/yahoo/search/grouping/GroupingValidator.java @@ -8,7 +8,6 @@ import com.yahoo.component.chain.dependencies.Provides; import com.yahoo.processing.IllegalInputException; import com.yahoo.search.grouping.request.AttributeMapLookupValue; import com.yahoo.vespa.config.search.AttributesConfig; -import com.yahoo.container.QrSearchersConfig; import com.yahoo.processing.request.CompoundName; import com.yahoo.search.Query; import com.yahoo.search.Result; @@ -45,17 +44,12 @@ public class GroupingValidator extends Searcher { /** * Constructs a new instance of this searcher with the given component id and config. * - * @param qrsConfig The shared config for all searchers. * @param clusterConfig The config for the cluster that this searcher is deployed for. */ @Inject - public GroupingValidator(QrSearchersConfig qrsConfig, ClusterConfig clusterConfig, - AttributesConfig attributesConfig) { - int clusterId = clusterConfig.clusterId(); - var searchCluster = qrsConfig.searchcluster(clusterId); - QrSearchersConfig.Searchcluster.Indexingmode.Enum indexingMode = searchCluster.indexingmode(); - enabled = (indexingMode != QrSearchersConfig.Searchcluster.Indexingmode.STREAMING); - clusterName = searchCluster.name(); + public GroupingValidator(ClusterConfig clusterConfig, AttributesConfig attributesConfig) { + enabled = (clusterConfig.indexMode() != ClusterConfig.IndexMode.Enum.STREAMING); + clusterName = clusterConfig.clusterName(); for (AttributesConfig.Attribute attr : attributesConfig.attribute()) { attributes.put(attr.name(), attr); } diff --git a/container-search/src/main/java/com/yahoo/search/searchers/ValidateMatchPhaseSearcher.java b/container-search/src/main/java/com/yahoo/search/searchers/ValidateMatchPhaseSearcher.java index 7761660d551..c5ffb6c02ea 100644 --- a/container-search/src/main/java/com/yahoo/search/searchers/ValidateMatchPhaseSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/searchers/ValidateMatchPhaseSearcher.java @@ -1,7 +1,6 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.search.searchers; -import com.yahoo.container.QrSearchersConfig; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.Searcher; diff --git a/container-search/src/main/resources/configdefinitions/search.config.cluster.def b/container-search/src/main/resources/configdefinitions/search.config.cluster.def index 2bd98f86ca8..ac88d5baa24 100644 --- a/container-search/src/main/resources/configdefinitions/search.config.cluster.def +++ b/container-search/src/main/resources/configdefinitions/search.config.cluster.def @@ -5,17 +5,11 @@ namespace=search.config #Note: Use clusterName where possible instead clusterId int default=0 -# Not used -cacheSize int default=1 - #Timeout for internal searcher cache. Entries older than this number #of seconds will be removed from cache. 0 or less means the cache is #disabled. cacheTimeout double default=0 -#Whether or not to try another TLD if the current request fails. -failoverToRemote bool default=false - #The name of the cluster (as specified in qr-searchers) clusterName string @@ -25,3 +19,12 @@ maxQueryTimeout double default=600 #The maximum query timeout allowed before disabling the backend query cache for the given query (default 10 seconds). #Note that the query timeout is used as the query cache timeout in the backend if enabled. maxQueryCacheTimeout double default=10 + +#The configid to use to get other clusterspecific configs. +configid string default="" + +#The mbus route to the backing content cluster +storageRoute string default="" + +#Indexing mode for this cluster. This is a temporary workaround until this is correctly resolved per schema all over. +indexMode enum {INDEX, STREAMING, STORE_ONLY} default = INDEX -- cgit v1.2.3