summaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-11-24 12:10:45 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2022-11-24 12:10:45 +0100
commit8e2abfc58e936bd6be3194f9e02a21a9b70b7692 (patch)
tree9918c66fc57647c0b1c831223f6b0f9c5d6b680d /container-search/src/test/java/com/yahoo/prelude
parent90b260e83678edc36eb877ec235e0e6ce5892a48 (diff)
Put loadbalancer and invokerfactory in a volatile object to ensure atomic switch when reconfiguring.
Diffstat (limited to 'container-search/src/test/java/com/yahoo/prelude')
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java1
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java59
2 files changed, 1 insertions, 59 deletions
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
index 2f960add4a8..e9b1cbabc79 100644
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
+++ b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java
@@ -13,6 +13,7 @@ import com.yahoo.prelude.fastsearch.SummaryParameters;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
import com.yahoo.search.Searcher;
+import com.yahoo.search.dispatch.MockDispatcher;
import com.yahoo.search.dispatch.rpc.RpcResourcePool;
import com.yahoo.search.dispatch.searchcluster.Node;
import com.yahoo.search.grouping.GroupingRequest;
diff --git a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java b/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java
deleted file mode 100644
index 886c9818842..00000000000
--- a/container-search/src/test/java/com/yahoo/prelude/fastsearch/test/MockDispatcher.java
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.prelude.fastsearch.test;
-
-import com.yahoo.container.handler.VipStatus;
-import com.yahoo.search.cluster.ClusterMonitor;
-import com.yahoo.search.dispatch.Dispatcher;
-import com.yahoo.search.dispatch.rpc.RpcInvokerFactory;
-import com.yahoo.search.dispatch.rpc.RpcPingFactory;
-import com.yahoo.search.dispatch.rpc.RpcResourcePool;
-import com.yahoo.search.dispatch.searchcluster.Node;
-import com.yahoo.search.dispatch.searchcluster.SearchCluster;
-import com.yahoo.vespa.config.search.DispatchConfig;
-import com.yahoo.vespa.config.search.DispatchNodesConfig;
-
-import java.util.List;
-
-class MockDispatcher extends Dispatcher {
-
- public final ClusterMonitor clusterMonitor;
-
- public static MockDispatcher create(List<Node> nodes) {
- var rpcResourcePool = new RpcResourcePool(toDispatchConfig(), toNodesConfig(nodes));
-
- return create(nodes, rpcResourcePool, new VipStatus());
- }
-
- public static MockDispatcher create(List<Node> nodes, RpcResourcePool rpcResourcePool, VipStatus vipStatus) {
- var dispatchConfig = toDispatchConfig();
- var searchCluster = new SearchCluster("a", dispatchConfig.minActivedocsPercentage(), nodes, vipStatus, new RpcPingFactory(rpcResourcePool));
- return new MockDispatcher(new ClusterMonitor<>(searchCluster, true), searchCluster, dispatchConfig, rpcResourcePool);
- }
-
- private MockDispatcher(ClusterMonitor clusterMonitor, SearchCluster searchCluster, DispatchConfig dispatchConfig, RpcResourcePool rpcResourcePool) {
- this(clusterMonitor, searchCluster, dispatchConfig, new RpcInvokerFactory(rpcResourcePool, searchCluster, dispatchConfig));
- }
-
- private MockDispatcher(ClusterMonitor clusterMonitor, SearchCluster searchCluster, DispatchConfig dispatchConfig, RpcInvokerFactory invokerFactory) {
- super(clusterMonitor, searchCluster, dispatchConfig, invokerFactory);
- this.clusterMonitor = clusterMonitor;
- }
-
- static DispatchConfig toDispatchConfig() {
- return new DispatchConfig.Builder().build();
- }
- static DispatchNodesConfig toNodesConfig(List<Node> nodes) {
- DispatchNodesConfig.Builder dispatchConfigBuilder = new DispatchNodesConfig.Builder();
- int key = 0;
- for (Node node : nodes) {
- DispatchNodesConfig.Node.Builder dispatchConfigNodeBuilder = new DispatchNodesConfig.Node.Builder();
- dispatchConfigNodeBuilder.host(node.hostname());
- dispatchConfigNodeBuilder.port(0); // Mandatory, but currently not used here
- dispatchConfigNodeBuilder.group(node.group());
- dispatchConfigNodeBuilder.key(key++); // not used
- dispatchConfigBuilder.node(dispatchConfigNodeBuilder);
- }
- return dispatchConfigBuilder.build();
- }
-
-}