Search in sources :

Example 1 with PartitionsConfig

use of com.yahoo.vespa.config.search.core.PartitionsConfig in project vespa by vespa-engine.

the class ContentBuilderTest method handleIndexedOnlyWithoutPersistence.

@Test
public void handleIndexedOnlyWithoutPersistence() throws Exception {
    VespaModel m = new VespaModelCreatorWithMockPkg(createAppWithMusic(getHosts(), getBasicServices())).create();
    ContentCluster c = CollectionUtil.first(m.getContentClusters().values());
    ContentSearchCluster s = c.getSearch();
    assertTrue(s.hasIndexedCluster());
    assertEquals(1, s.getClusters().size());
    assertNotNull(s.getIndexed());
    assertEquals("clu", s.getIndexed().getClusterName());
    assertEquals(7.3, s.getIndexed().getQueryTimeout(), 0.0);
    assertTrue(c.getPersistence() instanceof ProtonEngine.Factory);
    assertEquals(1, c.getStorageNodes().getChildren().size());
    assertEquals("clu", c.getConfigId());
    // assertEquals("content/a/0", a.getRootGroup().getNodes().get(0).getConfigId()); // This is how it should look like in an ideal world.
    // Due to reuse.
    assertEquals("clu/storage/0", c.getRootGroup().getNodes().get(0).getConfigId());
    assertEquals(1, c.getRoot().getHostSystem().getHosts().size());
    HostResource h = c.getRoot().getHostSystem().getHost("mockhost");
    String[] expectedServices = { "logd", "configproxy", "config-sentinel", "qrserver", "storagenode", "searchnode", "distributor", "topleveldispatch", "transactionlogserver" };
    // TODO        assertServices(h, expectedServices);
    assertEquals("clu/storage/0", h.getService("storagenode").getConfigId());
    assertEquals("clu/search/cluster.clu/0", h.getService("searchnode").getConfigId());
    assertEquals("clu/distributor/0", h.getService("distributor").getConfigId());
    assertEquals("clu/search/cluster.clu/tlds/qrc.0.tld.0", h.getService("topleveldispatch").getConfigId());
    // assertEquals("tcp/node0:19104", h.getService("topleveldispatch").getConfig("partitions", "").innerArray("dataset").value("0").innerArray("engine").value("0").getString("name_and_port"));
    PartitionsConfig partitionsConfig = new PartitionsConfig((PartitionsConfig.Builder) m.getConfig(new PartitionsConfig.Builder(), "clu/search/cluster.clu/tlds/qrc.0.tld.0"));
    assertTrue(partitionsConfig.dataset(0).engine(0).name_and_port().startsWith("tcp/node0:191"));
}
Also used : ContentSearchCluster(com.yahoo.vespa.model.content.ContentSearchCluster) HostResource(com.yahoo.vespa.model.HostResource) VespaModelCreatorWithMockPkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg) VespaModel(com.yahoo.vespa.model.VespaModel) ProtonEngine(com.yahoo.vespa.model.content.engines.ProtonEngine) Matchers.containsString(org.hamcrest.Matchers.containsString) PartitionsConfig(com.yahoo.vespa.config.search.core.PartitionsConfig) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 2 with PartitionsConfig

use of com.yahoo.vespa.config.search.core.PartitionsConfig in project vespa by vespa-engine.

the class ClusterTest method requireThatSearchCoverageIsApplied.

@Test
public void requireThatSearchCoverageIsApplied() throws ParseException {
    ContentCluster cluster = newContentCluster(joinLines("<search>", "  <coverage>", "    <minimum>0.11</minimum>", "    <min-wait-after-coverage-factor>0.23</min-wait-after-coverage-factor>", "    <max-wait-after-coverage-factor>0.58</max-wait-after-coverage-factor>", "  </coverage>", "</search>"));
    for (Dispatch tld : cluster.getSearch().getIndexed().getTLDs()) {
        PartitionsConfig.Builder builder = new PartitionsConfig.Builder();
        tld.getConfig(builder);
        PartitionsConfig config = new PartitionsConfig(builder);
        assertEquals(11.0, config.dataset(0).minimal_searchcoverage(), 1E-6);
        assertEquals(0.23, config.dataset(0).higher_coverage_minsearchwait(), 1E-6);
        assertEquals(0.58, config.dataset(0).higher_coverage_maxsearchwait(), 1E-6);
    }
}
Also used : SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) Dispatch(com.yahoo.vespa.model.search.Dispatch) PartitionsConfig(com.yahoo.vespa.config.search.core.PartitionsConfig) Test(org.junit.Test)

Example 3 with PartitionsConfig

use of com.yahoo.vespa.config.search.core.PartitionsConfig in project vespa by vespa-engine.

the class MultilevelDispatchTest method requireThatSearchCoverageIsSetInMultilevelSetup.

@Test
public void requireThatSearchCoverageIsSetInMultilevelSetup() throws Exception {
    ContentCluster cr = createCluster(getSimpleDispatchXml() + getCoverage());
    Dispatch tld = cr.getSearch().getIndexed().getTLDs().get(0);
    PartitionsConfig.Builder builder = new PartitionsConfig.Builder();
    tld.getConfig(builder);
    PartitionsConfig config = new PartitionsConfig(builder);
    assertThat(config.dataset().size(), is(1));
    assertEquals(95.0, config.dataset(0).minimal_searchcoverage(), 0.1);
    for (Dispatch dispatch : getDispatchers(tld)) {
        PartitionsConfig.Builder b = new PartitionsConfig.Builder();
        dispatch.getConfig(b);
        PartitionsConfig c = new PartitionsConfig(b);
        assertThat(c.dataset().size(), is(1));
        assertEquals(95.0, c.dataset(0).minimal_searchcoverage(), 0.1);
    }
}
Also used : PartitionsConfig(com.yahoo.vespa.config.search.core.PartitionsConfig) ContentCluster(com.yahoo.vespa.model.content.cluster.ContentCluster) Test(org.junit.Test)

Example 4 with PartitionsConfig

use of com.yahoo.vespa.config.search.core.PartitionsConfig in project vespa by vespa-engine.

the class MultilevelDispatchTest method requireThatSearchCoverageIsSetInSingleLevelSetup.

@Test
public void requireThatSearchCoverageIsSetInSingleLevelSetup() throws Exception {
    TestRoot root = new TestDriver(true).buildModel(new MockApplicationPackage.Builder().withServices("<services version='1.0'>" + "<content id='stateful' version='1.0'>" + "  <redundancy>1</redundancy>" + "  <documents><document mode='index' type='music' /></documents>" + "  <nodes>" + "    <node distribution-key='1' hostalias='mockroot' />" + "  </nodes>" + "  <search><coverage><minimum>0.95</minimum></coverage></search>" + "</content>" + "<jdisc id='foo' version='1.0'>" + "  <search />" + "  <nodes><node hostalias='mockroot' /></nodes>" + "</jdisc>" + "</services>").withSearchDefinition(MockApplicationPackage.MUSIC_SEARCHDEFINITION).build());
    PartitionsConfig config = root.getConfig(PartitionsConfig.class, "stateful/search/cluster.stateful/tlds/foo.0.tld.0");
    assertThat(config.dataset().size(), is(1));
    assertEquals(95.0, config.dataset(0).minimal_searchcoverage(), 0.1);
}
Also used : TestRoot(com.yahoo.config.model.test.TestRoot) PartitionsConfig(com.yahoo.vespa.config.search.core.PartitionsConfig) TestDriver(com.yahoo.config.model.test.TestDriver) Test(org.junit.Test)

Example 5 with PartitionsConfig

use of com.yahoo.vespa.config.search.core.PartitionsConfig in project vespa by vespa-engine.

the class TldTest method requireThatUseLocalPolicyIsOk.

@Test
public void requireThatUseLocalPolicyIsOk() {
    ApplicationPackage app = new MockApplicationPackage.Builder().withHosts("<hosts>" + "<host name='search.node1'><alias>search1</alias></host>" + "<host name='search.node2'><alias>search2</alias></host>" + "<host name='jdisc.host.other'><alias>gateway</alias></host>" + "</hosts>").withServices("<services>" + "  <admin version='2.0'>" + "    <adminserver hostalias='gateway' />" + "  </admin>" + "  <jdisc version='1.0' id='default'>" + "    <search />" + "    <nodes>" + "      <node hostalias='search1'/>" + "      <node hostalias='search2'/>" + "    </nodes>" + "  </jdisc>" + "  <jdisc version='1.0' id='gw'>" + "    <document-api/>" + "    <nodes>" + "      <node hostalias='gateway'/>" + "    </nodes>" + "  </jdisc>" + "  <content version='1.0' id='foo'>" + "    <redundancy>2</redundancy>" + "    <documents>" + "      <document type='music' mode='index'/>" + "    </documents>" + "    <group name='topGroup'>" + "    <distribution partitions='1|*'/>" + "     <group name='group1' distribution-key='0'>" + "       <node hostalias='search1' distribution-key='0'/>" + "     </group>" + "     <group name='group2' distribution-key='1'>" + "       <node hostalias='search2' distribution-key='1'/>" + "     </group>" + "    </group>" + "    <tuning>" + "      <dispatch>" + "        <use-local-node>true</use-local-node>" + "      </dispatch>" + "    </tuning>" + "  </content>" + "</services>").withSearchDefinition(MockApplicationPackage.MUSIC_SEARCHDEFINITION).build();
    PartitionsConfig.Builder builder = new PartitionsConfig.Builder();
    new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/gw.0.tld.0");
    PartitionsConfig config = new PartitionsConfig(builder);
    assertEquals(1, config.dataset().size());
    // gateway TLD with no local search node gets all search nodes
    assertEquals(2, config.dataset(0).engine().size());
    // Load Balance row 0
    assertEquals("rowid not equal 0", 0, config.dataset(0).engine(0).rowid());
    assertEquals("partid not equal 0", 0, config.dataset(0).engine(0).partid());
    assertTrue("Not configured with correct search node", config.dataset(0).engine(0).name_and_port().contains("search.node1"));
    // Load Balance row 1
    assertEquals("rowid not equal to 1", 1, config.dataset(0).engine(1).rowid());
    assertEquals("partid no equal to 0", 0, config.dataset(0).engine(1).partid());
    assertTrue("Not configured with correct search node", config.dataset(0).engine(1).name_and_port().contains("search.node2"));
    // First container with a local search node
    builder = new PartitionsConfig.Builder();
    new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/default.0.tld.0");
    config = new PartitionsConfig(builder);
    assertEquals(1, config.dataset().size());
    assertEquals(1, config.dataset(0).engine().size());
    assertEquals(0, config.dataset(0).engine(0).rowid());
    assertEquals(0, config.dataset(0).engine(0).partid());
    assertTrue("Not configured with local search node as engine", config.dataset(0).engine(0).name_and_port().contains("search.node1"));
    // Second container with a local search node
    builder = new PartitionsConfig.Builder();
    new TestDriver(true).buildModel(app).getConfig(builder, "foo/search/cluster.foo/tlds/default.1.tld.1");
    config = new PartitionsConfig(builder);
    assertEquals(1, config.dataset().size());
    assertEquals(1, config.dataset(0).engine().size());
    assertEquals(0, config.dataset(0).engine(0).rowid());
    assertEquals(0, config.dataset(0).engine(0).partid());
    assertTrue("Not configured with local search node as engine", config.dataset(0).engine(0).name_and_port().contains("search.node2"));
}
Also used : PartitionsConfig(com.yahoo.vespa.config.search.core.PartitionsConfig) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) TestDriver(com.yahoo.config.model.test.TestDriver) Test(org.junit.Test)

Aggregations

PartitionsConfig (com.yahoo.vespa.config.search.core.PartitionsConfig)10 Test (org.junit.Test)9 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)3 TestDriver (com.yahoo.config.model.test.TestDriver)3 VespaModel (com.yahoo.vespa.model.VespaModel)3 ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)3 VespaModelCreatorWithMockPkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithMockPkg)3 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)2 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)2 Matchers.containsString (org.hamcrest.Matchers.containsString)2 TestRoot (com.yahoo.config.model.test.TestRoot)1 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)1 HostResource (com.yahoo.vespa.model.HostResource)1 ContentSearchCluster (com.yahoo.vespa.model.content.ContentSearchCluster)1 ProtonEngine (com.yahoo.vespa.model.content.engines.ProtonEngine)1 Dispatch (com.yahoo.vespa.model.search.Dispatch)1