summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@yahoo-inc.com>2016-08-18 13:16:59 +0200
committerJon Bratseth <bratseth@yahoo-inc.com>2016-08-18 13:16:59 +0200
commit4f1437c35a6adbb5df26c3372bba5f32c3cdf882 (patch)
tree13e1d495343cf52e55b1ec7d19d3af6ddf803d09 /container-search/src/main/java/com/yahoo/search
parent008827e05bef46027d54d33e01e597e45d9435e8 (diff)
Handle single group
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/SearchCluster.java27
1 files changed, 15 insertions, 12 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/SearchCluster.java b/container-search/src/main/java/com/yahoo/search/dispatch/SearchCluster.java
index ff0d420027f..05c27c6ca86 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/SearchCluster.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/SearchCluster.java
@@ -131,19 +131,22 @@ public class SearchCluster implements NodeManager<SearchCluster.Node> {
// Update active documents per group and use it to decide if the group should be active
for (Group group : groups.values())
group.aggregateActiveDocuments();
- for (Group currentGroup : groups.values()) {
- long sumOfAactiveDocumentsInOtherGroups = 0;
- for (Group otherGroup : groups.values())
- if ( otherGroup != currentGroup)
- sumOfAactiveDocumentsInOtherGroups += otherGroup.getActiveDocuments();
- long averageDocumentsInOtherGroups = sumOfAactiveDocumentsInOtherGroups / (groups.size() - 1);
- if (averageDocumentsInOtherGroups == 0)
- currentGroup.setHasSufficientCoverage(true); // no information about any group; assume coverage
- else
- currentGroup.setHasSufficientCoverage(
- 100 * (double)currentGroup.getActiveDocuments() / averageDocumentsInOtherGroups > minActivedocsCoveragePercentage);
+ if (groups.size() == 1) {
+ groups.values().iterator().next().setHasSufficientCoverage(true); // by definition
+ } else {
+ for (Group currentGroup : groups.values()) {
+ long sumOfAactiveDocumentsInOtherGroups = 0;
+ for (Group otherGroup : groups.values())
+ if (otherGroup != currentGroup)
+ sumOfAactiveDocumentsInOtherGroups += otherGroup.getActiveDocuments();
+ long averageDocumentsInOtherGroups = sumOfAactiveDocumentsInOtherGroups / (groups.size() - 1);
+ if (averageDocumentsInOtherGroups == 0)
+ currentGroup.setHasSufficientCoverage(true); // no information about any group; assume coverage
+ else
+ currentGroup.setHasSufficientCoverage(
+ 100 * (double) currentGroup.getActiveDocuments() / averageDocumentsInOtherGroups > minActivedocsCoveragePercentage);
+ }
}
-
}
private Pong getPong(FutureTask<Pong> futurePong, Node node) {