diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-23 12:04:55 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-23 12:04:55 +0100 |
commit | f82fe83ea8cdab7e190e917b9391b5f0c36a3351 (patch) | |
tree | 1d149f456c4c29666aa50ef65c15c9fcf44dc503 /container-search/src/main/java | |
parent | 02dbfdece2c0bc6a1e2352c737da9c2ba7ae3d82 (diff) |
No need to require the full SearchCluster when you only need a list of Groups.
Diffstat (limited to 'container-search/src/main/java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java | 9 | ||||
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java | 7 |
2 files changed, 7 insertions, 9 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 55073f25f0e..3a198c3576a 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 @@ -52,10 +52,9 @@ public class Dispatcher extends AbstractComponent { /** If set will control computation of how many hits will be fetched from each partition.*/ public static final CompoundName topKProbability = CompoundName.fromComponents(DISPATCH, TOP_K_PROBABILITY); - /** A model of the search cluster this dispatches to */ - private final SearchCluster searchCluster; private final ClusterMonitor<Node> clusterMonitor; private final LoadBalancer loadBalancer; + private final SearchCluster searchCluster; private final InvokerFactory invokerFactory; private final int maxHitsPerNode; private final RpcResourcePool rpcResourcePool; @@ -114,7 +113,7 @@ public class Dispatcher extends AbstractComponent { this.searchCluster = searchCluster; this.clusterMonitor = clusterMonitor; - this.loadBalancer = new LoadBalancer(searchCluster, toLoadBalancerPolicy(dispatchConfig.distributionPolicy())); + this.loadBalancer = new LoadBalancer(searchCluster.orderedGroups(), toLoadBalancerPolicy(dispatchConfig.distributionPolicy())); this.invokerFactory = invokerFactory; this.rpcResourcePool = rpcResourcePool; this.maxHitsPerNode = dispatchConfig.maxHitsPerNode(); @@ -172,7 +171,7 @@ public class Dispatcher extends AbstractComponent { public SearchInvoker getSearchInvoker(Query query, VespaBackEndSearcher searcher) { SearchCluster cluster = searchCluster; // Take a snapshot - SearchInvoker invoker = getSearchPathInvoker(query, searcher, cluster).orElseGet(() -> getInternalInvoker(query, searcher, cluster)); + SearchInvoker invoker = getSearchPathInvoker(query, searcher, cluster).orElseGet(() -> getInternalInvoker(query, searcher, cluster, loadBalancer)); if (query.properties().getBoolean(com.yahoo.search.query.Model.ESTIMATE)) { query.setHits(0); @@ -201,7 +200,7 @@ public class Dispatcher extends AbstractComponent { } } - private SearchInvoker getInternalInvoker(Query query, VespaBackEndSearcher searcher, SearchCluster cluster) { + private SearchInvoker getInternalInvoker(Query query, VespaBackEndSearcher searcher, SearchCluster cluster, LoadBalancer loadBalancer) { Optional<Node> directNode = cluster.localCorpusDispatchTarget(); if (directNode.isPresent()) { Node node = directNode.get(); diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java b/container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java index 59821827d4e..52cc6ad7711 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java @@ -2,7 +2,6 @@ package com.yahoo.search.dispatch; import com.yahoo.search.dispatch.searchcluster.Group; -import com.yahoo.search.dispatch.searchcluster.SearchCluster; import java.time.Duration; import java.util.ArrayList; @@ -34,9 +33,9 @@ public class LoadBalancer { public enum Policy { ROUNDROBIN, LATENCY_AMORTIZED_OVER_REQUESTS, LATENCY_AMORTIZED_OVER_TIME, BEST_OF_RANDOM_2} - public LoadBalancer(SearchCluster searchCluster, Policy policy) { - this.scoreboard = new ArrayList<>(searchCluster.groups().size()); - for (Group group : searchCluster.orderedGroups()) { + public LoadBalancer(List<Group> groups, Policy policy) { + this.scoreboard = new ArrayList<>(groups.size()); + for (Group group : groups) { scoreboard.add(new GroupStatus(group)); } if (scoreboard.size() == 1) |