Search in sources :

Example 6 with ContentCluster

use of com.yahoo.vespa.model.content.cluster.ContentCluster in project vespa by vespa-engine.

the class ModelProvisioningTest method checkThatTldAndContainerRunningOnSameHostHaveSameId.

private void checkThatTldAndContainerRunningOnSameHostHaveSameId(Collection<ContainerCluster> containerClusters, Collection<ContentCluster> contentClusters, int startIndexForContainerIds) {
    for (ContentCluster contentCluster : contentClusters) {
        String contentClusterName = contentCluster.getName();
        int i = 0;
        for (ContainerCluster containerCluster : containerClusters) {
            String containerClusterName = containerCluster.getName();
            for (int j = 0; j < 2; j++) {
                Dispatch tld = contentCluster.getSearch().getIndexed().getTLDs().get(2 * i + j);
                Container container = containerCluster.getContainers().get(j);
                int containerConfigIdIndex = j + startIndexForContainerIds;
                assertEquals(container.getHostName(), tld.getHostname());
                assertEquals(contentClusterName + "/search/cluster." + contentClusterName + "/tlds/" + containerClusterName + "." + containerConfigIdIndex + ".tld." + containerConfigIdIndex, tld.getConfigId());
                assertEquals(containerClusterName + "/" + "container." + containerConfigIdIndex, container.getConfigId());
            }
            i++;
        }
    }
}
Also used : Container(com.yahoo.vespa.model.container.Container) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) Dispatch(com.yahoo.vespa.model.search.Dispatch) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster)

Example 7 with ContentCluster

use of com.yahoo.vespa.model.content.cluster.ContentCluster in project vespa by vespa-engine.

the class ModelProvisioningTest method testExplicitNonDedicatedClusterControllers.

@Test
public void testExplicitNonDedicatedClusterControllers() {
    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>" + "     <controllers><nodes dedicated='false' count='6'/></controllers>" + "     <nodes count='9' groups='3'/>" + "  </content>" + "</services>";
    int numberOfHosts = 19;
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(numberOfHosts);
    VespaModel model = tester.createModel(services, true);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
    // Check content clusters
    ContentCluster cluster = model.getContentClusters().get("bar");
    ContainerCluster clusterControllers = cluster.getClusterControllers();
    assertEquals(8, cluster.distributionBits());
    assertEquals("We get the closest odd number", 5, clusterControllers.getContainers().size());
    assertEquals("bar-controllers", clusterControllers.getName());
    assertEquals("default01", clusterControllers.getContainers().get(0).getHostName());
    assertEquals("default02", clusterControllers.getContainers().get(1).getHostName());
    assertEquals("default04", clusterControllers.getContainers().get(2).getHostName());
    assertEquals("default05", clusterControllers.getContainers().get(3).getHostName());
    assertEquals("default07", clusterControllers.getContainers().get(4).getHostName());
    assertEquals("default09", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
    assertEquals("default08", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(1).getHostName());
    assertEquals("default06", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
    assertEquals("default03", cluster.getRootGroup().getSubgroups().get(2).getNodes().get(0).getHostName());
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test)

Example 8 with ContentCluster

use of com.yahoo.vespa.model.content.cluster.ContentCluster in project vespa by vespa-engine.

the class ModelProvisioningTest method testNodeCountForContentGroup.

@Test
public void testNodeCountForContentGroup() {
    String xmlWithNodes = "<?xml version='1.0' encoding='utf-8' ?>" + "<services>" + "\n" + "  <admin version='3.0'>" + "    <nodes count='3'/>" + "  </admin>" + "  <content version='1.0' id='bar'>" + "     <redundancy>2</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='2'/>" + "   </content>" + "</services>";
    VespaModelTester tester = new VespaModelTester();
    int numberOfHosts = 2;
    tester.addHosts(numberOfHosts);
    int numberOfContentNodes = 2;
    VespaModel model = tester.createModel(xmlWithNodes, true);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
    final Map<String, ContentCluster> contentClusters = model.getContentClusters();
    ContentCluster cluster = contentClusters.get("bar");
    assertThat(cluster.getRootGroup().getNodes().size(), is(numberOfContentNodes));
    int i = 0;
    for (StorageNode node : cluster.getRootGroup().getNodes()) assertEquals(i++, node.getDistributionKey());
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) StorageNode(com.yahoo.vespa.model.content.StorageNode) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test)

Example 9 with ContentCluster

use of com.yahoo.vespa.model.content.cluster.ContentCluster in project vespa by vespa-engine.

the class ModelProvisioningTest method testGroupsOfSize1.

@Test
public void testGroupsOfSize1() {
    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>1</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='8' groups='8'/>" + "  </content>" + "</services>";
    int numberOfHosts = 18;
    VespaModelTester tester = new VespaModelTester();
    tester.addHosts(numberOfHosts);
    VespaModel model = tester.createModel(services, true);
    assertThat(model.getRoot().getHostSystem().getHosts().size(), is(numberOfHosts));
    // Check content cluster
    ContentCluster cluster = model.getContentClusters().get("bar");
    ContainerCluster clusterControllers = cluster.getClusterControllers();
    assertEquals(3, clusterControllers.getContainers().size());
    assertEquals("bar-controllers", clusterControllers.getName());
    assertEquals("default01", clusterControllers.getContainers().get(0).getHostName());
    assertEquals("default02", clusterControllers.getContainers().get(1).getHostName());
    assertEquals("default08", clusterControllers.getContainers().get(2).getHostName());
    assertEquals(0, cluster.getRootGroup().getNodes().size());
    assertEquals(8, cluster.getRootGroup().getSubgroups().size());
    assertEquals(8, cluster.distributionBits());
    // first group
    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("bar/storage/0"));
    assertEquals("default08", cluster.getRootGroup().getSubgroups().get(0).getNodes().get(0).getHostName());
    // second group
    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("bar/storage/1"));
    assertEquals("default07", cluster.getRootGroup().getSubgroups().get(1).getNodes().get(0).getHostName());
    // ... last group
    assertThat(cluster.getRootGroup().getSubgroups().get(7).getIndex(), is("7"));
    assertThat(cluster.getRootGroup().getSubgroups().get(7).getNodes().size(), is(1));
    assertThat(cluster.getRootGroup().getSubgroups().get(7).getNodes().get(0).getDistributionKey(), is(7));
    assertThat(cluster.getRootGroup().getSubgroups().get(7).getNodes().get(0).getConfigId(), is("bar/storage/7"));
    assertEquals("default01", cluster.getRootGroup().getSubgroups().get(7).getNodes().get(0).getHostName());
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test)

Example 10 with ContentCluster

use of com.yahoo.vespa.model.content.cluster.ContentCluster in project vespa by vespa-engine.

the class ModelProvisioningTest method test2ContentNodesOn2ClustersWithContainerClusterProducesMixedClusterControllerCluster.

// TODO: unignore when feature is enabled again
@Ignore
@Test
public void test2ContentNodesOn2ClustersWithContainerClusterProducesMixedClusterControllerCluster() throws ParseException {
    String services = "<?xml version='1.0' encoding='utf-8' ?>\n" + "<services>" + "  <container version='1.0' id='container'>" + "     <nodes count='3' flavor='container-node'/>" + "  </container>" + "  <content version='1.0' id='content1'>" + "     <redundancy>2</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='2' flavor='content1-node'/>" + "  </content>" + "  <content version='1.0' id='content2'>" + "     <redundancy>2</redundancy>" + "     <documents>" + "       <document type='type1' mode='index'/>" + "     </documents>" + "     <nodes count='2' flavor='content2-node'/>" + "  </content>" + "</services>";
    VespaModelTester tester = new VespaModelTester();
    // use different flavors to make the test clearer
    tester.addHosts("container-node", 3);
    tester.addHosts("content1-node", 2);
    tester.addHosts("content2-node", 2);
    VespaModel model = tester.createModel(services, true);
    ContentCluster cluster1 = model.getContentClusters().get("content1");
    ContainerCluster clusterControllers1 = cluster1.getClusterControllers();
    assertEquals(1, clusterControllers1.getContainers().size());
    assertEquals("content1-node0", clusterControllers1.getContainers().get(0).getHostName());
    assertEquals("content1-node1", clusterControllers1.getContainers().get(1).getHostName());
    assertEquals("container-node0", clusterControllers1.getContainers().get(2).getHostName());
    ContentCluster cluster2 = model.getContentClusters().get("content2");
    ContainerCluster clusterControllers2 = cluster2.getClusterControllers();
    assertEquals(3, clusterControllers2.getContainers().size());
    assertEquals("content2-node0", clusterControllers2.getContainers().get(0).getHostName());
    assertEquals("content2-node1", clusterControllers2.getContainers().get(1).getHostName());
    assertEquals("We do not pick the container used to supplement another cluster", "container-node1", clusterControllers2.getContainers().get(2).getHostName());
}
Also used : VespaModelTester(com.yahoo.vespa.model.test.VespaModelTester) VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)83 Test (org.junit.Test)70 VespaModel (com.yahoo.vespa.model.VespaModel)22 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)20 ContentSearchCluster (com.yahoo.vespa.model.content.ContentSearchCluster)18 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)16 VespaModelTester (com.yahoo.vespa.model.test.VespaModelTester)15 MockRoot (com.yahoo.config.model.test.MockRoot)7 ContentClusterBuilder (com.yahoo.vespa.model.content.utils.ContentClusterBuilder)7 SearchDefinitionBuilder (com.yahoo.vespa.model.content.utils.SearchDefinitionBuilder)6 PartitionsConfig (com.yahoo.vespa.config.search.core.PartitionsConfig)5 HostResource (com.yahoo.vespa.model.HostResource)5 SearchNode (com.yahoo.vespa.model.search.SearchNode)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 StorDistributionConfig (com.yahoo.vespa.config.content.StorDistributionConfig)4 ProtonConfig (com.yahoo.vespa.config.search.core.ProtonConfig)4 ProtonEngine (com.yahoo.vespa.model.content.engines.ProtonEngine)4 VDSEngine (com.yahoo.vespa.model.content.engines.VDSEngine)4 StorServerConfig (com.yahoo.vespa.config.content.core.StorServerConfig)3 ConfigChangeAction (com.yahoo.config.model.api.ConfigChangeAction)2