Search in sources :

Example 1 with DocprocChain

use of com.yahoo.vespa.model.container.docproc.DocprocChain in project vespa by vespa-engine.

the class ContainerIncludeTest method include.

@Test
public void include() {
    VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg("src/test/cfg/container/data/containerinclude/");
    VespaModel model = creator.create();
    assertThat(model.getContainerClusters().size(), is(1));
    ContainerCluster cluster = model.getContainerClusters().values().iterator().next();
    assertThat(cluster.getSearchChains(), notNullValue());
    Map<String, SearchChain> searchChainMap = new HashMap<>();
    for (SearchChain searchChain : cluster.getSearchChains().allChains().allComponents()) {
        searchChainMap.put(searchChain.getId().stringValue(), searchChain);
    }
    assertThat(searchChainMap.get("searchchain1"), notNullValue());
    assertThat(searchChainMap.get("searchchain1").getInnerComponents().size(), is(1));
    assertThat(searchChainMap.get("searchchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher1"));
    assertThat(searchChainMap.get("searchchain2"), notNullValue());
    assertThat(searchChainMap.get("searchchain2").getInnerComponents().size(), is(1));
    assertThat(searchChainMap.get("searchchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher2"));
    assertThat(searchChainMap.get("searchchain3"), notNullValue());
    assertThat(searchChainMap.get("searchchain3").getInnerComponents().size(), is(1));
    assertThat(searchChainMap.get("searchchain3").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher3"));
    assertThat(searchChainMap.get("searchchain4"), notNullValue());
    assertThat(searchChainMap.get("searchchain4").getInnerComponents().size(), is(1));
    assertThat(searchChainMap.get("searchchain4").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Searcher4"));
    assertThat(cluster.getDocprocChains(), notNullValue());
    Map<String, DocprocChain> docprocChainMap = new HashMap<>();
    for (DocprocChain docprocChain : cluster.getDocprocChains().allChains().allComponents()) {
        docprocChainMap.put(docprocChain.getId().stringValue(), docprocChain);
    }
    assertThat(docprocChainMap.get("docprocchain1"), notNullValue());
    assertThat(docprocChainMap.get("docprocchain1").getInnerComponents().size(), is(1));
    assertThat(docprocChainMap.get("docprocchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.DocumentProcessor1"));
    assertThat(docprocChainMap.get("docprocchain2"), notNullValue());
    assertThat(docprocChainMap.get("docprocchain2").getInnerComponents().size(), is(1));
    assertThat(docprocChainMap.get("docprocchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.DocumentProcessor2"));
    assertThat(cluster.getProcessingChains(), notNullValue());
    Map<String, ProcessingChain> processingChainMap = new HashMap<>();
    for (ProcessingChain processingChain : cluster.getProcessingChains().allChains().allComponents()) {
        processingChainMap.put(processingChain.getId().stringValue(), processingChain);
    }
    assertThat(processingChainMap.get("processingchain1"), notNullValue());
    assertThat(processingChainMap.get("processingchain1").getInnerComponents().size(), is(1));
    assertThat(processingChainMap.get("processingchain1").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Processor1"));
    assertThat(processingChainMap.get("processingchain2"), notNullValue());
    assertThat(processingChainMap.get("processingchain2").getInnerComponents().size(), is(1));
    assertThat(processingChainMap.get("processingchain2").getInnerComponents().iterator().next().getComponentId().stringValue(), is("com.yahoo.Processor2"));
}
Also used : VespaModelCreatorWithFilePkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg) ProcessingChain(com.yahoo.vespa.model.container.processing.ProcessingChain) HashMap(java.util.HashMap) VespaModel(com.yahoo.vespa.model.VespaModel) DocprocChain(com.yahoo.vespa.model.container.docproc.DocprocChain) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) SearchChain(com.yahoo.vespa.model.container.search.searchchain.SearchChain) Test(org.junit.Test)

Example 2 with DocprocChain

use of com.yahoo.vespa.model.container.docproc.DocprocChain in project vespa by vespa-engine.

the class DocprocBuilderTest method testDocprocCluster.

// TODO: re-enable assertions when the appropriate attributes are handled by the builder
@Test
public void testDocprocCluster() {
    assertThat(cluster.getName(), is("banan"));
    assertThat(cluster.getDocproc().isCompressDocuments(), is(true));
    // assertThat(cluster.getContainerDocproc().isPreferLocalNode(), is(true));
    // assertThat(cluster.getContainerDocproc().getNumNodesPerClient(), is(2));
    List<Container> services = cluster.getContainers();
    assertThat(services.size(), is(1));
    Container service = services.get(0);
    assertThat(service, notNullValue());
    Map<String, DocprocChain> chains = new HashMap<>();
    for (DocprocChain chain : cluster.getDocprocChains().allChains().allComponents()) {
        chains.put(chain.getId().stringValue(), chain);
    }
    assertThat(chains.size(), is(1));
    DocprocChain chain = chains.get("chein");
    assertThat(chain.getId().stringValue(), is("chein"));
    assertThat(chain.getInnerComponents().size(), is(1));
    DocumentProcessor processor = chain.getInnerComponents().iterator().next();
    assertThat(processor.getComponentId().stringValue(), is("docproc2"));
}
Also used : Container(com.yahoo.vespa.model.container.Container) HashMap(java.util.HashMap) DocumentProcessor(com.yahoo.vespa.model.container.docproc.DocumentProcessor) DocprocChain(com.yahoo.vespa.model.container.docproc.DocprocChain) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 3 with DocprocChain

use of com.yahoo.vespa.model.container.docproc.DocprocChain in project vespa by vespa-engine.

the class IndexingAndDocprocRoutingTest method assertIndexing.

private void assertIndexing(VespaModel model, DocprocClusterSpec... expectedDocprocClusters) {
    Map<String, ContainerCluster> docprocClusters = getDocprocClusters(model);
    assertThat(docprocClusters.size(), is(expectedDocprocClusters.length));
    for (DocprocClusterSpec expectedDocprocCluster : expectedDocprocClusters) {
        ContainerCluster docprocCluster = docprocClusters.get(expectedDocprocCluster.name);
        assertThat(docprocCluster, not(nullValue()));
        assertThat(docprocCluster.getName(), is(expectedDocprocCluster.name));
        ContainerDocproc containerDocproc = docprocCluster.getDocproc();
        assertThat(containerDocproc, not(nullValue()));
        List<DocprocChain> chains = containerDocproc.getChains().allChains().allComponents();
        assertThat(chains.size(), is(expectedDocprocCluster.chains.size()));
        List<String> actualDocprocChains = new ArrayList<>();
        for (DocprocChain chain : chains) {
            actualDocprocChains.add(chain.getServiceName());
        }
        List<String> expectedDocprocChainStrings = new ArrayList<>();
        for (DocprocChainSpec spec : expectedDocprocCluster.chains) {
            expectedDocprocChainStrings.add(spec.name);
        }
        assertThat(actualDocprocChains, hasItems(expectedDocprocChainStrings.toArray(new String[0])));
    }
}
Also used : DocprocChain(com.yahoo.vespa.model.container.docproc.DocprocChain) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) ContainerDocproc(com.yahoo.vespa.model.container.docproc.ContainerDocproc)

Example 4 with DocprocChain

use of com.yahoo.vespa.model.container.docproc.DocprocChain in project vespa by vespa-engine.

the class Content method addIndexingChain.

private static void addIndexingChain(ContainerCluster containerCluster) {
    DocprocChain chainAlreadyPresent = containerCluster.getDocprocChains().allChains().getComponent(new ComponentId(IndexingDocprocChain.NAME));
    if (chainAlreadyPresent != null) {
        if (chainAlreadyPresent instanceof IndexingDocprocChain)
            return;
        throw new IllegalArgumentException("A docproc chain may not have the ID '" + IndexingDocprocChain.NAME + ", since this is reserved by Vespa. Please use a different ID.");
    }
    containerCluster.getDocprocChains().add(new IndexingDocprocChain());
}
Also used : IndexingDocprocChain(com.yahoo.vespa.model.search.IndexingDocprocChain) DocprocChain(com.yahoo.vespa.model.container.docproc.DocprocChain) IndexingDocprocChain(com.yahoo.vespa.model.search.IndexingDocprocChain) ComponentId(com.yahoo.component.ComponentId)

Aggregations

DocprocChain (com.yahoo.vespa.model.container.docproc.DocprocChain)4 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 ComponentId (com.yahoo.component.ComponentId)1 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)1 VespaModel (com.yahoo.vespa.model.VespaModel)1 Container (com.yahoo.vespa.model.container.Container)1 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)1 ContainerDocproc (com.yahoo.vespa.model.container.docproc.ContainerDocproc)1 DocumentProcessor (com.yahoo.vespa.model.container.docproc.DocumentProcessor)1 ProcessingChain (com.yahoo.vespa.model.container.processing.ProcessingChain)1 SearchChain (com.yahoo.vespa.model.container.search.searchchain.SearchChain)1 IndexingDocprocChain (com.yahoo.vespa.model.search.IndexingDocprocChain)1 VespaModelCreatorWithFilePkg (com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1