diff options
author | gjoranv <gv@verizonmedia.com> | 2020-05-23 00:06:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-23 00:06:35 +0200 |
commit | 5c0bfb06784075ac72c7891b7dce6454d85bdff8 (patch) | |
tree | 672488ea6296ddcf8d5532b41adaea82cf985f12 /config-model | |
parent | 70fb7d3afb4960314aee74ae7c8f629e6867f0b3 (diff) | |
parent | 35bf92aabba393a11bbb086efa8bbe63482bf695 (diff) |
Merge pull request #13351 from vespa-engine/gjoranv/injectable-query-profile-registry
Gjoranv/injectable query profile registry
Diffstat (limited to 'config-model')
4 files changed, 26 insertions, 2 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/component/Component.java b/config-model/src/main/java/com/yahoo/vespa/model/container/component/Component.java index 08b6e321aa3..6d891c55075 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/component/Component.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/component/Component.java @@ -26,6 +26,11 @@ public class Component<CHILD extends AbstractConfigProducer<?>, MODEL extends Co this.model = model; } + /** Returns a component that uses its class name as id. */ + public static Component<?,?> fromClassAndBundle(String className, String bundle) { + return new Component<>(new ComponentModel(className, null, bundle)); + } + public ComponentId getGlobalComponentId() { return model.getComponentId(); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/component/SimpleComponent.java b/config-model/src/main/java/com/yahoo/vespa/model/container/component/SimpleComponent.java index 46ee0d0bd37..0b72971336f 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/component/SimpleComponent.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/component/SimpleComponent.java @@ -6,7 +6,7 @@ import com.yahoo.osgi.provider.model.ComponentModel; import com.yahoo.config.model.producer.AbstractConfigProducer; /** - * A component that only needs a simple ComponentModel. + * A component that uses the class name as id, and resides in the container-disc bundle. * * @author gjoranv */ @@ -16,7 +16,6 @@ public class SimpleComponent extends Component<AbstractConfigProducer<?>, Compon super(model); } - // For a component that uses the class name as id, and resides in the container-disc bundle. public SimpleComponent(String className) { this(new ComponentModel(BundleInstantiationSpecification.getFromStrings(className, null, null))); } diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java b/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java index 4c4b1ca7f82..58d12663c86 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/search/ContainerSearch.java @@ -1,13 +1,17 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.container.search; +import com.yahoo.config.model.producer.AbstractConfigProducer; import com.yahoo.container.QrSearchersConfig; +import com.yahoo.osgi.provider.model.ComponentModel; import com.yahoo.prelude.semantics.SemanticRulesConfig; import com.yahoo.search.config.IndexInfoConfig; import com.yahoo.search.pagetemplates.PageTemplatesConfig; +import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry; import com.yahoo.search.query.profile.config.QueryProfilesConfig; import com.yahoo.vespa.configdefinition.IlscriptsConfig; import com.yahoo.vespa.model.container.ApplicationContainerCluster; +import com.yahoo.vespa.model.container.component.Component; import com.yahoo.vespa.model.container.component.ContainerSubsystem; import com.yahoo.vespa.model.container.search.searchchain.LocalProvider; import com.yahoo.vespa.model.container.search.searchchain.SearchChains; @@ -21,6 +25,8 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import static com.yahoo.vespa.model.container.xml.BundleMapper.searchAndDocprocBundle; + /** * @author gjoranv * @author Tony Vaagenes @@ -34,6 +40,8 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> SemanticRulesConfig.Producer, PageTemplatesConfig.Producer { + public static final String QUERY_PROFILE_REGISTRY_CLASS = CompiledQueryProfileRegistry.class.getName(); + private ApplicationContainerCluster owningCluster; private final List<AbstractSearchCluster> searchClusters = new LinkedList<>(); private final Options options; @@ -46,6 +54,8 @@ public class ContainerSearch extends ContainerSubsystem<SearchChains> super(chains); this.owningCluster = cluster; this.options = options; + + owningCluster.addComponent(Component.fromClassAndBundle(QUERY_PROFILE_REGISTRY_CLASS, searchAndDocprocBundle)); } public void connectSearchClusters(Map<String, AbstractSearchCluster> searchClusters) { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java index 47f37a75fd0..a2d13439f4e 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/SearchBuilderTest.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.model.container.xml; +import com.yahoo.component.ComponentId; import com.yahoo.config.model.builder.xml.test.DomBuilderTest; import com.yahoo.container.core.ChainsConfig; import com.yahoo.container.jdisc.JdiscBindingsConfig; @@ -16,6 +17,7 @@ import org.w3c.dom.Element; import static com.yahoo.config.model.api.container.ContainerServiceType.QRSERVER; import static com.yahoo.test.Matchers.hasItemWithMethod; +import static com.yahoo.vespa.model.container.search.ContainerSearch.QUERY_PROFILE_REGISTRY_CLASS; import static com.yahoo.vespa.model.container.xml.ContainerModelBuilder.SEARCH_HANDLER_BINDING; import static com.yahoo.vespa.model.container.xml.ContainerModelBuilder.SEARCH_HANDLER_CLASS; import static org.hamcrest.CoreMatchers.is; @@ -127,6 +129,14 @@ public class SearchBuilderTest extends ContainerModelBuilderTestBase { assertThat(chainsConfig().chains(), hasItemWithMethod("vespa", "id")); } + @Test + public void query_profiles_registry_component_is_added() { + createClusterWithOnlyDefaultChains(); + ApplicationContainerCluster cluster = (ApplicationContainerCluster)root.getChildren().get("default"); + var queryProfileRegistryId = ComponentId.fromString(QUERY_PROFILE_REGISTRY_CLASS); + assertTrue(cluster.getComponentsMap().containsKey(queryProfileRegistryId)); + } + private void createClusterWithOnlyDefaultChains() { Element containerElem = DomBuilderTest.parse( "<container id='default' version='1.0'>", |