diff options
author | Olli Virtanen <olli.virtanen@oath.com> | 2018-11-08 14:54:18 +0100 |
---|---|---|
committer | Olli Virtanen <olli.virtanen@oath.com> | 2018-11-08 14:54:18 +0100 |
commit | 94f6a46855d65620386bc9a41f231ffaa0dab8b9 (patch) | |
tree | 8f1af4ba6a19a9863eee96fec4c1abcf060e1eba | |
parent | 7fac48575f1d6c58ca9ea73e8c554fb32b2f9aa9 (diff) |
Disable java dispatcher if multi-level dispatching is configured
3 files changed, 34 insertions, 26 deletions
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 623a963f77a..fe83148d7af 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 @@ -404,23 +404,24 @@ public class IndexedSearchCluster extends SearchCluster nodeBuilder.host(node.getHostName()); nodeBuilder.port(node.getRpcPort()); nodeBuilder.fs4port(node.getDispatchPort()); - 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 RANDOM: - builder.distributionPolicy(DistributionPolicy.RANDOM); - break; - case ROUNDROBIN: - builder.distributionPolicy(DistributionPolicy.ROUNDROBIN); - break; - } - } - builder.maxNodesDownPerGroup(rootDispatch.getMaxNodesDownPerFixedRow()); builder.node(nodeBuilder); } + 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 RANDOM: + builder.distributionPolicy(DistributionPolicy.RANDOM); + break; + case ROUNDROBIN: + builder.distributionPolicy(DistributionPolicy.ROUNDROBIN); + break; + } + } + builder.maxNodesDownPerGroup(rootDispatch.getMaxNodesDownPerFixedRow()); + builder.useMultilevelDispatch(useMultilevelDispatchSetup()); } @Override diff --git a/configdefinitions/src/vespa/dispatch.def b/configdefinitions/src/vespa/dispatch.def index 602d3b17a8e..487f8ac24c3 100644 --- a/configdefinitions/src/vespa/dispatch.def +++ b/configdefinitions/src/vespa/dispatch.def @@ -16,6 +16,9 @@ maxNodesDownPerGroup int default=0 # Distribution policy for group selection distributionPolicy enum { ROUNDROBIN, RANDOM } default=ROUNDROBIN +# Is multi-level dispatch configured for this cluster +useMultilevelDispatch bool default=false + # The unique key of a search node node[].key int diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java index 0dd682dee0e..f83d5eb23f6 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java @@ -46,12 +46,14 @@ public class Dispatcher extends AbstractComponent { private final LoadBalancer loadBalancer; private final RpcResourcePool rpcResourcePool; + private final boolean multilevelDispatch; public Dispatcher(DispatchConfig dispatchConfig, FS4ResourcePool fs4ResourcePool, int containerClusterSize, VipStatus vipStatus) { this.searchCluster = new SearchCluster(dispatchConfig, fs4ResourcePool, containerClusterSize, vipStatus); this.loadBalancer = new LoadBalancer(searchCluster, dispatchConfig.distributionPolicy() == DispatchConfig.DistributionPolicy.ROUNDROBIN); this.rpcResourcePool = new RpcResourcePool(dispatchConfig); + this.multilevelDispatch = dispatchConfig.useMultilevelDispatch(); } /** For testing */ @@ -59,6 +61,7 @@ public class Dispatcher extends AbstractComponent { this.searchCluster = null; this.loadBalancer = new LoadBalancer(searchCluster, true); this.rpcResourcePool = new RpcResourcePool(client, nodeConnections); + this.multilevelDispatch = false; } /** Returns the search cluster this dispatches to */ @@ -87,19 +90,20 @@ public class Dispatcher extends AbstractComponent { } public Optional<SearchInvoker> getSearchInvoker(Query query, FS4InvokerFactory fs4InvokerFactory) { - if (query.properties().getBoolean(dispatchInternal, false)) { - Optional<SearchInvoker> invoker = getSearchPathInvoker(query, fs4InvokerFactory::getSearchInvoker); + if (multilevelDispatch || ! query.properties().getBoolean(dispatchInternal, false)) { + return Optional.empty(); + } - if(! invoker.isPresent()) { - invoker = getInternalInvoker(query, fs4InvokerFactory::getSearchInvoker); - } - if(invoker.isPresent() && query.properties().getBoolean(com.yahoo.search.query.Model.ESTIMATE)) { - query.setHits(0); - query.setOffset(0); - } - return invoker; + Optional<SearchInvoker> invoker = getSearchPathInvoker(query, fs4InvokerFactory::getSearchInvoker); + + if (!invoker.isPresent()) { + invoker = getInternalInvoker(query, fs4InvokerFactory::getSearchInvoker); } - return Optional.empty(); + if (invoker.isPresent() && query.properties().getBoolean(com.yahoo.search.query.Model.ESTIMATE)) { + query.setHits(0); + query.setOffset(0); + } + return invoker; } @FunctionalInterface |