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