summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2023-07-04 00:28:03 +0200
committerHarald Musum <musum@yahooinc.com>2023-07-04 00:28:03 +0200
commit8c01cbbd641514e3654f7031fb300d932b8da760 (patch)
treeb2d44cc5ed0612db6a8582b236a3e8ac9d55e2f9 /config-model
parent86bd836d889e6648f459701fe8fec7e5a364afd6 (diff)
Warn if dispatch config is used in services.xml
Log a warning, add deprecation TODOs and removed code only used in tests
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/DispatchSpec.java82
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java6
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/cluster/DomDispatchBuilder.java53
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/DispatchGroupBuilder.java39
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java21
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/MultilevelDispatchValidator.java89
-rw-r--r--config-model/src/main/resources/schema/content.rnc1
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java4
8 files changed, 9 insertions, 286 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/DispatchSpec.java b/config-model/src/main/java/com/yahoo/vespa/model/content/DispatchSpec.java
deleted file mode 100644
index 69557e1a974..00000000000
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/DispatchSpec.java
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.model.content;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Represents the dispatch setup for a content cluster.
- * This EITHER has a number of dispatch groups OR a an explicit list of groups.
- *
- * @author geirst
- */
-public class DispatchSpec {
-
- private final Integer numDispatchGroups;
- private final List<Group> groups;
-
- private DispatchSpec(Builder builder) {
- numDispatchGroups = builder.numDispatchGroups;
- groups = builder.groups;
- }
-
- public Integer getNumDispatchGroups() { return numDispatchGroups; }
-
- public List<Group> getGroups() {
- return groups;
- }
-
- public boolean valid() {
- return numDispatchGroups != null || groups != null;
- }
-
- /**
- * Reference to a node which is contained in a dispatch group.
- */
- public static class Node {
- private final int distributionKey;
- public Node(int distributionKey) {
- this.distributionKey = distributionKey;
- }
- public int getDistributionKey() {
- return distributionKey;
- }
- }
-
- /**
- * A dispatch group with a list of nodes contained in that group.
- */
- public static class Group {
- private final List<Node> nodes = new ArrayList<>();
- public Group() {
-
- }
- public Group addNode(Node node) {
- nodes.add(node);
- return this;
- }
- public List<Node> getNodes() {
- return nodes;
- }
- }
-
- public static class Builder {
-
- private Integer numDispatchGroups;
- private List<Group> groups;
-
- public DispatchSpec build() {
- return new DispatchSpec(this);
- }
-
- public Builder setNumDispatchGroups(Integer numDispatchGroups) {
- this.numDispatchGroups = numDispatchGroups;
- return this;
- }
-
- public Builder setGroups(List<Group> groups) {
- this.groups = groups;
- return this;
- }
- }
-}
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 f792ac3a591..f2d55b4d49f 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
@@ -64,6 +64,8 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.logging.Level;
+import static java.util.logging.Level.WARNING;
+
/**
* A content cluster.
*
@@ -190,7 +192,9 @@ public class ContentCluster extends TreeConfigProducer<AnyConfigProducer> implem
index.setQueryTimeout(queryTimeout);
}
index.setSearchCoverage(DomSearchCoverageBuilder.build(element));
- index.setDispatchSpec(DomDispatchBuilder.build(element));
+ if (element.child("dispatch") != null)
+ logger.logApplicationPackage(WARNING, "The <dispatch> element is deprecated and ignored and will be removed in the next major release. "
+ + " See https://docs.vespa.ai/en/reference/services-content.html#dispatch for details.");
if (index.getTuning() == null)
index.setTuning(new Tuning(index));
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/DomDispatchBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/DomDispatchBuilder.java
deleted file mode 100644
index 57da49fa351..00000000000
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/DomDispatchBuilder.java
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.model.content.cluster;
-
-
-import com.yahoo.vespa.model.content.DispatchSpec;
-import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Builder for the dispatch setup for a content cluster.
- *
- * @author geirst
- */
-public class DomDispatchBuilder {
-
- public static DispatchSpec build(ModelElement contentXml) {
- DispatchSpec.Builder builder = new DispatchSpec.Builder();
- ModelElement dispatchElement = contentXml.child("dispatch");
- if (dispatchElement == null) {
- return builder.build();
- }
- builder.setNumDispatchGroups(dispatchElement.childAsInteger("num-dispatch-groups"));
-
- List<ModelElement> groupsElement = dispatchElement.subElements("group");
- if (groupsElement != null) {
- builder.setGroups(buildGroups(groupsElement));
- }
- return builder.build();
- }
-
- private static List<DispatchSpec.Group> buildGroups(List<ModelElement> groupsElement) {
- List<DispatchSpec.Group> groups = new ArrayList<>();
- for (ModelElement groupElement : groupsElement) {
- groups.add(buildGroup(groupElement));
- }
- return groups;
- }
-
- private static DispatchSpec.Group buildGroup(ModelElement groupElement) {
- List<ModelElement> nodes = groupElement.subElements("node");
- DispatchSpec.Group group = new DispatchSpec.Group();
- for (ModelElement nodeElement : nodes) {
- group.addNode(buildNode(nodeElement));
- }
- return group;
- }
-
- private static DispatchSpec.Node buildNode(ModelElement nodeElement) {
- return new DispatchSpec.Node(nodeElement.integerAttribute("distribution-key"));
- }
-}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/DispatchGroupBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/search/DispatchGroupBuilder.java
deleted file mode 100644
index f1676da2491..00000000000
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/DispatchGroupBuilder.java
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright Yahoo. 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.vespa.model.content.DispatchSpec;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Class used to build the mid-level dispatch groups in an indexed content cluster.
- *
- * @author geirst
- */
-public class DispatchGroupBuilder {
-
- public static List<DispatchSpec.Group> createDispatchGroups(List<SearchNode> searchNodes,
- int numDispatchGroups) {
- if (numDispatchGroups > searchNodes.size())
- numDispatchGroups = searchNodes.size();
-
- List<DispatchSpec.Group> groupsSpec = new ArrayList<>();
- int numNodesPerGroup = searchNodes.size() / numDispatchGroups;
- if (searchNodes.size() % numDispatchGroups != 0) {
- numNodesPerGroup += 1;
- }
- int searchNodeIdx = 0;
- for (int i = 0; i < numDispatchGroups; ++i) {
- DispatchSpec.Group groupSpec = new DispatchSpec.Group();
- for (int j = 0; j < numNodesPerGroup && searchNodeIdx < searchNodes.size(); ++j) {
- groupSpec.addNode(new DispatchSpec.Node(searchNodes.get(searchNodeIdx++).getDistributionKey()));
- }
- groupsSpec.add(groupSpec);
- }
- assert(searchNodeIdx == searchNodes.size());
- return groupsSpec;
- }
-
-}
-
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 960850def1f..a71e72c0ef8 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
@@ -7,11 +7,11 @@ import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.config.model.producer.AnyConfigProducer;
import com.yahoo.config.model.producer.TreeConfigProducer;
import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
-import com.yahoo.search.config.IndexInfoConfig;
-import com.yahoo.search.config.SchemaInfoConfig;
import com.yahoo.schema.DocumentOnlySchema;
import com.yahoo.schema.derived.DerivedConfiguration;
import com.yahoo.schema.derived.SchemaInfo;
+import com.yahoo.search.config.IndexInfoConfig;
+import com.yahoo.search.config.SchemaInfoConfig;
import com.yahoo.vespa.config.search.AttributesConfig;
import com.yahoo.vespa.config.search.DispatchConfig;
import com.yahoo.vespa.config.search.DispatchConfig.DistributionPolicy;
@@ -19,8 +19,6 @@ import com.yahoo.vespa.config.search.DispatchNodesConfig;
import com.yahoo.vespa.config.search.RankProfilesConfig;
import com.yahoo.vespa.config.search.core.ProtonConfig;
import com.yahoo.vespa.configdefinition.IlscriptsConfig;
-import com.yahoo.vespa.model.container.docproc.DocprocChain;
-import com.yahoo.vespa.model.content.DispatchSpec;
import com.yahoo.vespa.model.content.DispatchTuning;
import com.yahoo.vespa.model.content.SearchCoverage;
@@ -56,7 +54,6 @@ public class IndexedSearchCluster extends SearchCluster
private int redundancy = 1;
private final DispatchGroup rootDispatch;
- private DispatchSpec dispatchSpec;
private final List<SearchNode> searchNodes = new ArrayList<>();
private final DispatchTuning.DispatchPolicy defaultDispatchPolicy;
private final double dispatchWarmup;
@@ -226,20 +223,6 @@ public class IndexedSearchCluster extends SearchCluster
this.redundancy = redundancy;
}
- public void setDispatchSpec(DispatchSpec dispatchSpec) {
- if (dispatchSpec.getNumDispatchGroups() != null) {
- this.dispatchSpec = new DispatchSpec.Builder().setGroups
- (DispatchGroupBuilder.createDispatchGroups(getSearchNodes(),
- dispatchSpec.getNumDispatchGroups())).build();
- } else {
- this.dispatchSpec = dispatchSpec;
- }
- }
-
- public DispatchSpec getDispatchSpec() {
- return dispatchSpec;
- }
-
private static DistributionPolicy.Enum toDistributionPolicy(DispatchTuning.DispatchPolicy tuning) {
return switch (tuning) {
case ADAPTIVE: yield DistributionPolicy.ADAPTIVE;
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/MultilevelDispatchValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/search/MultilevelDispatchValidator.java
deleted file mode 100644
index 666fd77226b..00000000000
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/MultilevelDispatchValidator.java
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright Yahoo. 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.vespa.model.content.DispatchSpec;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Class used to validate that multilevel dispatch is correctly setup in an indexed content cluster.
- *
- * @author geirst
- */
-public class MultilevelDispatchValidator {
-
- private final String clusterName;
- private final DispatchSpec dispatchSpec;
- private final List<SearchNode> searchNodes;
-
- public MultilevelDispatchValidator(String clusterName,
- DispatchSpec dispatchSpec,
- List<SearchNode> searchNodes) {
- this.clusterName = clusterName;
- this.dispatchSpec = dispatchSpec;
- this.searchNodes = searchNodes;
- }
-
- public void validate() {
- validateThatWeReferenceNodesOnlyOnce();
- validateThatWeReferenceAllNodes();
- validateThatWeUseValidNodeReferences();
- }
-
- private void validateThatWeReferenceNodesOnlyOnce() {
- Set<Integer> distKeys = new HashSet<>();
- for (DispatchSpec.Group group : dispatchSpec.getGroups()) {
- for (DispatchSpec.Node node : group.getNodes()) {
- int distKey = node.getDistributionKey();
- if (distKeys.contains(distKey)) {
- throw new IllegalArgumentException(getErrorMsgPrefix() + "Expected nodes to be referenced only once in dispatch groups, but node with distribution key '" + distKey + "' is referenced multiple times.");
- }
- distKeys.add(distKey);
- }
- }
- }
-
- private void validateThatWeReferenceAllNodes() {
- Set<Integer> distKeys = createDistributionKeysSet();
- for (DispatchSpec.Group group : dispatchSpec.getGroups()) {
- for (DispatchSpec.Node node : group.getNodes()) {
- distKeys.remove(node.getDistributionKey());
- }
- }
- if (!distKeys.isEmpty()) {
- Object[] sorted = distKeys.toArray();
- Arrays.sort(sorted);
- throw new IllegalArgumentException(getErrorMsgPrefix() + "Expected all nodes to be referenced in dispatch groups, but " + distKeys.size() +
- " node(s) with distribution keys " + Arrays.toString(sorted) + " are not referenced.");
- }
- }
-
- private void validateThatWeUseValidNodeReferences() {
- Set<Integer> distKeys = createDistributionKeysSet();
- for (DispatchSpec.Group group : dispatchSpec.getGroups()) {
- for (DispatchSpec.Node node : group.getNodes()) {
- int distKey = node.getDistributionKey();
- if (!distKeys.contains(distKey)) {
- throw new IllegalArgumentException(getErrorMsgPrefix() + "Expected all node references in dispatch groups to reference existing nodes, " +
- "but node with distribution key '" + distKey + "' does not exists.");
- }
- }
- }
- }
-
- private Set<Integer> createDistributionKeysSet() {
- Set<Integer> distKeys = new HashSet<>();
- for (SearchNode node : searchNodes) {
- distKeys.add(node.getDistributionKey());
- }
- return distKeys;
- }
-
- private String getErrorMsgPrefix() {
- return "In indexed content cluster '" + clusterName + "': ";
- }
-
-}
diff --git a/config-model/src/main/resources/schema/content.rnc b/config-model/src/main/resources/schema/content.rnc
index a73236454c6..4d8b44f3fc1 100644
--- a/config-model/src/main/resources/schema/content.rnc
+++ b/config-model/src/main/resources/schema/content.rnc
@@ -144,6 +144,7 @@ SearchCoverage = element coverage {
element max-wait-after-coverage-factor { xsd:double { minInclusive = "0" maxInclusive = "1" } }?
}
+# TODO: Deprecated, remove in Vespa 9
Dispatch = element dispatch {
element num-dispatch-groups { xsd:nonNegativeInteger }? &
DispatchGroup*
diff --git a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
index 19fe9e0038d..7273053db5c 100644
--- a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
@@ -1313,7 +1313,7 @@ public class ModelProvisioningTest {
" </documents>" +
" <nodes count='24'/>" +
" <engine><proton><searchable-copies>5</searchable-copies></proton></engine>" +
- " <dispatch><num-dispatch-groups>7</num-dispatch-groups></dispatch>" +
+ " <dispatch><num-dispatch-groups>7</num-dispatch-groups></dispatch>" + // TODO: Allowed, but ignored, remove in Vespa 9
" </content>" +
"</services>";
@@ -1327,7 +1327,6 @@ public class ModelProvisioningTest {
assertEquals(4, cluster.getRedundancy().effectiveInitialRedundancy());
assertEquals(4, cluster.getRedundancy().effectiveFinalRedundancy());
assertEquals(4, cluster.getRedundancy().effectiveReadyCopies());
- assertEquals(4, cluster.getSearch().getIndexed().getDispatchSpec().getGroups().size());
assertEquals(4, cluster.getSearch().getIndexed().getSearchableCopies());
assertFalse(cluster.getRootGroup().getPartitions().isPresent());
assertEquals(4, cluster.getRootGroup().getNodes().size());
@@ -1477,7 +1476,6 @@ public class ModelProvisioningTest {
assertEquals(1, cluster.getRedundancy().effectiveFinalRedundancy());
assertEquals(1, cluster.getRedundancy().effectiveReadyCopies());
- assertEquals(1, cluster.getSearch().getIndexed().getDispatchSpec().getGroups().size());
assertFalse(cluster.getRootGroup().getPartitions().isPresent());
assertEquals(1, cluster.getRootGroup().getNodes().size());
assertEquals(0, cluster.getRootGroup().getSubgroups().size());