From 2640874585166c2224dbb7e2904dc9f07c75bb59 Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Thu, 19 Sep 2019 17:05:28 +0200 Subject: Revert "Clarify logic: No functional change" --- .../dispatch/searchcluster/SearchCluster.java | 36 ++++++++++++---------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'container-search') 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 e2719545a6a..6f775e7218e 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,33 +232,35 @@ public class SearchCluster implements NodeManager { updateVipStatusOnCoverageChange(group, sufficientCoverage); } - private void updateVipStatusOnNodeChange(Node node, boolean nodeIsWorking) { - if (localCorpusDispatchTarget.isEmpty()) { // consider entire cluster - if (hasInformationAboutAllNodes()) - setInRotationOnlyIf(hasWorkingNodes()); + 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); } - else if (usesLocalCorpusIn(node)) { // follow the status of this node - setInRotationOnlyIf(nodeIsWorking); + else if (localCorpusDispatchTarget.isEmpty() && hasInformationAboutAllNodes()) { + if (hasWorkingNodes()) + vipStatus.addToRotation(clusterId); + else + vipStatus.removeFromRotation(clusterId); } } private void updateVipStatusOnCoverageChange(Group group, boolean sufficientCoverage) { - if ( localCorpusDispatchTarget.isEmpty()) { // consider entire cluster - if (vipStatus.isInRotation() && sufficientCoverage) + boolean isInRotation = vipStatus.isInRotation(); + if (usesLocalCorpusIn(group)) { // follow the status of the local corpus + if (sufficientCoverage) vipStatus.addToRotation(clusterId); + else + vipStatus.removeFromRotation(clusterId); } - else if (usesLocalCorpusIn(group)) { // follow the status of this group - setInRotationOnlyIf(sufficientCoverage); + else if ( localCorpusDispatchTarget.isEmpty()) { + if (isInRotation && sufficientCoverage) + vipStatus.addToRotation(clusterId); } } - private void setInRotationOnlyIf(boolean inRotation) { - if (inRotation) - vipStatus.addToRotation(clusterId); - else - vipStatus.removeFromRotation(clusterId); - } - private boolean hasInformationAboutAllNodes() { return nodesByHost.values().stream().allMatch(Node::getStatusIsKnown); } -- cgit v1.2.3