From c07f7df456d48ab8f58810ac0033c48488f82de5 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Fri, 8 Jan 2021 10:36:03 +0000 Subject: Add logging. --- .../main/java/com/yahoo/search/dispatch/searchcluster/Group.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'container-search') 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 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. */ -- cgit v1.2.3