Search in sources :

Example 1 with Admin

use of com.yahoo.vespa.model.admin.Admin in project vespa by vespa-engine.

the class ContentClusterUtils method createCluster.

public static ContentCluster createCluster(String clusterXml, MockRoot root) {
    Document doc = XML.getDocument(clusterXml);
    Admin admin = new Admin(root, new DefaultMonitoring("vespa", 60), new Metrics(), Collections.emptyMap(), false, new FileDistributionConfigProducer(root, new MockFileRegistry(), null));
    ConfigModelContext context = ConfigModelContext.create(null, root.getDeployState(), null, root, null);
    return new ContentCluster.Builder(admin).build(Collections.emptyList(), context, doc.getDocumentElement());
}
Also used : FileDistributionConfigProducer(com.yahoo.vespa.model.filedistribution.FileDistributionConfigProducer) Metrics(com.yahoo.vespa.model.admin.monitoring.builder.Metrics) DefaultMonitoring(com.yahoo.vespa.model.admin.monitoring.DefaultMonitoring) Document(org.w3c.dom.Document) Admin(com.yahoo.vespa.model.admin.Admin) MockFileRegistry(com.yahoo.config.model.application.provider.MockFileRegistry) ConfigModelContext(com.yahoo.config.model.ConfigModelContext) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster)

Example 2 with Admin

use of com.yahoo.vespa.model.admin.Admin in project vespa by vespa-engine.

the class AbstractConfigProducer method getMonitoringService.

// TODO: Make producers depend on AdminModel instead
/**
 * Returns a monitoring service if configured, null otherwise
 */
protected Monitoring getMonitoringService() {
    AbstractConfigProducerRoot root = getRoot();
    Admin admin = (root == null ? null : root.getAdmin());
    if (admin == null) {
        return null;
    }
    if (admin.getMonitoring() != null) {
        return admin.getMonitoring();
    }
    return null;
}
Also used : Admin(com.yahoo.vespa.model.admin.Admin)

Example 3 with Admin

use of com.yahoo.vespa.model.admin.Admin in project vespa by vespa-engine.

the class ModelProvisioningTest method testUsingNodesAndGroupCountAttributes.

@Test
public void testUsingNodesAndGroupCountAttributes() {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + "  <admin version='4.0'/>" + "  <container version='1.0' id='foo'>" + "     <nodes count='10'/>" + "  </container>" + "  <content version='1.0' id='bar'>" + "     <redundancy>2</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='27' groups='9'/>" + "  </content>" + "  <content version='1.0' id='baz'>" + "     <redundancy>1</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='27' groups='27'/>" + "   </content>" + "</services>";
    int numberOfHosts = 64;
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(numberOfHosts);
    VespaModel model = tester.createModel(services, true);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
    // Check container cluster
    assertEquals(1, model.getContainerClusters().size());
    Set<com.yahoo.vespa.model.Host> containerHosts = model.getContainerClusters().get("foo").getContainers().stream().map(Container::getHost).collect(Collectors.toSet());
    assertEquals(10, containerHosts.size());
    // Check admin clusters
    Admin admin = model.getAdmin();
    Set<com.yahoo.vespa.model.Host> slobrokHosts = admin.getSlobroks().stream().map(Slobrok::getHost).collect(Collectors.toSet());
    assertEquals(3, slobrokHosts.size());
    assertTrue("Slobroks are assigned from container nodes", containerHosts.containsAll(slobrokHosts));
    assertTrue("Logserver is assigned from container nodes", containerHosts.contains(admin.getLogserver().getHost()));
    assertEquals("No in-cluster config servers in a hosted environment", 0, admin.getConfigservers().size());
    assertEquals("No admin cluster controller when multitenant", null, admin.getClusterControllers());
    // Check content clusters
    ContentCluster cluster = model.getContentClusters().get("bar");
    ContainerCluster clusterControllers = cluster.getClusterControllers();
    assertEquals(3, clusterControllers.getContainers().size());
    assertEquals("bar-controllers", clusterControllers.getName());
    assertEquals("default28", clusterControllers.getContainers().get(0).getHostName());
    assertEquals("default31", clusterControllers.getContainers().get(1).getHostName());
    assertEquals("default54", clusterControllers.getContainers().get(2).getHostName());
    assertEquals(0, cluster.getRootGroup().getNodes().size());
    assertEquals(9, cluster.getRootGroup().getSubgroups().size());
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getIndex(), is("0"));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().size(), is(3));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getDistributionKey(), is(0));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getConfigId(), is("bar/storage/0"));
    assertEquals("default54", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(1).getDistributionKey(), is(1));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(1).getConfigId(), is("bar/storage/1"));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(2).getDistributionKey(), is(2));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(2).getConfigId(), is("bar/storage/2"));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getIndex(), is("1"));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().size(), is(3));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getDistributionKey(), is(3));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getConfigId(), is("bar/storage/3"));
    assertEquals("default51", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(1).getDistributionKey(), is(4));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(1).getConfigId(), is("bar/storage/4"));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(2).getDistributionKey(), is(5));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(2).getConfigId(), is("bar/storage/5"));
    // ...
    assertEquals("default48", cluster.getRootGroup().getSubgroups().get(2).getNodes().get(0).getHostName());
    // ...
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getIndex(), is("8"));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().size(), is(3));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(0).getDistributionKey(), is(24));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(0).getConfigId(), is("bar/storage/24"));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(1).getDistributionKey(), is(25));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(1).getConfigId(), is("bar/storage/25"));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(2).getDistributionKey(), is(26));
    assertThat(cluster.getRootGroup().getSubgroups().get(8).getNodes().get(2).getConfigId(), is("bar/storage/26"));
    cluster = model.getContentClusters().get("baz");
    clusterControllers = cluster.getClusterControllers();
    assertEquals(3, clusterControllers.getContainers().size());
    assertEquals("baz-controllers", clusterControllers.getName());
    assertEquals("default01", clusterControllers.getContainers().get(0).getHostName());
    assertEquals("default02", clusterControllers.getContainers().get(1).getHostName());
    assertEquals("default27", clusterControllers.getContainers().get(2).getHostName());
    assertEquals(0, cluster.getRootGroup().getNodes().size());
    assertEquals(27, cluster.getRootGroup().getSubgroups().size());
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getIndex(), is("0"));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().size(), is(1));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getDistributionKey(), is(0));
    assertThat(cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getConfigId(), is("baz/storage/0"));
    assertEquals("default27", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getIndex(), is("1"));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().size(), is(1));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getDistributionKey(), is(1));
    assertThat(cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getConfigId(), is("baz/storage/1"));
    assertEquals("default26", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
    // ...
    assertEquals("default25", cluster.getRootGroup().getSubgroups().get(2).getNodes().get(0).getHostName());
    // ...
    assertThat(cluster.getRootGroup().getSubgroups().get(26).getIndex(), is("26"));
    assertThat(cluster.getRootGroup().getSubgroups().get(26).getNodes().size(), is(1));
    assertThat(cluster.getRootGroup().getSubgroups().get(26).getNodes().get(0).getDistributionKey(), is(26));
    assertThat(cluster.getRootGroup().getSubgroups().get(26).getNodes().get(0).getConfigId(), is("baz/storage/26"));
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) Admin(com.yahoo.vespa.model.admin.Admin) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test)

Example 4 with Admin

use of com.yahoo.vespa.model.admin.Admin in project vespa by vespa-engine.

the class VespaModelTestCase method testNoAdmin.

@Test
public void testNoAdmin() {
    VespaModel model = CommonVespaModelSetup.createVespaModelWithMusic(simpleHosts, "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" + "<services version=\"1.0\">" + "</services>");
    Admin admin = model.getAdmin();
    assertThat(admin.getSlobroks().size(), is(1));
    assertThat(admin.getConfigservers().size(), is(1));
    Set<HostInfo> hosts = model.getHosts();
    assertThat(hosts.size(), is(1));
    // logd, config proxy, sentinel, config server, slobrok, log server
    HostInfo host = hosts.iterator().next();
    assertThat(host.getServices().size(), is(6));
    new LogdConfig((LogdConfig.Builder) model.getConfig(new LogdConfig.Builder(), "admin/model"));
}
Also used : LogdConfig(com.yahoo.cloud.config.log.LogdConfig) VespaModel(com.yahoo.vespa.model.VespaModel) Admin(com.yahoo.vespa.model.admin.Admin) HostInfo(com.yahoo.config.model.api.HostInfo) Test(org.junit.Test)

Aggregations

Admin (com.yahoo.vespa.model.admin.Admin)4 VespaModel (com.yahoo.vespa.model.VespaModel)2 ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)2 Test (org.junit.Test)2 LogdConfig (com.yahoo.cloud.config.log.LogdConfig)1 ConfigModelContext (com.yahoo.config.model.ConfigModelContext)1 HostInfo (com.yahoo.config.model.api.HostInfo)1 MockFileRegistry (com.yahoo.config.model.application.provider.MockFileRegistry)1 DefaultMonitoring (com.yahoo.vespa.model.admin.monitoring.DefaultMonitoring)1 Metrics (com.yahoo.vespa.model.admin.monitoring.builder.Metrics)1 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)1 FileDistributionConfigProducer (com.yahoo.vespa.model.filedistribution.FileDistributionConfigProducer)1 VespaModelTester (com.yahoo.vespa.model.test.VespaModelTester)1 Document (org.w3c.dom.Document)1