Search in sources :

Example 1 with Handler

use of com.yahoo.vespa.model.container.component.Handler in project vespa by vespa-engine.

the class ContainerCluster method addDefaultRootHandler.

public void addDefaultRootHandler() {
    if (hasHandlerWithBinding(ROOT_HANDLER_BINDING))
        return;
    Handler<AbstractConfigProducer<?>> handler = new Handler<>(new ComponentModel(BundleInstantiationSpecification.getFromStrings(BINDINGS_OVERVIEW_HANDLER_CLASS, null, null), // null bundle, as the handler is in container-disc
    null));
    handler.addServerBindings(ROOT_HANDLER_BINDING);
    addComponent(handler);
}
Also used : AbstractConfigProducer(com.yahoo.config.model.producer.AbstractConfigProducer) ComponentModel(com.yahoo.osgi.provider.model.ComponentModel) BindingsOverviewHandler(com.yahoo.container.usability.BindingsOverviewHandler) ProcessingHandler(com.yahoo.vespa.model.container.component.chain.ProcessingHandler) Handler(com.yahoo.vespa.model.container.component.Handler) JerseyHandler(com.yahoo.vespa.model.container.jersey.JerseyHandler) StateHandler(com.yahoo.container.jdisc.state.StateHandler)

Example 2 with Handler

use of com.yahoo.vespa.model.container.component.Handler in project vespa by vespa-engine.

the class ContainerDocumentApiBuilderTest method requireThatHandlersAreSetup.

@Test
public void requireThatHandlersAreSetup() throws Exception {
    Element elem = DomBuilderTest.parse("<jdisc id='cluster1' version='1.0'>", "  <document-api />", nodesXml, "</jdisc>");
    createModel(root, elem);
    Map<String, Handler<?>> handlerMap = getHandlers("cluster1");
    assertThat(handlerMap.get("com.yahoo.container.config.StatisticsRequestHandler"), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.container.handler.VipStatusHandler"), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.container.handler.observability.ApplicationStatusHandler"), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.container.jdisc.state.StateHandler"), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandler"), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandler").getServerBindings().contains("http://*/feed"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandler").getServerBindings().contains("https://*/feed"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandler").getServerBindings().contains("http://*/feed/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandler").getServerBindings().contains("https://*/feed/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandler").getServerBindings().size(), equalTo(4));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerCompatibility").getComponentId().toString(), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerCompatibility").getServerBindings().contains("http://*/document"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerCompatibility").getServerBindings().contains("https://*/document"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerCompatibility").getServerBindings().contains("http://*/document/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerCompatibility").getServerBindings().contains("https://*/document/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerCompatibility").getServerBindings().size(), equalTo(4));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerGet"), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerGet").getServerBindings().contains("http://*/get"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerGet").getServerBindings().contains("https://*/get"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerGet").getServerBindings().contains("http://*/get/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerGet").getServerBindings().contains("https://*/get/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerGet").getServerBindings().size(), equalTo(4));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerRemove"), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerRemove").getServerBindings().contains("http://*/remove"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerRemove").getServerBindings().contains("https://*/remove"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerRemove").getServerBindings().contains("http://*/remove/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerRemove").getServerBindings().contains("https://*/remove/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerRemove").getServerBindings().size(), equalTo(4));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerRemoveLocation"), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerRemoveLocation").getServerBindings().contains("http://*/removelocation"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerRemoveLocation").getServerBindings().contains("https://*/removelocation"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerRemoveLocation").getServerBindings().contains("http://*/removelocation/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerRemoveLocation").getServerBindings().contains("https://*/removelocation/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerRemoveLocation").getServerBindings().size(), equalTo(4));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerStatus"), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerStatus").getServerBindings().contains("http://*/feedstatus"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerStatus").getServerBindings().contains("https://*/feedstatus"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerStatus").getServerBindings().contains("http://*/feedstatus/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerStatus").getServerBindings().contains("https://*/feedstatus/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerStatus").getServerBindings().size(), equalTo(4));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerVisit"), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerVisit").getServerBindings().contains("http://*/visit"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerVisit").getServerBindings().contains("https://*/visit"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerVisit").getServerBindings().contains("http://*/visit/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerVisit").getServerBindings().contains("https://*/visit/"), is(true));
    assertThat(handlerMap.get("com.yahoo.feedhandler.VespaFeedHandlerVisit").getServerBindings().size(), equalTo(4));
    assertThat(handlerMap.get("com.yahoo.search.handler.SearchHandler"), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.search.handler.SearchHandler").getServerBindings().contains("http://*/search/*"), is(true));
    assertThat(handlerMap.get("com.yahoo.search.handler.SearchHandler").getServerBindings().contains("https://*/search/*"), is(true));
    assertThat(handlerMap.get("com.yahoo.search.handler.SearchHandler").getServerBindings().size(), equalTo(2));
    assertThat(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler"), not(nullValue()));
    assertThat(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler").getServerBindings().contains("http://*/" + ContainerCluster.RESERVED_URI_PREFIX + "/feedapi"), is(true));
    assertThat(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler").getServerBindings().contains("https://*/" + ContainerCluster.RESERVED_URI_PREFIX + "/feedapi"), is(true));
    assertThat(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler").getServerBindings().contains("http://*/" + ContainerCluster.RESERVED_URI_PREFIX + "/feedapi/"), is(true));
    assertThat(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler").getServerBindings().contains("https://*/" + ContainerCluster.RESERVED_URI_PREFIX + "/feedapi/"), is(true));
    assertThat(handlerMap.get("com.yahoo.vespa.http.server.FeedHandler").getServerBindings().size(), equalTo(4));
}
Also used : Element(org.w3c.dom.Element) Handler(com.yahoo.vespa.model.container.component.Handler) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 3 with Handler

use of com.yahoo.vespa.model.container.component.Handler in project vespa by vespa-engine.

the class RestApiTest method legacy_syntax_should_produce_valid_model.

@Test
public void legacy_syntax_should_produce_valid_model() throws Exception {
    String legacyXml = "<container version=\"1.0\" >\n" + "  <handler id=\"" + JerseyHandler.CLASS + "\" >\n" + "    <binding>" + HttpBinding + "</binding>\n" + "    <config name=\"jdisc.jersey.jersey-handler\">\n" + "      <jerseyMapping>jersey</jerseyMapping>\n" + "    </config>\n" + "  </handler>\n" + "</container>";
    createModel(root, DomBuilderTest.parse(legacyXml));
    Handler<?> handler = (Handler<?>) getContainerComponent("container", JerseyHandler.CLASS);
    assertThat(handler, not(nullValue()));
    assertThat(handler.getServerBindings(), hasItem(HttpBinding));
    JdiscBindingsConfig bindingsConfig = root.getConfig(JdiscBindingsConfig.class, ClusterId);
    assertThat(bindingsConfig.handlers(JerseyHandler.CLASS).serverBindings(), hasItem(HttpBinding));
}
Also used : Handler(com.yahoo.vespa.model.container.component.Handler) JerseyHandler(com.yahoo.vespa.model.container.jersey.JerseyHandler) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) JdiscBindingsConfig(com.yahoo.container.jdisc.JdiscBindingsConfig) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 4 with Handler

use of com.yahoo.vespa.model.container.component.Handler in project vespa by vespa-engine.

the class ContainerCluster method addMetricStateHandler.

public void addMetricStateHandler() {
    Handler<AbstractConfigProducer<?>> stateHandler = new Handler<>(new ComponentModel(STATE_HANDLER_CLASS, null, null, null));
    stateHandler.addServerBindings("http://*" + StateHandler.STATE_API_ROOT, "https://*" + StateHandler.STATE_API_ROOT, "http://*" + StateHandler.STATE_API_ROOT + "/*", "https://*" + StateHandler.STATE_API_ROOT + "/*");
    addComponent(stateHandler);
}
Also used : AbstractConfigProducer(com.yahoo.config.model.producer.AbstractConfigProducer) ComponentModel(com.yahoo.osgi.provider.model.ComponentModel) BindingsOverviewHandler(com.yahoo.container.usability.BindingsOverviewHandler) ProcessingHandler(com.yahoo.vespa.model.container.component.chain.ProcessingHandler) Handler(com.yahoo.vespa.model.container.component.Handler) JerseyHandler(com.yahoo.vespa.model.container.jersey.JerseyHandler) StateHandler(com.yahoo.container.jdisc.state.StateHandler)

Example 5 with Handler

use of com.yahoo.vespa.model.container.component.Handler in project vespa by vespa-engine.

the class ContainerCluster method addApplicationStatusHandler.

public void addApplicationStatusHandler() {
    Handler<AbstractConfigProducer<?>> statusHandler = new Handler<>(new ComponentModel(BundleInstantiationSpecification.getInternalHandlerSpecificationFromStrings(APPLICATION_STATUS_HANDLER_CLASS, null), null));
    statusHandler.addServerBindings("http://*/ApplicationStatus", "https://*/ApplicationStatus");
    addComponent(statusHandler);
}
Also used : AbstractConfigProducer(com.yahoo.config.model.producer.AbstractConfigProducer) ComponentModel(com.yahoo.osgi.provider.model.ComponentModel) BindingsOverviewHandler(com.yahoo.container.usability.BindingsOverviewHandler) ProcessingHandler(com.yahoo.vespa.model.container.component.chain.ProcessingHandler) Handler(com.yahoo.vespa.model.container.component.Handler) JerseyHandler(com.yahoo.vespa.model.container.jersey.JerseyHandler) StateHandler(com.yahoo.container.jdisc.state.StateHandler)

Aggregations

Handler (com.yahoo.vespa.model.container.component.Handler)6 JerseyHandler (com.yahoo.vespa.model.container.jersey.JerseyHandler)4 AbstractConfigProducer (com.yahoo.config.model.producer.AbstractConfigProducer)3 StateHandler (com.yahoo.container.jdisc.state.StateHandler)3 BindingsOverviewHandler (com.yahoo.container.usability.BindingsOverviewHandler)3 ComponentModel (com.yahoo.osgi.provider.model.ComponentModel)3 ProcessingHandler (com.yahoo.vespa.model.container.component.chain.ProcessingHandler)3 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)2 Test (org.junit.Test)2 JdiscBindingsConfig (com.yahoo.container.jdisc.JdiscBindingsConfig)1 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)1 HashMap (java.util.HashMap)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Element (org.w3c.dom.Element)1