Search in sources :

Example 11 with ClusterSpec

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

the class ProvisioningTester method assertMembersOf.

void assertMembersOf(ClusterSpec requestedCluster, Collection<HostSpec> hosts) {
    Set<Integer> indices = new HashSet<>();
    for (HostSpec host : hosts) {
        ClusterSpec nodeCluster = host.membership().get().cluster();
        assertTrue(requestedCluster.equalsIgnoringGroupAndVespaVersion(nodeCluster));
        if (requestedCluster.group().isPresent())
            assertEquals(requestedCluster.group(), nodeCluster.group());
        else
            assertEquals(0, nodeCluster.group().get().index());
        indices.add(host.membership().get().index());
    }
    assertEquals("Indexes in " + requestedCluster + " are disjunct", hosts.size(), indices.size());
}
Also used : ClusterSpec(com.yahoo.config.provision.ClusterSpec) HostSpec(com.yahoo.config.provision.HostSpec) HashSet(java.util.HashSet)

Example 12 with ClusterSpec

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

the class MockNodeRepository method populate.

private void populate() {
    NodeRepositoryProvisioner provisioner = new NodeRepositoryProvisioner(this, flavors, Zone.defaultZone());
    List<Node> nodes = new ArrayList<>();
    final List<String> ipAddressesForAllHost = Arrays.asList("127.0.0.1", "::1");
    Collections.sort(ipAddressesForAllHost);
    final HashSet<String> ipAddresses = new HashSet<>(ipAddressesForAllHost);
    final List<String> additionalIpAddressesForAllHost = Arrays.asList("::2", "::3", "::4");
    Collections.sort(additionalIpAddressesForAllHost);
    final HashSet<String> additionalIpAddresses = new HashSet<>(additionalIpAddressesForAllHost);
    nodes.add(createNode("node1", "host1.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
    nodes.add(createNode("node2", "host2.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
    nodes.add(createNode("node3", "host3.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("expensive"), NodeType.tenant));
    Node node4 = createNode("node4", "host4.yahoo.com", ipAddresses, Optional.of("dockerhost1.yahoo.com"), flavors.getFlavorOrThrow("docker"), NodeType.tenant);
    node4 = node4.with(node4.status().withVespaVersion(new Version("6.41.0")));
    nodes.add(node4);
    Node node5 = createNode("node5", "host5.yahoo.com", ipAddresses, Optional.of("dockerhost2.yahoo.com"), flavors.getFlavorOrThrow("docker"), NodeType.tenant);
    nodes.add(node5.with(node5.status().withVespaVersion(new Version("1.2.3"))));
    nodes.add(createNode("node6", "host6.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
    nodes.add(createNode("node7", "host7.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant));
    // 8 and 9 are added by web service calls
    Node node10 = createNode("node10", "host10.yahoo.com", ipAddresses, Optional.of("parent1.yahoo.com"), flavors.getFlavorOrThrow("default"), NodeType.tenant);
    Status node10newStatus = node10.status();
    node10newStatus = node10newStatus.withVespaVersion(Version.fromString("5.104.142"));
    node10 = node10.with(node10newStatus);
    nodes.add(node10);
    Node node55 = createNode("node55", "host55.yahoo.com", ipAddresses, Optional.empty(), flavors.getFlavorOrThrow("default"), NodeType.tenant);
    nodes.add(node55.with(node55.status().withWantToRetire(true).withWantToDeprovision(true)));
    /* Setup docker hosts (two of these will be reserved for spares */
    nodes.add(createNode("dockerhost1", "dockerhost1.yahoo.com", ipAddresses, additionalIpAddresses, Optional.empty(), flavors.getFlavorOrThrow("large"), NodeType.host));
    nodes.add(createNode("dockerhost2", "dockerhost2.yahoo.com", ipAddresses, additionalIpAddresses, Optional.empty(), flavors.getFlavorOrThrow("large"), NodeType.host));
    nodes.add(createNode("dockerhost3", "dockerhost3.yahoo.com", ipAddresses, additionalIpAddresses, Optional.empty(), flavors.getFlavorOrThrow("large"), NodeType.host));
    nodes.add(createNode("dockerhost4", "dockerhost4.yahoo.com", ipAddresses, additionalIpAddresses, Optional.empty(), flavors.getFlavorOrThrow("large"), NodeType.host));
    nodes.add(createNode("dockerhost5", "dockerhost5.yahoo.com", ipAddresses, additionalIpAddresses, Optional.empty(), flavors.getFlavorOrThrow("large"), NodeType.host));
    nodes = addNodes(nodes);
    nodes.remove(6);
    nodes.remove(7);
    nodes = setDirty(nodes, Agent.system, getClass().getSimpleName());
    setReady(nodes, Agent.system, getClass().getSimpleName());
    fail("host5.yahoo.com", Agent.system, getClass().getSimpleName());
    setDirty("host55.yahoo.com", Agent.system, getClass().getSimpleName());
    ApplicationId zoneApp = ApplicationId.from(TenantName.from("zoneapp"), ApplicationName.from("zoneapp"), InstanceName.from("zoneapp"));
    ClusterSpec zoneCluster = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("node-admin"), Version.fromString("6.42"), false);
    activate(provisioner.prepare(zoneApp, zoneCluster, Capacity.fromRequiredNodeType(NodeType.host), 1, null), zoneApp, provisioner);
    ApplicationId app1 = ApplicationId.from(TenantName.from("tenant1"), ApplicationName.from("application1"), InstanceName.from("instance1"));
    ClusterSpec cluster1 = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from("id1"), Version.fromString("6.42"), false);
    provisioner.prepare(app1, cluster1, Capacity.fromNodeCount(2), 1, null);
    ApplicationId app2 = ApplicationId.from(TenantName.from("tenant2"), ApplicationName.from("application2"), InstanceName.from("instance2"));
    ClusterSpec cluster2 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("id2"), Version.fromString("6.42"), false);
    activate(provisioner.prepare(app2, cluster2, Capacity.fromNodeCount(2), 1, null), app2, provisioner);
    ApplicationId app3 = ApplicationId.from(TenantName.from("tenant3"), ApplicationName.from("application3"), InstanceName.from("instance3"));
    ClusterSpec cluster3 = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("id3"), Version.fromString("6.42"), false);
    activate(provisioner.prepare(app3, cluster3, Capacity.fromNodeCount(2, Optional.of("docker"), false), 1, null), app3, provisioner);
}
Also used : Status(com.yahoo.vespa.hosted.provision.node.Status) Version(com.yahoo.component.Version) Node(com.yahoo.vespa.hosted.provision.Node) NodeRepositoryProvisioner(com.yahoo.vespa.hosted.provision.provisioning.NodeRepositoryProvisioner) ArrayList(java.util.ArrayList) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ApplicationId(com.yahoo.config.provision.ApplicationId) HashSet(java.util.HashSet)

Example 13 with ClusterSpec

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

the class Preparer method findHighestIndex.

/**
 * Returns the highest index number of all active and failed nodes in this cluster, or -1 if there are no nodes.
 * We include failed nodes to avoid reusing the index of the failed node in the case where the failed node is the
 * node with the highest index.
 */
private int findHighestIndex(ApplicationId application, ClusterSpec cluster) {
    int highestIndex = -1;
    for (Node node : nodeRepository.getNodes(application, Node.State.active, Node.State.failed)) {
        ClusterSpec nodeCluster = node.allocation().get().membership().cluster();
        if (!nodeCluster.id().equals(cluster.id()))
            continue;
        if (!nodeCluster.type().equals(cluster.type()))
            continue;
        highestIndex = Math.max(node.allocation().get().membership().index(), highestIndex);
    }
    return highestIndex;
}
Also used : Node(com.yahoo.vespa.hosted.provision.Node) ClusterSpec(com.yahoo.config.provision.ClusterSpec)

Example 14 with ClusterSpec

use of com.yahoo.config.provision.ClusterSpec 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 15 with ClusterSpec

use of com.yahoo.config.provision.ClusterSpec 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)

Aggregations

ClusterSpec (com.yahoo.config.provision.ClusterSpec)32 Node (com.yahoo.vespa.hosted.provision.Node)23 ApplicationId (com.yahoo.config.provision.ApplicationId)20 Test (org.junit.Test)18 Zone (com.yahoo.config.provision.Zone)14 MockDeployer (com.yahoo.vespa.hosted.provision.testutils.MockDeployer)10 HashSet (java.util.HashSet)10 Flavor (com.yahoo.config.provision.Flavor)9 HostSpec (com.yahoo.config.provision.HostSpec)9 Capacity (com.yahoo.config.provision.Capacity)7 ArrayList (java.util.ArrayList)6 Version (com.yahoo.component.Version)5 ClusterMembership (com.yahoo.config.provision.ClusterMembership)5 List (java.util.List)5 Collections (java.util.Collections)4 HashMap (java.util.HashMap)4 Assert.assertTrue (org.junit.Assert.assertTrue)4 Environment (com.yahoo.config.provision.Environment)3 NodeType (com.yahoo.config.provision.NodeType)3 RegionName (com.yahoo.config.provision.RegionName)3