summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Christian Seime <bjorn.christian@seime.no>2020-01-16 16:30:58 +0100
committerGitHub <noreply@github.com>2020-01-16 16:30:58 +0100
commitcd5c763a56c5137ee69b485466595af754318d78 (patch)
tree41408d954552b4ae81ba33f59bb44401c76d07e7
parent878b95a5c82a299b5f5b453409c3837b48f7d206 (diff)
Revert "Bratseth/dispatch tuning cleanup"
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilder.java15
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/ContentSearchCluster.java4
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionValidator.java6
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/TuningDispatch.java (renamed from config-model/src/main/java/com/yahoo/vespa/model/content/DispatchTuning.java)29
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java21
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilder.java6
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java3
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/IndexedSearchCluster.java16
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java12
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilderTest.java28
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/DispatchTuningTest.java57
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/TuningDispatchTest.java54
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilderTest.java (renamed from config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomDispatchTuningBuilderTest.java)41
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java7
14 files changed, 171 insertions, 128 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilder.java
index e40cb76ad7e..1b8a5d14e6c 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilder.java
@@ -4,7 +4,6 @@ package com.yahoo.vespa.model.builder.xml.dom;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.text.XML;
import com.yahoo.config.model.producer.AbstractConfigProducer;
-import com.yahoo.vespa.model.content.DispatchTuning;
import com.yahoo.vespa.model.search.Tuning;
import org.w3c.dom.Element;
@@ -19,8 +18,11 @@ public class DomSearchTuningBuilder extends VespaDomBuilder.DomConfigProducerBui
protected Tuning doBuild(DeployState deployState, AbstractConfigProducer parent, Element spec) {
Tuning tuning = new Tuning(parent);
for (Element e : XML.getChildren(spec)) {
- if (equals("searchnode", e))
+ if (equals("dispatch", e)) {
+ handleDispatch(e, tuning);
+ } else if (equals("searchnode", e)) {
handleSearchNode(e, tuning);
+ }
}
return tuning;
}
@@ -45,6 +47,15 @@ public class DomSearchTuningBuilder extends VespaDomBuilder.DomConfigProducerBui
return Double.parseDouble(e.getFirstChild().getNodeValue());
}
+ private void handleDispatch(Element spec, Tuning t) {
+ t.dispatch = new Tuning.Dispatch();
+ for (Element e : XML.getChildren(spec)) {
+ if (equals("max-hits-per-partition", e)) {
+ t.dispatch.maxHitsPerPartition = asInt(e);
+ }
+ }
+ }
+
private void handleSearchNode(Element spec, Tuning t) {
t.searchNode = new Tuning.SearchNode();
for (Element e : XML.getChildren(spec)) {
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 75161859068..cae7ede463d 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
@@ -266,7 +266,9 @@ public class ContentSearchCluster extends AbstractConfigProducer implements Prot
private Tuning tuning;
- public void setTuning(Tuning tuning) { this.tuning = tuning; }
+ public void setTuning(Tuning t) {
+ tuning = t;
+ }
private void setResourceLimits(ResourceLimits resourceLimits) {
this.resourceLimits = Optional.of(resourceLimits);
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionValidator.java
index 909a29fd0a3..56945264789 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionValidator.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/IndexedHierarchicDistributionValidator.java
@@ -15,12 +15,12 @@ public class IndexedHierarchicDistributionValidator {
private final String clusterName;
private final StorageGroup rootGroup;
private final Redundancy redundancy;
- private final DispatchTuning.DispatchPolicy dispatchPolicy;
+ private final TuningDispatch.DispatchPolicy dispatchPolicy;
public IndexedHierarchicDistributionValidator(String clusterName,
StorageGroup rootGroup,
Redundancy redundancy,
- DispatchTuning.DispatchPolicy dispatchPolicy) {
+ TuningDispatch.DispatchPolicy dispatchPolicy) {
this.clusterName = clusterName;
this.rootGroup = rootGroup;
this.redundancy = redundancy;
@@ -46,7 +46,7 @@ public class IndexedHierarchicDistributionValidator {
}
private void validateThatLeafGroupsHasEqualNumberOfNodes() {
- if (dispatchPolicy != DispatchTuning.DispatchPolicy.ROUNDROBIN) return;
+ if (dispatchPolicy != TuningDispatch.DispatchPolicy.ROUNDROBIN) return;
StorageGroup previousGroup = null;
for (StorageGroup group : rootGroup.getSubgroups()) {
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/DispatchTuning.java b/config-model/src/main/java/com/yahoo/vespa/model/content/TuningDispatch.java
index fc470b8e560..9e5a3428726 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/DispatchTuning.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/TuningDispatch.java
@@ -2,14 +2,9 @@
package com.yahoo.vespa.model.content;
/**
- * Tuning of dispatching to content nodes, see the
- * <a href="https://docs.vespa.ai/documentation/reference/services-content.html#dispatch-tuning">dispatch tuning documentation</a>.
- *
* @author Simon Thoresen Hult
*/
-public class DispatchTuning {
-
- public static final DispatchTuning empty = new DispatchTuning.Builder().build();
+public class TuningDispatch {
private final Integer maxHitsPerPartition;
public enum DispatchPolicy { ROUNDROBIN, ADAPTIVE};
@@ -17,24 +12,20 @@ public class DispatchTuning {
private final Double minGroupCoverage;
private final Double minActiveDocsCoverage;
- private DispatchTuning(Builder builder) {
+ private TuningDispatch(Builder builder) {
maxHitsPerPartition = builder.maxHitsPerPartition;
dispatchPolicy = builder.dispatchPolicy;
minGroupCoverage = builder.minGroupCoverage;
minActiveDocsCoverage = builder.minActiveDocsCoverage;
}
- /** Returns the max number of hits to fetch from each partition, or null to fetch all */
- public Integer maxHitsPerPartition() { return maxHitsPerPartition; }
-
- /** Returns the policy used to select which group to dispatch a query to */
- public DispatchPolicy dispatchPolicy() { return dispatchPolicy; }
-
- /** Returns the percentage of nodes in a group which must be up for that group to receive queries */
- public Double minGroupCoverage() { return minGroupCoverage; }
+ public Integer getMaxHitsPerPartition() {
+ return maxHitsPerPartition;
+ }
- /** Returns the percentage of documents which must be available in a group for that group to receive queries */
- public Double minActiveDocsCoverage() { return minActiveDocsCoverage; }
+ public DispatchPolicy getDispatchPolicy() { return dispatchPolicy; }
+ public Double getMinGroupCoverage() { return minGroupCoverage; }
+ public Double getMinActiveDocsCoverage() { return minActiveDocsCoverage; }
public static class Builder {
@@ -43,8 +34,8 @@ public class DispatchTuning {
private Double minGroupCoverage;
private Double minActiveDocsCoverage;
- public DispatchTuning build() {
- return new DispatchTuning(this);
+ public TuningDispatch build() {
+ return new TuningDispatch(this);
}
public Builder setMaxHitsPerPartition(Integer maxHitsPerPartition) {
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 e7a3439e6bb..04e997110a6 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
@@ -46,6 +46,7 @@ import com.yahoo.vespa.model.content.Redundancy;
import com.yahoo.vespa.model.content.ReservedDocumentTypeNameValidator;
import com.yahoo.vespa.model.content.StorageGroup;
import com.yahoo.vespa.model.content.StorageNode;
+import com.yahoo.vespa.model.content.TuningDispatch;
import com.yahoo.vespa.model.content.engines.PersistenceEngine;
import com.yahoo.vespa.model.content.engines.ProtonEngine;
import com.yahoo.vespa.model.content.storagecluster.StorageCluster;
@@ -171,18 +172,30 @@ public class ContentCluster extends AbstractConfigProducer implements
Double queryTimeout = search.getQueryTimeout();
if (queryTimeout != null) {
Preconditions.checkState(index.getQueryTimeout() == null,
- "In " + index + ": You may not specify query-timeout in both proton and content.");
+ "You may not specify query-timeout in both proton and content.");
index.setQueryTimeout(queryTimeout);
}
Double visibilityDelay = search.getVisibilityDelay();
- if (visibilityDelay != null)
+ if (visibilityDelay != null) {
index.setVisibilityDelay(visibilityDelay);
+ }
index.setSearchCoverage(DomSearchCoverageBuilder.build(element));
index.setDispatchSpec(DomDispatchBuilder.build(element));
+ // TODO: This should be cleaned up to avoid having to change code in 100 places
+ // every time we add a dispatch option.
+ TuningDispatch tuningDispatch = DomTuningDispatchBuilder.build(element, logger);
+ Integer maxHitsPerPartition = tuningDispatch.getMaxHitsPerPartition();
+
if (index.getTuning() == null)
index.setTuning(new Tuning(index));
- index.getTuning().dispatch = DomTuningDispatchBuilder.build(element, logger);
+ if (index.getTuning().dispatch == null)
+ index.getTuning().dispatch = new Tuning.Dispatch();
+ if (maxHitsPerPartition != null)
+ index.getTuning().dispatch.maxHitsPerPartition = maxHitsPerPartition;
+ index.getTuning().dispatch.minGroupCoverage = tuningDispatch.getMinGroupCoverage();
+ index.getTuning().dispatch.minActiveDocsCoverage = tuningDispatch.getMinActiveDocsCoverage();
+ index.getTuning().dispatch.policy = tuningDispatch.getDispatchPolicy();
}
private void setupDocumentProcessing(ContentCluster c, ModelElement e) {
@@ -637,7 +650,7 @@ public class ContentCluster extends AbstractConfigProducer implements
super.validate();
if (search.usesHierarchicDistribution() && !isHosted) {
// validate manually configured groups
- new IndexedHierarchicDistributionValidator(search.getClusterName(), rootGroup, redundancy, search.getIndexed().getTuning().dispatch.dispatchPolicy()).validate();
+ new IndexedHierarchicDistributionValidator(search.getClusterName(), rootGroup, redundancy, search.getIndexed().getTuning().dispatch.policy).validate();
}
new ReservedDocumentTypeNameValidator().validate(documentDefinitions);
new GlobalDistributionValidator().validate(documentDefinitions, globallyDistributedDocuments);
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilder.java
index b53d66632a8..536793e848f 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilder.java
@@ -2,7 +2,7 @@
package com.yahoo.vespa.model.content.cluster;
import com.yahoo.config.application.api.DeployLogger;
-import com.yahoo.vespa.model.content.DispatchTuning;
+import com.yahoo.vespa.model.content.TuningDispatch;
import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
import java.util.logging.Level;
@@ -12,8 +12,8 @@ import java.util.logging.Level;
*/
public class DomTuningDispatchBuilder {
- public static DispatchTuning build(ModelElement contentXml, DeployLogger logger) {
- DispatchTuning.Builder builder = new DispatchTuning.Builder();
+ public static TuningDispatch build(ModelElement contentXml, DeployLogger logger) {
+ TuningDispatch.Builder builder = new TuningDispatch.Builder();
ModelElement tuningElement = contentXml.child("tuning");
if (tuningElement == null) {
return builder.build();
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java
index 8a88e720bed..85663a59556 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/AbstractSearchCluster.java
@@ -86,9 +86,6 @@ public abstract class AbstractSearchCluster extends AbstractConfigProducer
public abstract void getConfig(RankProfilesConfig.Builder builder);
public abstract void getConfig(AttributesConfig.Builder builder);
- @Override
- public String toString() { return "search-capable cluster '" + clusterName + "'"; }
-
public static final class IndexingMode {
public static final IndexingMode REALTIME = new IndexingMode("REALTIME");
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 78cdb53871d..53b4d085351 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
@@ -307,12 +307,12 @@ public class IndexedSearchCluster extends SearchCluster
if (useAdaptiveDispatch)
builder.distributionPolicy(DistributionPolicy.ADAPTIVE);
- if (tuning.dispatch.minActiveDocsCoverage() != null)
- builder.minActivedocsPercentage(tuning.dispatch.minActiveDocsCoverage());
- if (tuning.dispatch.minGroupCoverage() != null)
- builder.minGroupCoverage(tuning.dispatch.minGroupCoverage());
- if (tuning.dispatch.dispatchPolicy() != null) {
- switch (tuning.dispatch.dispatchPolicy()) {
+ if (tuning.dispatch.minActiveDocsCoverage != null)
+ builder.minActivedocsPercentage(tuning.dispatch.minActiveDocsCoverage);
+ if (tuning.dispatch.minGroupCoverage != null)
+ builder.minGroupCoverage(tuning.dispatch.minGroupCoverage);
+ if (tuning.dispatch.policy != null) {
+ switch (tuning.dispatch.policy) {
case ADAPTIVE:
builder.distributionPolicy(DistributionPolicy.ADAPTIVE);
break;
@@ -321,8 +321,8 @@ public class IndexedSearchCluster extends SearchCluster
break;
}
}
- if (tuning.dispatch.maxHitsPerPartition() != null)
- builder.maxHitsPerNode(tuning.dispatch.maxHitsPerPartition());
+ if (tuning.dispatch.maxHitsPerPartition != null)
+ builder.maxHitsPerNode(tuning.dispatch.maxHitsPerPartition);
builder.maxNodesDownPerGroup(rootDispatch.getMaxNodesDownPerFixedRow());
builder.searchableCopies(rootDispatch.getSearchableCopies());
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java b/config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java
index f5a91297e9e..95498a2a902 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/search/Tuning.java
@@ -3,7 +3,7 @@ package com.yahoo.vespa.model.search;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.vespa.config.search.core.ProtonConfig;
-import com.yahoo.vespa.model.content.DispatchTuning;
+import com.yahoo.vespa.model.content.TuningDispatch;
import static com.yahoo.text.Lowercase.toLowerCase;
@@ -15,6 +15,14 @@ import static com.yahoo.text.Lowercase.toLowerCase;
*/
public class Tuning extends AbstractConfigProducer implements ProtonConfig.Producer {
+ public static class Dispatch {
+
+ public Integer maxHitsPerPartition = null;
+ public TuningDispatch.DispatchPolicy policy = null;
+ public Double minGroupCoverage = null;
+ public Double minActiveDocsCoverage = null;
+ }
+
public static class SearchNode implements ProtonConfig.Producer {
public enum IoType {
@@ -382,7 +390,7 @@ public class Tuning extends AbstractConfigProducer implements ProtonConfig.Produ
}
}
- public DispatchTuning dispatch = DispatchTuning.empty;
+ public Dispatch dispatch;
public SearchNode searchNode;
public Tuning(AbstractConfigProducer parent) {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilderTest.java
index 060fff5bf66..b39e503f837 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/builder/xml/dom/DomSearchTuningBuilderTest.java
@@ -4,7 +4,6 @@ package com.yahoo.vespa.model.builder.xml.dom;
import com.yahoo.collections.CollectionUtil;
import com.yahoo.vespa.config.search.core.ProtonConfig;
import com.yahoo.config.model.builder.xml.test.DomBuilderTest;
-import com.yahoo.vespa.model.content.DispatchTuning;
import com.yahoo.vespa.model.search.Tuning;
import org.junit.Test;
import org.w3c.dom.Element;
@@ -47,6 +46,33 @@ public class DomSearchTuningBuilderTest extends DomBuilderTest {
}
@Test
+ public void requireThatNullDispatchIsSafe() {
+ Tuning tuning = newTuning("<tuning />");
+ assertNull(tuning.dispatch);
+ }
+
+ @Test
+ public void requireThatEmptyDispatchIsSafe() {
+ Tuning tuning = newTuning("<tuning><dispatch/></tuning>");
+ Tuning.Dispatch dispatch = tuning.dispatch;
+ assertNotNull(dispatch);
+ assertNull(dispatch.maxHitsPerPartition);
+ }
+
+ @Test
+ public void requireThatDispatchSettingsAreParsed() {
+ Tuning tuning = createTuning(parse("<tuning>" +
+ " <dispatch>" +
+ " <max-hits-per-partition>69</max-hits-per-partition>" +
+ " </dispatch>" +
+ "</tuning>"));
+ Tuning.Dispatch dispatch = tuning.dispatch;
+ assertNotNull(dispatch);
+ assertNotNull(dispatch.maxHitsPerPartition);
+ assertEquals(69, dispatch.maxHitsPerPartition.intValue());
+ }
+
+ @Test
public void requireThatWeCanParseRequestThreadsTag() {
Tuning t = createTuning(parseXml("<requestthreads>",
"<search>123</search>",
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/DispatchTuningTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/DispatchTuningTest.java
deleted file mode 100644
index 4d71e0ef568..00000000000
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/DispatchTuningTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.model.content;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Simon Thoresen Hult
- */
-public class DispatchTuningTest {
-
- @Test
- public void requireThatAccessorWork() {
- DispatchTuning dispatch = new DispatchTuning.Builder()
- .setMaxHitsPerPartition(69)
- .setDispatchPolicy("round-robin")
- .setMinGroupCoverage(7.5)
- .setMinActiveDocsCoverage(12.5)
- .build();
- assertEquals(69, dispatch.maxHitsPerPartition().intValue());
- assertEquals(7.5, dispatch.minGroupCoverage().doubleValue(), 0.0);
- assertEquals(12.5, dispatch.minActiveDocsCoverage().doubleValue(), 0.0);
- assertTrue(DispatchTuning.DispatchPolicy.ROUNDROBIN == dispatch.dispatchPolicy());
- }
- @Test
- public void requireThatRandomDispatchWork() {
- DispatchTuning dispatch = new DispatchTuning.Builder()
- .setDispatchPolicy("random")
- .build();
- assertTrue(DispatchTuning.DispatchPolicy.ADAPTIVE == dispatch.dispatchPolicy());
- assertNull(dispatch.minGroupCoverage());
- assertNull(dispatch.minActiveDocsCoverage());
- }
-
- @Test
- public void requireThatWeightedDispatchWork() {
- DispatchTuning dispatch = new DispatchTuning.Builder()
- .setDispatchPolicy("adaptive")
- .build();
- assertTrue(DispatchTuning.DispatchPolicy.ADAPTIVE == dispatch.dispatchPolicy());
- assertNull(dispatch.minGroupCoverage());
- assertNull(dispatch.minActiveDocsCoverage());
- }
-
- @Test
- public void requireThatDefaultsAreNull() {
- DispatchTuning dispatch = new DispatchTuning.Builder().build();
- assertNull(dispatch.maxHitsPerPartition());
- assertNull(dispatch.dispatchPolicy());
- assertNull(dispatch.minActiveDocsCoverage());
- assertNull(dispatch.minGroupCoverage());
- }
-
-}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/TuningDispatchTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/TuningDispatchTest.java
new file mode 100644
index 00000000000..fe00648317a
--- /dev/null
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/TuningDispatchTest.java
@@ -0,0 +1,54 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.model.content;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Simon Thoresen Hult
+ */
+public class TuningDispatchTest {
+
+ @Test
+ public void requireThatAccessorWork() {
+ TuningDispatch dispatch = new TuningDispatch.Builder()
+ .setMaxHitsPerPartition(69)
+ .setDispatchPolicy("round-robin")
+ .setMinGroupCoverage(7.5)
+ .setMinActiveDocsCoverage(12.5)
+ .build();
+ assertEquals(69, dispatch.getMaxHitsPerPartition().intValue());
+ assertEquals(7.5, dispatch.getMinGroupCoverage().doubleValue(), 0.0);
+ assertEquals(12.5, dispatch.getMinActiveDocsCoverage().doubleValue(), 0.0);
+ assertTrue(TuningDispatch.DispatchPolicy.ROUNDROBIN == dispatch.getDispatchPolicy());
+ }
+ @Test
+ public void requireThatRandomDispatchWork() {
+ TuningDispatch dispatch = new TuningDispatch.Builder()
+ .setDispatchPolicy("random")
+ .build();
+ assertTrue(TuningDispatch.DispatchPolicy.ADAPTIVE == dispatch.getDispatchPolicy());
+ assertNull(dispatch.getMinGroupCoverage());
+ assertNull(dispatch.getMinActiveDocsCoverage());
+ }
+
+ @Test
+ public void requireThatWeightedDispatchWork() {
+ TuningDispatch dispatch = new TuningDispatch.Builder()
+ .setDispatchPolicy("adaptive")
+ .build();
+ assertTrue(TuningDispatch.DispatchPolicy.ADAPTIVE == dispatch.getDispatchPolicy());
+ assertNull(dispatch.getMinGroupCoverage());
+ assertNull(dispatch.getMinActiveDocsCoverage());
+ }
+
+ @Test
+ public void requireThatDefaultsAreNull() {
+ TuningDispatch dispatch = new TuningDispatch.Builder().build();
+ assertNull(dispatch.getMaxHitsPerPartition());
+ assertNull(dispatch.getDispatchPolicy());
+ }
+}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomDispatchTuningBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilderTest.java
index 3f3d4b5e4c1..0c7c16c15c7 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomDispatchTuningBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilderTest.java
@@ -1,8 +1,9 @@
// Copyright 2017 Yahoo Holdings. 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.config.application.api.DeployLogger;
import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
-import com.yahoo.vespa.model.content.DispatchTuning;
+import com.yahoo.vespa.model.content.TuningDispatch;
import com.yahoo.vespa.model.test.utils.DeployLoggerStub;
import org.junit.Test;
@@ -17,41 +18,41 @@ import static org.junit.Assert.assertTrue;
/**
* @author Simon Thoresen Hult
*/
-public class DomDispatchTuningBuilderTest {
+public class DomTuningDispatchBuilderTest {
@Test
public void requireThatDefaultsAreNull() throws Exception {
- DispatchTuning dispatch = newTuningDispatch(
+ TuningDispatch dispatch = newTuningDispatch(
"<content/>");
- assertNull(dispatch.maxHitsPerPartition());
+ assertNull(dispatch.getMaxHitsPerPartition());
}
@Test
public void requireThatEmptyTuningIsSafe() throws Exception {
- DispatchTuning dispatch = newTuningDispatch(
+ TuningDispatch dispatch = newTuningDispatch(
"<content>" +
" <tuning/>" +
"</content>");
- assertNull(dispatch.maxHitsPerPartition());
+ assertNull(dispatch.getMaxHitsPerPartition());
}
@Test
public void requireThatEmptydispatchIsSafe() throws Exception {
- DispatchTuning dispatch = newTuningDispatch(
+ TuningDispatch dispatch = newTuningDispatch(
"<content>" +
" <tuning>" +
" <dispatch/>" +
" </tuning>" +
"</content>");
- assertNull(dispatch.maxHitsPerPartition());
- assertNull(dispatch.minGroupCoverage());
- assertNull(dispatch.minActiveDocsCoverage());
- assertNull(dispatch.dispatchPolicy());
+ assertNull(dispatch.getMaxHitsPerPartition());
+ assertNull(dispatch.getMinGroupCoverage());
+ assertNull(dispatch.getMinActiveDocsCoverage());
+ assertNull(dispatch.getDispatchPolicy());
}
@Test
public void requireThatTuningDispatchCanBeBuilt() throws Exception {
- DispatchTuning dispatch = newTuningDispatch(
+ TuningDispatch dispatch = newTuningDispatch(
"<content>" +
" <tuning>" +
" <dispatch>" +
@@ -61,13 +62,13 @@ public class DomDispatchTuningBuilderTest {
" </dispatch>" +
" </tuning>" +
"</content>");
- assertEquals(69, dispatch.maxHitsPerPartition().intValue());
- assertEquals(7.5, dispatch.minGroupCoverage().doubleValue(), 0.0);
- assertEquals(12.5, dispatch.minActiveDocsCoverage().doubleValue(), 0.0);
+ assertEquals(69, dispatch.getMaxHitsPerPartition().intValue());
+ assertEquals(7.5, dispatch.getMinGroupCoverage().doubleValue(), 0.0);
+ assertEquals(12.5, dispatch.getMinActiveDocsCoverage().doubleValue(), 0.0);
}
@Test
public void requireThatTuningDispatchPolicyRoundRobin() throws Exception {
- DispatchTuning dispatch = newTuningDispatch(
+ TuningDispatch dispatch = newTuningDispatch(
"<content>" +
" <tuning>" +
" <dispatch>" +
@@ -75,11 +76,11 @@ public class DomDispatchTuningBuilderTest {
" </dispatch>" +
" </tuning>" +
"</content>");
- assertTrue(DispatchTuning.DispatchPolicy.ROUNDROBIN == dispatch.dispatchPolicy());
+ assertTrue(TuningDispatch.DispatchPolicy.ROUNDROBIN == dispatch.getDispatchPolicy());
}
@Test
public void requireThatTuningDispatchPolicyRandom() throws Exception {
- DispatchTuning dispatch = newTuningDispatch(
+ TuningDispatch dispatch = newTuningDispatch(
"<content>" +
" <tuning>" +
" <dispatch>" +
@@ -87,10 +88,10 @@ public class DomDispatchTuningBuilderTest {
" </dispatch>" +
" </tuning>" +
"</content>");
- assertTrue(DispatchTuning.DispatchPolicy.ADAPTIVE == dispatch.dispatchPolicy());
+ assertTrue(TuningDispatch.DispatchPolicy.ADAPTIVE == dispatch.getDispatchPolicy());
}
- private static DispatchTuning newTuningDispatch(String xml) throws Exception {
+ private static TuningDispatch newTuningDispatch(String xml) throws Exception {
return DomTuningDispatchBuilder.build(
new ModelElement(DocumentBuilderFactory.newInstance()
.newDocumentBuilder()
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java
index 2f70c37cd48..09ad715b471 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java
@@ -82,10 +82,7 @@ public class Node {
}
@Override
- public String toString() {
- return "search node key = " + key + " hostname = "+ hostname + " path = " + pathIndex + " in group " + group +
- " statusIsKnown = " + statusIsKnown.get() + " working = " + working.get() +
- " activeDocs = " + activeDocuments.get();
- }
+ public String toString() { return "search node key = " + key + " hostname = "+ hostname + " path = " + pathIndex + " in group " + group +
+ " statusIsKnown = " + statusIsKnown.get() + " working = " + working.get() + " activeDocs = " + activeDocuments.get(); }
}