summaryrefslogtreecommitdiffstats
path: root/node-repository/src/main/java
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-05-18 13:41:24 +0200
committerJon Bratseth <bratseth@gmail.com>2020-05-18 13:41:24 +0200
commit60b1619d6c154c352fe47153d02279dc6698eb18 (patch)
treea8a8ff6acfb3ed908f82f04dd5a604d0e626b0c4 /node-repository/src/main/java
parent6002bf421f7e2e813704e642e33992d930755062 (diff)
Prepare to iterate over groups 2
Diffstat (limited to 'node-repository/src/main/java')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java
index a556dcf9ced..d1a5a91e985 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocationOptimizer.java
@@ -43,18 +43,21 @@ public class AllocationOptimizer {
// This is the group size, since we (for now) assume the group size is decided by someone wiser than us
// and we decide the number of groups.
// The exception is when we only have one group, where we can add and remove single nodes in it.
- boolean singleGroupMode = current.groups() == 1 && ( limits.isEmpty() || limits.min().groups() == 1 );
- int nodeIncrement = singleGroupMode ? 1 : current.groupSize();
Optional<AllocatableClusterResources> bestAllocation = Optional.empty();
-
- for (int nodes = minNodes(limits, singleGroupMode, current); nodes <= maxNodes(limits, singleGroupMode, current); nodes += nodeIncrement) {
+ for (int nodes = minNodes(limits); nodes <= maxNodes(limits); nodes++) {
+ boolean singleGroupMode = current.groups() == 1 && ( limits.isEmpty() || limits.min().groups() == 1 );
int groups = singleGroupMode ? 1 : nodes / current.groupSize();
if ( ! limits.isEmpty() && ( groups < limits.min().groups() || groups > limits.max().groups())) continue;
+ if (nodes % groups != 0) continue;
+ int groupSize = nodes / groups;
+ if (groups != 1 && groupSize != current.groupSize()) continue; // TODO: Remove this line
+
+
// Adjust for redundancy: Node in group if groups = 1, an extra group if multiple groups
// TODO: Make the best choice based on size and redundancy setting instead
- int nodesAdjustedForRedundancy = target.adjustForRedundancy() ? nodes - nodeIncrement : nodes;
+ int nodesAdjustedForRedundancy = target.adjustForRedundancy() ? ( groups == 1 ? nodes - 1 : nodes - groupSize ) : nodes;
if (nodesAdjustedForRedundancy < 1) continue;
int groupsAdjustedForRedundancy = target.adjustForRedundancy() ? ( groups == 1 ? 1 : groups - 1 ) : groups;
@@ -71,16 +74,14 @@ public class AllocationOptimizer {
return bestAllocation;
}
- private int minNodes(Limits limits, boolean singleGroupMode, AllocatableClusterResources current) {
+ private int minNodes(Limits limits) {
if (limits.isEmpty()) return minimumNodes;
- if (singleGroupMode) return limits.min().nodes();
- return Math.max(limits.min().nodes(), limits.min().groups() * current.groupSize() );
+ return limits.min().nodes();
}
- private int maxNodes(Limits limits, boolean singleGroupMode, AllocatableClusterResources current) {
+ private int maxNodes(Limits limits) {
if (limits.isEmpty()) return maximumNodes;
- if (singleGroupMode) return limits.max().nodes();
- return Math.min(limits.max().nodes(), limits.max().groups() * current.groupSize() );
+ return limits.max().nodes();
}
/**