Search in sources :

Example 1 with Jetty93InstrumentedConnectionFactory

use of io.dropwizard.jetty.Jetty93InstrumentedConnectionFactory in project dropwizard by dropwizard.

the class Http2CConnectorFactory method build.

@Override
public Connector build(Server server, MetricRegistry metrics, String name, ThreadPool threadPool) {
    // Prepare connection factories for HTTP/2c
    final HttpConfiguration httpConfig = buildHttpConfiguration();
    final HttpConnectionFactory http11 = buildHttpConnectionFactory(httpConfig);
    final HTTP2ServerConnectionFactory http2c = new HTTP2CServerConnectionFactory(httpConfig);
    http2c.setMaxConcurrentStreams(maxConcurrentStreams);
    http2c.setInitialStreamRecvWindow(initialStreamRecvWindow);
    // new protocol.
    return buildConnector(server, new ScheduledExecutorScheduler(), buildBufferPool(), name, threadPool, new Jetty93InstrumentedConnectionFactory(http11, metrics.timer(httpConnections())), http2c);
}
Also used : HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HTTP2CServerConnectionFactory(org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory) ScheduledExecutorScheduler(org.eclipse.jetty.util.thread.ScheduledExecutorScheduler) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) HTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory) Jetty93InstrumentedConnectionFactory(io.dropwizard.jetty.Jetty93InstrumentedConnectionFactory)

Example 2 with Jetty93InstrumentedConnectionFactory

use of io.dropwizard.jetty.Jetty93InstrumentedConnectionFactory in project dropwizard by dropwizard.

the class Http2ConnectorFactory method build.

@Override
public Connector build(Server server, MetricRegistry metrics, String name, ThreadPool threadPool) {
    // HTTP/2 requires that a server MUST support TLSv1.2 and TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher
    // See http://http2.github.io/http2-spec/index.html#rfc.section.9.2.2
    setSupportedProtocols(ImmutableList.of("TLSv1.2"));
    setSupportedCipherSuites(ImmutableList.of("TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"));
    // Setup connection factories
    final HttpConfiguration httpConfig = buildHttpConfiguration();
    final HttpConnectionFactory http1 = buildHttpConnectionFactory(httpConfig);
    final HTTP2ServerConnectionFactory http2 = new HTTP2ServerConnectionFactory(httpConfig);
    http2.setMaxConcurrentStreams(maxConcurrentStreams);
    http2.setInitialStreamRecvWindow(initialStreamRecvWindow);
    final NegotiatingServerConnectionFactory alpn = new ALPNServerConnectionFactory(H2, H2_17);
    // Speak HTTP 1.1 over TLS if negotiation fails
    alpn.setDefaultProtocol(HTTP_1_1);
    final SslContextFactory sslContextFactory = configureSslContextFactory(new SslContextFactory());
    sslContextFactory.addLifeCycleListener(logSslInfoOnStart(sslContextFactory));
    server.addBean(sslContextFactory);
    server.addBean(new SslReload(sslContextFactory, this::configureSslContextFactory));
    // We should use ALPN as a negotiation protocol. Old clients that don't support it will be served
    // via HTTPS. New clients, however, that want to use HTTP/2 will use TLS with ALPN extension.
    // If negotiation succeeds, the client and server switch to HTTP/2 protocol.
    final SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, "alpn");
    return buildConnector(server, new ScheduledExecutorScheduler(), buildBufferPool(), name, threadPool, new Jetty93InstrumentedConnectionFactory(sslConnectionFactory, metrics.timer(httpConnections())), alpn, http2, http1);
}
Also used : SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SslReload(io.dropwizard.jetty.SslReload) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) ALPNServerConnectionFactory(org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory) ScheduledExecutorScheduler(org.eclipse.jetty.util.thread.ScheduledExecutorScheduler) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) HTTP2ServerConnectionFactory(org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory) NegotiatingServerConnectionFactory(org.eclipse.jetty.server.NegotiatingServerConnectionFactory) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) Jetty93InstrumentedConnectionFactory(io.dropwizard.jetty.Jetty93InstrumentedConnectionFactory)

Aggregations

Jetty93InstrumentedConnectionFactory (io.dropwizard.jetty.Jetty93InstrumentedConnectionFactory)2 HTTP2ServerConnectionFactory (org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory)2 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)2 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)2 ScheduledExecutorScheduler (org.eclipse.jetty.util.thread.ScheduledExecutorScheduler)2 SslReload (io.dropwizard.jetty.SslReload)1 ALPNServerConnectionFactory (org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory)1 HTTP2CServerConnectionFactory (org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory)1 NegotiatingServerConnectionFactory (org.eclipse.jetty.server.NegotiatingServerConnectionFactory)1 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)1 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)1