aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@vespa.ai>2023-07-12 08:47:29 +0200
committerJon Bratseth <bratseth@vespa.ai>2023-07-12 08:47:29 +0200
commit7bf12d37859f3bcf32b8851b7cd8f824262cccdf (patch)
tree288cb0ee08379acd9ca745add47fe437d3ec7f78
parent2e06511ec5d6f977fa249f887f7eb2055ece7f90 (diff)
Simplify
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java8
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java6
2 files changed, 5 insertions, 9 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java
index f8cc3ffd530..6fbb0c6d268 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java
@@ -48,8 +48,6 @@ public class GroupPreparer {
* @param requestedNodes a specification of the requested nodes
* @param surplusActiveNodes currently active nodes which are available to be assigned to this group.
* This method will remove from this list if it finds it needs additional nodes
- * @param indices the next available node indices for this cluster.
- * This method will consume these when it allocates new nodes to the cluster.
* @param allNodes list of all nodes and hosts
* @return the list of nodes this cluster group will have allocated if activated
*/
@@ -57,12 +55,14 @@ public class GroupPreparer {
// but it may not change the set of active nodes, as the active nodes must stay in sync with the
// active config model which is changed on activate
public List<Node> prepare(ApplicationId application, ClusterSpec cluster, NodeSpec requestedNodes,
- List<Node> surplusActiveNodes, NodeIndices indices,
- LockedNodeList allNodes) {
+ List<Node> surplusActiveNodes, LockedNodeList allNodes) {
log.log(Level.FINE, () -> "Preparing " + cluster.type().name() + " " + cluster.id() + " with requested resources " +
requestedNodes.resources().orElse(NodeResources.unspecified()));
// Try preparing in memory without global unallocated lock. Most of the time there should be no changes,
// and we can return nodes previously allocated.
+ List<Integer> usedIndices = allNodes.cluster(cluster.id()).mapToList(node -> node.allocation().get().membership().index());
+ NodeIndices indices = new NodeIndices(usedIndices);
+
NodeAllocation probeAllocation = prepareAllocation(application, cluster, requestedNodes, surplusActiveNodes,
indices::probeNext, allNodes);
if (probeAllocation.fulfilledAndNoChanges()) {
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java
index 71795fd7393..4900c0be5a6 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java
@@ -10,7 +10,6 @@ import com.yahoo.vespa.hosted.provision.Node;
import com.yahoo.vespa.hosted.provision.NodeList;
import com.yahoo.vespa.hosted.provision.NodeRepository;
-import java.time.Clock;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
@@ -60,10 +59,7 @@ class Preparer {
NodeList clusterNodes = allNodes.owner(application);
List<Node> surplusNodes = findNodesInRemovableGroups(clusterNodes, requestedNodes.groups());
- List<Integer> usedIndices = clusterNodes.mapToList(node -> node.allocation().get().membership().index());
- NodeIndices indices = new NodeIndices(usedIndices);
-
- List<Node> accepted = groupPreparer.prepare(application, cluster, requestedNodes, surplusNodes, indices, allNodes);
+ List<Node> accepted = groupPreparer.prepare(application, cluster, requestedNodes, surplusNodes, allNodes);
if (requestedNodes.rejectNonActiveParent()) {
NodeList activeHosts = allNodes.state(Node.State.active).parents().nodeType(requestedNodes.type().hostType());
accepted = accepted.stream()