diff options
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/SearchCluster.java | 36 |
1 files changed, 17 insertions, 19 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 6f775e7218e..e2719545a6a 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 @@ -232,35 +232,33 @@ public class SearchCluster implements NodeManager<Node> { updateVipStatusOnCoverageChange(group, sufficientCoverage); } - private void updateVipStatusOnNodeChange(Node node, boolean working) { - if (usesLocalCorpusIn(node)) { // follow the status of the local corpus - if (working) - vipStatus.addToRotation(clusterId); - else - vipStatus.removeFromRotation(clusterId); + private void updateVipStatusOnNodeChange(Node node, boolean nodeIsWorking) { + if (localCorpusDispatchTarget.isEmpty()) { // consider entire cluster + if (hasInformationAboutAllNodes()) + setInRotationOnlyIf(hasWorkingNodes()); } - else if (localCorpusDispatchTarget.isEmpty() && hasInformationAboutAllNodes()) { - if (hasWorkingNodes()) - vipStatus.addToRotation(clusterId); - else - vipStatus.removeFromRotation(clusterId); + else if (usesLocalCorpusIn(node)) { // follow the status of this node + setInRotationOnlyIf(nodeIsWorking); } } private void updateVipStatusOnCoverageChange(Group group, boolean sufficientCoverage) { - boolean isInRotation = vipStatus.isInRotation(); - if (usesLocalCorpusIn(group)) { // follow the status of the local corpus - if (sufficientCoverage) + if ( localCorpusDispatchTarget.isEmpty()) { // consider entire cluster + if (vipStatus.isInRotation() && sufficientCoverage) vipStatus.addToRotation(clusterId); - else - vipStatus.removeFromRotation(clusterId); } - else if ( localCorpusDispatchTarget.isEmpty()) { - if (isInRotation && sufficientCoverage) - vipStatus.addToRotation(clusterId); + else if (usesLocalCorpusIn(group)) { // follow the status of this group + setInRotationOnlyIf(sufficientCoverage); } } + private void setInRotationOnlyIf(boolean inRotation) { + if (inRotation) + vipStatus.addToRotation(clusterId); + else + vipStatus.removeFromRotation(clusterId); + } + private boolean hasInformationAboutAllNodes() { return nodesByHost.values().stream().allMatch(Node::getStatusIsKnown); } |