aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/dispatch
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2022-03-09 12:47:54 +0100
committerJon Bratseth <bratseth@gmail.com>2022-03-09 12:47:54 +0100
commitb303b3a8c674c9f3f514a1747dc7abbf99907627 (patch)
treed8db22dc6911bd671bb35c7dadf9c2e96b739c12 /container-search/src/main/java/com/yahoo/search/dispatch
parentd7fe7b4d8d265665f7dbfb1f3054a5e5ec797992 (diff)
Simplify
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/dispatch')
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java29
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java7
2 files changed, 12 insertions, 24 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java b/container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java
index 7f4d8fc4739..7934a9e25f6 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/LoadBalancer.java
@@ -12,13 +12,14 @@ import java.util.Set;
import java.util.logging.Logger;
/**
- * LoadBalancer determines which group of content nodes should be accessed next for each search query when the internal java dispatcher is
- * used.
+ * LoadBalancer determines which group of content nodes should be accessed next for each search query when the
+ * internal java dispatcher is used.
+ *
+ * The implementation here is a simplistic least queries in flight + round-robin load balancer
*
* @author ollivir
*/
public class LoadBalancer {
- // The implementation here is a simplistic least queries in flight + round-robin load balancer
private static final Logger log = Logger.getLogger(LoadBalancer.class.getName());
@@ -174,24 +175,10 @@ public class LoadBalancer {
* @return the better of the two
*/
private static GroupStatus betterGroup(GroupStatus first, GroupStatus second) {
- if (second == null) {
- return first;
- }
- if (first == null) {
- return second;
- }
-
- // different coverage
- if (first.group.hasSufficientCoverage() != second.group.hasSufficientCoverage()) {
- if (!first.group.hasSufficientCoverage()) {
- // first doesn't have coverage, second does
- return second;
- } else {
- // second doesn't have coverage, first does
- return first;
- }
- }
-
+ if (second == null) return first;
+ if (first == null) return second;
+ if (first.group.hasSufficientCoverage() != second.group.hasSufficientCoverage())
+ return first.group.hasSufficientCoverage() ? first : second;
return first;
}
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 e99c1d5ad32..8f6e1b1ee2f 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
@@ -17,7 +17,9 @@ import java.util.logging.Logger;
public class Group {
private static final Logger log = Logger.getLogger(Group.class.getName());
- private final static double maxContentSkew = 0.10; // If documents on a node is more than 10% off from the average the group is unbalanced
+
+ // If documents on a node is more than 10% off from the average the group is unbalanced
+ private final static double maxContentSkew = 0.10;
private final static int minDocsPerNodeToRequireLowSkew = 100;
private final int id;
@@ -41,8 +43,7 @@ public class Group {
/**
* Returns the unique identity of this group.
- * NOTE: This is a contiguous index from 0, NOT necessarily the group id assigned
- * by the user or node repo.
+ * NOTE: This is a contiguous index from 0, NOT necessarily the group id assigned by the user or node repo.
*/
public int id() { return id; }