Search in sources :

Example 61 with Connector

use of org.eclipse.jetty.server.Connector in project jena by apache.

the class SPARQLServer method defaultServerConfig.

private static Server defaultServerConfig(int port, boolean loopback) {
    // Server, with one NIO-based connector, large input buffer size (for
    // long URLs, POSTed forms (queries, updates)).
    Server server = new Server();
    // Using "= new SelectChannelConnector() ;" on Darwin (OS/X) causes
    // problems
    // with initialization not seen (thread scheduling?) in Joseki.
    // BlockingChannelConnector is better for pumping large responses back
    // but there have been observed problems with DirectMemory allocation
    // (-XX:MaxDirectMemorySize=1G does not help)
    // Connector connector = new SelectChannelConnector() ;
    // Connector and specific settings.
    BlockingChannelConnector bcConnector = new BlockingChannelConnector();
    // bcConnector.setUseDirectBuffers(false) ;
    Connector connector = bcConnector;
    // Ignore. If set, then if this goes off, it keeps going off
    // and you get a lot of log messages.
    // Jetty outputs a lot of messages if this
    connector.setMaxIdleTime(0);
    // goes off.
    if (loopback)
        connector.setHost("localhost");
    connector.setPort(port);
    // Some people do try very large operations ...
    connector.setRequestHeaderSize(64 * 1024);
    connector.setRequestBufferSize(5 * 1024 * 1024);
    connector.setResponseBufferSize(5 * 1024 * 1024);
    server.addConnector(connector);
    return server;
}
Also used : BlockingChannelConnector(org.eclipse.jetty.server.nio.BlockingChannelConnector) Connector(org.eclipse.jetty.server.Connector) Server(org.eclipse.jetty.server.Server) BlockingChannelConnector(org.eclipse.jetty.server.nio.BlockingChannelConnector)

Aggregations

Connector (org.eclipse.jetty.server.Connector)61 Server (org.eclipse.jetty.server.Server)29 ServerConnector (org.eclipse.jetty.server.ServerConnector)20 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)18 IOException (java.io.IOException)12 HttpConnectionFactory (org.eclipse.jetty.server.HttpConnectionFactory)12 NetworkConnector (org.eclipse.jetty.server.NetworkConnector)12 HttpConfiguration (org.eclipse.jetty.server.HttpConfiguration)11 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)10 SelectChannelConnector (org.eclipse.jetty.server.nio.SelectChannelConnector)8 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)8 Test (org.junit.Test)7 Handler (org.eclipse.jetty.server.Handler)6 ServletException (javax.servlet.ServletException)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 EndPoint (org.eclipse.jetty.io.EndPoint)5 Request (org.eclipse.jetty.server.Request)5 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)5 ByteBuffer (java.nio.ByteBuffer)4