diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-09-20 12:51:35 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-09-20 12:51:35 +0200 |
commit | 978ff3980abdbd04bf5d5cbdaa020475b2d08e24 (patch) | |
tree | e7867fbebdcd93c20da0a2e009a0066a114205ce /node-repository | |
parent | 1ed9d4a2f425b299b13c83b8fdf67ae6b4563f74 (diff) |
Distinguish saturation and sufficiency
Diffstat (limited to 'node-repository')
-rw-r--r-- | node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/GroupPreparer.java | 25 |
1 files changed, 15 insertions, 10 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 023c97a1d61..97956c44ebe 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 @@ -64,21 +64,21 @@ class GroupPreparer { // Use active nodes nodeList.offer(nodeRepository.getNodes(application, Node.State.active), !canChangeGroup); - if (nodeList.satisfied()) return nodeList.finalNodes(surplusActiveNodes); + if (nodeList.saturated()) return nodeList.finalNodes(surplusActiveNodes); // Use active nodes from other groups that will otherwise be retired List<Node> accepted = nodeList.offer(sortNodeListByCost(surplusActiveNodes), canChangeGroup); surplusActiveNodes.removeAll(accepted); - if (nodeList.satisfied()) return nodeList.finalNodes(surplusActiveNodes); + if (nodeList.saturated()) return nodeList.finalNodes(surplusActiveNodes); // Use previously reserved nodes nodeList.offer(nodeRepository.getNodes(application, Node.State.reserved), !canChangeGroup); - if (nodeList.satisfied()) return nodeList.finalNodes(surplusActiveNodes); + if (nodeList.saturated()) return nodeList.finalNodes(surplusActiveNodes); // Use inactive nodes accepted = nodeList.offer(sortNodeListByCost(nodeRepository.getNodes(application, Node.State.inactive)), !canChangeGroup); nodeList.update(nodeRepository.reserve(accepted)); - if (nodeList.satisfied()) return nodeList.finalNodes(surplusActiveNodes); + if (nodeList.saturated()) return nodeList.finalNodes(surplusActiveNodes); // Use new, ready nodes. Lock ready pool to ensure that nodes are not grabbed by others. try (Mutex readyLock = nodeRepository.lockUnallocated()) { @@ -86,7 +86,7 @@ class GroupPreparer { accepted = nodeList.offer(stripeOverHosts(sortNodeListByCost(readyNodes)), !canChangeGroup); nodeList.update(nodeRepository.reserve(accepted)); } - if (nodeList.satisfied()) return nodeList.finalNodes(surplusActiveNodes); + if (nodeList.sufficient()) return nodeList.finalNodes(surplusActiveNodes); if (nodeList.whatAboutUsingRetiredNodes()) { throw new OutOfCapacityException("Could not satisfy request for " + nodeCount + @@ -211,7 +211,7 @@ class GroupPreparer { ClusterMembership membership = offered.allocation().get().membership(); if ( ! offered.allocation().get().owner().equals(application)) continue; // wrong application if ( ! membership.cluster().equalsIgnoringGroup(cluster)) continue; // wrong cluster id/type - if ( (! canChangeGroup || satisfied()) && ! membership.cluster().group().equals(cluster.group())) continue; // wrong group and we can't or have no reason to change it + if ((! canChangeGroup || saturated()) && ! membership.cluster().group().equals(cluster.group())) continue; // wrong group and we can't or have no reason to change it if ( offered.allocation().get().isRemovable()) continue; // don't accept; causes removal if ( indexes.contains(membership.index())) continue; // duplicate index (just to be sure) @@ -219,10 +219,10 @@ class GroupPreparer { if ( offeredNodeHasParentHostnameAlreadyAccepted(this.nodes, offered)) wantToRetireNode = true; if ( !hasCompatibleFlavor(offered)) wantToRetireNode = true; - if ( ( !satisfied() && hasCompatibleFlavor(offered)) || acceptToRetire(offered) ) + if ((!saturated() && hasCompatibleFlavor(offered)) || acceptToRetire(offered) ) accepted.add(acceptNode(offered, wantToRetireNode)); } - else if (! satisfied() && hasCompatibleFlavor(offered)) { + else if (! saturated() && hasCompatibleFlavor(offered)) { if ( offeredNodeHasParentHostnameAlreadyAccepted(this.nodes, offered)) { ++rejectedWithClashingParentHost; continue; @@ -306,11 +306,16 @@ class GroupPreparer { return node.with(node.allocation().get().with(membership)); } - /** Returns true if we have accepted at least the requested number of nodes of the requested flavor */ - public boolean satisfied() { + /** Returns true if no more nodes are needed in this list */ + public boolean saturated() { return acceptedOfRequestedFlavor >= requestedNodes; } + /** Returns true if the content of this list is sufficient to meet the request */ + public boolean sufficient() { + return saturated(); + } + public boolean whatAboutUsingRetiredNodes() { return acceptedOfRequestedFlavor + wasRetiredJustNow >= requestedNodes; } |