Search in sources :

Example 6 with ClusterMembership

use of com.yahoo.config.provision.ClusterMembership in project vespa by vespa-engine.

the class Preparer method moveToActiveGroup.

/**
 * Move nodes from unwanted groups to wanted groups to avoid lingering groups consisting of retired nodes
 */
private void moveToActiveGroup(List<Node> surplusNodes, int wantedGroups, Optional<ClusterSpec.Group> targetGroup) {
    for (ListIterator<Node> i = surplusNodes.listIterator(); i.hasNext(); ) {
        Node node = i.next();
        ClusterMembership membership = node.allocation().get().membership();
        ClusterSpec cluster = membership.cluster();
        if (cluster.group().get().index() >= wantedGroups) {
            ClusterSpec.Group newGroup = targetGroup.orElse(ClusterSpec.Group.from(0));
            ClusterMembership newGroupMembership = membership.with(cluster.with(Optional.of(newGroup)));
            i.set(node.with(node.allocation().get().with(newGroupMembership)));
        }
    }
}
Also used : ClusterMembership(com.yahoo.config.provision.ClusterMembership) Node(com.yahoo.vespa.hosted.provision.Node) ClusterSpec(com.yahoo.config.provision.ClusterSpec)

Example 7 with ClusterMembership

use of com.yahoo.config.provision.ClusterMembership in project vespa by vespa-engine.

the class ContainerModelBuilder method createNodesFromNodeCount.

private List<Container> createNodesFromNodeCount(ContainerCluster cluster, Element nodesElement, ConfigModelContext context) {
    NodesSpecification nodesSpecification = NodesSpecification.from(new ModelElement(nodesElement), context.getDeployState().getWantedNodeVespaVersion());
    Map<HostResource, ClusterMembership> hosts = nodesSpecification.provision(cluster.getRoot().getHostSystem(), ClusterSpec.Type.container, ClusterSpec.Id.from(cluster.getName()), log);
    return createNodesFromHosts(hosts, cluster);
}
Also used : HostResource(com.yahoo.vespa.model.HostResource) ModelElement(com.yahoo.vespa.model.builder.xml.dom.ModelElement) NodesSpecification(com.yahoo.vespa.model.builder.xml.dom.NodesSpecification) ClusterMembership(com.yahoo.config.provision.ClusterMembership)

Example 8 with ClusterMembership

use of com.yahoo.config.provision.ClusterMembership in project vespa by vespa-engine.

the class ContainerModelBuilder method createNodesFromNodeType.

private List<Container> createNodesFromNodeType(ContainerCluster cluster, Element nodesElement, ConfigModelContext context) {
    NodeType type = NodeType.valueOf(nodesElement.getAttribute("type"));
    ClusterSpec clusterSpec = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from(cluster.getName()), context.getDeployState().getWantedNodeVespaVersion(), false);
    Map<HostResource, ClusterMembership> hosts = cluster.getRoot().getHostSystem().allocateHosts(clusterSpec, Capacity.fromRequiredNodeType(type), 1, log);
    return createNodesFromHosts(hosts, cluster);
}
Also used : HostResource(com.yahoo.vespa.model.HostResource) ClusterMembership(com.yahoo.config.provision.ClusterMembership) NodeType(com.yahoo.config.provision.NodeType) ClusterSpec(com.yahoo.config.provision.ClusterSpec)

Example 9 with ClusterMembership

use of com.yahoo.config.provision.ClusterMembership in project vespa by vespa-engine.

the class ContainerModelBuilder method createNodesFromContentServiceReference.

private List<Container> createNodesFromContentServiceReference(ContainerCluster cluster, Element nodesElement, ConfigModelContext context) {
    // Resolve references to content clusters at the XML level because content clusters must be built after container clusters
    String referenceId = nodesElement.getAttribute("of");
    Element services = servicesRootOf(nodesElement).orElseThrow(() -> clusterReferenceNotFoundException(cluster, referenceId));
    Element referencedService = findChildById(services, referenceId).orElseThrow(() -> clusterReferenceNotFoundException(cluster, referenceId));
    if (!referencedService.getTagName().equals("content"))
        throw new IllegalArgumentException(cluster + " references service '" + referenceId + "', " + "but that is not a content service");
    Element referencedNodesElement = XML.getChild(referencedService, "nodes");
    if (referencedNodesElement == null)
        throw new IllegalArgumentException(cluster + " references service '" + referenceId + "' to supply nodes, " + "but that service has no <nodes> element");
    cluster.setHostClusterId(referenceId);
    Map<HostResource, ClusterMembership> hosts = StorageGroup.provisionHosts(NodesSpecification.from(new ModelElement(referencedNodesElement), context.getDeployState().getWantedNodeVespaVersion()), referenceId, cluster.getRoot().getHostSystem(), context.getDeployLogger());
    return createNodesFromHosts(hosts, cluster);
}
Also used : HostResource(com.yahoo.vespa.model.HostResource) ModelElement(com.yahoo.vespa.model.builder.xml.dom.ModelElement) ClusterMembership(com.yahoo.config.provision.ClusterMembership) ModelElement(com.yahoo.vespa.model.builder.xml.dom.ModelElement) Element(org.w3c.dom.Element)

Example 10 with ClusterMembership

use of com.yahoo.config.provision.ClusterMembership in project vespa by vespa-engine.

the class DynamicDockerProvisioningTest method addAndAssignNode.

private Node addAndAssignNode(ApplicationId id, String hostname, String parentHostname, Flavor flavor, int index, ProvisioningTester tester) {
    Node node1a = Node.create("open1", Collections.singleton("127.0.0.100"), new HashSet<>(), hostname, Optional.of(parentHostname), flavor, NodeType.tenant);
    ClusterSpec clusterSpec = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false).with(Optional.of(ClusterSpec.Group.from(0)));
    ClusterMembership clusterMembership1 = ClusterMembership.from(clusterSpec, index);
    Node node1aAllocation = node1a.allocate(id, clusterMembership1, Instant.now());
    tester.nodeRepository().addNodes(Collections.singletonList(node1aAllocation));
    NestedTransaction transaction = new NestedTransaction().add(new CuratorTransaction(tester.getCurator()));
    tester.nodeRepository().activate(Collections.singletonList(node1aAllocation), transaction);
    transaction.commit();
    return node1aAllocation;
}
Also used : ClusterMembership(com.yahoo.config.provision.ClusterMembership) CuratorTransaction(com.yahoo.vespa.curator.transaction.CuratorTransaction) Node(com.yahoo.vespa.hosted.provision.Node) NestedTransaction(com.yahoo.transaction.NestedTransaction) ClusterSpec(com.yahoo.config.provision.ClusterSpec)

Aggregations

ClusterMembership (com.yahoo.config.provision.ClusterMembership)11 HostResource (com.yahoo.vespa.model.HostResource)6 ClusterSpec (com.yahoo.config.provision.ClusterSpec)3 Node (com.yahoo.vespa.hosted.provision.Node)3 ModelElement (com.yahoo.vespa.model.builder.xml.dom.ModelElement)3 HostSpec (com.yahoo.config.provision.HostSpec)2 NodesSpecification (com.yahoo.vespa.model.builder.xml.dom.NodesSpecification)2 ArrayList (java.util.ArrayList)2 Element (org.w3c.dom.Element)2 NodeType (com.yahoo.config.provision.NodeType)1 NestedTransaction (com.yahoo.transaction.NestedTransaction)1 CuratorTransaction (com.yahoo.vespa.curator.transaction.CuratorTransaction)1 VespaModel (com.yahoo.vespa.model.VespaModel)1 Container (com.yahoo.vespa.model.container.Container)1 VespaModelTester (com.yahoo.vespa.model.test.VespaModelTester)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Test (org.junit.Test)1