Search in sources :

Example 1 with ServiceCluster

use of com.yahoo.vespa.model.generic.service.ServiceCluster in project vespa by vespa-engine.

the class DomServiceClusterBuilder method doBuild.

@Override
protected ServiceCluster doBuild(AbstractConfigProducer ancestor, Element spec) {
    ServiceCluster cluster = new ServiceCluster(ancestor, name, spec.getAttribute("command"));
    int nodeIndex = 0;
    for (Element nodeSpec : XML.getChildren(spec, "node")) {
        com.yahoo.vespa.model.generic.service.Service service = new DomServiceBuilder(nodeIndex).build(cluster, nodeSpec);
        // and store them in ServiceCluster. Then have some way of referencing them from each service.
        for (Element subServiceSpec : XML.getChildren(spec, "module")) {
            String subServiceName = subServiceSpec.getAttribute("name");
            Map<String, AbstractConfigProducer<?>> map = service.getChildren();
            // Add only non-conflicting modules. Does not merge unspecified configs that are specified in root though.
            if (!map.containsKey(subServiceName))
                new DomModuleBuilder(subServiceName).build(service, subServiceSpec);
        }
        nodeIndex++;
    }
    return cluster;
}
Also used : ServiceCluster(com.yahoo.vespa.model.generic.service.ServiceCluster) AbstractConfigProducer(com.yahoo.config.model.producer.AbstractConfigProducer) Element(org.w3c.dom.Element)

Example 2 with ServiceCluster

use of com.yahoo.vespa.model.generic.service.ServiceCluster in project vespa by vespa-engine.

the class VespaDomBuilder method getClusters.

@Override
public List<ServiceCluster> getClusters(ApplicationPackage pkg, AbstractConfigProducer parent) {
    List<ServiceCluster> clusters = new ArrayList<>();
    Document services = XmlHelper.getDocument(pkg.getServices());
    for (Element clusterSpec : XML.getChildren(services.getDocumentElement(), "cluster")) {
        DomServiceClusterBuilder clusterBuilder = new DomServiceClusterBuilder(clusterSpec.getAttribute("name"));
        clusters.add(clusterBuilder.build(parent.getRoot(), clusterSpec));
    }
    return clusters;
}
Also used : ServiceCluster(com.yahoo.vespa.model.generic.service.ServiceCluster) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document) DomServiceClusterBuilder(com.yahoo.vespa.model.generic.builder.DomServiceClusterBuilder)

Example 3 with ServiceCluster

use of com.yahoo.vespa.model.generic.service.ServiceCluster in project vespa by vespa-engine.

the class DomServiceBuilder method doBuild.

@Override
protected com.yahoo.vespa.model.generic.service.Service doBuild(AbstractConfigProducer parent, Element serviceSpec) {
    ServiceCluster sc = (ServiceCluster) parent;
    com.yahoo.vespa.model.generic.service.Service service = new com.yahoo.vespa.model.generic.service.Service(sc, i + "");
    for (Element subServiceSpec : XML.getChildren(serviceSpec, "module")) {
        new DomModuleBuilder(subServiceSpec.getAttribute("name")).build(service, subServiceSpec);
    }
    return service;
}
Also used : Service(com.yahoo.vespa.model.generic.service.Service) ServiceCluster(com.yahoo.vespa.model.generic.service.ServiceCluster) Element(org.w3c.dom.Element) Service(com.yahoo.vespa.model.generic.service.Service)

Example 4 with ServiceCluster

use of com.yahoo.vespa.model.generic.service.ServiceCluster in project vespa by vespa-engine.

the class GenericServicesModelTest method test_generic_services_model.

@Test
public void test_generic_services_model() {
    MockRoot root = new MockRoot();
    GenericServicesModel model = new GenericServicesModel(ConfigModelContext.create(null, root, "foo"));
    assertThat(model.serviceClusters().size(), is(0));
    model.addCluster(new ServiceCluster(root, "mycluster", "/bin/foo"));
    assertThat(model.serviceClusters().size(), is(1));
    assertThat(model.serviceClusters().get(0).getName(), is("mycluster"));
}
Also used : MockRoot(com.yahoo.config.model.test.MockRoot) ServiceCluster(com.yahoo.vespa.model.generic.service.ServiceCluster) Test(org.junit.Test)

Aggregations

ServiceCluster (com.yahoo.vespa.model.generic.service.ServiceCluster)4 Element (org.w3c.dom.Element)3 AbstractConfigProducer (com.yahoo.config.model.producer.AbstractConfigProducer)1 MockRoot (com.yahoo.config.model.test.MockRoot)1 DomServiceClusterBuilder (com.yahoo.vespa.model.generic.builder.DomServiceClusterBuilder)1 Service (com.yahoo.vespa.model.generic.service.Service)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Document (org.w3c.dom.Document)1