diff options
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/dispatch/searchcluster')
3 files changed, 15 insertions, 5 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 d30abd1d047..cf161638104 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 @@ -26,6 +26,7 @@ public class Group { private final AtomicBoolean hasSufficientCoverage = new AtomicBoolean(true); private final AtomicBoolean hasFullCoverage = new AtomicBoolean(true); private final AtomicLong activeDocuments = new AtomicLong(0); + private final AtomicLong targetActiveDocuments = new AtomicLong(0); private final AtomicBoolean isBlockingWrites = new AtomicBoolean(false); private final AtomicBoolean isBalanced = new AtomicBoolean(true); @@ -68,6 +69,8 @@ public class Group { public void aggregateNodeValues() { long activeDocs = nodes.stream().filter(node -> node.isWorking() == Boolean.TRUE).mapToLong(Node::getActiveDocuments).sum(); activeDocuments.set(activeDocs); + long targetActiveDocs = nodes.stream().filter(node -> node.isWorking() == Boolean.TRUE).mapToLong(Node::getTargetActiveDocuments).sum(); + targetActiveDocuments.set(targetActiveDocs); isBlockingWrites.set(nodes.stream().anyMatch(Node::isBlockingWrites)); int numWorkingNodes = workingNodes(); if (numWorkingNodes > 0) { @@ -90,6 +93,9 @@ public class Group { /** Returns the active documents on this group. If unknown, 0 is returned. */ long activeDocuments() { return activeDocuments.get(); } + /** Returns the target active documents on this group. If unknown, 0 is returned. */ + long targetActiveDocuments() { return targetActiveDocuments.get(); } + /** Returns whether any node in this group is currently blocking write operations */ public boolean isBlockingWrites() { return isBlockingWrites.get(); } @@ -99,7 +105,7 @@ public class Group { /** Returns whether this group has too few documents per node to expect it to be balanced */ public boolean isSparse() { if (nodes.isEmpty()) return false; - return activeDocuments.get() / nodes.size() < minDocsPerNodeToRequireLowSkew; + return activeDocuments() / nodes.size() < minDocsPerNodeToRequireLowSkew; } public boolean fullCoverageStatusChanged(boolean hasFullCoverageNow) { diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java index 0dce3d84273..d9c0198a472 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/searchcluster/Node.java @@ -21,6 +21,7 @@ public class Node { private final AtomicBoolean statusIsKnown = new AtomicBoolean(false); private final AtomicBoolean working = new AtomicBoolean(true); private final AtomicLong activeDocuments = new AtomicLong(0); + private final AtomicLong targetActiveDocuments = new AtomicLong(0); private final AtomicLong pingSequence = new AtomicLong(0); private final AtomicLong lastPong = new AtomicLong(0); private final AtomicBoolean isBlockingWrites = new AtomicBoolean(false); @@ -62,6 +63,7 @@ public class Node { this.working.lazySet(working); if ( ! working ) { activeDocuments.set(0); + targetActiveDocuments.set(0); } } @@ -71,10 +73,12 @@ public class Node { } /** Updates the active documents on this node */ - public void setActiveDocuments(long activeDocuments) { this.activeDocuments.set(activeDocuments); } + public void setActiveDocuments(long documents) { this.activeDocuments.set(documents); } + public void setTargetActiveDocuments(long documents) { this.targetActiveDocuments.set(documents); } /** Returns the active documents on this node. If unknown, 0 is returned. */ long getActiveDocuments() { return activeDocuments.get(); } + long getTargetActiveDocuments() { return targetActiveDocuments.get(); } public void setBlockingWrites(boolean isBlockingWrites) { this.isBlockingWrites.set(isBlockingWrites); } @@ -86,8 +90,7 @@ public class Node { @Override public boolean equals(Object o) { if (o == this) return true; - if ( ! (o instanceof Node)) return false; - Node other = (Node)o; + if ( ! (o instanceof Node other)) return false; if ( ! Objects.equals(this.hostname, other.hostname)) return false; if ( ! Objects.equals(this.key, other.key)) return false; if ( ! Objects.equals(this.pathIndex, other.pathIndex)) return false; @@ -100,7 +103,7 @@ public class Node { public String toString() { return "search node key = " + key + " hostname = "+ hostname + " path = " + pathIndex + " in group " + group + " statusIsKnown = " + statusIsKnown.get() + " working = " + working.get() + - " activeDocs = " + activeDocuments.get(); + " activeDocs = " + getActiveDocuments() + " targetActiveDocs = " + getTargetActiveDocuments(); } } 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 f8c4627473d..82d3d98d9ef 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 @@ -339,6 +339,7 @@ public class SearchCluster implements NodeManager<Node> { } else { if (pong.activeDocuments().isPresent()) { node.setActiveDocuments(pong.activeDocuments().get()); + node.setTargetActiveDocuments(pong.targetActiveDocuments().get()); node.setBlockingWrites(pong.isBlockingWrites()); } clusterMonitor.responded(node); |