aboutsummaryrefslogtreecommitdiffstats
path: root/node-repository/src
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2021-02-24 17:01:03 +0100
committerJon Marius Venstad <venstad@gmail.com>2021-02-24 17:01:03 +0100
commit28bc4276f6e6ba8f4ed1f081d2cf902b33c521e3 (patch)
tree196694470f040acc094c519666f1b932aafdc1af /node-repository/src
parenta285c18e7dd2872f11e81f9d3d85037fb00c268f (diff)
Check only cluster id, better doc, test to show usage
Diffstat (limited to 'node-repository/src')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeIndices.java11
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java9
2 files changed, 10 insertions, 10 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeIndices.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeIndices.java
index 310e4f1e69a..da4ae2a119e 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeIndices.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeIndices.java
@@ -15,15 +15,14 @@ import static java.util.Comparator.naturalOrder;
*/
class NodeIndices {
- private final boolean compact;
private final List<Integer> used;
private int last;
private int probe;
- NodeIndices(NodeList nodes, boolean compact) {
- this.compact = compact;
- this.used = nodes.mapToList(node -> node.allocation().get().membership().index());
+ /** Pass the list of current indices in the cluster, and whether to fill gaps or not. */
+ NodeIndices(List<Integer> used, boolean compact) {
+ this.used = List.copyOf(used);
this.last = compact ? -1 : used.stream().max(naturalOrder()).orElse(-1);
this.probe = last;
}
@@ -38,13 +37,13 @@ class NodeIndices {
return last;
}
- /** Returns the next available index, without committing to using it. May be called multiple times. */
+ /** Returns the next available index, without committing to using it. Yields increasing indices when called multiple times. */
int probeNext() {
while (used.contains(++probe));
return probe;
}
- /** Commits to using any indices returned by an ongoing probe. */
+ /** Commits to using all indices returned by an ongoing probe. */
void commitProbe() {
last = probe;
}
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 0e22f4f0e6b..e36554b3600 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
@@ -61,10 +61,11 @@ class Preparer {
private List<Node> prepareNodes(ApplicationId application, ClusterSpec cluster, NodeSpec requestedNodes, int wantedGroups) {
List<Node> surplusNodes = findNodesInRemovableGroups(application, cluster, wantedGroups);
- NodeList nodesInCluster = nodeRepository.nodes().list(Node.State.allocatedStates().toArray(new Node.State[0]))
- .owner(application)
- .matching(node -> node.allocation().get().membership().cluster().satisfies(cluster));
- NodeIndices indices = new NodeIndices(nodesInCluster, ! cluster.type().isContent());
+ List<Integer> usedIndices = nodeRepository.nodes().list(Node.State.allocatedStates().toArray(new Node.State[0]))
+ .owner(application)
+ .cluster(cluster.id())
+ .mapToList(node -> node.allocation().get().membership().index());
+ NodeIndices indices = new NodeIndices(usedIndices, ! cluster.type().isContent());
List<Node> acceptedNodes = new ArrayList<>();
for (int groupIndex = 0; groupIndex < wantedGroups; groupIndex++) {
ClusterSpec clusterGroup = cluster.with(Optional.of(ClusterSpec.Group.from(groupIndex)));