summaryrefslogtreecommitdiffstats
path: root/clustercontroller-core
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2023-07-16 22:52:40 +0200
committerHarald Musum <musum@yahooinc.com>2023-07-16 22:52:40 +0200
commitd86f86f334a5ad41346f1aecf8f927114f0409c0 (patch)
tree5f45af90ed4f40d4d0b24f3383305c0a60ce016e /clustercontroller-core
parent1375d80d4949799cb37d68c8f2b90a7a4f331b57 (diff)
Avoid code duplication
Diffstat (limited to 'clustercontroller-core')
-rw-r--r--clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeChecker.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeChecker.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeChecker.java
index 31bd9c59992..c81f01bd9aa 100644
--- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeChecker.java
+++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/NodeStateChangeChecker.java
@@ -422,15 +422,7 @@ public class NodeStateChangeChecker {
private Result checkRedundancy(DistributorNodeInfo distributorNodeInfo, Node node) {
Integer minReplication = minReplication(distributorNodeInfo).get(node.getIndex());
- // Why test on != null? Missing min-replication is OK (indicate empty/few buckets on system).
- if (minReplication != null && minReplication < requiredRedundancy) {
- return disallow("Distributor " + distributorNodeInfo.getNodeIndex()
- + " says storage node " + node.getIndex()
- + " has buckets with redundancy as low as "
- + minReplication + ", but we require at least " + requiredRedundancy);
- }
-
- return allow();
+ return verifyRedundancy(distributorNodeInfo, minReplication, node.getIndex());
}
private Result checkRedundancySeenFromDistributor(DistributorNodeInfo distributorNodeInfo, Set<Integer> indexesToCheck) {
@@ -444,11 +436,17 @@ public class NodeStateChangeChecker {
if ( ! indexesToCheck.contains(nodeIndex)) continue;
if (minReplication == null || (value != null && value < minReplication)) {
minReplication = value;
+ if (minReplication == null) continue;
+
minReplicationIndex = nodeIndex;
if (minReplication < requiredRedundancy) break;
}
}
+ return verifyRedundancy(distributorNodeInfo, minReplication, minReplicationIndex);
+ }
+
+ private Result verifyRedundancy(DistributorNodeInfo distributorNodeInfo, Integer minReplication, Integer minReplicationIndex) {
// Why test on != null? Missing min-replication is OK (indicate empty/few buckets on system).
if (minReplication != null && minReplication < requiredRedundancy) {
return disallow("Distributor " + distributorNodeInfo.getNodeIndex()