Search in sources :

Example 26 with ComponentId

use of com.yahoo.component.ComponentId 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)

Example 27 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class ContainerModelBuilderTest method component_includes_are_added.

@Test
public void component_includes_are_added() {
    VespaModelCreatorWithFilePkg creator = new VespaModelCreatorWithFilePkg("src/test/cfg/application/include_dirs");
    VespaModel model = creator.create(true);
    ContainerCluster cluster = model.getContainerClusters().get("default");
    Map<ComponentId, Component<?, ?>> componentsMap = cluster.getComponentsMap();
    Component<?, ?> example = componentsMap.get(ComponentId.fromString("test.Exampledocproc"));
    assertThat(example.getComponentId().getName(), is("test.Exampledocproc"));
}
Also used : VespaModelCreatorWithFilePkg(com.yahoo.vespa.model.test.utils.VespaModelCreatorWithFilePkg) VespaModel(com.yahoo.vespa.model.VespaModel) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) Component(com.yahoo.vespa.model.container.component.Component) ComponentId(com.yahoo.component.ComponentId) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Test(org.junit.Test)

Example 28 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class RestApiTest method all_non_restApi_components_are_injected_to_RestApiContext.

@Test
public void all_non_restApi_components_are_injected_to_RestApiContext() throws Exception {
    setup();
    ComponentsConfig componentsConfig = root.getConfig(ComponentsConfig.class, ClusterId);
    Set<ComponentId> clusterChildrenComponentIds = getContainerCluster(ClusterId).getAllComponents().stream().map(Component::getComponentId).collect(Collectors.toSet());
    Set<ComponentId> restApiChildrenComponentIds = restApi.getChildren().values().stream().map(child -> ((Component<?, ?>) child).getComponentId()).collect(Collectors.toSet());
    // TODO: Review: replace with filtering against RestApiContext.isCycleGeneratingComponent
    ComponentId cycleInducingComponents = ComponentId.fromString("com.yahoo.container.handler.observability.ApplicationStatusHandler");
    Set<ComponentId> expectedInjectedConfigIds = new HashSet<>(clusterChildrenComponentIds);
    expectedInjectedConfigIds.removeAll(restApiChildrenComponentIds);
    expectedInjectedConfigIds.remove(cycleInducingComponents);
    Set<ComponentId> injectedConfigIds = restApiContextConfig(componentsConfig).inject().stream().map(inject -> ComponentId.fromString(inject.id())).collect(Collectors.toSet());
    // Verify that the two sets are equal. Split in two asserts to get decent failure messages.
    assertThat("Not all required components are injected", injectedConfigIds, containsInAnyOrder(expectedInjectedConfigIds.toArray()));
    assertThat("We inject some components that should not be injected", expectedInjectedConfigIds, containsInAnyOrder(injectedConfigIds.toArray()));
}
Also used : ComponentsConfig(com.yahoo.container.ComponentsConfig) CoreMatchers.is(org.hamcrest.CoreMatchers.is) CoreMatchers.hasItem(org.hamcrest.CoreMatchers.hasItem) Handler(com.yahoo.vespa.model.container.component.Handler) ComponentId(com.yahoo.component.ComponentId) CoreMatchers.not(org.hamcrest.CoreMatchers.not) HashSet(java.util.HashSet) RestApiContext(com.yahoo.vespa.model.container.jersey.RestApiContext) JerseyBundlesConfig(com.yahoo.container.di.config.JerseyBundlesConfig) RestApi(com.yahoo.vespa.model.container.jersey.RestApi) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) CoreMatchers.nullValue(org.hamcrest.CoreMatchers.nullValue) JerseyInitConfig(com.yahoo.container.config.jersey.JerseyInitConfig) Component(com.yahoo.vespa.model.container.component.Component) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) CoreMatchers.hasItems(org.hamcrest.CoreMatchers.hasItems) JdiscBindingsConfig(com.yahoo.container.jdisc.JdiscBindingsConfig) JerseyHandler(com.yahoo.vespa.model.container.jersey.JerseyHandler) Set(java.util.Set) Test(org.junit.Test) ContainerModelBuilderTestBase(com.yahoo.vespa.model.container.xml.ContainerModelBuilderTestBase) Collectors(java.util.stream.Collectors) JerseyInjectionConfig(com.yahoo.container.di.config.JerseyInjectionConfig) Ignore(org.junit.Ignore) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) ComponentsConfig(com.yahoo.container.ComponentsConfig) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest) Component(com.yahoo.vespa.model.container.component.Component) ComponentId(com.yahoo.component.ComponentId) HashSet(java.util.HashSet) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 29 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class ComponentIdTestCase method testCompareWithNameSpace.

@Test
public void testCompareWithNameSpace() {
    ComponentId withNS = ComponentId.fromString("foo@ns");
    // Should be less than withNs
    ComponentId withoutNS = ComponentId.fromString("foo");
    assertEquals(withNS.compareTo(withoutNS), 1);
    assertEquals(withoutNS.compareTo(withNS), -1);
}
Also used : ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test)

Example 30 with ComponentId

use of com.yahoo.component.ComponentId in project vespa by vespa-engine.

the class ComponentClassTestCase method testCreateComponent.

@SuppressWarnings("unchecked")
@Test
public void testCreateComponent() throws NoSuchMethodException {
    Map<ConfigKey, ConfigInstance> availableConfigs = new HashMap<>();
    String configId = "testConfigId";
    availableConfigs.put(new ConfigKey(StringConfig.class, configId), new StringConfig(new StringConfig.Builder()));
    availableConfigs.put(new ConfigKey(IntConfig.class, configId), new IntConfig(new IntConfig.Builder()));
    ComponentClass<TestComponent> testClass = new ComponentClass<>(TestComponent.class);
    TestComponent component = testClass.createComponent(new ComponentId("test", new Version(1)), availableConfigs, configId);
    assertEquals("test", component.getId().getName());
    assertEquals(1, component.getId().getVersion().getMajor());
    assertEquals(1, component.intVal);
    assertEquals("_default_", component.stringVal);
}
Also used : ConfigKey(com.yahoo.vespa.config.ConfigKey) HashMap(java.util.HashMap) IntConfig(com.yahoo.config.core.IntConfig) StringConfig(com.yahoo.config.core.StringConfig) Version(com.yahoo.component.Version) ComponentId(com.yahoo.component.ComponentId) ComponentClass(com.yahoo.component.provider.ComponentClass) ConfigInstance(com.yahoo.config.ConfigInstance) Test(org.junit.Test)

Aggregations

ComponentId (com.yahoo.component.ComponentId)68 Test (org.junit.Test)25 Result (com.yahoo.search.Result)14 Query (com.yahoo.search.Query)13 Execution (com.yahoo.search.searchchain.Execution)13 ArrayList (java.util.ArrayList)10 Chain (com.yahoo.component.chain.Chain)8 Searcher (com.yahoo.search.Searcher)8 ComponentRegistry (com.yahoo.component.provider.ComponentRegistry)7 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)7 FederationSearcher (com.yahoo.search.federation.FederationSearcher)6 Hit (com.yahoo.search.result.Hit)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)4 ChainsConfig (com.yahoo.container.core.ChainsConfig)4 FilterChainRepository (com.yahoo.container.http.filter.FilterChainRepository)4 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)4 QueryProfileTypeRegistry (com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)4 Component (com.yahoo.vespa.model.container.component.Component)4 HashMap (java.util.HashMap)4