diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-08-16 11:38:04 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-08-16 11:38:04 +0200 |
commit | e32d551e91700add8758cf57d9b91f7624c2bd3a (patch) | |
tree | 9f43d024bbcee0699d62643f362b8856b791ba48 /container-search/src/main/java/com/yahoo/search/dispatch | |
parent | 76cc3b290bcc5378a29eb48d47fc70436ae57d9e (diff) |
Don't direct dispatch if the containerCluster.size<searchCluster.size
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/dispatch')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java | 8 | ||||
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/dispatch/SearchCluster.java | 6 |
2 files changed, 10 insertions, 4 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 e9cc7b5eafd..e1b9f717d61 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 @@ -41,7 +41,7 @@ public class Dispatcher extends AbstractComponent { private final Client client; /** A model of the search cluster this dispatches to */ - private final SearchCluster cluster; + private final SearchCluster searchCluster; /** Connections to the search nodes this talks to, indexed by node id ("partid") */ private final ImmutableMap<Integer, Client.NodeConnection> nodeConnections; @@ -51,7 +51,7 @@ public class Dispatcher extends AbstractComponent { @Inject public Dispatcher(DispatchConfig dispatchConfig) { this.client = new RpcClient(); - this.cluster = new SearchCluster(dispatchConfig); + this.searchCluster = new SearchCluster(dispatchConfig); // Create node rpc connections, indexed by the legacy "partid", which allows us to bridge // between fs4 calls (for search) and rpc calls (for summary fetch) @@ -64,13 +64,13 @@ public class Dispatcher extends AbstractComponent { /** For testing */ public Dispatcher(Map<Integer, Client.NodeConnection> nodeConnections, Client client) { - this.cluster = null; + this.searchCluster = null; this.nodeConnections = ImmutableMap.copyOf(nodeConnections); this.client = client; } /** Returns the search cluster this dispatches to */ - public SearchCluster cluster() { return cluster; } + public SearchCluster searchCluster() { return searchCluster; } /** Fills the given summary class by sending RPC requests to the right search nodes */ public void fill(Result result, String summaryClass, CompressionType compression) { diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/SearchCluster.java b/container-search/src/main/java/com/yahoo/search/dispatch/SearchCluster.java index 374d36bb161..4f1b1ebfec0 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/SearchCluster.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/SearchCluster.java @@ -16,6 +16,7 @@ import java.util.stream.Collectors; */ public class SearchCluster { + private final int size; private final ImmutableMap<Integer, Group> groups; private final ImmutableMultimap<String, Node> nodesByHost; @@ -24,6 +25,8 @@ public class SearchCluster { } public SearchCluster(List<Node> nodes) { + size = nodes.size(); + // Create groups ImmutableMap.Builder<Integer, Group> groupsBuilder = new ImmutableMap.Builder<>(); for (Map.Entry<Integer, List<Node>> group : nodes.stream().collect(Collectors.groupingBy(Node::group)).entrySet()) @@ -44,6 +47,9 @@ public class SearchCluster { return nodesBuilder.build(); } + /** Returns the number of nodes in this cluster (across all groups) */ + public int size() { return size; } + /** Returns the groups of this cluster as an immutable map indexed by group id */ public ImmutableMap<Integer, Group> groups() { return groups; } |