diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-02-01 17:04:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-01 17:04:44 +0100 |
commit | dabedc23155a0fe2598b9ae9482987a554341b3d (patch) | |
tree | 814433e99b2b521f38fbbacc1e68bb7f51eeff38 /config-model | |
parent | 66de2d3c4648028d445263ec4936083809e812d7 (diff) | |
parent | 3169f307a6c23338b4cbdbab184bb7dd71fce4e5 (diff) |
Merge pull request #8320 from vespa-engine/balder/control-default-dispatch-policy-by-flag
Add a flag to control default dispatch policy per zone.
Diffstat (limited to 'config-model')
11 files changed, 115 insertions, 133 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java index a6f2a205f94..f93688abddc 100644 --- a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java +++ b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java @@ -36,6 +36,7 @@ public class TestProperties implements ModelContext.Properties { private boolean isFirstTimeDeployment = false; private boolean useDedicatedNodeForLogserver = false; private boolean useFdispatchByDefault = true; + private boolean useAdaptiveDispatch = false; @Override public boolean multitenant() { return multitenant; } @Override public ApplicationId applicationId() { return applicationId; } @@ -48,6 +49,7 @@ public class TestProperties implements ModelContext.Properties { @Override public Set<Rotation> rotations() { return rotations; } @Override public boolean isBootstrap() { return isBootstrap; } @Override public boolean isFirstTimeDeployment() { return isFirstTimeDeployment; } + @Override public boolean useAdaptiveDispatch() { return useAdaptiveDispatch; } @Override public boolean useDedicatedNodeForLogserver() { return useDedicatedNodeForLogserver; } @Override public boolean useFdispatchByDefault() { return useFdispatchByDefault; } @@ -61,6 +63,11 @@ public class TestProperties implements ModelContext.Properties { return this; } + public TestProperties setUseAdaptiveDispatch(boolean useAdaptiveDispatch) { + this.useAdaptiveDispatch = useAdaptiveDispatch; + return this; + } + public TestProperties setMultitenant(boolean multitenant) { this.multitenant = multitenant; return this; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/TuningDispatch.java b/config-model/src/main/java/com/yahoo/vespa/model/content/TuningDispatch.java index b3815994742..ec958589483 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/content/TuningDispatch.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/content/TuningDispatch.java @@ -33,7 +33,7 @@ public class TuningDispatch { public static class Builder { private Integer maxHitsPerPartition; - private DispatchPolicy dispatchPolicy = DispatchPolicy.ROUNDROBIN; + private DispatchPolicy dispatchPolicy; private Boolean useLocalNode; private Double minGroupCoverage; private Double minActiveDocsCoverage; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/search/Dispatch.java b/config-model/src/main/java/com/yahoo/vespa/model/search/Dispatch.java index 8158de692a9..b9c937b4a4c 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/search/Dispatch.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/search/Dispatch.java @@ -7,7 +7,6 @@ import com.yahoo.config.model.producer.AbstractConfigProducer; import com.yahoo.vespa.model.AbstractService; import com.yahoo.vespa.model.application.validation.RestartConfigs; import com.yahoo.vespa.model.content.SearchCoverage; -import com.yahoo.vespa.model.content.TuningDispatch; import java.util.ArrayList; import java.util.List; @@ -32,6 +31,7 @@ public class Dispatch extends AbstractService implements SearchInterface, private final int dispatchLevel; private final boolean preferLocalRow; private final boolean isTopLevel; + private boolean useAdaptiveDispatch; private Dispatch(DispatchGroup dispatchGroup, AbstractConfigProducer parent, String subConfigId, NodeSpec nodeSpec, int dispatchLevel, boolean preferLocalRow, boolean isTopLevel) { @@ -41,6 +41,7 @@ public class Dispatch extends AbstractService implements SearchInterface, this.dispatchLevel = dispatchLevel; this.preferLocalRow = preferLocalRow; this.isTopLevel = isTopLevel; + this.useAdaptiveDispatch = false; portsMeta.on(0).tag("rpc").tag("admin"); portsMeta.on(1).tag("fs4"); portsMeta.on(2).tag("http").tag("json").tag("health").tag("state"); @@ -49,6 +50,11 @@ public class Dispatch extends AbstractService implements SearchInterface, .setProp("index", nodeSpec.groupIndex()); } + public Dispatch useAdaptiveDispatch(boolean useAdaptiveDispatch) { + this.useAdaptiveDispatch = useAdaptiveDispatch; + return this; + } + public static Dispatch createTld(DispatchGroup dispatchGroup, AbstractConfigProducer parent, int rowId) { return createTld(dispatchGroup, parent, rowId, false); } @@ -139,6 +145,9 @@ public class Dispatch extends AbstractService implements SearchInterface, datasetBuilder.querydistribution(PartitionsConfig.Dataset.Querydistribution.Enum.FIXEDROW); datasetBuilder.maxnodesdownperfixedrow(dispatchGroup.getMaxNodesDownPerFixedRow()); } + if (useAdaptiveDispatch) { + datasetBuilder.useroundrobinforfixedrow(false); + } SearchCoverage coverage = dispatchGroup.getSearchCoverage(); if (coverage != null) { if (coverage.getMinimum() != null) { 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 6aa023e486b..fe61041196b 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 @@ -107,6 +107,7 @@ public class IndexedSearchCluster extends SearchCluster private final DispatchGroup rootDispatch; private DispatchSpec dispatchSpec; private final boolean useFdispatchByDefault; + private final boolean useAdaptiveDispatch; private List<SearchNode> searchNodes = new ArrayList<>(); /** @@ -125,6 +126,7 @@ public class IndexedSearchCluster extends SearchCluster dispatchParent = new SimpleConfigProducer(this, "dispatchers"); rootDispatch = new DispatchGroup(this); useFdispatchByDefault = deployState.getProperties().useFdispatchByDefault(); + useAdaptiveDispatch = deployState.getProperties().useAdaptiveDispatch(); } @Override @@ -186,6 +188,7 @@ public class IndexedSearchCluster extends SearchCluster public Dispatch addTld(DeployLogger deployLogger, AbstractConfigProducer tldParent, HostResource hostResource) { int index = rootDispatch.getDispatchers().size(); Dispatch tld = Dispatch.createTld(rootDispatch, tldParent, index); + tld.useAdaptiveDispatch(useAdaptiveDispatch); tld.setHostResource(hostResource); tld.initService(deployLogger); rootDispatch.addDispatcher(tld); @@ -210,12 +213,13 @@ public class IndexedSearchCluster extends SearchCluster log.log(LogLevel.DEBUG, "Adding tld with index " + containerIndex + " for content cluster " + this.getClusterName() + ", container cluster " + containerClusterName + " (container id " + containerSubId + ") on host " + container.getHostResource().getHostname()); - rootDispatch.addDispatcher(createTld(deployLogger, tldParent, container.getHostResource(), containerClusterName, containerIndex)); + rootDispatch.addDispatcher(createTld(deployLogger, tldParent, container.getHostResource(), containerClusterName, containerIndex).useAdaptiveDispatch(useAdaptiveDispatch)); } } private Dispatch createTld(DeployLogger deployLogger, AbstractConfigProducer tldParent, HostResource hostResource, String containerClusterName, int containerIndex) { Dispatch tld = Dispatch.createTldWithContainerIdInName(rootDispatch, tldParent, containerClusterName, containerIndex); + tld.useAdaptiveDispatch(useAdaptiveDispatch); tld.setHostResource(hostResource); tld.initService(deployLogger); return tld; 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 2571381167e..2e51e432e68 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 @@ -19,7 +19,7 @@ public class Tuning extends AbstractConfigProducer implements PartitionsConfig.P public static class Dispatch implements PartitionsConfig.Producer { public Integer maxHitsPerPartition = null; - public TuningDispatch.DispatchPolicy policy = TuningDispatch.DispatchPolicy.ROUNDROBIN; + public TuningDispatch.DispatchPolicy policy = null; public boolean useLocalNode = false; public Double minGroupCoverage = null; public Double minActiveDocsCoverage = null; @@ -41,15 +41,17 @@ public class Tuning extends AbstractConfigProducer implements PartitionsConfig.P dataset.min_activedocs_coverage(minActiveDocsCoverage); } } - for (PartitionsConfig.Dataset.Builder dataset : builder.dataset) { - switch (policy) { - case ADAPTIVE: - dataset.useroundrobinforfixedrow(false); - break; - case ROUNDROBIN: - default: - dataset.useroundrobinforfixedrow(true); - break; + if (policy != null) { + for (PartitionsConfig.Dataset.Builder dataset : builder.dataset) { + switch (policy) { + case ADAPTIVE: + dataset.useroundrobinforfixedrow(false); + break; + case ROUNDROBIN: + default: + dataset.useroundrobinforfixedrow(true); + break; + } } } } diff --git a/config-model/src/test/java/com/yahoo/config/model/MockModelContext.java b/config-model/src/test/java/com/yahoo/config/model/MockModelContext.java index 18d017d76f0..38e438e4d3a 100644 --- a/config-model/src/test/java/com/yahoo/config/model/MockModelContext.java +++ b/config-model/src/test/java/com/yahoo/config/model/MockModelContext.java @@ -6,25 +6,16 @@ import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.application.api.FileRegistry; import com.yahoo.config.model.api.ConfigDefinitionRepo; -import com.yahoo.config.model.api.ConfigServerSpec; import com.yahoo.config.model.api.HostProvisioner; import com.yahoo.config.model.api.Model; import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.application.provider.BaseDeployLogger; import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.model.application.provider.StaticConfigDefinitionRepo; +import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.config.model.test.MockApplicationPackage; -import com.yahoo.config.provision.ApplicationId; -import com.yahoo.config.provision.HostName; -import com.yahoo.config.provision.Rotation; -import com.yahoo.config.provision.Zone; - -import java.net.URI; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; + import java.util.Optional; -import java.util.Set; /** * @author hmusum @@ -84,61 +75,6 @@ public class MockModelContext implements ModelContext { @Override public Properties properties() { - return new Properties() { - @Override - public boolean multitenant() { - return false; - } - - @Override - public ApplicationId applicationId() { - return ApplicationId.defaultId(); - } - - @Override - public List<ConfigServerSpec> configServerSpecs() { - return Collections.emptyList(); - } - - @Override - public HostName loadBalancerName() { - return null; - } - - @Override - public URI ztsUrl() { - return null; - } - - @Override - public String athenzDnsSuffix() { - return null; - } - - @Override - public boolean hostedVespa() {return false; } - - @Override - public Zone zone() { - return Zone.defaultZone(); - } - - @Override - public Set<Rotation> rotations() { - return new HashSet<>(); - } - - @Override - public boolean isBootstrap() { return false; } - - @Override - public boolean isFirstTimeDeployment() { return false; } - - @Override - public boolean useDedicatedNodeForLogserver() { return false; } - - @Override - public boolean useFdispatchByDefault() { return true; } - }; + return new TestProperties(); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java index e2337c42cf3..0e200efd688 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/ContentClusterTest.java @@ -1,6 +1,7 @@ // 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 com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.config.model.test.MockRoot; @@ -16,6 +17,7 @@ import com.yahoo.vespa.config.content.StorDistributionConfig; import com.yahoo.vespa.config.content.StorFilestorConfig; import com.yahoo.vespa.config.content.core.StorDistributormanagerConfig; import com.yahoo.vespa.config.content.core.StorServerConfig; +import com.yahoo.vespa.config.search.core.PartitionsConfig; import com.yahoo.vespa.config.search.core.ProtonConfig; import com.yahoo.vespa.model.VespaModel; import com.yahoo.vespa.model.container.ContainerCluster; @@ -177,7 +179,7 @@ public class ContentClusterTest extends ContentBaseTest { } @Test - public void testEndToEnd() throws Exception { + public void testEndToEnd() { String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + "<services>\n" + @@ -220,49 +222,73 @@ public class ContentClusterTest extends ContentBaseTest { assertEquals(3, cluster.getContainers().size()); } - @Test - public void testEndToEndOneNode() throws Exception { + VespaModel createEnd2EndOneNode(ModelContext.Properties properties) { String services = - "<?xml version='1.0' encoding='UTF-8' ?>" + - "<services version='1.0'>" + - " <admin version='2.0'>" + - " <adminserver hostalias='node1'/>" + - " </admin>" + - " <jdisc id='default' version='1.0'>" + - " <search/>" + - " <nodes>" + - " <node hostalias='node1'/>" + - " </nodes>" + - " </jdisc>" + - " <content id='storage' version='1.0'>" + - " <redundancy>2</redundancy>" + - " <group>" + - " <node distribution-key='0' hostalias='node1'/>" + - " <node distribution-key='1' hostalias='node1'/>" + - " </group>" + - " <tuning>" + - " <cluster-controller>" + - " <transition-time>0</transition-time>" + - " </cluster-controller>" + - " </tuning>" + - " <documents>" + - " <document mode='store-only' type='type1'/>" + - " </documents>" + - " <engine>" + - " <proton/>" + - " </engine>" + - " </content>" + - " </services>"; - + "<?xml version='1.0' encoding='UTF-8' ?>" + + "<services version='1.0'>" + + " <admin version='2.0'>" + + " <adminserver hostalias='node1'/>" + + " </admin>" + + " <jdisc id='default' version='1.0'>" + + " <search/>" + + " <nodes>" + + " <node hostalias='node1'/>" + + " </nodes>" + + " </jdisc>" + + " <content id='storage' version='1.0'>" + + " <redundancy>2</redundancy>" + + " <group>" + + " <node distribution-key='0' hostalias='node1'/>" + + " <node distribution-key='1' hostalias='node1'/>" + + " </group>" + + " <tuning>" + + " <cluster-controller>" + + " <transition-time>0</transition-time>" + + " </cluster-controller>" + + " </tuning>" + + " <documents>" + + " <document mode='index' type='type1'/>" + + " </documents>" + + " <engine>" + + " <proton/>" + + " </engine>" + + " </content>" + + " </services>"; + + DeployState.Builder deployStateBuilder = new DeployState.Builder().properties(properties); List<String> sds = ApplicationPackageUtils.generateSearchDefinitions("type1"); - VespaModel model = (new VespaModelCreatorWithMockPkg(null, services, sds)).create(); + return (new VespaModelCreatorWithMockPkg(null, services, sds)).create(deployStateBuilder); + } + @Test + public void testEndToEndOneNode() { + VespaModel model = createEnd2EndOneNode(new TestProperties()); + assertEquals(1, model.getContentClusters().get("storage").getDocumentDefinitions().size()); ContainerCluster cluster = model.getAdmin().getClusterControllers(); assertEquals(1, cluster.getContainers().size()); } + private void verifyRoundRobinPropertiesControl(boolean useAdaptiveDispatch) { + VespaModel model = createEnd2EndOneNode(new TestProperties().setUseAdaptiveDispatch(useAdaptiveDispatch)); + + ContentCluster cc = model.getContentClusters().get("storage"); + PartitionsConfig.Builder partBuilder = new PartitionsConfig.Builder(); + assertNotNull(cc.getSearch()); + assertNotNull(cc.getSearch().getIndexed()); + assertEquals(1, cc.getSearch().getIndexed().getTLDs().size()); + cc.getSearch().getIndexed().getTLDs().get(0).getConfig(partBuilder); + PartitionsConfig partitionsConfig = new PartitionsConfig(partBuilder); + assertFalse(useAdaptiveDispatch == partitionsConfig.dataset(0).useroundrobinforfixedrow()); + } + + @Test + public void default_dispatch_controlled_by_properties() { + verifyRoundRobinPropertiesControl(false); + verifyRoundRobinPropertiesControl(true); + } + @Test - public void testSearchTuning() throws Exception { + public void testSearchTuning() { String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + "<services>\n" + @@ -312,7 +338,7 @@ public class ContentClusterTest extends ContentBaseTest { } @Test - public void testRedundancyRequired() throws Exception { + public void testRedundancyRequired() { String xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" + "<services>\n" + @@ -754,8 +780,6 @@ public class ContentClusterTest extends ContentBaseTest { " <node distribution-key=\"0\" hostalias=\"mockhost\"/>" + " </group>" + "</content>", isHostedVespa); - - } private static ContentCluster createClusterWithFlushOnShutdownOverride(boolean flushOnShutdown, boolean isHostedVespa) throws Exception { 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 index e84f256d6dc..fe00648317a 100644 --- 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 @@ -49,6 +49,6 @@ public class TuningDispatchTest { public void requireThatDefaultsAreNull() { TuningDispatch dispatch = new TuningDispatch.Builder().build(); assertNull(dispatch.getMaxHitsPerPartition()); - assertTrue(TuningDispatch.DispatchPolicy.ROUNDROBIN == dispatch.getDispatchPolicy()); + assertNull(dispatch.getDispatchPolicy()); } } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java index 1a2eb93face..44986bc0b69 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/ClusterTest.java @@ -28,7 +28,7 @@ import static org.junit.Assert.assertTrue; public class ClusterTest { @Test - public void requireThatContentSearchIsApplied() throws ParseException { + public void requireThatContentSearchIsApplied() { ContentCluster cluster = newContentCluster(joinLines("<search>", " <query-timeout>1.1</query-timeout>", " <visibility-delay>2.3</visibility-delay>", @@ -64,7 +64,7 @@ public class ClusterTest { } @Test - public void requireThatDispatchTuningIsApplied() throws ParseException { + public void requireThatDispatchTuningIsApplied() { ContentCluster cluster = newContentCluster(joinLines("<search>", "</search>"), joinLines("<tuning>", "</tuning>")); @@ -79,7 +79,7 @@ public class ClusterTest { } @Test - public void requireThatVisibilityDelayIsZeroForGlobalDocumentType() throws ParseException { + public void requireThatVisibilityDelayIsZeroForGlobalDocumentType() { ContentCluster cluster = newContentCluster(joinLines("<search>", " <visibility-delay>2.3</visibility-delay>", "</search>"), true); @@ -87,19 +87,19 @@ public class ClusterTest { assertEquals(0.0, proton.documentdb(0).visibilitydelay(), 1E-6); } - private static ContentCluster newContentCluster(String contentSearchXml) throws ParseException { + private static ContentCluster newContentCluster(String contentSearchXml) { return newContentCluster(contentSearchXml, "", false); } - private static ContentCluster newContentCluster(String contentSearchXml, String searchNodeTuningXml) throws ParseException { + private static ContentCluster newContentCluster(String contentSearchXml, String searchNodeTuningXml) { return newContentCluster(contentSearchXml, searchNodeTuningXml, false); } - private static ContentCluster newContentCluster(String contentSearchXml, boolean globalDocType) throws ParseException { + private static ContentCluster newContentCluster(String contentSearchXml, boolean globalDocType) { return newContentCluster(contentSearchXml, "", globalDocType); } - private static ContentCluster newContentCluster(String contentSearchXml, String searchNodeTuningXml, boolean globalDocType) throws ParseException { + private static ContentCluster newContentCluster(String contentSearchXml, String searchNodeTuningXml, boolean globalDocType) { ApplicationPackage app = new MockApplicationPackage.Builder() .withHosts(joinLines( "<hosts>", diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilderTest.java index d9646c163e4..46b5b630f9e 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/content/cluster/DomTuningDispatchBuilderTest.java @@ -45,7 +45,7 @@ public class DomTuningDispatchBuilderTest { assertNull(dispatch.getMaxHitsPerPartition()); assertNull(dispatch.getMinGroupCoverage()); assertNull(dispatch.getMinActiveDocsCoverage()); - assertTrue(TuningDispatch.DispatchPolicy.ROUNDROBIN == dispatch.getDispatchPolicy()); + assertNull(dispatch.getDispatchPolicy()); } @Test diff --git a/config-model/src/test/schema-test-files/services.xml b/config-model/src/test/schema-test-files/services.xml index 899fd83eca1..13612a91726 100644 --- a/config-model/src/test/schema-test-files/services.xml +++ b/config-model/src/test/schema-test-files/services.xml @@ -34,7 +34,7 @@ <intVal>1</intVal> </config> - <jdisc id='qrsCluster_1' version='1.0'> + <container id='qrsCluster_1' version='1.0'> <secret-store type="oath-ckms"> <!-- NOTE: when removing (or adding) an environment, the rnc schema must also be updated! --> <group name="foo" environment="alpha" /> @@ -206,14 +206,14 @@ </server> <nodes jvm-options="-XX:+PrintGCDetails -XX:+PrintGCTimeStamps"> + <environment-variables> + <TEST_VAR>7</TEST_VAR> + </environment-variables> <node hostalias="host1" /> <node hostalias="host1"> <server-port id="myServer" port="4090" /> </node> - <environment-variables> - <TEST_VAR>7</TEST_VAR> - </environment-variables> </nodes> - </jdisc> + </container> </services> |