summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2024-03-04 12:12:49 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2024-03-04 12:12:49 +0100
commitab14184549b1f39a4cb5b42e847fbf5553e51fc3 (patch)
treefe37ad9ec3327afe905a8dddc08024261211efdf /config-model
parent65c1240681f7e4d091776974a2f4348937d00d75 (diff)
- GC unused ancient code. documents selection validation is
done correctly in ContentCluster. GC old leftower from 5.0.
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java31
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java5
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java17
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/DocumentSelectionConverter.java57
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java38
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/SearchCluster.java2
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/StreamingSearchCluster.java3
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/MockSearchClusters.java41
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/search/test/DocumentSelectionConverterTest.java33
9 files changed, 16 insertions, 211 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java
deleted file mode 100644
index bd933f1c656..00000000000
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/RoutingSelectorValidator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.model.application.validation;
-
-import com.yahoo.document.select.DocumentSelector;
-import com.yahoo.vespa.model.application.validation.Validation.Context;
-import com.yahoo.vespa.model.search.IndexedSearchCluster;
-import com.yahoo.vespa.model.search.SearchCluster;
-
-
-/**
- * Validates routing selector for search and content clusters
- */
-public class RoutingSelectorValidator implements Validator {
-
- @Override
- public void validate(Context context) {
- for (SearchCluster cluster : context.model().getSearchClusters()) {
- if (cluster instanceof IndexedSearchCluster) {
- IndexedSearchCluster sc = (IndexedSearchCluster) cluster;
- String routingSelector = sc.getRoutingSelector();
- if (routingSelector == null) continue;
- try {
- new DocumentSelector(routingSelector);
- } catch (com.yahoo.document.select.parser.ParseException e) {
- context.illegal("Failed to parse routing selector for search cluster '" + sc.getClusterName() + "'", e);
- }
- }
- }
- }
-
-}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java
index 56b7e6ee0c8..ed0804f7420 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java
@@ -7,7 +7,6 @@ import com.yahoo.config.application.api.ValidationOverrides.ValidationException;
import com.yahoo.config.model.api.ConfigChangeAction;
import com.yahoo.config.model.api.ValidationParameters;
import com.yahoo.config.model.deploy.DeployState;
-import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.vespa.model.application.validation.change.CertificateRemovalChangeValidator;
import com.yahoo.vespa.model.application.validation.change.ConfigValueChangeValidator;
@@ -28,13 +27,10 @@ import com.yahoo.yolean.Exceptions;
import java.util.ArrayList;
import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.Set;
import java.util.logging.Level;
-import java.util.stream.Collectors;
/**
* Executor of validators. This defines the right order of validator execution.
@@ -82,7 +78,6 @@ public class Validation {
private static void validateRouting(Execution execution) {
new RoutingValidator().validate(execution);
- new RoutingSelectorValidator().validate(execution);
}
private static void validateModel(ValidationParameters validationParameters, Execution execution) {
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 0027a9ca45c..99630c5f048 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
@@ -103,14 +103,13 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer>
Boolean flushOnShutdownElem = clusterElem.childAsBoolean("engine.proton.flush-on-shutdown");
Boolean syncTransactionLog = clusterElem.childAsBoolean("engine.proton.sync-transactionlog");
- ContentSearchCluster search = new ContentSearchCluster(ancestor,
- clusterName,
- deployState.getProperties().featureFlags(),
- documentDefinitions,
- globallyDistributedDocuments,
- getFlushOnShutdown(flushOnShutdownElem),
- syncTransactionLog,
- fractionOfMemoryReserved);
+ var search = new ContentSearchCluster(ancestor, clusterName,
+ deployState.getProperties().featureFlags(),
+ documentDefinitions,
+ globallyDistributedDocuments,
+ getFlushOnShutdown(flushOnShutdownElem),
+ syncTransactionLog,
+ fractionOfMemoryReserved);
ModelElement tuning = clusterElem.childByPath("engine.proton.tuning");
if (tuning != null) {
@@ -162,7 +161,6 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer>
List<ModelElement> indexedDefs = getIndexedSchemas(clusterElem);
if (!indexedDefs.isEmpty()) {
IndexedSearchCluster isc = new IndexedSearchCluster(search, clusterName, 0, deployState.featureFlags());
- isc.setRoutingSelector(clusterElem.childAsString("documents.selection"));
Double visibilityDelay = clusterElem.childAsDouble("engine.proton.visibility-delay");
if (visibilityDelay != null) {
@@ -236,7 +234,6 @@ public class ContentSearchCluster extends TreeConfigProducer<AnyConfigProducer>
if (queryTimeout != null) {
cluster.setQueryTimeout(queryTimeout);
}
- cluster.defaultDocumentsConfig();
cluster.deriveFromSchemas(deployState);
addCluster(cluster);
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/DocumentSelectionConverter.java b/config-model/src/main/java/com/yahoo/vespa/model/search/DocumentSelectionConverter.java
deleted file mode 100644
index 89d2bdaf54f..00000000000
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/DocumentSelectionConverter.java
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright Vespa.ai. 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.document.select.*;
-import com.yahoo.document.select.convert.SelectionExpressionConverter;
-import com.yahoo.document.select.parser.ParseException;
-import java.util.Map;
-
-/**
- * @author Ulf Lilleengen
- */
-// TODO: This should be renamed to reflect it is only a validator of expressions
-// (in DocumentSelector and SelectionExpressionConverter)
-public class DocumentSelectionConverter {
-
- private final DocumentSelector selector;
- private final Map<String, String> queryExpressionMap;
-
- public DocumentSelectionConverter(String selection) throws ParseException, UnsupportedOperationException, IllegalArgumentException {
- this.selector = new DocumentSelector(selection);
- NowCheckVisitor nowChecker = new NowCheckVisitor();
- selector.visit(nowChecker);
- if (nowChecker.requiresConversion()) {
- SelectionExpressionConverter converter = new SelectionExpressionConverter();
- selector.visit(converter);
- this.queryExpressionMap = converter.getQueryMap();
- } else {
- this.queryExpressionMap = null;
- }
- }
-
- /**
- * Transforms the selection into a search query.
- *
- * @return a search query representing the selection
- */
- public String getQuery(String documentType) {
- if (queryExpressionMap == null)
- return null;
- if (!queryExpressionMap.containsKey(documentType))
- return null;
- return queryExpressionMap.get(documentType);
- }
-
- /**
- * Transforms the selection into an inverted search query.
- *
- * @return a search query representing the selection
- */
- public String getInvertedQuery(String documentType) {
- String query = getQuery(documentType);
- if (query == null)
- return null;
- return query.replaceAll(">", "<");
- }
-
-}
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 8824112c118..c9057c16499 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
@@ -24,7 +24,6 @@ import com.yahoo.vespa.model.content.SearchCoverage;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -44,8 +43,6 @@ public class IndexedSearchCluster extends SearchCluster
private Tuning tuning;
private SearchCoverage searchCoverage;
- // This is the document selector string as derived from the subscription tag.
- private String routingSelector = null;
private final List<DocumentDatabase> documentDbs = new LinkedList<>();
private final MultipleDocumentDatabasesConfigProducer documentDbsConfigProducer;
@@ -55,15 +52,6 @@ public class IndexedSearchCluster extends SearchCluster
private final DispatchTuning.DispatchPolicy defaultDispatchPolicy;
private final double dispatchWarmup;
private final String summaryDecodePolicy;
- /**
- * Returns the document selector that is able to resolve what documents are to be routed to this search cluster.
- * This string uses the document selector language as defined in the "document" module.
- *
- * @return the document selector
- */
- public String getRoutingSelector() {
- return routingSelector;
- }
public IndexedSearchCluster(TreeConfigProducer<AnyConfigProducer> parent, String clusterName, int index, ModelContext.FeatureFlags featureFlags) {
super(parent, clusterName, index);
@@ -102,32 +90,6 @@ public class IndexedSearchCluster extends SearchCluster
.configid(sdoc.getConfigId());
}
- public void setRoutingSelector(String selector) {
- this.routingSelector = selector;
- if (this.routingSelector != null) {
- try {
- new DocumentSelectionConverter(this.routingSelector);
- } catch (Exception e) {
- throw new IllegalArgumentException("Invalid routing selector: " + e.getMessage());
- }
- }
- }
- /**
- * Create default config if not specified by user.
- * Accept empty strings as user config - it means that all feeds/documents are accepted.
- */
- public void defaultDocumentsConfig() {
- if ((routingSelector == null) && !getDocumentNames().isEmpty()) {
- Iterator<String> it = getDocumentNames().iterator();
- routingSelector = it.next();
- StringBuilder sb = new StringBuilder(routingSelector);
- while (it.hasNext()) {
- sb.append(" or ").append(it.next());
- }
- routingSelector = sb.toString();
- }
- }
-
@Override
public void deriveFromSchemas(DeployState deployState) {
for (SchemaInfo spec : schemas().values()) {
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 c4f1069e0aa..9ccc6abfc35 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
@@ -79,8 +79,6 @@ public abstract class SearchCluster extends TreeConfigProducer<AnyConfigProducer
public final void setClusterIndex(int index) { this.index = index; }
public final int getClusterIndex() { return index; }
- public abstract void defaultDocumentsConfig();
-
public abstract void getConfig(AttributesConfig.Builder builder);
public abstract void getConfig(RankProfilesConfig.Builder builder);
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 7a4dd935acf..f3ae7e2a312 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
@@ -95,9 +95,6 @@ public class StreamingSearchCluster extends SearchCluster implements
}
@Override
- public void defaultDocumentsConfig() { }
-
- @Override
public void getConfig(IndexInfoConfig.Builder builder) {
derivedConfig.getIndexInfo().getConfig(builder);
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/MockSearchClusters.java b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/MockSearchClusters.java
index 75884c298fb..8f9102801c2 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/MockSearchClusters.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/MockSearchClusters.java
@@ -28,42 +28,19 @@ public class MockSearchClusters {
@Override
public void deriveFromSchemas(DeployState deployState) { }
+ @Override public List<DocumentDatabase> getDocumentDbs() {return List.of();}
+ @Override public void getConfig(AttributesConfig.Builder builder) {}
+ @Override public void getConfig(DocumentdbInfoConfig.Builder builder) {}
+ @Override public void getConfig(RankProfilesConfig.Builder builder) {}
+ @Override public void getConfig(IndexInfoConfig.Builder builder) {}
+ @Override public void getConfig(IlscriptsConfig.Builder builder) {}
+ @Override public void getConfig(SchemaInfoConfig.Builder builder) {}
@Override
- public List<DocumentDatabase> getDocumentDbs() {
- return List.of();
+ protected SearchCluster.IndexingMode getIndexingMode() {
+ return streaming ? SearchCluster.IndexingMode.STREAMING : SearchCluster.IndexingMode.REALTIME;
}
- @Override
- public void defaultDocumentsConfig() {}
-
- @Override
- public void getConfig(AttributesConfig.Builder builder) {
- }
-
- @Override
- public void getConfig(DocumentdbInfoConfig.Builder builder) {
- }
-
- @Override
- public void getConfig(RankProfilesConfig.Builder builder) {
- }
-
- @Override
- public void getConfig(IndexInfoConfig.Builder builder) {
- }
-
- @Override
- public void getConfig(IlscriptsConfig.Builder builder) {
- }
-
- @Override
- public void getConfig(SchemaInfoConfig.Builder builder) {
- }
-
- @Override
- protected SearchCluster.IndexingMode getIndexingMode() { return streaming ? SearchCluster.IndexingMode.STREAMING : SearchCluster.IndexingMode.REALTIME; }
-
}
public static SearchCluster mockSearchCluster(AbstractConfigProducerRoot root, String clusterName, int clusterIndex, boolean isStreaming) {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/search/test/DocumentSelectionConverterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/search/test/DocumentSelectionConverterTest.java
deleted file mode 100644
index f495de2c6a4..00000000000
--- a/config-model/src/test/java/com/yahoo/vespa/model/search/test/DocumentSelectionConverterTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.model.search.test;
-
-import com.yahoo.document.select.parser.ParseException;
-import com.yahoo.vespa.model.search.DocumentSelectionConverter;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
-/**
- * Unit tests for RemoveSelection.
- * @author Ulf Lilleengen
- */
-public class DocumentSelectionConverterTest {
- @Test
- void testQueryConversion() throws ParseException, IllegalArgumentException, UnsupportedOperationException {
- DocumentSelectionConverter converter = new DocumentSelectionConverter("music.expire>now() - 3600 and video.expire > now() - 300");
- assertEquals("expire:>now(3600)", converter.getQuery("music"));
- assertEquals("expire:<now(3600)", converter.getInvertedQuery("music"));
- assertEquals("expire:>now(300)", converter.getQuery("video"));
- assertEquals("expire:<now(300)", converter.getInvertedQuery("video"));
- assertNull(converter.getQuery("book"));
- assertNull(converter.getInvertedQuery("book"));
- }
-
- @Test
- void testSelection() throws ParseException, IllegalArgumentException, UnsupportedOperationException {
- DocumentSelectionConverter converter = new DocumentSelectionConverter("music.expire>music.expire.nowdate");
- assertNull(converter.getQuery("music"));
- assertNull(converter.getInvertedQuery("music"));
- }
-}