diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-21 17:56:57 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-11-21 17:56:57 +0100 |
commit | 3e955a564d65de056c87b706432a4a12ff8d1d10 (patch) | |
tree | 5f4346c521fb07e3c2dc17b9747ffc30400274c9 /container-search/src/main/java/com/yahoo/search | |
parent | aaaa5efdde6562a44e3fa4e6168783029d0d5a98 (diff) |
Splitt nodes static and dynamic config in DispatchConfig to prepare for seamless cluster changes.
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search')
3 files changed, 13 insertions, 8 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 2a95908ba05..e4147f6ba14 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 @@ -23,6 +23,7 @@ import com.yahoo.search.query.profile.types.FieldType; import com.yahoo.search.query.profile.types.QueryProfileType; import com.yahoo.search.result.ErrorMessage; import com.yahoo.vespa.config.search.DispatchConfig; +import com.yahoo.vespa.config.search.DispatchNodesConfig; import java.time.Duration; import java.util.HashSet; @@ -74,8 +75,9 @@ public class Dispatcher extends AbstractComponent { public Dispatcher(RpcResourcePool resourcePool, ComponentId clusterId, DispatchConfig dispatchConfig, + DispatchNodesConfig nodesConfig, VipStatus vipStatus) { - this(resourcePool, new SearchCluster(clusterId.stringValue(), dispatchConfig, + this(resourcePool, new SearchCluster(clusterId.stringValue(), dispatchConfig, nodesConfig, vipStatus, new RpcPingFactory(resourcePool)), dispatchConfig); diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcResourcePool.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcResourcePool.java index 09628db1284..eb937e00b17 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcResourcePool.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcResourcePool.java @@ -12,6 +12,7 @@ import com.yahoo.search.Query; import com.yahoo.search.dispatch.FillInvoker; import com.yahoo.search.dispatch.rpc.Client.NodeConnection; import com.yahoo.vespa.config.search.DispatchConfig; +import com.yahoo.vespa.config.search.DispatchNodesConfig; import java.util.ArrayList; import java.util.Collections; @@ -45,14 +46,14 @@ public class RpcResourcePool extends AbstractComponent { } @Inject - public RpcResourcePool(DispatchConfig dispatchConfig) { + public RpcResourcePool(DispatchConfig dispatchConfig, DispatchNodesConfig nodesConfig) { super(); client = new RpcClient("dispatch-client", dispatchConfig.numJrtTransportThreads()); // Create rpc node connection pools indexed by the node distribution key var builder = new ImmutableMap.Builder<Integer, NodeConnectionPool>(); var numConnections = dispatchConfig.numJrtConnectionsPerNode(); - for (var node : dispatchConfig.node()) { + for (var node : nodesConfig.node()) { var connections = new ArrayList<NodeConnection>(numConnections); for (int i = 0; i < numConnections; i++) { connections.add(client.createConnection(node.host(), node.port())); 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 25617e48aa1..54a3e42b9ab 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 @@ -10,6 +10,7 @@ import com.yahoo.search.cluster.ClusterMonitor; import com.yahoo.search.cluster.NodeManager; import com.yahoo.search.dispatch.TopKEstimator; import com.yahoo.vespa.config.search.DispatchConfig; +import com.yahoo.vespa.config.search.DispatchNodesConfig; import java.util.LinkedHashMap; import java.util.List; @@ -50,13 +51,14 @@ public class SearchCluster implements NodeManager<Node> { private final Optional<Node> localCorpusDispatchTarget; public SearchCluster(String clusterId, DispatchConfig dispatchConfig, + DispatchNodesConfig nodesConfig, VipStatus vipStatus, PingFactory pingFactory) { this.clusterId = clusterId; this.dispatchConfig = dispatchConfig; this.vipStatus = vipStatus; this.pingFactory = pingFactory; - this.nodes = toNodes(dispatchConfig); + this.nodes = toNodes(nodesConfig); // Create groups ImmutableMap.Builder<Integer, Group> groupsBuilder = new ImmutableMap.Builder<>(); @@ -92,7 +94,7 @@ public class SearchCluster implements NodeManager<Node> { // The search cluster to be searched has at least as many nodes as the container cluster we're running in. List<Node> localSearchNodes = nodes.stream() .filter(node -> node.hostname().equals(selfHostname)) - .collect(Collectors.toList()); + .toList(); // Only use direct dispatch if we have exactly 1 search node on the same machine: if (localSearchNodes.size() != 1) return Optional.empty(); @@ -105,10 +107,10 @@ public class SearchCluster implements NodeManager<Node> { return Optional.of(localSearchNode); } - private static List<Node> toNodes(DispatchConfig dispatchConfig) { - return dispatchConfig.node().stream() + private static List<Node> toNodes(DispatchNodesConfig nodesConfig) { + return nodesConfig.node().stream() .map(n -> new Node(n.key(), n.host(), n.group())) - .collect(Collectors.toUnmodifiableList()); + .toList(); } public DispatchConfig dispatchConfig() { |