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());
}
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);
}
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();
}
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;
}
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());
}
}
Aggregations