diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2021-01-08 10:36:03 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2021-01-08 14:43:42 +0000 |
commit | c07f7df456d48ab8f58810ac0033c48488f82de5 (patch) | |
tree | d1a30bced29784631299a279cde0ef9c226c7630 /container-search | |
parent | 3f3021757fbfa2c1002c0bf3055a734a374fc8bd (diff) |
Add logging.
Diffstat (limited to 'container-search')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java index 23255fff330..be98ac57fc5 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Group.java @@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; +import java.util.logging.Logger; /** * A group in a search cluster. This class is multithread safe. @@ -24,6 +25,7 @@ public class Group { private final AtomicBoolean isBlockingWrites = new AtomicBoolean(false); private final AtomicBoolean isContentWellBalanced = new AtomicBoolean(true); private final static double MAX_UNBALANCE = 0.10; // If documents on a node is more than 10% off from the average the group is unbalanced + private static final Logger log = Logger.getLogger(Group.class.getName()); public Group(int id, List<Node> nodes) { this.id = id; @@ -66,11 +68,14 @@ public class Group { if (numWorkingNodes > 0) { long average = activeDocs / numWorkingNodes; long deviation = nodes.stream().filter(node -> node.isWorking() == Boolean.TRUE).mapToLong(node -> Math.abs(node.getActiveDocuments() - average)).sum(); - isContentWellBalanced.set(deviation <= (activeDocs * MAX_UNBALANCE)); + boolean isDeviationSmall = deviation <= (activeDocs * MAX_UNBALANCE); + if (isDeviationSmall != isContentWellBalanced.get()) { + log.info("Content is well balanced has changed to" + isDeviationSmall); + isContentWellBalanced.set(isDeviationSmall); + } } else { isContentWellBalanced.set(true); } - } /** Returns the active documents on this group. If unknown, 0 is returned. */ |