aboutsummaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-09-01 12:23:51 +0200
committerjonmv <venstad@gmail.com>2023-09-01 12:23:51 +0200
commit424b9147adcc164ca74ab41c6e6968147e76e8ec (patch)
treeaf1111f183eaad8affe6293d35a6ef3f6375139e /container-search
parent1dbda815fe14531068c001f27a95798d3f7788cf (diff)
Show search cluster name in Node.toString
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/Dispatcher.java10
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java8
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/fastsearch/test/FastSearcherTestCase.java11
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java8
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java18
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java6
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java6
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/MockSearchCluster.java2
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java34
10 files changed, 50 insertions, 55 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 6f6b0fc2b79..eca0c8058a1 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
@@ -121,7 +121,7 @@ public class Dispatcher extends AbstractComponent {
DispatchNodesConfig nodesConfig, VipStatus vipStatus, InvokerFactoryFactory invokerFactories) {
this(dispatchConfig, rpcConnectionPool,
new SearchCluster(clusterId.stringValue(), dispatchConfig.minActivedocsPercentage(),
- toNodes(nodesConfig), vipStatus, new RpcPingFactory(rpcConnectionPool)),
+ toNodes(clusterId.stringValue(), nodesConfig), vipStatus, new RpcPingFactory(rpcConnectionPool)),
invokerFactories);
}
@@ -180,7 +180,7 @@ public class Dispatcher extends AbstractComponent {
* under the assumption that this is the common case, i.e., new nodes have no documents yet.
*/
void updateWithNewConfig(DispatchNodesConfig nodesConfig) {
- try (var items = volatileItems()) { // Marking a reference to the old snapshot, which we want to have cleaned up.
+ try (var items = volatileItems()) { // Mark a reference to the old snapshot, which we want to have cleaned up.
items.get().countDown(); // Decrement for its initial creation reference, so it may reach 0.
// Let the RPC pool know about the new nodes, and set up the delayed cleanup that we need to do.
@@ -192,7 +192,7 @@ public class Dispatcher extends AbstractComponent {
};
// Update the nodes the search cluster keeps track of, and what nodes are monitored.
- ClusterMonitor<Node> newMonitor = searchCluster.updateNodes(toNodes(nodesConfig), dispatchConfig.minActivedocsPercentage());
+ ClusterMonitor<Node> newMonitor = searchCluster.updateNodes(toNodes(searchCluster.name(), nodesConfig), dispatchConfig.minActivedocsPercentage());
// Update the snapshot to use the new nodes set in the search cluster; the RPC pool is ready for this.
this.volatileItems = update(newMonitor);
@@ -234,9 +234,9 @@ public class Dispatcher extends AbstractComponent {
case LATENCY_AMORTIZED_OVER_TIME -> LoadBalancer.Policy.LATENCY_AMORTIZED_OVER_TIME;
};
}
- private static List<Node> toNodes(DispatchNodesConfig nodesConfig) {
+ private static List<Node> toNodes(String clusterName, DispatchNodesConfig nodesConfig) {
return nodesConfig.node().stream()
- .map(n -> new Node(n.key(), n.host(), n.group()))
+ .map(n -> new Node(clusterName, n.key(), n.host(), n.group()))
.toList();
}
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 aeb04bfb141..c93f2f4c491 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
@@ -12,6 +12,7 @@ import java.util.concurrent.atomic.AtomicLong;
*/
public class Node {
+ private final String clusterName;
private final int key;
private final String hostname;
private final int group;
@@ -25,7 +26,8 @@ public class Node {
private volatile boolean working = true;
private volatile boolean isBlockingWrites = false;
- public Node(int key, String hostname, int group) {
+ public Node(String clusterName, int key, String hostname, int group) {
+ this.clusterName = clusterName;
this.key = key;
this.hostname = hostname;
this.group = group;
@@ -103,8 +105,8 @@ public class Node {
@Override
public String toString() {
- return "search node key = " + key + " hostname = "+ hostname + " path = " + pathIndex + " in group " + group +
- " statusIsKnown = " + statusIsKnown + " working = " + working +
+ return "search node in cluster = " + clusterName + " key = " + key + " hostname = "+ hostname +
+ " path = " + pathIndex + " in group " + group + " statusIsKnown = " + statusIsKnown + " working = " + working +
" activeDocs = " + getActiveDocuments() + " targetActiveDocs = " + getTargetActiveDocuments();
}
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 7a63eb07641..fb483a8eb7b 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
@@ -30,7 +30,6 @@ import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -83,7 +82,7 @@ public class FastSearcherTestCase {
@Test
void testSinglePassGroupingIsForcedWithSingleNodeGroups() {
FastSearcher fastSearcher = new FastSearcher("container.0",
- MockDispatcher.create(List.of(new Node(0, "host0", 0))),
+ MockDispatcher.create(List.of(new Node("test", 0, "host0", 0))),
new SummaryParameters(null),
new ClusterParams("testhittype"),
documentdbInfoConfig("test"),
@@ -106,7 +105,7 @@ public class FastSearcherTestCase {
@Test
void testRankProfileValidation() {
FastSearcher fastSearcher = new FastSearcher("container.0",
- MockDispatcher.create(List.of(new Node(0, "host0", 0))),
+ MockDispatcher.create(List.of(new Node("test", 0, "host0", 0))),
new SummaryParameters(null),
new ClusterParams("testhittype"),
documentdbInfoConfig("test"),
@@ -125,7 +124,7 @@ public class FastSearcherTestCase {
.setHasSummaryFeatures(false)
.build());
FastSearcher backend = new FastSearcher("container.0",
- MockDispatcher.create(Collections.singletonList(new Node(0, "host0", 0))),
+ MockDispatcher.create(Collections.singletonList(new Node("test", 0, "host0", 0))),
new SummaryParameters(null),
new ClusterParams("testhittype"),
documentDb,
@@ -142,7 +141,7 @@ public class FastSearcherTestCase {
@Test
void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() {
- MockDispatcher dispatcher = MockDispatcher.create(List.of(new Node(0, "host0", 0), new Node(2, "host1", 0)));
+ MockDispatcher dispatcher = MockDispatcher.create(List.of(new Node("test", 0, "host0", 0), new Node("test", 2, "host1", 0)));
FastSearcher fastSearcher = new FastSearcher("container.0",
dispatcher,
@@ -184,7 +183,7 @@ public class FastSearcherTestCase {
searchClusterB.name(clusterName);
b.searchcluster(searchClusterB);
VipStatus vipStatus = new VipStatus(b.build());
- List<Node> nodes_1 = List.of(new Node(0, "host0", 0));
+ List<Node> nodes_1 = List.of(new Node("test", 0, "host0", 0));
RpcResourcePool rpcPool_1 = new RpcResourcePool(MockDispatcher.toDispatchConfig(), MockDispatcher.toNodesConfig(nodes_1));
MockDispatcher dispatch_1 = MockDispatcher.create(nodes_1, rpcPool_1, vipStatus);
dispatch_1.clusterMonitor.shutdown();
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java
index 1278afe3759..3397638b950 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/DispatcherTest.java
@@ -77,7 +77,7 @@ public class DispatcherTest {
SearchCluster cl = new MockSearchCluster("1", 0, 0) {
@Override
public Optional<Node> localCorpusDispatchTarget() {
- return Optional.of(new Node(1, "test", 1));
+ return Optional.of(new Node("test", 1, "test", 1));
}
};
MockInvokerFactory invokerFactory = new MockInvokerFactory(cl.groupList(), dispatchConfig, (n, a) -> true);
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
index 688cdffe22d..500201df26f 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/InterleavedSearchInvokerTest.java
@@ -238,8 +238,8 @@ public class InterleavedSearchInvokerTest {
@Test
void requireThatTopKProbabilityOverrideIsDisabledOnContentSkew() throws IOException {
- Node node0 = new Node(0, "host0", 0);
- Node node1 = new Node(1, "host1", 0);
+ Node node0 = new Node("test", 0, "host0", 0);
+ Node node1 = new Node("test", 1, "host1", 0);
Group group = new Group(0, List.of(node0, node1));
node0.setActiveDocuments(1000000);
@@ -250,8 +250,8 @@ public class InterleavedSearchInvokerTest {
@Test
void requireThatTopKProbabilityOverrideIsDisabledOnLittleContent() throws IOException {
- Node node0 = new Node(0, "host0", 0);
- Node node1 = new Node(1, "host1", 0);
+ Node node0 = new Node("test", 0, "host0", 0);
+ Node node1 = new Node("test", 1, "host1", 0);
Group group = new Group(0, List.of(node0, node1));
node0.setActiveDocuments(10);
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java
index 4956698cc2f..b57d97ebb84 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/LoadBalancerTest.java
@@ -28,7 +28,7 @@ public class LoadBalancerTest {
private static final double delta = 0.0000001;
@Test
void requireThatLoadBalancerServesSingleNodeSetups() {
- Node n1 = new Node(0, "test-node1", 0);
+ Node n1 = new Node("test", 0, "test-node1", 0);
LoadBalancer lb = new LoadBalancer(List.of(new Group(0, List.of(n1))), LoadBalancer.Policy.ROUNDROBIN);
Optional<Group> grp = lb.takeGroup(null);
@@ -40,8 +40,8 @@ public class LoadBalancerTest {
@Test
void requireThatLoadBalancerServesMultiGroupSetups() {
- Node n1 = new Node(0, "test-node1", 0);
- Node n2 = new Node(1, "test-node2", 1);
+ Node n1 = new Node("test", 0, "test-node1", 0);
+ Node n2 = new Node("test", 1, "test-node2", 1);
LoadBalancer lb = new LoadBalancer(List.of(new Group(0, List.of(n1)), new Group(1,List.of(n2))), LoadBalancer.Policy.ROUNDROBIN);
Optional<Group> grp = lb.takeGroup(null);
@@ -53,10 +53,10 @@ public class LoadBalancerTest {
@Test
void requireThatLoadBalancerServesClusteredGroups() {
- Node n1 = new Node(0, "test-node1", 0);
- Node n2 = new Node(1, "test-node2", 0);
- Node n3 = new Node(0, "test-node3", 1);
- Node n4 = new Node(1, "test-node4", 1);
+ Node n1 = new Node("test", 0, "test-node1", 0);
+ Node n2 = new Node("test", 1, "test-node2", 0);
+ Node n3 = new Node("test", 0, "test-node3", 1);
+ Node n4 = new Node("test", 1, "test-node4", 1);
LoadBalancer lb = new LoadBalancer(List.of(new Group(0, List.of(n1,n2)), new Group(1,List.of(n3,n4))), LoadBalancer.Policy.ROUNDROBIN);
Optional<Group> grp = lb.takeGroup(null);
@@ -65,8 +65,8 @@ public class LoadBalancerTest {
@Test
void requireThatLoadBalancerReturnsDifferentGroups() {
- Node n1 = new Node(0, "test-node1", 0);
- Node n2 = new Node(1, "test-node2", 1);
+ Node n1 = new Node("test", 0, "test-node1", 0);
+ Node n2 = new Node("test", 1, "test-node2", 1);
LoadBalancer lb = new LoadBalancer(List.of(new Group(0, List.of(n1)), new Group(1,List.of(n2))), LoadBalancer.Policy.ROUNDROBIN);
// get first group
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java b/container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java
index aca84386af7..b47015c08c6 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/MockInvoker.java
@@ -3,17 +3,13 @@ package com.yahoo.search.dispatch;
import com.yahoo.prelude.fastsearch.FastHit;
import com.yahoo.search.Query;
-import com.yahoo.search.Result;
-import com.yahoo.search.dispatch.searchcluster.Group;
import com.yahoo.search.dispatch.searchcluster.Node;
import com.yahoo.search.result.Coverage;
import com.yahoo.search.result.Hit;
import com.yahoo.search.searchchain.Execution;
-import java.io.IOException;
import java.util.List;
import java.util.Optional;
-import java.util.OptionalInt;
class MockInvoker extends SearchInvoker {
@@ -23,7 +19,7 @@ class MockInvoker extends SearchInvoker {
int hitsRequested;
protected MockInvoker(int key, Coverage coverage) {
- super(Optional.of(new Node(key, "?", 0)));
+ super(Optional.of(new Node("test", key, "?", 0)));
this.coverage = coverage;
}
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java
index 7c1e7372507..b877bac5d74 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/rpc/RpcSearchInvokerTest.java
@@ -33,7 +33,7 @@ public class RpcSearchInvokerTest {
var lengthHolder = new AtomicInteger();
var mockClient = parameterCollectorClient(compressionTypeHolder, payloadHolder, lengthHolder);
var mockPool = new RpcResourcePool(ImmutableMap.of(7, mockClient.createConnection("foo", 123)));
- var invoker = new RpcSearchInvoker(mockSearcher(), compressor, new Node(7, "seven", 1), mockPool, 1000);
+ var invoker = new RpcSearchInvoker(mockSearcher(), compressor, new Node("test", 7, "seven", 1), mockPool, 1000);
Query q = new Query("search/?query=test&hits=10&offset=3");
RpcSearchInvoker.RpcContext context = (RpcSearchInvoker.RpcContext) invoker.sendSearchRequest(q, null);
@@ -47,7 +47,7 @@ public class RpcSearchInvokerTest {
assertEquals(3, request.getOffset());
assertTrue(request.getQueryTreeBlob().size() > 0);
- var invoker2 = new RpcSearchInvoker(mockSearcher(), compressor, new Node(8, "eight", 1), mockPool, 1000);
+ var invoker2 = new RpcSearchInvoker(mockSearcher(), compressor, new Node("test", 8, "eight", 1), mockPool, 1000);
RpcSearchInvoker.RpcContext context2 = (RpcSearchInvoker.RpcContext) invoker2.sendSearchRequest(q, context);
assertSame(context, context2);
assertEquals(lengthHolder.get(), context.compressedPayload.uncompressedSize());
@@ -62,7 +62,7 @@ public class RpcSearchInvokerTest {
var lengthHolder = new AtomicInteger();
var mockClient = parameterCollectorClient(compressionTypeHolder, payloadHolder, lengthHolder);
var mockPool = new RpcResourcePool(ImmutableMap.of(7, mockClient.createConnection("foo", 123)));
- var invoker = new RpcSearchInvoker(mockSearcher(), compressor, new Node(7, "seven", 1), mockPool, maxHits);
+ var invoker = new RpcSearchInvoker(mockSearcher(), compressor, new Node("test", 7, "seven", 1), mockPool, maxHits);
Query q = new Query("search/?query=test&hits=10&offset=3");
invoker.sendSearchRequest(q, null);
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/MockSearchCluster.java b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/MockSearchCluster.java
index cd0791a3881..6900cc5dd52 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/MockSearchCluster.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/MockSearchCluster.java
@@ -79,7 +79,7 @@ public class MockSearchCluster extends SearchCluster {
for (int group = 0; group < numGroups; group++) {
List<Node> groupNodes = new ArrayList<>();
for (int i = 0; i < nodesPerGroup; i++) {
- Node node = new Node(distributionKey, "host" + distributionKey, group);
+ Node node = new Node("test", distributionKey, "host" + distributionKey, group);
node.setWorking(true);
groupNodes.add(node);
distributionKey++;
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
index bfe1aed1084..65b0261b1f8 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java
@@ -19,8 +19,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.function.Function;
-import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static java.util.function.Function.identity;
@@ -58,7 +56,7 @@ public class SearchClusterTest {
for (String name : nodeNames) {
int key = nodes.size() % nodesPerGroup;
int group = nodes.size() / nodesPerGroup;
- nodes.add(new Node(key, name, group));
+ nodes.add(new Node("test", key, name, group));
numDocsPerNode.add(new AtomicInteger(1));
pingCounts.add(new AtomicInteger(0));
}
@@ -326,7 +324,7 @@ public class SearchClusterTest {
@Test
void requireThatPingSequenceIsUpHeld() {
- Node node = new Node(1, "n", 1);
+ Node node = new Node("test", 1, "n", 1);
assertEquals(1, node.createPingSequenceId());
assertEquals(2, node.createPingSequenceId());
assertEquals(0, node.getLastReceivedPongId());
@@ -348,7 +346,7 @@ public class SearchClusterTest {
@Test
void requireThatSingleNodeGroupIsInBalance() {
- Group group = new Group(0, List.of(new Node(1, "n", 1)));
+ Group group = new Group(0, List.of(new Node("test", 1, "n", 1)));
group.nodes().forEach(node -> node.setWorking(true));
assertTrue(group.isBalanced());
group.aggregateNodeValues();
@@ -360,7 +358,7 @@ public class SearchClusterTest {
@Test
void requireThatMultiNodeGroupDetectsBalance() {
- Group group = new Group(0, List.of(new Node(1, "n1", 1), new Node(2, "n2", 1)));
+ Group group = new Group(0, List.of(new Node("test", 1, "n1", 1), new Node("test", 2, "n2", 1)));
assertTrue(group.isBalanced());
group.nodes().forEach(node -> node.setWorking(true));
assertTrue(group.isBalanced());
@@ -386,21 +384,21 @@ public class SearchClusterTest {
@Test
void requireThatPreciselyTheRetainedNodesAreKeptWhenNodesAreUpdated() {
try (State state = new State("query", 2, IntStream.range(0, 6).mapToObj(i -> "node-" + i).toList())) {
- List<Node> referenceNodes = List.of(new Node(0, "node-0", 0),
- new Node(1, "node-1", 0),
- new Node(0, "node-2", 1),
- new Node(1, "node-3", 1),
- new Node(0, "node-4", 2),
- new Node(1, "node-5", 2));
+ List<Node> referenceNodes = List.of(new Node("test", 0, "node-0", 0),
+ new Node("test", 1, "node-1", 0),
+ new Node("test", 0, "node-2", 1),
+ new Node("test", 1, "node-3", 1),
+ new Node("test", 0, "node-4", 2),
+ new Node("test", 1, "node-5", 2));
SearchGroups oldGroups = state.searchCluster.groupList();
assertEquals(Set.copyOf(referenceNodes), oldGroups.nodes());
- List<Node> updatedNodes = List.of(new Node(0, "node-1", 0), // Swap node-0 and node-1
- new Node(1, "node-0", 0), // Swap node-1 and node-0
- new Node(0, "node-4", 1), // Swap node-2 and node-4
- new Node(1, "node-3", 1),
- new Node(0, "node-2", 2), // Swap node-4 and node-2
- new Node(1, "node-6", 2)); // Replace node-6
+ List<Node> updatedNodes = List.of(new Node("test", 0, "node-1", 0), // Swap node-0 and node-1
+ new Node("test", 1, "node-0", 0), // Swap node-1 and node-0
+ new Node("test", 0, "node-4", 1), // Swap node-2 and node-4
+ new Node("test", 1, "node-3", 1),
+ new Node("test", 0, "node-2", 2), // Swap node-4 and node-2
+ new Node("test", 1, "node-6", 2)); // Replace node-6
state.searchCluster.updateNodes(updatedNodes, 100.0);
SearchGroups newGroups = state.searchCluster.groupList();
assertEquals(Set.copyOf(updatedNodes), newGroups.nodes());