Search in sources :

Example 1 with NodesSpecification

use of com.yahoo.vespa.model.builder.xml.dom.NodesSpecification 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 2 with NodesSpecification

use of com.yahoo.vespa.model.builder.xml.dom.NodesSpecification 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)

Aggregations

ClusterMembership (com.yahoo.config.provision.ClusterMembership)2 HostResource (com.yahoo.vespa.model.HostResource)2 ModelElement (com.yahoo.vespa.model.builder.xml.dom.ModelElement)2 NodesSpecification (com.yahoo.vespa.model.builder.xml.dom.NodesSpecification)2 Element (org.w3c.dom.Element)1