aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-06-17 09:51:41 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-06-17 09:51:41 +0000
commitbaa81340f6cfbbd70480b3981a14fd3d087e13fe (patch)
treeefa85925730f8d1f5c4e5ddc7a0753c26329aeea /documentapi
parent544ba2e3d8cc1e4f1766ead5651712401d98a86f (diff)
Randomness is also needed when having only 2 nodes. If not it will always select [0] when pending is equal.
Diffstat (limited to 'documentapi')
-rw-r--r--documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/AdaptiveLoadBalancer.java10
1 files changed, 3 insertions, 7 deletions
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/AdaptiveLoadBalancer.java b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/AdaptiveLoadBalancer.java
index 6a68a6e122b..621064c178e 100644
--- a/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/AdaptiveLoadBalancer.java
+++ b/documentapi/src/main/java/com/yahoo/documentapi/messagebus/protocol/AdaptiveLoadBalancer.java
@@ -30,14 +30,10 @@ class AdaptiveLoadBalancer extends LoadBalancer {
entry = choices.get(0);
metrics = getNodeMetrics(entry);
} else {
- int candA = 0;
- int candB = 1;
- if (choices.size() > 2) {
- candA = random.nextInt(choices.size());
+ int candA = random.nextInt(choices.size());
+ int candB = random.nextInt(choices.size());
+ while (candB == candA) {
candB = random.nextInt(choices.size());
- while (candB == candA) {
- candB = random.nextInt(choices.size());
- }
}
entry = choices.get(candA);
Mirror.Entry entryB = choices.get(candB);