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 /container-search/src/main | |
parent | 7fac48575f1d6c58ca9ea73e8c554fb32b2f9aa9 (diff) |
Disable java dispatcher if multi-level dispatching is configured
Diffstat (limited to 'container-search/src/main')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java | 26 |
1 files changed, 15 insertions, 11 deletions
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 |