Search in sources :

Example 36 with ComponentId

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

the class JettyHttpServerBuilder method doBuild.

@Override
protected JettyHttpServer doBuild(AbstractConfigProducer ancestor, Element http) {
    JettyHttpServer jettyHttpServer = new JettyHttpServer(new ComponentId("jdisc-jetty"));
    for (Element serverSpec : XML.getChildren(http, "server")) {
        ConnectorFactory connectorFactory = new JettyConnectorBuilder().build(ancestor, serverSpec);
        jettyHttpServer.addConnector(connectorFactory);
    }
    return jettyHttpServer;
}
Also used : ConnectorFactory(com.yahoo.vespa.model.container.http.ConnectorFactory) Element(org.w3c.dom.Element) ComponentId(com.yahoo.component.ComponentId) JettyHttpServer(com.yahoo.vespa.model.container.http.JettyHttpServer)

Example 37 with ComponentId

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

the class StandaloneDocprocContainerTest method requireNoMbusProvidersWhenStandalone.

@Test
public void requireNoMbusProvidersWhenStandalone() {
    ContainerCluster containerCluster = setupCluster(true);
    Map<ComponentId, Component<?, ?>> components = containerCluster.getComponentsMap();
    boolean foundAtLeastOneClient = false;
    boolean foundAtLeastOneServer = false;
    for (ComponentId componentId : components.keySet()) {
        if (componentId.stringValue().contains("MbusClient"))
            foundAtLeastOneClient = true;
        if (componentId.stringValue().contains("MbusServer"))
            foundAtLeastOneServer = true;
    }
    assertThat(foundAtLeastOneClient, is(false));
    assertThat(foundAtLeastOneServer, is(false));
}
Also used : ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) Component(com.yahoo.vespa.model.container.component.Component) ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 38 with ComponentId

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

the class StandaloneDocprocContainerTest method requireMbusProvidersWhenNonStandalone.

@Test
public void requireMbusProvidersWhenNonStandalone() {
    ContainerCluster containerCluster = setupCluster(false);
    Map<ComponentId, Component<?, ?>> components = containerCluster.getComponentsMap();
    boolean foundAtLeastOneClient = false;
    boolean foundAtLeastOneServer = false;
    for (ComponentId componentId : components.keySet()) {
        if (componentId.stringValue().contains("MbusClient"))
            foundAtLeastOneClient = true;
        if (componentId.stringValue().contains("MbusServer"))
            foundAtLeastOneServer = true;
    }
    assertThat(foundAtLeastOneClient, is(true));
    assertThat(foundAtLeastOneServer, is(true));
}
Also used : ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) Component(com.yahoo.vespa.model.container.component.Component) ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 39 with ComponentId

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

the class ModelAmendingTestCase method testModelAmending.

@Test
public void testModelAmending() throws IOException, SAXException {
    ConfigModelRegistry amendingModelRepo = MapConfigModelRegistry.createFromList(new AdminModelAmenderBuilder(), new ContainerModelAmenderBuilder(), new ContentModelAmenderBuilder());
    String services = "<services version='1.0'>" + "    <admin version='4.0'/>" + "    <jdisc id='test1' version='1.0'>" + "        <search/>" + "        <nodes count='2'/>" + "    </jdisc>" + "    <jdisc id='test2' version='1.0'>" + "        <http><server id='server1' port='19110'/></http>" + "        <document-api/>" + "        <nodes count='2'/>" + "    </jdisc>" + "    <content id='test3' version='1.0'>" + "        <redundancy>1</redundancy>" + "        <documents>" + "            <document mode='index' type='type1'/>" + "        </documents>" + "        <nodes count='2'/>" + "    </content>" + "    <content id='test4' version='1.0'>" + "        <redundancy>1</redundancy>" + "        <documents>" + "            <document mode='index' type='type1'/>" + "        </documents>" + "        <nodes count='3'/>" + "    </content>" + "</services>";
    VespaModelTester tester = new VespaModelTester(amendingModelRepo);
    tester.addHosts(10);
    VespaModel model = tester.createModel(services);
    // Check that all hosts are amended
    for (HostResource host : model.getAdmin().getHostSystem().getHosts()) {
        assertFalse(host + " is amended", host.getHost().getChildrenByTypeRecursive(AmendedService.class).isEmpty());
    }
    // Check that jdisc clusters are amended
    assertEquals(2, model.getContainerClusters().size());
    assertNotNull(model.getContainerClusters().get("test1").getComponentsMap().get(new ComponentId("com.yahoo.MyAmendedComponent")));
    assertNotNull(model.getContainerClusters().get("test2").getComponentsMap().get(new ComponentId("com.yahoo.MyAmendedComponent")));
}
Also used : HostResource(com.yahoo.vespa.model.HostResource) ConfigModelRegistry(com.yahoo.config.model.ConfigModelRegistry) MapConfigModelRegistry(com.yahoo.config.model.MapConfigModelRegistry) VespaModel(com.yahoo.vespa.model.VespaModel) ComponentId(com.yahoo.component.ComponentId) Test(org.junit.Test)

Example 40 with ComponentId

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

the class FilterBindingsProviderTest method requireThatCorrectlyConfiguredFiltersAreIncluded.

@Test
public void requireThatCorrectlyConfiguredFiltersAreIncluded() {
    final String requestFilter1Id = "requestFilter1";
    final String requestFilter2Id = "requestFilter2";
    final String requestFilter3Id = "requestFilter3";
    final String responseFilter1Id = "responseFilter1";
    final String responseFilter2Id = "responseFilter2";
    final String responseFilter3Id = "responseFilter3";
    // Set up config.
    configBuilder.filter(new ServerConfig.Filter.Builder().id(requestFilter1Id).binding("http://*/a"));
    configBuilder.filter(new ServerConfig.Filter.Builder().id(requestFilter2Id).binding("http://*/b"));
    configBuilder.filter(new ServerConfig.Filter.Builder().id(responseFilter1Id).binding("http://*/c"));
    configBuilder.filter(new ServerConfig.Filter.Builder().id(responseFilter3Id).binding("http://*/d"));
    // Set up registry.
    final ComponentRegistry<RequestFilter> availableRequestFilters = new ComponentRegistry<>();
    final RequestFilter requestFilter1Instance = mock(RequestFilter.class);
    final RequestFilter requestFilter2Instance = mock(RequestFilter.class);
    final RequestFilter requestFilter3Instance = mock(RequestFilter.class);
    availableRequestFilters.register(ComponentId.fromString(requestFilter1Id), requestFilter1Instance);
    availableRequestFilters.register(ComponentId.fromString(requestFilter2Id), requestFilter2Instance);
    availableRequestFilters.register(ComponentId.fromString(requestFilter3Id), requestFilter3Instance);
    final ComponentRegistry<ResponseFilter> availableResponseFilters = new ComponentRegistry<>();
    final ResponseFilter responseFilter1Instance = mock(ResponseFilter.class);
    final ResponseFilter responseFilter2Instance = mock(ResponseFilter.class);
    final ResponseFilter responseFilter3Instance = mock(ResponseFilter.class);
    availableResponseFilters.register(ComponentId.fromString(responseFilter1Id), responseFilter1Instance);
    availableResponseFilters.register(ComponentId.fromString(responseFilter2Id), responseFilter2Instance);
    availableResponseFilters.register(ComponentId.fromString(responseFilter3Id), responseFilter3Instance);
    final FilterChainRepository filterChainRepository = new FilterChainRepository(new ChainsConfig(new ChainsConfig.Builder()), availableRequestFilters, availableResponseFilters, new ComponentRegistry<SecurityRequestFilter>(), new ComponentRegistry<SecurityResponseFilter>());
    // Set up the provider that we aim to test.
    final FilterBindingsProvider provider = new FilterBindingsProvider(new ComponentId("foo"), new ServerConfig(configBuilder), filterChainRepository, new ComponentRegistry<SecurityRequestFilter>());
    // Execute.
    final FilterBindings filterBindings = provider.get();
    // Verify.
    assertThat(filterBindings, is(not(nullValue())));
    assertThat(filterBindings.getRequestFilters(), containsFilters(requestFilter1Instance, requestFilter2Instance));
    assertThat(filterBindings.getRequestFilters(), not(containsFilters(requestFilter3Instance)));
    assertThat(filterBindings.getResponseFilters(), containsFilters(responseFilter1Instance, responseFilter3Instance));
    assertThat(filterBindings.getResponseFilters(), not(containsFilters(responseFilter2Instance)));
}
Also used : SecurityResponseFilter(com.yahoo.jdisc.http.filter.SecurityResponseFilter) ChainsConfig(com.yahoo.container.core.ChainsConfig) FilterBindings(com.yahoo.jdisc.http.server.FilterBindings) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ServerConfig(com.yahoo.jdisc.http.ServerConfig) SecurityRequestFilter(com.yahoo.jdisc.http.filter.SecurityRequestFilter) RequestFilter(com.yahoo.jdisc.http.filter.RequestFilter) SecurityRequestFilter(com.yahoo.jdisc.http.filter.SecurityRequestFilter) ResponseFilter(com.yahoo.jdisc.http.filter.ResponseFilter) SecurityResponseFilter(com.yahoo.jdisc.http.filter.SecurityResponseFilter) ComponentRegistry(com.yahoo.component.provider.ComponentRegistry) ResponseFilter(com.yahoo.jdisc.http.filter.ResponseFilter) SecurityResponseFilter(com.yahoo.jdisc.http.filter.SecurityResponseFilter) FilterChainRepository(com.yahoo.container.http.filter.FilterChainRepository) ComponentId(com.yahoo.component.ComponentId) RequestFilter(com.yahoo.jdisc.http.filter.RequestFilter) SecurityRequestFilter(com.yahoo.jdisc.http.filter.SecurityRequestFilter) 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