Search in sources :

Example 11 with QueuedThreadPool

use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.

the class FastCGIProxyServletTest method prepare.

public void prepare(HttpServlet servlet) throws Exception {
    QueuedThreadPool serverThreads = new QueuedThreadPool();
    serverThreads.setName("server");
    server = new Server(serverThreads);
    httpConnector = new ServerConnector(server);
    server.addConnector(httpConnector);
    fcgiConnector = new ServerConnector(server, new ServerFCGIConnectionFactory(new HttpConfiguration(), sendStatus200));
    server.addConnector(fcgiConnector);
    final String contextPath = "/";
    context = new ServletContextHandler(server, contextPath);
    final String servletPath = "/script";
    FastCGIProxyServlet fcgiServlet = new FastCGIProxyServlet() {

        @Override
        protected String rewriteTarget(HttpServletRequest request) {
            return "http://localhost:" + fcgiConnector.getLocalPort() + servletPath + request.getServletPath();
        }
    };
    ServletHolder fcgiServletHolder = new ServletHolder(fcgiServlet);
    fcgiServletHolder.setName("fcgi");
    fcgiServletHolder.setInitParameter(FastCGIProxyServlet.SCRIPT_ROOT_INIT_PARAM, "/scriptRoot");
    fcgiServletHolder.setInitParameter("proxyTo", "http://localhost");
    fcgiServletHolder.setInitParameter(FastCGIProxyServlet.SCRIPT_PATTERN_INIT_PARAM, "(.+?\\.php)");
    context.addServlet(fcgiServletHolder, "*.php");
    context.addServlet(new ServletHolder(servlet), servletPath + "/*");
    QueuedThreadPool clientThreads = new QueuedThreadPool();
    clientThreads.setName("client");
    client = new HttpClient();
    client.setExecutor(clientThreads);
    server.addBean(client);
    server.start();
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) HttpServletRequest(javax.servlet.http.HttpServletRequest) Server(org.eclipse.jetty.server.Server) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) HttpClient(org.eclipse.jetty.client.HttpClient) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) ServerFCGIConnectionFactory(org.eclipse.jetty.fcgi.server.ServerFCGIConnectionFactory) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 12 with QueuedThreadPool

use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.

the class AbstractTest method prepareServer.

protected void prepareServer(ConnectionFactory connectionFactory) {
    QueuedThreadPool serverExecutor = new QueuedThreadPool();
    serverExecutor.setName("server");
    server = new Server(serverExecutor);
    connector = new ServerConnector(server, 1, 1, connectionFactory);
    server.addConnector(connector);
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) Server(org.eclipse.jetty.server.Server) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool)

Example 13 with QueuedThreadPool

use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.

the class HttpChannelAssociationTest method testAssociationFailedAbortsRequest.

@Test
public void testAssociationFailedAbortsRequest() throws Exception {
    startServer(new EmptyServerHandler());
    client = new HttpClient(newHttpClientTransport(transport, exchange -> false), sslContextFactory);
    QueuedThreadPool clientThreads = new QueuedThreadPool();
    clientThreads.setName("client");
    client.setExecutor(clientThreads);
    client.start();
    CountDownLatch latch = new CountDownLatch(1);
    client.newRequest(newURI()).send(result -> {
        if (result.isFailed())
            latch.countDown();
    });
    Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
}
Also used : QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) HttpClient(org.eclipse.jetty.client.HttpClient) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 14 with QueuedThreadPool

use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.

the class AbstractHttpClientServerTest method startServer.

protected void startServer(Handler handler) throws Exception {
    if (sslContextFactory != null) {
        sslContextFactory.setEndpointIdentificationAlgorithm("");
        sslContextFactory.setKeyStorePath("src/test/resources/keystore.jks");
        sslContextFactory.setKeyStorePassword("storepwd");
        sslContextFactory.setTrustStorePath("src/test/resources/truststore.jks");
        sslContextFactory.setTrustStorePassword("storepwd");
    }
    if (server == null) {
        QueuedThreadPool serverThreads = new QueuedThreadPool();
        serverThreads.setName("server");
        server = new Server(serverThreads);
    }
    connector = new ServerConnector(server, sslContextFactory);
    server.addConnector(connector);
    server.setHandler(handler);
    server.start();
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) Server(org.eclipse.jetty.server.Server) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool)

Example 15 with QueuedThreadPool

use of org.eclipse.jetty.util.thread.QueuedThreadPool in project jetty.project by eclipse.

the class HttpClientChunkedContentTest method startClient.

private void startClient() throws Exception {
    QueuedThreadPool clientThreads = new QueuedThreadPool();
    clientThreads.setName("client");
    client = new HttpClient();
    client.setExecutor(clientThreads);
    client.start();
}
Also used : QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool)

Aggregations

QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)126 Server (org.eclipse.jetty.server.Server)65 ServerConnector (org.eclipse.jetty.server.ServerConnector)51 Test (org.junit.Test)30 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)26 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)23 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)22 HttpClient (org.eclipse.jetty.client.HttpClient)18 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)18 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)18 IOException (java.io.IOException)17 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)11 ContextHandlerCollection (org.eclipse.jetty.server.handler.ContextHandlerCollection)11 DefaultHandler (org.eclipse.jetty.server.handler.DefaultHandler)10 File (java.io.File)9 CountDownLatch (java.util.concurrent.CountDownLatch)9 HttpServletRequest (javax.servlet.http.HttpServletRequest)9 InputStream (java.io.InputStream)8 HttpServletResponse (javax.servlet.http.HttpServletResponse)8 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)8