diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-25 13:41:56 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-25 13:41:56 +0100 |
commit | b2dc289bb231800fe241255997052ab38db73965 (patch) | |
tree | 3fc31538763f9a87703c515bb3a461dcedab6380 /container-search/src/main/java | |
parent | 2433bce1d4126c121f691035b0d91efbf3862f33 (diff) |
pathIndex should not be part of equals and hashcode.
Diffstat (limited to 'container-search/src/main/java')
4 files changed, 9 insertions, 16 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 92a522e9970..09db1be4732 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 @@ -87,7 +87,7 @@ public class Dispatcher extends AbstractComponent { this.dispatchConfig = dispatchConfig; rpcResourcePool = new RpcResourcePool(dispatchConfig, nodesConfig); searchCluster = new SearchCluster(clusterId.stringValue(), dispatchConfig.minActivedocsPercentage(), - nodesConfig, vipStatus, new RpcPingFactory(rpcResourcePool)); + toNodes(nodesConfig), vipStatus, new RpcPingFactory(rpcResourcePool)); clusterMonitor = new ClusterMonitor<>(searchCluster, true); volatileItems = update(null); initialWarmup(dispatchConfig.warmuptime()); @@ -102,6 +102,7 @@ public class Dispatcher extends AbstractComponent { this.clusterMonitor = clusterMonitor; this.volatileItems = update(invokerFactory); } + private VolatileItems update(InvokerFactory invokerFactory) { var items = new VolatileItems(new LoadBalancer(searchCluster.groupList().groups(), toLoadBalancerPolicy(dispatchConfig.distributionPolicy())), (invokerFactory == null) @@ -135,6 +136,11 @@ public class Dispatcher extends AbstractComponent { case LATENCY_AMORTIZED_OVER_TIME: yield LoadBalancer.Policy.LATENCY_AMORTIZED_OVER_TIME; }; } + private static List<Node> toNodes(DispatchNodesConfig nodesConfig) { + return nodesConfig.node().stream() + .map(n -> new Node(n.key(), n.host(), n.group())) + .toList(); + } /** * Will run important code in order to trigger JIT compilation and avoid cold start issues. diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java index 3d3efce2ab2..a9115d009f1 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java @@ -34,7 +34,7 @@ public class Group { this.nodes = List.copyOf(nodes); int idx = 0; - for(var node: nodes) { + for (var node: nodes) { node.setPathIndex(idx); idx++; } diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java index 38d51585ae4..aeb04bfb141 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java @@ -88,7 +88,7 @@ public class Node { boolean isBlockingWrites() { return isBlockingWrites; } @Override - public int hashCode() { return Objects.hash(hostname, key, pathIndex, group); } + public int hashCode() { return Objects.hash(hostname, key, group); } @Override public boolean equals(Object o) { @@ -96,7 +96,6 @@ public class Node { if ( ! (o instanceof Node other)) return false; if ( ! Objects.equals(this.hostname, other.hostname)) return false; if ( ! Objects.equals(this.key, other.key)) return false; - if ( ! Objects.equals(this.pathIndex, other.pathIndex)) return false; if ( ! Objects.equals(this.group, other.group)) return false; return true; diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java index 6c48b00d175..2783b45f724 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java @@ -6,7 +6,6 @@ import com.yahoo.net.HostName; import com.yahoo.prelude.Pong; import com.yahoo.search.cluster.ClusterMonitor; import com.yahoo.search.cluster.NodeManager; -import com.yahoo.vespa.config.search.DispatchNodesConfig; import java.util.Collection; import java.util.HashMap; @@ -42,11 +41,6 @@ public class SearchCluster implements NodeManager<Node> { */ private final Node localCorpusDispatchTarget; - public SearchCluster(String clusterId, double minActivedocsPercentage, - DispatchNodesConfig nodesConfig, - VipStatus vipStatus, PingFactory pingFactory) { - this(clusterId, minActivedocsPercentage, toNodes(nodesConfig), vipStatus, pingFactory); - } public SearchCluster(String clusterId, double minActivedocsPercentage, List<Node> nodes, VipStatus vipStatus, PingFactory pingFactory) { this(clusterId, toGroups(nodes, minActivedocsPercentage), vipStatus, pingFactory); @@ -89,12 +83,6 @@ public class SearchCluster implements NodeManager<Node> { return localSearchNode; } - private static List<Node> toNodes(DispatchNodesConfig nodesConfig) { - return nodesConfig.node().stream() - .map(n -> new Node(n.key(), n.host(), n.group())) - .toList(); - } - private static SearchGroupsImpl toGroups(Collection<Node> nodes, double minActivedocsPercentage) { Map<Integer, Group> groups = new HashMap<>(); for (Map.Entry<Integer, List<Node>> group : nodes.stream().collect(Collectors.groupingBy(Node::group)).entrySet()) { |