Search in sources :

Example 11 with SelectChannelConnector

use of org.eclipse.jetty.server.nio.SelectChannelConnector in project storm by apache.

the class UIHelpers method jettyCreateServer.

/**
     * Construct a Jetty Server instance.
     */
public static Server jettyCreateServer(Integer port, String host, Integer httpsPort) {
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(Utils.getInt(port, 80));
    connector.setHost(host);
    connector.setMaxIdleTime(200000);
    Server server = new Server();
    server.addConnector(connector);
    server.setSendDateHeader(true);
    if (httpsPort != null && httpsPort > 0) {
        removeNonSslConnector(server);
    }
    return server;
}
Also used : SelectChannelConnector(org.eclipse.jetty.server.nio.SelectChannelConnector) Server(org.eclipse.jetty.server.Server)

Example 12 with SelectChannelConnector

use of org.eclipse.jetty.server.nio.SelectChannelConnector in project hive by apache.

the class HttpServer method createChannelConnector.

/**
   * Create a channel connector for "http/https" requests
   */
Connector createChannelConnector(int queueSize, Builder b) {
    SelectChannelConnector connector;
    if (!b.useSSL) {
        connector = new SelectChannelConnector();
    } else {
        SslContextFactory sslContextFactory = new SslContextFactory();
        sslContextFactory.setKeyStorePath(b.keyStorePath);
        Set<String> excludedSSLProtocols = Sets.newHashSet(Splitter.on(",").trimResults().omitEmptyStrings().split(Strings.nullToEmpty(b.conf.getVar(ConfVars.HIVE_SSL_PROTOCOL_BLACKLIST))));
        sslContextFactory.addExcludeProtocols(excludedSSLProtocols.toArray(new String[excludedSSLProtocols.size()]));
        sslContextFactory.setKeyStorePassword(b.keyStorePassword);
        connector = new SslSelectChannelConnector(sslContextFactory);
    }
    connector.setLowResourcesMaxIdleTime(10000);
    connector.setAcceptQueueSize(queueSize);
    connector.setResolveNames(false);
    connector.setUseDirectBuffers(false);
    connector.setRequestHeaderSize(1024 * 64);
    connector.setReuseAddress(true);
    return connector;
}
Also used : SelectChannelConnector(org.eclipse.jetty.server.nio.SelectChannelConnector) SslSelectChannelConnector(org.eclipse.jetty.server.ssl.SslSelectChannelConnector) SslContextFactory(org.eclipse.jetty.util.ssl.SslContextFactory) SslSelectChannelConnector(org.eclipse.jetty.server.ssl.SslSelectChannelConnector)

Example 13 with SelectChannelConnector

use of org.eclipse.jetty.server.nio.SelectChannelConnector in project lucida by claritylab.

the class OpenEphyraServer method main.

/**
	 * Entry point of Ephyra. Initializes the engine and starts the web service interface.
	 * 
	 * @param args command line arguments are ignored
	 */
public static void main(String[] args) throws Exception {
    // enable output of status and error messages
    MsgPrinter.enableStatusMsgs(true);
    MsgPrinter.enableErrorMsgs(true);
    // set log file and enable logging
    Logger.setLogfile("log/OpenEphyra");
    Logger.enableLogging(true);
    String addr = "localhost";
    int port = 8080;
    if (args.length > 1) {
        addr = args[0];
        port = Integer.parseInt(args[1]);
    }
    int NTHREADS = Integer.parseInt(System.getenv("THREADS"));
    Server server = new Server();
    SelectChannelConnector con1 = new SelectChannelConnector();
    con1.setHost(addr);
    con1.setPort(port);
    con1.setThreadPool(new QueuedThreadPool(NTHREADS));
    con1.setMaxIdleTime(30000);
    con1.setRequestHeaderSize(8192);
    server.setConnectors(new Connector[] { con1 });
    server.setHandler(new OpenEphyraServer());
    server.start();
    server.join();
}
Also used : SelectChannelConnector(org.eclipse.jetty.server.nio.SelectChannelConnector) Server(org.eclipse.jetty.server.Server) QueuedThreadPool(org.eclipse.jetty.util.thread.QueuedThreadPool)

Example 14 with SelectChannelConnector

use of org.eclipse.jetty.server.nio.SelectChannelConnector in project hazelcast by hazelcast.

the class JettyServer method buildJetty.

private void buildJetty(int port, String sourceDir, String webXmlFile) throws Exception {
    server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);
    server.addConnector(connector);
    WebAppContext context = new WebAppContext();
    context.setResourceBase(sourceDir);
    context.setDescriptor(sourceDir + "/WEB-INF/" + webXmlFile);
    context.setLogUrlOnStart(true);
    context.setContextPath("/");
    context.setParentLoaderPriority(true);
    server.setHandler(context);
    server.start();
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) SelectChannelConnector(org.eclipse.jetty.server.nio.SelectChannelConnector) Server(org.eclipse.jetty.server.Server)

Example 15 with SelectChannelConnector

use of org.eclipse.jetty.server.nio.SelectChannelConnector in project jfinal by jfinal.

the class JettyServer method doStart.

private void doStart() {
    if (!available(port)) {
        throw new IllegalStateException("port: " + port + " already in use!");
    }
    deleteSessionData();
    System.out.println("Starting JFinal " + Const.JFINAL_VERSION);
    server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);
    server.addConnector(connector);
    webApp = new WebAppContext();
    // 在启动过程中允许抛出异常终止启动并退出 JVM
    webApp.setThrowUnavailableOnStartupException(true);
    webApp.setContextPath(context);
    // webApp.setWar(webAppDir);
    webApp.setResourceBase(webAppDir);
    webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
    // webApp.setInitParams(Collections.singletonMap("org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false"));
    webApp.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
    persistSession(webApp);
    server.setHandler(webApp);
    changeClassLoader(webApp);
    // configureScanner
    if (scanIntervalSeconds > 0) {
        Scanner scanner = new Scanner(PathKit.getRootClassPath(), scanIntervalSeconds) {

            public void onChange() {
                try {
                    System.err.println("\nLoading changes ......");
                    webApp.stop();
                    JFinalClassLoader loader = new JFinalClassLoader(webApp, getClassPath());
                    webApp.setClassLoader(loader);
                    webApp.start();
                    System.err.println("Loading complete.");
                } catch (Exception e) {
                    System.err.println("Error reconfiguring/restarting webapp after change in watched files");
                    LogKit.error(e.getMessage(), e);
                }
            }
        };
        System.out.println("Starting scanner at interval of " + scanIntervalSeconds + " seconds.");
        scanner.start();
    }
    try {
        System.out.println("Starting web server on port: " + port);
        server.start();
        System.out.println("Starting Complete. Welcome To The JFinal World :)");
        server.join();
    } catch (Exception e) {
        LogKit.error(e.getMessage(), e);
        System.exit(100);
    }
    return;
}
Also used : WebAppContext(org.eclipse.jetty.webapp.WebAppContext) SelectChannelConnector(org.eclipse.jetty.server.nio.SelectChannelConnector) Server(org.eclipse.jetty.server.Server) IOException(java.io.IOException)

Aggregations

SelectChannelConnector (org.eclipse.jetty.server.nio.SelectChannelConnector)19 Server (org.eclipse.jetty.server.Server)14 Connector (org.eclipse.jetty.server.Connector)8 ServletContextHandler (org.eclipse.jetty.servlet.ServletContextHandler)7 ServletHolder (org.eclipse.jetty.servlet.ServletHolder)6 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)5 IOException (java.io.IOException)4 SslSelectChannelConnector (org.eclipse.jetty.server.ssl.SslSelectChannelConnector)4 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 HandlerCollection (org.eclipse.jetty.server.handler.HandlerCollection)3 QueuedThreadPool (org.eclipse.jetty.util.thread.QueuedThreadPool)3 UnknownHostException (java.net.UnknownHostException)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 ResourceHandler (org.eclipse.jetty.server.handler.ResourceHandler)2 ServiceBindException (co.cask.cdap.common.ServiceBindException)1 ResolvingDiscoverable (co.cask.cdap.common.discovery.ResolvingDiscoverable)1 AgentException (com.axway.ats.agentapp.standalone.exceptions.AgentException)1 Injector (com.google.inject.Injector)1 GuiceServletContextListener (com.google.inject.servlet.GuiceServletContextListener)1