diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-03-18 17:19:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-18 17:19:38 +0100 |
commit | dd8ebed8c817e3ce39676cc41008dbe6131c29df (patch) | |
tree | 6450b30006ccc13d30b6db05b1c14c0b416a62a1 /config-model/src/main/java/com | |
parent | 3e1f91d50f016ce573cee3223e639dc689f9b4de (diff) | |
parent | ebfc7be5f5b6383e02c142b7e38bc4cc57b26324 (diff) |
Merge pull request #30651 from vespa-engine/balder/rename-some-searchcluster-related-terms
Balder/rename some searchcluster related terms
Diffstat (limited to 'config-model/src/main/java/com')
9 files changed, 86 insertions, 89 deletions
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 e76e40f2235..e8103f1d1df 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 @@ -55,7 +55,6 @@ import com.yahoo.vespa.model.ml.ConvertedModel; import com.yahoo.vespa.model.ml.ModelName; import com.yahoo.vespa.model.ml.OnnxModelInfo; import com.yahoo.vespa.model.routing.Routing; -import com.yahoo.vespa.model.search.DocumentDatabase; import com.yahoo.vespa.model.search.SearchCluster; import com.yahoo.vespa.model.utils.internal.ReflectionUtil; import org.xml.sax.SAXException; @@ -207,9 +206,9 @@ public final class VespaModel extends AbstractConfigProducerRoot implements Mode .map(type -> type.getFullName().getName()) .collect(Collectors.toCollection(LinkedHashSet::new)); - Set<String> typesWithIndexedFields = content.getSearch().getIndexed() == null + Set<String> typesWithIndexedFields = content.getSearch().getSearchCluster() == null ? Set.of() - : content.getSearch().getIndexed().schemas().values().stream() + : content.getSearch().getSearchCluster().schemas().values().stream() .filter(schemaInfo -> schemaInfo.fullSchema() .allConcreteFields() .stream().anyMatch(SDField::doesIndexing)) diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/IndexedSearchClusterChangeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/IndexedSearchClusterChangeValidator.java index 5117fb7272c..f95ae0b6153 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/IndexedSearchClusterChangeValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/IndexedSearchClusterChangeValidator.java @@ -8,10 +8,10 @@ import com.yahoo.documentmodel.NewDocumentType; import com.yahoo.vespa.model.AbstractService; import com.yahoo.vespa.model.application.validation.Validation.ChangeContext; import com.yahoo.vespa.model.application.validation.change.search.DocumentDatabaseChangeValidator; -import com.yahoo.vespa.model.content.ContentSearchCluster; import com.yahoo.vespa.model.content.cluster.ContentCluster; import com.yahoo.vespa.model.search.DocumentDatabase; import com.yahoo.vespa.model.search.IndexedSearchCluster; +import com.yahoo.vespa.model.search.SearchCluster; import java.util.ArrayList; import java.util.List; @@ -29,7 +29,7 @@ public class IndexedSearchClusterChangeValidator implements ChangeValidator { public void validate(ChangeContext context) { for (Map.Entry<String, ContentCluster> currentEntry : context.previousModel().getContentClusters().entrySet()) { ContentCluster nextCluster = context.model().getContentClusters().get(currentEntry.getKey()); - if (nextCluster != null && nextCluster.getSearch().hasIndexedCluster()) { + if (nextCluster != null && nextCluster.getSearch().hasSearchCluster()) { validateContentCluster(currentEntry.getValue(), nextCluster, context.deployState()).forEach(context::require); } } @@ -47,9 +47,9 @@ public class IndexedSearchClusterChangeValidator implements ChangeValidator { DeployState deployState) { List<ConfigChangeAction> result = new ArrayList<>(); - for (DocumentDatabase currentDb : getDocumentDbs(currentCluster.getSearch())) { + for (DocumentDatabase currentDb : getDocumentDbs(currentCluster.getSearch().getSearchCluster())) { String docTypeName = currentDb.getName(); - var nextDb = nextCluster.getSearch().getIndexed().getDocumentDB(docTypeName); + var nextDb = nextCluster.getSearch().getSearchCluster().getDocumentDB(docTypeName); if (nextDb != null) { result.addAll(validateDocumentDatabase(currentCluster, nextCluster, docTypeName, currentDb, nextDb, deployState)); @@ -71,14 +71,14 @@ public class IndexedSearchClusterChangeValidator implements ChangeValidator { new DocumentDatabaseChangeValidator(currentCluster.id(), currentDb, currentDocType, nextDb, nextDocType, deployState).validate(); - return modifyActions(result, getSearchNodeServices(nextCluster.getSearch().getIndexed()), docTypeName); + return modifyActions(result, getSearchNodeServices(nextCluster.getSearch().getSearchCluster()), docTypeName); } - private static List<DocumentDatabase> getDocumentDbs(ContentSearchCluster cluster) { - if (cluster.getIndexed() != null) { - return cluster.getIndexed().getDocumentDbs(); + private static List<DocumentDatabase> getDocumentDbs(SearchCluster cluster) { + if (cluster != null) { + return cluster.getDocumentDbs(); } - return new ArrayList<>(); + return List.of(); } private static List<ServiceInfo> getSearchNodeServices(IndexedSearchCluster cluster) { diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidator.java index 39894d95c2c..7c1e0def42d 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/StreamingSearchClusterChangeValidator.java @@ -30,9 +30,9 @@ public class StreamingSearchClusterChangeValidator implements ChangeValidator { context.previousModel().getContentClusters().forEach((clusterName, currentCluster) -> { ContentCluster nextCluster = context.model().getContentClusters().get(clusterName); if (nextCluster != null) { - if (currentCluster.getSearch().getIndexed() != null && nextCluster.getSearch().getIndexed() != null) { - validateStreamingCluster(currentCluster, currentCluster.getSearch().getIndexed(), - nextCluster, nextCluster.getSearch().getIndexed()) + if (currentCluster.getSearch().getSearchCluster() != null && nextCluster.getSearch().getSearchCluster() != null) { + validateStreamingCluster(currentCluster, currentCluster.getSearch().getSearchCluster(), + nextCluster, nextCluster.getSearch().getSearchCluster()) .forEach(context::require); } } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java index da7dfdc7b84..554dacb39e3 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/LocalProvider.java @@ -17,7 +17,6 @@ import com.yahoo.vespa.model.search.SearchCluster; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; -import java.util.Objects; import java.util.Set; /** @@ -38,12 +37,7 @@ public class LocalProvider extends Provider implements @Override public void getConfig(ClusterConfig.Builder builder) { - Objects.requireNonNull(searchCluster, "Null search cluster!"); - builder.clusterId(searchCluster.getClusterIndex()); - builder.clusterName(searchCluster.getClusterName()); - - if (searchCluster.getVisibilityDelay() != null) - builder.cacheTimeout(convertVisibilityDelay(searchCluster.getVisibilityDelay())); + searchCluster.getConfig(builder); } @Override @@ -131,13 +125,4 @@ public class LocalProvider extends Provider implements searchCluster.getConfig(builder); } - // The semantics of visibility delay in search is deactivating caches if the - // delay is less than 1.0, in qrs the cache is deactivated if the delay is 0 - // (or less). 1.0 seems a little arbitrary, so just doing the conversion - // here instead of having two totally independent implementations having to - // follow each other down in the modules. - private static Double convertVisibilityDelay(Double visibilityDelay) { - return (visibilityDelay < 1.0d) ? 0.0d : visibilityDelay; - } - } 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 4ac7a8e442a..3ccc44fe60b 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 @@ -136,8 +136,9 @@ public class Content extends ConfigModel { public static List<SearchCluster> getSearchClusters(ConfigModelRepo pc) { List<SearchCluster> clusters = new ArrayList<>(); for (ContentCluster c : getContentClusters(pc)) { - if (c.getSearch().hasIndexedCluster()) { - clusters.add(c.getSearch().getIndexed()); + SearchCluster sc = c.getSearch().getSearchCluster(); + if (sc != null) { + clusters.add(sc); } } return clusters; 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 378907eafd7..ebb556a2ba2 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 @@ -31,7 +31,6 @@ import java.util.Map; import java.util.Set; import java.util.LinkedHashMap; import java.util.Objects; -import java.util.TreeMap; import java.util.function.Predicate; /** @@ -51,11 +50,8 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> private final boolean flushOnShutdown; private final Boolean syncTransactionLog; - /** If this is set up for streaming search, it is modelled as one search cluster per search definition */ - private final Map<String, SearchCluster> clusters = new TreeMap<>(); - /** The single, indexed search cluster this sets up (supporting multiple document types), or null if none */ - private IndexedSearchCluster indexedCluster; + private IndexedSearchCluster searchCluster; private final IndexingDocproc indexingDocproc; private Redundancy redundancy; @@ -135,7 +131,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> search.setVisibilityDelay(visibilityDelay); } - IndexedSearchCluster isc = new IndexedSearchCluster(search, clusterName, 0, search, deployState.featureFlags()); + var isc = new IndexedSearchCluster(search, clusterName, 0, search, deployState.featureFlags()); search.addSearchCluster(deployState, isc, getQueryTimeout(clusterElem), docElem.subElements("document")); } } @@ -175,12 +171,12 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> public void setVisibilityDelay(double delay) { this.visibilityDelay=delay; - if (hasIndexedCluster()) { - indexedCluster.setVisibilityDelay(delay); + if (searchCluster != null) { + searchCluster.setVisibilityDelay(delay); } } - private void addSearchCluster(DeployState deployState, SearchCluster cluster, Double queryTimeout, List<ModelElement> documentDefs) { + private void addSearchCluster(DeployState deployState, IndexedSearchCluster cluster, Double queryTimeout, List<ModelElement> documentDefs) { addSchemas(deployState, documentDefs, cluster); if (queryTimeout != null) { @@ -206,17 +202,11 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> } } - private void addCluster(SearchCluster sc) { - if (clusters.containsKey(sc.getClusterName())) { - throw new IllegalArgumentException("Duplicate cluster '" + sc.getClusterName() + "'"); - } - if (sc instanceof IndexedSearchCluster) { - if (indexedCluster != null) { - throw new IllegalArgumentException("Duplicate indexed cluster '" + indexedCluster.getClusterName() + "'"); - } - indexedCluster = (IndexedSearchCluster)sc; + private void addCluster(IndexedSearchCluster sc) { + if (searchCluster != null) { + throw new IllegalArgumentException("Duplicate indexed cluster '" + searchCluster.getClusterName() + "'"); } - clusters.put(sc.getClusterName(), sc); + searchCluster = sc; } /** @@ -226,26 +216,26 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> * with indexing, null if it has both or none. */ public Boolean isStreaming() { - if (indexedCluster == null) return false; - boolean hasStreaming = indexedCluster.hasStreaming(); - if (indexedCluster.hasIndexed() == hasStreaming) return null; + if (searchCluster == null) return false; + boolean hasStreaming = searchCluster.hasStreaming(); + if (searchCluster.hasIndexed() == hasStreaming) return null; return hasStreaming; } public boolean hasStreaming() { - return (indexedCluster != null) && indexedCluster.hasStreaming(); + return (searchCluster != null) && searchCluster.hasStreaming(); } public boolean hasIndexed() { - return (indexedCluster != null) && indexedCluster.hasIndexed(); + return (searchCluster != null) && searchCluster.hasIndexed(); } public List<SearchNode> getSearchNodes() { - return hasIndexedCluster() ? getIndexed().getSearchNodes() : nonIndexed; + return (searchCluster != null) ? searchCluster.getSearchNodes() : nonIndexed; } public void addSearchNode(DeployState deployState, ContentNode node, StorageGroup parentGroup, ModelElement element) { - TreeConfigProducer<AnyConfigProducer> parent = hasIndexedCluster() ? getIndexed() : this; + TreeConfigProducer<AnyConfigProducer> parent = (searchCluster != null) ? searchCluster : this; NodeSpec spec = getNextSearchNodeSpec(parentGroup); SearchNode searchNode; @@ -267,8 +257,8 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> tls = new TransactionLogServer.Builder(clusterName, syncTransactionLog).build(deployState, searchNode, element.getXml()); } searchNode.setTls(tls); - if (hasIndexedCluster()) { - getIndexed().addSearcher(searchNode); + if (searchCluster != null) { + searchCluster.addSearcher(searchNode); } else { nonIndexed.add(searchNode); } @@ -295,7 +285,7 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> } public boolean usesHierarchicDistribution() { - return indexedCluster != null && groupToSpecMap.size() > 1; + return searchCluster != null && groupToSpecMap.size() > 1; } public void handleRedundancy(Redundancy redundancy) { @@ -313,14 +303,14 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> } private boolean hasIndexingModeStreaming(NewDocumentType type) { - if (indexedCluster == null) return false; - var schemaInfo = indexedCluster.schemas().get(type.getName()); + if (searchCluster == null) return false; + var schemaInfo = searchCluster.schemas().get(type.getName()); return (schemaInfo != null) && (schemaInfo.getIndexMode() == SchemaInfo.IndexMode.STREAMING); } private boolean hasIndexingModeIndexed(NewDocumentType type) { - if (indexedCluster == null) return false; - var schemaInfo = indexedCluster.schemas().get(type.getName()); + if (searchCluster == null) return false; + var schemaInfo = searchCluster.schemas().get(type.getName()); return (schemaInfo != null) && (schemaInfo.getIndexMode() == SchemaInfo.IndexMode.INDEX); } @@ -343,10 +333,10 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> if (hasIndexingModeStreaming(type)) { hasAnyNonIndexedSchema = true; - indexedCluster.fillDocumentDBConfig(type.getFullName().getName(), ddbB); + searchCluster.fillDocumentDBConfig(type.getFullName().getName(), ddbB); ddbB.mode(ProtonConfig.Documentdb.Mode.Enum.STREAMING); } else if (hasIndexingModeIndexed(type)) { - indexedCluster.fillDocumentDBConfig(type.getFullName().getName(), ddbB); + searchCluster.fillDocumentDBConfig(type.getFullName().getName(), ddbB); } else { hasAnyNonIndexedSchema = true; ddbB.mode(ProtonConfig.Documentdb.Mode.Enum.STORE_ONLY); @@ -400,19 +390,19 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer> @Override public void getConfig(DispatchNodesConfig.Builder builder) { - if (hasIndexedCluster()) { - getIndexed().getConfig(builder); + if (searchCluster != null) { + searchCluster.getConfig(builder); } } @Override public void getConfig(DispatchConfig.Builder builder) { - if (hasIndexedCluster()) { - getIndexed().getConfig(builder); + if (searchCluster != null) { + searchCluster.getConfig(builder); } } - public IndexedSearchCluster getIndexed() { return indexedCluster; } - public boolean hasIndexedCluster() { return indexedCluster != null; } + public IndexedSearchCluster getSearchCluster() { return searchCluster; } + public boolean hasSearchCluster() { return searchCluster != null; } public IndexingDocproc getIndexingDocproc() { return indexingDocproc; } public String getClusterName() { return clusterName; } 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 5a9b4bb0760..bac86e37e8f 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 @@ -73,14 +73,14 @@ import static java.util.logging.Level.WARNING; * @author bratseth */ public class ContentCluster extends TreeConfigProducer<AnyConfigProducer> implements - DistributionConfig.Producer, - StorDistributionConfig.Producer, - StorDistributormanagerConfig.Producer, - FleetcontrollerConfig.Producer, - MetricsmanagerConfig.Producer, - MessagetyperouteselectorpolicyConfig.Producer, - BucketspacesConfig.Producer { - + DistributionConfig.Producer, + StorDistributionConfig.Producer, + StorDistributormanagerConfig.Producer, + FleetcontrollerConfig.Producer, + MetricsmanagerConfig.Producer, + MessagetyperouteselectorpolicyConfig.Producer, + BucketspacesConfig.Producer +{ private final String documentSelection; private ContentSearchCluster search; private final boolean isHosted; @@ -177,8 +177,9 @@ public class ContentCluster extends TreeConfigProducer<AnyConfigProducer> implem if (visibilityDelay != null) { csc.setVisibilityDelay(visibilityDelay); } - if (csc.hasIndexedCluster()) { - setupIndexedCluster(csc.getIndexed(), search, element, logger); + IndexedSearchCluster sc = csc.getSearchCluster(); + if (sc != null) { + setupIndexedCluster(sc, search, element, logger); } } @@ -530,7 +531,7 @@ public class ContentCluster extends TreeConfigProducer<AnyConfigProducer> implem super.validate(); if (search.usesHierarchicDistribution() && !isHosted) { // validate manually configured groups - new IndexedHierarchicDistributionValidator(rootGroup, redundancy, search.getIndexed().getTuning().dispatch.getDispatchPolicy()).validate(); + new IndexedHierarchicDistributionValidator(rootGroup, redundancy, search.getSearchCluster().getTuning().dispatch.getDispatchPolicy()).validate(); } new ReservedDocumentTypeNameValidator().validate(documentDefinitions); new GlobalDistributionValidator().validate(documentDefinitions, globallyDistributedDocuments); 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 67d99e300de..c9c7e424ee6 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 @@ -2,12 +2,8 @@ package com.yahoo.vespa.model.search; import com.yahoo.config.model.api.ModelContext; -import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.producer.AnyConfigProducer; import com.yahoo.config.model.producer.TreeConfigProducer; -import com.yahoo.schema.DocumentOnlySchema; -import com.yahoo.schema.derived.DerivedConfiguration; -import com.yahoo.schema.derived.SchemaInfo; import com.yahoo.vespa.config.search.DispatchConfig; import com.yahoo.vespa.config.search.DispatchConfig.DistributionPolicy; import com.yahoo.vespa.config.search.DispatchNodesConfig; 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 9d459259253..8a60930664e 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 @@ -7,6 +7,7 @@ import com.yahoo.container.QrSearchersConfig; import com.yahoo.schema.DocumentOnlySchema; import com.yahoo.schema.derived.AttributeFields; import com.yahoo.schema.derived.DerivedConfiguration; +import com.yahoo.search.config.ClusterConfig; import com.yahoo.search.config.SchemaInfoConfig; import com.yahoo.schema.derived.SchemaInfo; import com.yahoo.vespa.config.search.AttributesConfig; @@ -217,6 +218,30 @@ public abstract class SearchCluster extends TreeConfigProducer<AnyConfigProducer new Join(documentDbs.values()).getConfig(builder); } + public void getConfig(ClusterConfig.Builder builder) { + builder.clusterId(getClusterIndex()); + builder.clusterName(getClusterName()); + builder.storageRoute(getClusterName()); + builder.configid(getConfigId()); + if (visibilityDelay != null) { + builder.cacheTimeout(convertVisibilityDelay(visibilityDelay)); + } + if (hasStreaming()) { + builder.indexMode(ClusterConfig.IndexMode.Enum.STREAMING); + } else { + builder.indexMode(ClusterConfig.IndexMode.Enum.INDEX); + } + } + + // The semantics of visibility delay in search is deactivating caches if the + // delay is less than 1.0, in qrs the cache is deactivated if the delay is 0 + // (or less). 1.0 seems a little arbitrary, so just doing the conversion + // here instead of having two totally independent implementations having to + // follow each other down in the modules. + private static Double convertVisibilityDelay(Double visibilityDelay) { + return (visibilityDelay < 1.0d) ? 0.0d : visibilityDelay; + } + @Override public String toString() { return "search-capable cluster '" + clusterName + "'"; } |