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