Search in sources :

Example 1 with ModelElement

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

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

the class RedundancyBuilder method build.

Redundancy build(ModelElement clusterXml) {
    Integer initialRedundancy = 2;
    Integer finalRedundancy = 3;
    Integer readyCopies = 2;
    ModelElement redundancyElement = clusterXml.getChild("redundancy");
    if (redundancyElement != null) {
        initialRedundancy = redundancyElement.getIntegerAttribute("reply-after");
        finalRedundancy = (int) redundancyElement.asLong();
        if (initialRedundancy == null) {
            initialRedundancy = finalRedundancy;
        } else {
            if (finalRedundancy < initialRedundancy) {
                throw new IllegalArgumentException("Final redundancy must be higher than or equal to initial redundancy");
            }
        }
        readyCopies = clusterXml.childAsInteger("engine.proton.searchable-copies");
        if (readyCopies == null) {
            readyCopies = Math.min(finalRedundancy, 2);
        }
        if (readyCopies > finalRedundancy) {
            throw new IllegalArgumentException("Number of searchable copies can not be higher than final redundancy");
        }
    }
    return new Redundancy(initialRedundancy, finalRedundancy, readyCopies);
}
Also used : ModelElement(com.yahoo.vespa.model.builder.xml.dom.ModelElement) Redundancy(com.yahoo.vespa.model.content.Redundancy)

Example 3 with ModelElement

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

the class DomContentSearchBuilder method build.

public static ContentSearch build(ModelElement contentXml) {
    ContentSearch.Builder builder = new ContentSearch.Builder();
    ModelElement searchElement = contentXml.getChild("search");
    if (searchElement == null) {
        return builder.build();
    }
    builder.setQueryTimeout(searchElement.childAsDouble("query-timeout"));
    builder.setVisibilityDelay(searchElement.childAsDouble("visibility-delay"));
    return builder.build();
}
Also used : ContentSearch(com.yahoo.vespa.model.content.ContentSearch) ModelElement(com.yahoo.vespa.model.builder.xml.dom.ModelElement)

Example 4 with ModelElement

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

the class SearchDefinitionBuilder method build.

public Map<String, NewDocumentType> build(DocumentTypeRepo repo, ModelElement elem) {
    Map<String, NewDocumentType> docTypes = new TreeMap<>();
    if (elem != null) {
        for (ModelElement e : elem.subElements("document")) {
            // Schema-guaranteed presence
            String name = e.getStringAttribute("type");
            NewDocumentType documentType = repo.getDocumentType(name);
            if (documentType != null) {
                docTypes.put(documentType.getName(), documentType);
            } else {
                throw new RuntimeException("Document type '" + name + "' not found in application package");
            }
        }
    }
    return docTypes;
}
Also used : ModelElement(com.yahoo.vespa.model.builder.xml.dom.ModelElement) NewDocumentType(com.yahoo.documentmodel.NewDocumentType) TreeMap(java.util.TreeMap)

Example 5 with ModelElement

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

the class VDSEngine method getConfig.

@Override
public void getConfig(StorMemfilepersistenceConfig.Builder builder) {
    if (tuning == null) {
        return;
    }
    ModelElement diskFullRatio = tuning.getChild("disk-full-ratio");
    if (diskFullRatio != null) {
        builder.disk_full_factor(diskFullRatio.asDouble());
    }
    ModelElement cacheSize = tuning.getChild("cache-size");
    if (cacheSize != null) {
        builder.cache_size(cacheSize.asLong());
    }
}
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