Search in sources :

Example 1 with JettyConnectionMetrics

use of io.micrometer.core.instrument.binder.jetty.JettyConnectionMetrics in project zeppelin by apache.

the class ZeppelinServer method initServerConnector.

private static void initServerConnector(Server server, int port, int sslPort) {
    ServerConnector connector;
    HttpConfiguration httpConfig = new HttpConfiguration();
    httpConfig.addCustomizer(new ForwardedRequestCustomizer());
    httpConfig.setSendServerVersion(conf.sendJettyName());
    httpConfig.setRequestHeaderSize(conf.getJettyRequestHeaderSize());
    if (conf.useSsl()) {
        LOG.debug("Enabling SSL for Zeppelin Server on port {}", sslPort);
        httpConfig.setSecureScheme(HttpScheme.HTTPS.asString());
        httpConfig.setSecurePort(sslPort);
        HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig);
        httpsConfig.addCustomizer(new SecureRequestCustomizer());
        SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(getSslContextFactory(conf), HttpVersion.HTTP_1_1.asString());
        HttpConnectionFactory httpsConnectionFactory = new HttpConnectionFactory(httpsConfig);
        connector = new ServerConnector(server, sslConnectionFactory, httpsConnectionFactory);
        connector.setPort(sslPort);
        connector.addBean(new JettySslHandshakeMetrics(Metrics.globalRegistry, Tags.empty()));
    } else {
        HttpConnectionFactory httpConnectionFactory = new HttpConnectionFactory(httpConfig);
        connector = new ServerConnector(server, httpConnectionFactory);
        connector.setPort(port);
    }
    // Set some timeout options to make debugging easier.
    int timeout = 1000 * 30;
    connector.setIdleTimeout(timeout);
    connector.setHost(conf.getServerAddress());
    connector.addBean(new JettyConnectionMetrics(Metrics.globalRegistry, Tags.empty()));
    server.addConnector(connector);
}
Also used : ServerConnector(org.eclipse.jetty.server.ServerConnector) JettySslHandshakeMetrics(io.micrometer.core.instrument.binder.jetty.JettySslHandshakeMetrics) SecureRequestCustomizer(org.eclipse.jetty.server.SecureRequestCustomizer) HttpConnectionFactory(org.eclipse.jetty.server.HttpConnectionFactory) HttpConfiguration(org.eclipse.jetty.server.HttpConfiguration) SslConnectionFactory(org.eclipse.jetty.server.SslConnectionFactory) JettyConnectionMetrics(io.micrometer.core.instrument.binder.jetty.JettyConnectionMetrics) ForwardedRequestCustomizer(org.eclipse.jetty.server.ForwardedRequestCustomizer)

Aggregations

JettyConnectionMetrics (io.micrometer.core.instrument.binder.jetty.JettyConnectionMetrics)1 JettySslHandshakeMetrics (io.micrometer.core.instrument.binder.jetty.JettySslHandshakeMetrics)1 ForwardedRequestCustomizer (org.eclipse.jetty.server.ForwardedRequestCustomizer)1 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)1 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)1 SecureRequestCustomizer (org.eclipse.jetty.server.SecureRequestCustomizer)1 ServerConnector (org.eclipse.jetty.server.ServerConnector)1 SslConnectionFactory (org.eclipse.jetty.server.SslConnectionFactory)1