summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-01-23 16:13:24 +0100
committerGitHub <noreply@github.com>2023-01-23 16:13:24 +0100
commitf565ca152ded07eb1e6930b9e681ca462f3ff9cf (patch)
treeee1eac3ea6d69accdc07649a8f8df06eb2542449
parent2ac26e289ee124ae909efd820bb37e67796ed948 (diff)
parent16afc501e508f0b91039c278a216f5824629bd2b (diff)
Merge pull request #25683 from vespa-engine/bratseth/searchable-copies-defaults
Correct default searchable-copies with redundancy 1
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/Redundancy.java3
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/cluster/RedundancyBuilder.java10
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java29
3 files changed, 39 insertions, 3 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/Redundancy.java b/config-model/src/main/java/com/yahoo/vespa/model/content/Redundancy.java
index 55d1cfbfad5..616dcbbc760 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/Redundancy.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/Redundancy.java
@@ -22,6 +22,9 @@ public class Redundancy implements StorDistributionConfig.Producer, ProtonConfig
private final int totalNodes;
public Redundancy(Integer initialRedundancy, int finalRedundancy, int readyCopies, int groups, int totalNodes) {
+ if (readyCopies > finalRedundancy)
+ throw new IllegalArgumentException("Number of searchable copies (" + readyCopies +
+ ") can not be higher than final redundancy (" + finalRedundancy + ")");
this.initialRedundancy = initialRedundancy != null ? initialRedundancy : finalRedundancy;
this.finalRedundancy = finalRedundancy;
this.readyCopies = readyCopies;
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/RedundancyBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/RedundancyBuilder.java
index 52966c45e75..464937156a2 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/RedundancyBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/RedundancyBuilder.java
@@ -51,14 +51,18 @@ public class RedundancyBuilder {
if (isHosted) {
if (globalMinRedundancy != null && ( finalRedundancy == null || finalRedundancy * leafGroups < globalMinRedundancy ))
initialRedundancy = finalRedundancy = (int)Math.ceil((double)globalMinRedundancy / leafGroups);
- if (readyCopies == null)
- readyCopies = leafGroups > 1 ? 1 : 2;
+ if (readyCopies == null) {
+ if (leafGroups > 1)
+ readyCopies = 1;
+ else
+ readyCopies = finalRedundancy > 1 ? 2 : 1;
+ }
return new Redundancy(initialRedundancy, finalRedundancy, readyCopies, leafGroups, totalNodes);
} else {
if (globalMinRedundancy != null && ( finalRedundancy == null || finalRedundancy < globalMinRedundancy))
initialRedundancy = finalRedundancy = globalMinRedundancy;
if (readyCopies == null)
- readyCopies = 2;
+ readyCopies = finalRedundancy > 1 ? 2 : 1;
subGroups = Math.max(1, subGroups);
IndexedHierarchicDistributionValidator.validateThatLeafGroupsCountIsAFactorOfRedundancy(finalRedundancy, subGroups);
IndexedHierarchicDistributionValidator.validateThatReadyCopiesIsCompatibleWithRedundancy(finalRedundancy, readyCopies, subGroups);
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 4b6128ecc14..720ff1cebf0 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
@@ -1928,6 +1928,35 @@ public class ModelProvisioningTest {
assertEquals(2, protonConfig.distribution().redundancy());
}
+ @Test
+ public void testRedundancy1() {
+ String services =
+ "<?xml version='1.0' encoding='utf-8' ?>" +
+ "<services>" +
+ " <container version='1.0' id='container1'>" +
+ " <nodes count='1'/>" +
+ " </container>" +
+ " <content version='1.0'>" +
+ " <min-redundancy>1</min-redundancy>" +
+ " <documents>" +
+ " <document type='type1' mode='index'/>" +
+ " </documents>" +
+ " <nodes count='2' groups='1'/>" +
+ " </content>" +
+ "</services>";
+ VespaModelTester tester = new VespaModelTester();
+ tester.setHosted(true);
+ tester.addHosts(6);
+ VespaModel model = tester.createModel(services, true);
+
+ var contentCluster = model.getContentClusters().get("content");
+ ProtonConfig.Builder protonBuilder = new ProtonConfig.Builder();
+ contentCluster.getSearch().getConfig(protonBuilder);
+ ProtonConfig protonConfig = new ProtonConfig(protonBuilder);
+ assertEquals(1, protonConfig.distribution().searchablecopies());
+ assertEquals(1, protonConfig.distribution().redundancy());
+ }
+
/**
* Deploying an application with "nodes count" standalone should give a single-node deployment,
* also if the user has a lingering hosts file from running self-hosted.