Search in sources :

Example 16 with QueuedThreadPool

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

the class ProxyTest method startProxy.

private void startProxy(HttpServlet proxyServlet, Map<String, String> initParams) throws Exception {
    QueuedThreadPool proxyPool = new QueuedThreadPool();
    proxyPool.setName("proxy");
    proxy = new Server(proxyPool);
    HttpConfiguration configuration = new HttpConfiguration();
    configuration.setSendDateHeader(false);
    configuration.setSendServerVersion(false);
    String value = initParams.get("outputBufferSize");
    if (value != null)
        configuration.setOutputBufferSize(Integer.valueOf(value));
    proxyConnector = new ServerConnector(proxy, new HTTP2ServerConnectionFactory(configuration));
    proxy.addConnector(proxyConnector);
    ServletContextHandler proxyContext = new ServletContextHandler(proxy, "/", true, false);
    ServletHolder proxyServletHolder = new ServletHolder(proxyServlet);
    proxyServletHolder.setInitParameters(initParams);
    proxyContext.addServlet(proxyServletHolder, "/*");
    proxy.start();
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) Server(org.eclipse.jetty.server.Server) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ServletHolder(org.eclipse.jetty.servlet.ServletHolder) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) HTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory) ServletContextHandler(org.eclipse.jetty.servlet.ServletContextHandler)

Example 17 with QueuedThreadPool

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

the class HTTP2Client method doStart.

@Override
protected void doStart() throws Exception {
    if (executor == null)
        setExecutor(new QueuedThreadPool());
    if (scheduler == null)
        setScheduler(new ScheduledExecutorScheduler());
    if (bufferPool == null)
        setByteBufferPool(new MappedByteBufferPool());
    if (connectionFactory == null) {
        HTTP2ClientConnectionFactory h2 = new HTTP2ClientConnectionFactory();
        setClientConnectionFactory((endPoint, context) -> {
            ClientConnectionFactory factory = h2;
            SslContextFactory sslContextFactory = (SslContextFactory) context.get(SslClientConnectionFactory.SSL_CONTEXT_FACTORY_CONTEXT_KEY);
            if (sslContextFactory != null) {
                ALPNClientConnectionFactory alpn = new ALPNClientConnectionFactory(getExecutor(), h2, getProtocols());
                factory = new SslClientConnectionFactory(sslContextFactory, getByteBufferPool(), getExecutor(), alpn);
            }
            return factory.newConnection(endPoint, context);
        });
    }
    if (selector == null) {
        selector = newSelectorManager();
        addBean(selector);
    }
    selector.setConnectTimeout(getConnectTimeout());
    super.doStart();
}
Also used : MappedByteBufferPool(org.eclipse.jetty.io.MappedByteBufferPool) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) ScheduledExecutorScheduler(org.eclipse.jetty.util.thread.ScheduledExecutorScheduler) SslClientConnectionFactory(org.eclipse.jetty.io.ssl.SslClientConnectionFactory) ALPNClientConnectionFactory(org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory) ClientConnectionFactory(org.eclipse.jetty.io.ClientConnectionFactory) SslClientConnectionFactory(org.eclipse.jetty.io.ssl.SslClientConnectionFactory) ALPNClientConnectionFactory(org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory)

Example 18 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... connectionFactories) {
    QueuedThreadPool serverExecutor = new QueuedThreadPool();
    serverExecutor.setName("server");
    server = new Server(serverExecutor);
    connector = new ServerConnector(server, 1, 1, connectionFactories);
    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 19 with QueuedThreadPool

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

the class AbstractTest method prepareClient.

protected void prepareClient() {
    client = new HTTP2Client();
    QueuedThreadPool clientExecutor = new QueuedThreadPool();
    clientExecutor.setName("client");
    client.setExecutor(clientExecutor);
}
Also used : QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool)

Example 20 with QueuedThreadPool

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

the class SmallThreadPoolLoadTest method customizeContext.

@Override
protected void customizeContext(ServletContextHandler context) {
    QueuedThreadPool serverThreads = (QueuedThreadPool) context.getServer().getThreadPool();
    serverThreads.setDetailedDump(true);
    serverThreads.setMaxThreads(5);
    serverThreads.setLowThreadsThreshold(1);
    AbstractHTTP2ServerConnectionFactory h2 = connector.getBean(AbstractHTTP2ServerConnectionFactory.class);
    h2.setInitialSessionRecvWindow(Integer.MAX_VALUE);
}
Also used : QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool) AbstractHTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.AbstractHTTP2ServerConnectionFactory)

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