Search in sources :

Example 6 with HostResource

use of com.yahoo.vespa.model.HostResource in project vespa by vespa-engine.

the class ContainerModelBuilder method addNodesFromXml.

private void addNodesFromXml(ContainerCluster cluster, Element containerElement, ConfigModelContext context) {
    Element nodesElement = XML.getChild(containerElement, "nodes");
    if (nodesElement == null) {
        // default single node on localhost
        Container node = new Container(cluster, "container.0", 0);
        HostResource host = allocateSingleNodeHost(cluster, log, containerElement, context);
        node.setHostResource(host);
        if (// TODO: Fold this into initService
        !node.isInitialized())
            node.initService();
        cluster.addContainers(Collections.singleton(node));
    } else {
        List<Container> nodes = createNodes(cluster, nodesElement, context);
        applyNodesTagJvmArgs(nodes, nodesElement.getAttribute(VespaDomBuilder.JVMARGS_ATTRIB_NAME));
        applyRoutingAliasProperties(nodes, cluster);
        applyDefaultPreload(nodes, nodesElement);
        applyMemoryPercentage(cluster, nodesElement.getAttribute(VespaDomBuilder.Allocated_MEMORY_ATTRIB_NAME));
        if (useCpuSocketAffinity(nodesElement))
            AbstractService.distributeCpuSocketAffinity(nodes);
        cluster.addContainers(nodes);
    }
}
Also used : HostResource(com.yahoo.vespa.model.HostResource) Container(com.yahoo.vespa.model.container.Container) ModelElement(com.yahoo.vespa.model.builder.xml.dom.ModelElement) Element(org.w3c.dom.Element)

Example 7 with HostResource

use of com.yahoo.vespa.model.HostResource in project vespa by vespa-engine.

the class ContainerModelBuilder method getHostResourceFromContentClusters.

/**
 * This is used in case we are on hosted Vespa and no nodes tag is supplied:
 * If there are content clusters this will pick the first host in the first cluster as the container node.
 * If there are no content clusters this will return empty (such that the node can be created by the container here).
 */
private Optional<HostResource> getHostResourceFromContentClusters(ContainerCluster cluster, Element containersElement, ConfigModelContext context) {
    Optional<Element> services = servicesRootOf(containersElement);
    if (!services.isPresent())
        return Optional.empty();
    List<Element> contentServices = XML.getChildren(services.get(), "content");
    if (contentServices.isEmpty())
        return Optional.empty();
    Element contentNodesElementOrNull = XML.getChild(contentServices.get(0), "nodes");
    NodesSpecification nodesSpec;
    if (contentNodesElementOrNull == null)
        nodesSpec = NodesSpecification.nonDedicated(1, context.getDeployState().getWantedNodeVespaVersion());
    else
        nodesSpec = NodesSpecification.from(new ModelElement(contentNodesElementOrNull), context.getDeployState().getWantedNodeVespaVersion());
    Map<HostResource, ClusterMembership> hosts = StorageGroup.provisionHosts(nodesSpec, contentServices.get(0).getAttribute("id"), cluster.getRoot().getHostSystem(), context.getDeployLogger());
    return Optional.of(hosts.keySet().iterator().next());
}
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) ModelElement(com.yahoo.vespa.model.builder.xml.dom.ModelElement) Element(org.w3c.dom.Element)

Example 8 with HostResource

use of com.yahoo.vespa.model.HostResource in project vespa by vespa-engine.

the class ModelProvisioningTest method testClusterMembership.

@Test
public void testClusterMembership() {
    String xmlWithNodes = "<?xml version='1.0' encoding='utf-8' ?>" + "<services>" + "  <container version='1.0' id='container1'>" + "     <nodes count='1'/>" + "  </container>" + "</services>";
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(1);
    VespaModel model = tester.createModel(xmlWithNodes, true);
    assertEquals(1, model.getHostSystem().getHosts().size());
    HostResource host = model.getHostSystem().getHosts().iterator().next();
    assertEquals(1, host.clusterMemberships().size());
    ClusterMembership membership = host.clusterMemberships().iterator().next();
    assertEquals("container", membership.cluster().type().name());
    assertEquals("container1", membership.cluster().id().value());
}
Also used : HostResource(com.yahoo.vespa.model.HostResource) ClusterMembership(com.yahoo.config.provision.ClusterMembership) VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) Test(org.junit.Test)

Example 9 with HostResource

use of com.yahoo.vespa.model.HostResource in project vespa by vespa-engine.

the class ContainerClusterTest method addContainer.

private static void addContainer(ContainerCluster cluster, String name, String hostName) {
    Container container = new Container(cluster, name, 0);
    container.setHostResource(new HostResource(new Host(null, hostName)));
    container.initService();
    cluster.addContainer(container);
}
Also used : HostResource(com.yahoo.vespa.model.HostResource) ClusterControllerContainer(com.yahoo.vespa.model.admin.clustercontroller.ClusterControllerContainer) Host(com.yahoo.vespa.model.Host)

Example 10 with HostResource

use of com.yahoo.vespa.model.HostResource in project vespa by vespa-engine.

the class ContentBuilderTest method handleIndexedWithoutPersistence.

@Test
public void handleIndexedWithoutPersistence() throws Exception {
    ContentCluster b = createContent("<content version =\"1.0\" id=\"b\">" + "    <redundancy>3</redundancy>" + "      <documents>" + "        <document type='music' mode='index'/>" + "      </documents>" + "    <group>" + "      <node hostalias=\"mockhost\" distribution-key=\"0\"/>" + "    </group>" + "</content>");
    ContentSearchCluster s;
    s = b.getSearch();
    assertTrue(s.hasIndexedCluster());
    assertEquals(1, s.getClusters().size());
    assertNotNull(s.getIndexed());
    assertEquals("b", s.getIndexed().getClusterName());
    assertTrue(b.getPersistence() instanceof ProtonEngine.Factory);
    assertEquals(1, b.getStorageNodes().getChildren().size());
    assertEquals("b", b.getConfigId());
    // assertEquals("content/a/0", a.getRootGroup().getNodes().get(0).getConfigId());
    // Due to reuse.
    assertEquals("b/storage/0", b.getRootGroup().getNodes().get(0).getConfigId());
    assertEquals(1, b.getRoot().getHostSystem().getHosts().size());
    HostResource h = b.getRoot().getHostSystem().getHost("mockhost");
    assertEquals("b/storage/0", h.getService("storagenode").getConfigId());
}
Also used : ContentSearchCluster(com.yahoo.vespa.model.content.ContentSearchCluster) HostResource(com.yahoo.vespa.model.HostResource) ProtonEngine(com.yahoo.vespa.model.content.engines.ProtonEngine) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Aggregations

HostResource (com.yahoo.vespa.model.HostResource)25 Test (org.junit.Test)10 ClusterMembership (com.yahoo.config.provision.ClusterMembership)6 Host (com.yahoo.vespa.model.Host)6 VespaModel (com.yahoo.vespa.model.VespaModel)6 ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)5 ModelElement (com.yahoo.vespa.model.builder.xml.dom.ModelElement)4 ArrayList (java.util.ArrayList)4 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)3 MockRoot (com.yahoo.config.model.test.MockRoot)3 ContentSearchCluster (com.yahoo.vespa.model.content.ContentSearchCluster)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 Element (org.w3c.dom.Element)3 HostSystem (com.yahoo.vespa.model.HostSystem)2 ClusterControllerContainer (com.yahoo.vespa.model.admin.clustercontroller.ClusterControllerContainer)2 NodesSpecification (com.yahoo.vespa.model.builder.xml.dom.NodesSpecification)2 Container (com.yahoo.vespa.model.container.Container)2 ProtonEngine (com.yahoo.vespa.model.content.engines.ProtonEngine)2 NodeSpec (com.yahoo.vespa.model.search.NodeSpec)2 SearchNode (com.yahoo.vespa.model.search.SearchNode)2