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