aboutsummaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java22
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java14
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTest.java1
-rw-r--r--container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTester.java2
4 files changed, 32 insertions, 7 deletions
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 e755abc7d66..1be45b01367 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
@@ -173,11 +173,15 @@ public class SearchCluster implements NodeManager<Node> {
}
public boolean hasInformationAboutAllNodes() {
- return groups().stream().allMatch(g -> g.nodes().stream().allMatch(node -> node.isWorking() != null));
+ return groups().stream().allMatch(group -> group.nodes().stream().allMatch(node -> node.isWorking() != null));
+ }
+
+ public long nonWorkingNodeCount() {
+ return groups().stream().flatMap(group -> group.nodes().stream()).filter(node -> node.isWorking() == Boolean.FALSE).count();
}
private boolean hasWorkingNodes() {
- return groups().stream().anyMatch(g -> g.nodes().stream().anyMatch(node -> node.isWorking() != Boolean.FALSE));
+ return groups().stream().anyMatch(group -> group.nodes().stream().anyMatch(node -> node.isWorking() != Boolean.FALSE));
}
private boolean usesLocalCorpusIn(Node node) {
@@ -252,11 +256,15 @@ public class SearchCluster implements NodeManager<Node> {
if (node.isWorking() != Boolean.TRUE)
unresponsive.append('\n').append(node);
}
- log.warning("Cluster " + clusterId + ": " + group + " has reduced coverage: " +
- "Active documents: " + group.activeDocuments() + "/" + medianDocuments + ", " +
- "Target active documents: " + group.targetActiveDocuments() + ", " +
- "working nodes: " + group.workingNodes() + "/" + group.nodes().size() +
- ", unresponsive nodes: " + (unresponsive.toString().isEmpty() ? " none" : unresponsive));
+ String message = "Cluster " + clusterId + ": " + group + " has reduced coverage: " +
+ "Active documents: " + group.activeDocuments() + "/" + medianDocuments + ", " +
+ "Target active documents: " + group.targetActiveDocuments() + ", " +
+ "working nodes: " + group.workingNodes() + "/" + group.nodes().size() +
+ ", unresponsive nodes: " + (unresponsive.toString().isEmpty() ? " none" : unresponsive);
+ if (nonWorkingNodeCount() == 1) // That is normal
+ log.info(message);
+ else
+ log.warning(message);
}
}
}
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java
index 3d981c5e45a..a83ef963005 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterCoverageTest.java
@@ -3,6 +3,7 @@ package com.yahoo.search.dispatch.searchcluster;
import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -87,6 +88,19 @@ public class SearchClusterCoverageTest {
}
@Test
+ void test_non_working_node_count() {
+ var tester = new SearchClusterTester(3, 3);
+ tester.setDocsPerNode(100, 0);
+ tester.setDocsPerNode(100, 1);
+ tester.setDocsPerNode(100, 2);
+ assertEquals(0, tester.cluster().nonWorkingNodeCount());
+ tester.setWorking(1, 1, false);
+ assertEquals(1, tester.cluster().nonWorkingNodeCount());
+ tester.setWorking(2, 2, false);
+ assertEquals(2, tester.cluster().nonWorkingNodeCount());
+ }
+
+ @Test
void three_groups_one_has_a_node_down_but_remaining_has_enough_docs() {
var tester = new SearchClusterTester(3, 3);
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 ddb0b9fa809..51256ec496e 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
@@ -375,4 +375,5 @@ public class SearchClusterTest {
group.aggregateNodeValues();
assertTrue(group.isBalanced());
}
+
}
diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTester.java b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTester.java
index 31f250072fe..35d990be412 100644
--- a/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTester.java
+++ b/container-search/src/test/java/com/yahoo/search/dispatch/searchcluster/SearchClusterTester.java
@@ -9,6 +9,8 @@ public class SearchClusterTester {
cluster = new MockSearchCluster("1", groups, nodesPerGroup);
}
+ public SearchCluster cluster() { return cluster; }
+
public void pingIterationCompleted() {
cluster.pingIterationCompleted();
}