Search in sources :

Example 1 with MutableInteger

use of com.yahoo.lang.MutableInteger in project vespa by vespa-engine.

the class Preparer method prepare.

/**
 * Ensure sufficient nodes are reserved or active for the given application and cluster
 *
 * @return the list of nodes this cluster will have allocated if activated
 */
// Note: This operation may make persisted changes to the set of reserved and inactive nodes,
// 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, int wantedGroups) {
    List<Node> surplusNodes = findNodesInRemovableGroups(application, cluster, wantedGroups);
    MutableInteger highestIndex = new MutableInteger(findHighestIndex(application, cluster));
    List<Node> acceptedNodes = new ArrayList<>();
    for (int groupIndex = 0; groupIndex < wantedGroups; groupIndex++) {
        ClusterSpec clusterGroup = cluster.with(Optional.of(ClusterSpec.Group.from(groupIndex)));
        List<Node> accepted = groupPreparer.prepare(application, clusterGroup, requestedNodes.fraction(wantedGroups), surplusNodes, highestIndex, spareCount);
        replace(acceptedNodes, accepted);
    }
    moveToActiveGroup(surplusNodes, wantedGroups, cluster.group());
    replace(acceptedNodes, retire(surplusNodes));
    return acceptedNodes;
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) MutableInteger(com.yahoo.lang.MutableInteger) ArrayList(java.util.ArrayList) ClusterSpec(com.yahoo.config.provision.ClusterSpec)

Aggregations

ClusterSpec (com.yahoo.config.provision.ClusterSpec)1 MutableInteger (com.yahoo.lang.MutableInteger)1 Node (com.yahoo.vespa.hosted.provision.Node)1 ArrayList (java.util.ArrayList)1