From a30172716faa0a2f2ee6d300755158613e19f7c8 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 11 Jan 2021 19:18:20 +0000 Subject: You must use one of the candidates in the set you got. It is not legal to change the set of candidates and perform a re-election if you are unhappy. --- .../src/main/java/com/yahoo/search/dispatch/SearchPath.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/SearchPath.java b/container-search/src/main/java/com/yahoo/search/dispatch/SearchPath.java index f87fc20e96e..7937be50813 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/SearchPath.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/SearchPath.java @@ -105,7 +105,7 @@ public class SearchPath { } private Group selectRandomGroupWithSufficientCoverage(SearchCluster cluster, List groupIds) { - while ( ! groupIds.isEmpty()) { + while ( groupIds.size() > 1 ) { int index = random.nextInt(groupIds.size()); int groupId = groupIds.get(index); Optional group = cluster.group(groupId); @@ -119,7 +119,7 @@ public class SearchPath { throw new InvalidSearchPathException("Invalid searchPath, cluster does not have " + (groupId + 1) + " groups"); } } - return cluster.groups().values().iterator().next(); + return cluster.group(groupIds.get(0)).get(); } private Group selectGroup(SearchCluster cluster) { -- cgit v1.2.3