private NodeAllocation prepareAllocation(ApplicationId application, ClusterSpec cluster, NodeSpec requested,
                                             Supplier<Integer> nextIndex, LockedNodeList allNodes) {
        validateAccount(requested.cloudAccount(), application, allNodes);
        NodeAllocation allocation = new NodeAllocation(allNodes, application, cluster, requested, nextIndex, nodeRepository);
        IP.Allocation.Context allocationContext = IP.Allocation.Context.from(nodeRepository.zone().cloud(),
                                                                             requested.cloudAccount().isExclave(nodeRepository.zone()),
                                                                             nodeRepository.nameResolver());
        NodePrioritizer prioritizer = new NodePrioritizer(allNodes,
                                                          application,
                                                          cluster,
                                                          requested,
                                                          nodeRepository.zone().cloud().dynamicProvisioning(),
                                                          nodeRepository.zone().cloud().allowHostSharing(),
                                                          allocationContext,
                                                          nodeRepository.nodes(),
                                                          nodeRepository.resourcesCalculator(),
                                                          nodeRepository.spareCount(),
                                                          nodeRepository.exclusivity().allocation(cluster));
        allocation.offer(prioritizer.collect());
        if (requested.type() == NodeType.tenant && !requested.canFail() && allocation.changes()) {
            // This should not happen and indicates a bug in the allocation code because boostrap redeployment
            // resulted in allocation changes
            throw new IllegalArgumentException("Refusing change to allocated nodes for " + cluster + " in " +
                                               application + " during bootstrap deployment: " + requested);
        }
        return allocation;
    }
Ensure sufficient nodes are reserved or active for the given application, group and cluster

@param application        the application we are allocating to
@param cluster            the cluster and group we are allocating to
@param requested          a specification of the requested nodes
@return the list of nodes this cluster group will have allocated if activated
node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/Preparer.java