Search in sources :

Example 1 with ConnectorConfig

use of com.yahoo.jdisc.http.ConnectorConfig in project vespa by vespa-engine.

the class ConnectorFactoryTest method requireThatNoPreBoundChannelWorks.

@Test
public void requireThatNoPreBoundChannelWorks() throws Exception {
    Server server = new Server();
    try {
        ConnectorConfig config = new ConnectorConfig(new ConnectorConfig.Builder());
        ConnectorFactory factory = createConnectorFactory(config);
        JDiscServerConnector connector = (JDiscServerConnector) factory.createConnector(new DummyMetric(), server, null);
        server.addConnector(connector);
        server.setHandler(new HelloWorldHandler());
        server.start();
        SimpleHttpClient client = new SimpleHttpClient(null, connector.getLocalPort(), false);
        SimpleHttpClient.RequestExecutor ex = client.newGet("/blaasdfnb");
        SimpleHttpClient.ResponseValidator val = ex.execute();
        val.expectContent(equalTo("Hello world"));
    } finally {
        try {
            server.stop();
        } catch (Exception e) {
        // ignore
        }
    }
}
Also used : Server(org.eclipse.jetty.server.Server) ConnectorConfig(com.yahoo.jdisc.http.ConnectorConfig) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) Test(org.testng.annotations.Test)

Example 2 with ConnectorConfig

use of com.yahoo.jdisc.http.ConnectorConfig in project vespa by vespa-engine.

the class ConnectorFactoryTest method requireThatPreBoundChannelWorks.

@Test
public void requireThatPreBoundChannelWorks() throws Exception {
    Server server = new Server();
    try {
        ServerSocketChannel serverChannel = ServerSocketChannel.open();
        serverChannel.socket().bind(new InetSocketAddress(0));
        ConnectorConfig config = new ConnectorConfig(new ConnectorConfig.Builder());
        ConnectorFactory factory = createConnectorFactory(config);
        JDiscServerConnector connector = (JDiscServerConnector) factory.createConnector(new DummyMetric(), server, serverChannel);
        server.addConnector(connector);
        server.setHandler(new HelloWorldHandler());
        server.start();
        SimpleHttpClient client = new SimpleHttpClient(null, connector.getLocalPort(), false);
        SimpleHttpClient.RequestExecutor ex = client.newGet("/blaasdfnb");
        SimpleHttpClient.ResponseValidator val = ex.execute();
        val.expectContent(equalTo("Hello world"));
    } finally {
        try {
            server.stop();
        } catch (Exception e) {
        // ignore
        }
    }
}
Also used : Server(org.eclipse.jetty.server.Server) InetSocketAddress(java.net.InetSocketAddress) ConnectorConfig(com.yahoo.jdisc.http.ConnectorConfig) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) ServerSocketChannel(java.nio.channels.ServerSocketChannel) Test(org.testng.annotations.Test)

Example 3 with ConnectorConfig

use of com.yahoo.jdisc.http.ConnectorConfig in project vespa by vespa-engine.

the class ConnectorFactoryTest method ssl_jks_config_is_validated.

@Test(expectedExceptions = IllegalArgumentException.class)
public void ssl_jks_config_is_validated() {
    ConnectorConfig config = new ConnectorConfig(new ConnectorConfig.Builder().ssl(new Ssl.Builder().enabled(true).keyStoreType(JKS).pemKeyStore(new Ssl.PemKeyStore.Builder().keyPath("nonEmpty"))));
    ConnectorFactory willThrowException = createConnectorFactory(config);
}
Also used : ConnectorConfig(com.yahoo.jdisc.http.ConnectorConfig) Ssl(com.yahoo.jdisc.http.ConnectorConfig.Ssl) Test(org.testng.annotations.Test)

Example 4 with ConnectorConfig

use of com.yahoo.jdisc.http.ConnectorConfig in project vespa by vespa-engine.

the class JettyContainerModelBuilderTest method verify_that_overriding_connector_options_works.

@Test
public void verify_that_overriding_connector_options_works() throws Exception {
    Element clusterElem = DomBuilderTest.parse("<jdisc id='default' version='1.0' jetty='true'>\n" + "  <http>\n" + "    <server id='bananarama' port='4321'>\n" + "      <config name='jdisc.http.connector'>\n" + "        <requestHeaderSize>300000</requestHeaderSize>\n" + "        <headerCacheSize>300000</headerCacheSize>\n" + "      </config>\n" + "    </server>\n" + "  </http>\n" + nodesXml + "</jdisc>\n");
    createModel(root, clusterElem);
    ConnectorConfig.Builder connectorConfigBuilder = new ConnectorConfig.Builder();
    ConnectorConfig cfg = root.getConfig(ConnectorConfig.class, "default/http/jdisc-jetty/bananarama");
    assertThat(cfg.requestHeaderSize(), is(300000));
    assertThat(cfg.headerCacheSize(), is(300000));
}
Also used : ConnectorConfig(com.yahoo.jdisc.http.ConnectorConfig) Element(org.w3c.dom.Element) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Example 5 with ConnectorConfig

use of com.yahoo.jdisc.http.ConnectorConfig in project vespa by vespa-engine.

the class JettyContainerModelBuilderTest method verify_that_old_http_config_override_inside_server_tag_works.

@Test
public void verify_that_old_http_config_override_inside_server_tag_works() throws Exception {
    Element clusterElem = DomBuilderTest.parse("<jdisc id='default' version='1.0' jetty='true'>", "  <http>", "    <server port='9000' id='foo'>", "      <config name=\"container.jdisc.config.http-server\">", "        <tcpKeepAliveEnabled>true</tcpKeepAliveEnabled>", "        <tcpNoDelayEnabled>false</tcpNoDelayEnabled>", "        <tcpListenBacklogLength>2</tcpListenBacklogLength>", "        <idleConnectionTimeout>34.1</idleConnectionTimeout>", "        <soLinger>42.2</soLinger>", "        <sendBufferSize>1234</sendBufferSize>", "        <maxHeaderSize>4321</maxHeaderSize>", "        <ssl>", "          <enabled>true</enabled>", "          <keyStoreType>JKS</keyStoreType>", "          <keyStorePath>apple</keyStorePath>", "          <trustStorePath>grape</trustStorePath>", "          <keyDBKey>tomato</keyDBKey>", "          <algorithm>onion</algorithm>", "          <protocol>carrot</protocol>", "        </ssl>", "      </config>", "    </server>", "  </http>", nodesXml, "</jdisc>");
    createModel(root, clusterElem);
    ContainerCluster cluster = (ContainerCluster) root.getChildren().get("default");
    List<JettyHttpServer> jettyServers = cluster.getChildrenByTypeRecursive(JettyHttpServer.class);
    assertThat(jettyServers.size(), is(1));
    JettyHttpServer server = jettyServers.get(0);
    assertThat(server.model.bundleInstantiationSpec.classId.toString(), is(com.yahoo.jdisc.http.server.jetty.JettyHttpServer.class.getName()));
    assertThat(server.model.bundleInstantiationSpec.bundle.toString(), is("jdisc_http_service"));
    assertThat(server.getConnectorFactories().size(), is(1));
    ConnectorConfig.Builder connectorConfigBuilder = new ConnectorConfig.Builder();
    server.getConnectorFactories().get(0).getConfig(connectorConfigBuilder);
    ConnectorConfig connector = new ConnectorConfig(connectorConfigBuilder);
    assertThat(connector.name(), equalTo("foo"));
    assertThat(connector.tcpKeepAliveEnabled(), equalTo(true));
    assertThat(connector.tcpNoDelay(), equalTo(false));
    assertThat(connector.acceptQueueSize(), equalTo(2));
    assertThat(connector.idleTimeout(), equalTo(34.1));
    assertThat(connector.soLingerTime(), equalTo(42.2));
    assertThat(connector.outputBufferSize(), equalTo(1234));
    assertThat(connector.headerCacheSize(), equalTo(4321));
    assertThat(connector.ssl().enabled(), equalTo(true));
    assertThat(connector.ssl().keyStoreType(), equalTo(KeyStoreType.Enum.JKS));
    assertThat(connector.ssl().keyStorePath(), equalTo("apple"));
    assertThat(connector.ssl().trustStorePath(), equalTo("grape"));
    assertThat(connector.ssl().keyDbKey(), equalTo("tomato"));
    assertThat(connector.ssl().sslKeyManagerFactoryAlgorithm(), equalTo("onion"));
    assertThat(connector.ssl().protocol(), equalTo("carrot"));
    assertThat(extractComponentByClassName(clusterComponentsConfig(), com.yahoo.jdisc.http.server.jetty.JettyHttpServer.class.getName()), is(not(nullValue())));
}
Also used : ConnectorConfig(com.yahoo.jdisc.http.ConnectorConfig) Element(org.w3c.dom.Element) ContainerCluster(com.yahoo.vespa.model.container.ContainerCluster) JettyHttpServer(com.yahoo.vespa.model.container.http.JettyHttpServer) Test(org.junit.Test) DomBuilderTest(com.yahoo.config.model.builder.xml.test.DomBuilderTest)

Aggregations

ConnectorConfig (com.yahoo.jdisc.http.ConnectorConfig)7 Test (org.testng.annotations.Test)4 DomBuilderTest (com.yahoo.config.model.builder.xml.test.DomBuilderTest)2 Ssl (com.yahoo.jdisc.http.ConnectorConfig.Ssl)2 IOException (java.io.IOException)2 ServerSocketChannel (java.nio.channels.ServerSocketChannel)2 ServletException (javax.servlet.ServletException)2 Server (org.eclipse.jetty.server.Server)2 Test (org.junit.Test)2 Element (org.w3c.dom.Element)2 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)1 JettyHttpServer (com.yahoo.vespa.model.container.http.JettyHttpServer)1 InetSocketAddress (java.net.InetSocketAddress)1