Search in sources :

Example 6 with ModelElement

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

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

use of com.yahoo.vespa.model.builder.xml.dom.ModelElement in project vespa by vespa-engine.

the class DomResourceLimitsBuilder method build.

public static ResourceLimits build(ModelElement contentXml) {
    ResourceLimits.Builder builder = new ResourceLimits.Builder();
    ModelElement resourceLimits = contentXml.getChild("resource-limits");
    if (resourceLimits == null) {
        return builder.build();
    }
    if (resourceLimits.getChild("disk") != null) {
        builder.setDiskLimit(resourceLimits.childAsDouble("disk"));
    }
    if (resourceLimits.getChild("memory") != null) {
        builder.setMemoryLimit(resourceLimits.childAsDouble("memory"));
    }
    return builder.build();
}
Also used : ModelElement(com.yahoo.vespa.model.builder.xml.dom.ModelElement) ResourceLimits(com.yahoo.vespa.model.content.ResourceLimits)

Example 9 with ModelElement

use of com.yahoo.vespa.model.builder.xml.dom.ModelElement in project vespa by vespa-engine.

the class DomTuningDispatchBuilder method build.

public static TuningDispatch build(ModelElement contentXml) {
    TuningDispatch.Builder builder = new TuningDispatch.Builder();
    ModelElement tuningElement = contentXml.getChild("tuning");
    if (tuningElement == null) {
        return builder.build();
    }
    ModelElement dispatchElement = tuningElement.getChild("dispatch");
    if (dispatchElement == null) {
        return builder.build();
    }
    builder.setMaxHitsPerPartition(dispatchElement.childAsInteger("max-hits-per-partition"));
    builder.setDispatchPolicy(dispatchElement.childAsString("dispatch-policy"));
    builder.setUseLocalNode(dispatchElement.childAsBoolean("use-local-node"));
    builder.setMinGroupCoverage(dispatchElement.childAsDouble("min-group-coverage"));
    builder.setMinActiveDocsCoverage(dispatchElement.childAsDouble("min-active-docs-coverage"));
    return builder.build();
}
Also used : ModelElement(com.yahoo.vespa.model.builder.xml.dom.ModelElement) TuningDispatch(com.yahoo.vespa.model.content.TuningDispatch)

Example 10 with ModelElement

use of com.yahoo.vespa.model.builder.xml.dom.ModelElement in project vespa by vespa-engine.

the class ContentSearchCluster method addSearchDefinitions.

private void addSearchDefinitions(List<ModelElement> searchDefs, AbstractSearchCluster sc) {
    for (ModelElement e : searchDefs) {
        SearchDefinitionXMLHandler searchDefinitionXMLHandler = new SearchDefinitionXMLHandler(e);
        SearchDefinition searchDefinition = searchDefinitionXMLHandler.getResponsibleSearchDefinition(sc.getRoot().getDeployState().getSearchDefinitions());
        if (searchDefinition == null)
            throw new RuntimeException("Search definition parsing error or file does not exist: '" + searchDefinitionXMLHandler.getName() + "'");
        // TODO: remove explicit building of user configs when the complete content model is built using builders.
        sc.getLocalSDS().add(new AbstractSearchCluster.SearchDefinitionSpec(searchDefinition, UserConfigBuilder.build(e.getXml(), sc.getRoot().getDeployState(), sc.getRoot().deployLogger())));
        // need to get the document names from this sdfile
        sc.addDocumentNames(searchDefinition);
    }
}
Also used : ModelElement(com.yahoo.vespa.model.builder.xml.dom.ModelElement)

Aggregations

ModelElement (com.yahoo.vespa.model.builder.xml.dom.ModelElement)15 ClusterMembership (com.yahoo.config.provision.ClusterMembership)3 HostResource (com.yahoo.vespa.model.HostResource)3 NewDocumentType (com.yahoo.documentmodel.NewDocumentType)2 NodesSpecification (com.yahoo.vespa.model.builder.xml.dom.NodesSpecification)2 DispatchSpec (com.yahoo.vespa.model.content.DispatchSpec)2 Element (org.w3c.dom.Element)2 ContentSearch (com.yahoo.vespa.model.content.ContentSearch)1 Redundancy (com.yahoo.vespa.model.content.Redundancy)1 ResourceLimits (com.yahoo.vespa.model.content.ResourceLimits)1 SearchCoverage (com.yahoo.vespa.model.content.SearchCoverage)1 TuningDispatch (com.yahoo.vespa.model.content.TuningDispatch)1 HashSet (java.util.HashSet)1 TreeMap (java.util.TreeMap)1 Test (org.junit.Test)1