Java Code Examples for org.eclipse.jetty.util.thread.QueuedThreadPool#setMaxThreads()
The following examples show how to use
org.eclipse.jetty.util.thread.QueuedThreadPool#setMaxThreads() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AmforeasJetty.java From amforeas with GNU General Public License v3.0 | 6 votes |
protected void startServer (final AmforeasConfiguration conf) throws Exception { final QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMinThreads(conf.getServerThreadsMin()); threadPool.setMaxThreads(conf.getServerThreadsMax()); final Server server = new Server(threadPool); setupJerseyServlet(conf, server); setupHTTPConnection(conf, server); setupHTTPSConnection(conf, server); server.start(); server.setStopAtShutdown(true); server.join(); }
Example 2
Source File: ExecutionContainerModule.java From flux with Apache License 2.0 | 6 votes |
/** * Creates the Jetty server instance for the admin Dashboard and configures it with the @Named("ExecutionDashboardContext"). * @param port where the service is available * @param acceptorThreads no. of acceptors * @param maxWorkerThreads max no. of worker threads * @return Jetty Server instance */ @Named("ExecutionDashboardJettyServer") @Provides @javax.inject.Singleton Server getExecutionDashboardJettyServer(@Named("ExecutionDashboard.service.port") int port, @Named("ExecutionDashboard.service.acceptors") int acceptorThreads, @Named("ExecutionDashboard.service.selectors") int selectorThreads, @Named("ExecutionDashboard.service.workers") int maxWorkerThreads, @Named("ExecutionDashboardContext") WebAppContext webappContext) { QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMaxThreads(maxWorkerThreads); Server server = new Server(threadPool); ServerConnector http = new ServerConnector(server, acceptorThreads, selectorThreads); http.setPort(port); server.addConnector(http); server.setHandler(webappContext); server.setStopAtShutdown(true); return server; }
Example 3
Source File: ExecutionContainerModule.java From flux with Apache License 2.0 | 5 votes |
/** * Creates the Jetty server instance for the Flux Execution API endpoint. * @return Jetty Server instance */ @Named("ExecutionAPIJettyServer") @Provides @Singleton Server getExecutionAPIJettyServer(@Named("Execution.Node.Api.service.port") int port, @Named("ExecutionAPIResourceConfig")ResourceConfig resourceConfig, @Named("Execution.Node.Api.service.acceptors") int acceptorThreads, @Named("Execution.Node.Api.service.selectors") int selectorThreads, @Named("Execution.Node.Api.service.workers") int maxWorkerThreads, ObjectMapper objectMapper, MetricRegistry metricRegistry) throws URISyntaxException, UnknownHostException { JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); provider.setMapper(objectMapper); resourceConfig.register(provider); QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMaxThreads(maxWorkerThreads); Server server = new Server(threadPool); ServerConnector http = new ServerConnector(server, acceptorThreads, selectorThreads); http.setPort(port); server.addConnector(http); ServletContextHandler context = new ServletContextHandler(server, "/*"); ServletHolder servlet = new ServletHolder(new ServletContainer(resourceConfig)); context.addServlet(servlet, "/*"); final InstrumentedHandler handler = new InstrumentedHandler(metricRegistry); handler.setHandler(context); server.setHandler(handler); server.setStopAtShutdown(true); return server; }
Example 4
Source File: JettyHttpServer.java From dubbox with Apache License 2.0 | 5 votes |
public JettyHttpServer(URL url, final HttpHandler handler) { super(url, handler); DispatcherServlet.addHttpHandler(url.getPort(), handler); int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS); QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setDaemon(true); threadPool.setMaxThreads(threads); threadPool.setMinThreads(threads); server = new Server(threadPool); // HTTP connector ServerConnector connector = new ServerConnector(server); if (!url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) { connector.setHost(url.getHost()); } connector.setPort(url.getPort()); // connector.setIdleTimeout(30000); server.addConnector(connector); ServletHandler servletHandler = new ServletHandler(); ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*"); servletHolder.setInitOrder(2); server.insertHandler(servletHandler); try { server.start(); } catch (Exception e) { throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: " + e.getMessage(), e); } }
Example 5
Source File: HttpServer2.java From lucene-solr with Apache License 2.0 | 4 votes |
/** * Set the min, max number of worker threads (simultaneous connections). */ public void setThreads(int min, int max) { QueuedThreadPool pool = (QueuedThreadPool) webServer.getThreadPool(); pool.setMinThreads(min); pool.setMaxThreads(max); }
Example 6
Source File: StreamingReceiver.java From kylin with Apache License 2.0 | 4 votes |
private ThreadPool createThreadPool(KylinConfig kylinConfig) { QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMinThreads(kylinConfig.getStreamingReceiverHttpMinThreads()); threadPool.setMaxThreads(kylinConfig.getStreamingReceiverHttpMaxThreads()); return threadPool; }
Example 7
Source File: Main.java From dexter with Apache License 2.0 | 4 votes |
private void start() { // Start a Jetty server with some sensible(?) defaults try { Server srv = new Server(); srv.setStopAtShutdown(true); // Allow 5 seconds to complete. // Adjust this to fit with your own webapp needs. // Remove this if you wish to shut down immediately (i.e. kill <pid> // or Ctrl+C). srv.setGracefulShutdown(5000); // Increase thread pool QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMaxThreads(100); srv.setThreadPool(threadPool); // Ensure using the non-blocking connector (NIO) Connector connector = new SelectChannelConnector(); connector.setPort(port); connector.setMaxIdleTime(30000); srv.setConnectors(new Connector[] { connector }); // Get the war-file ProtectionDomain protectionDomain = Main.class .getProtectionDomain(); String warFile = protectionDomain.getCodeSource().getLocation() .toExternalForm(); String currentDir = new File(protectionDomain.getCodeSource() .getLocation().getPath()).getParent(); // Handle signout/signin in BigIP-cluster // Add the warFile (this jar) WebAppContext context = new WebAppContext(warFile, contextPath); context.setServer(srv); resetTempDirectory(context, currentDir); // Add the handlers HandlerList handlers = new HandlerList(); handlers.addHandler(context); handlers.addHandler(new ShutdownHandler(srv, context, secret)); handlers.addHandler(new BigIPNodeHandler(secret)); srv.setHandler(handlers); srv.start(); srv.join(); } catch (Exception e) { e.printStackTrace(); } }
Example 8
Source File: HttpServer2.java From knox with Apache License 2.0 | 4 votes |
public void setThreads(int min, int max) { QueuedThreadPool pool = (QueuedThreadPool) webServer.getThreadPool(); pool.setMinThreads(min); pool.setMaxThreads(max); }
Example 9
Source File: InstanceProviderContainer.java From athenz with Apache License 2.0 | 4 votes |
public void run() { try { QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMaxThreads(16); Server server = new Server(threadPool); ServletContextHandler handler = new ServletContextHandler(); handler.setContextPath(""); ResourceConfig config = new ResourceConfig(InstanceProviderResources.class) .register(JacksonFeature.class) .register(new Binder()); handler.addServlet(new ServletHolder(new ServletContainer(config)), "/*"); server.setHandler(handler); // SSL Context Factory SslContextFactory sslContextFactory = createSSLContextObject(); // SSL HTTP Configuration HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.setSecureScheme("https"); httpConfig.setSecurePort(10043); HttpConfiguration httpsConfig = new HttpConfiguration(httpConfig); httpsConfig.addCustomizer(new SecureRequestCustomizer()); // SSL Connector ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig)); sslConnector.setPort(10043); server.addConnector(sslConnector); server.start(); server.join(); } catch (Exception e) { System.err.println("*** " + e); } }
Example 10
Source File: HttpServer.java From hbase with Apache License 2.0 | 4 votes |
/** * Set the min, max number of worker threads (simultaneous connections). */ public void setThreads(int min, int max) { QueuedThreadPool pool = (QueuedThreadPool) webServer.getThreadPool(); pool.setMinThreads(min); pool.setMaxThreads(max); }
Example 11
Source File: CardFantasyJettyServer.java From CardFantasy with BSD 2-Clause "Simplified" License | 4 votes |
public static void main(String[] args) throws Exception { int port = 7878; if (args.length > 1) { if ("-port".equalsIgnoreCase(args[0])) { try { port = Integer.parseInt(args[1]); } catch (Exception e) { throw new IllegalArgumentException("Invalid port number " + args[1]); } } } QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMaxThreads(128); threadPool.setMinThreads(32); Server server = new Server(threadPool); ServerConnector connector = new ServerConnector(server); connector.setPort(port); server.addConnector(connector); HandlerList handlers = new HandlerList(); handlers.addHandler(new AbstractHandler() { @Override public void handle(String s, Request jettyRequest, HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws IOException, ServletException { servletResponse.setCharacterEncoding("UTF-8"); jettyRequest.setHandled(false); } }); ServletHandler servletHandler = new ServletHandler(); servletHandler.addServletWithMapping(BossGameJettyServlet.class, "/PlayBossMassiveGame"); servletHandler.addServletWithMapping(ArenaGameJettyServlet.class, "/PlayAutoMassiveGame"); servletHandler.addServletWithMapping(MapGameJettyServlet.class, "/PlayMapMassiveGame"); servletHandler.addServletWithMapping(LilithGameJettyServlet.class, "/PlayLilithMassiveGame"); servletHandler.addServletWithMapping(PingJettyServlet.class, "/Ping"); handlers.addHandler(servletHandler); server.setHandler(handlers); server.start(); server.join(); }
Example 12
Source File: EsigateServer.java From esigate with Apache License 2.0 | 4 votes |
/** * Create and start server. * * @throws Exception * when server cannot be started. */ public static void start() throws Exception { MetricRegistry registry = new MetricRegistry(); QueuedThreadPool threadPool = new InstrumentedQueuedThreadPool(registry); threadPool.setName("esigate"); threadPool.setMaxThreads(maxThreads); threadPool.setMinThreads(minThreads); srv = new Server(threadPool); srv.setStopAtShutdown(true); srv.setStopTimeout(5000); // HTTP Configuration HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.setOutputBufferSize(outputBufferSize); httpConfig.setSendServerVersion(false); Timer processTime = registry.timer("processTime"); try (ServerConnector connector = new InstrumentedServerConnector("main", EsigateServer.port, srv, registry, new InstrumentedConnectionFactory(new HttpConnectionFactory(httpConfig), processTime)); ServerConnector controlConnector = new ServerConnector(srv)) { // Main connector connector.setIdleTimeout(EsigateServer.idleTimeout); connector.setSoLingerTime(-1); connector.setName("main"); connector.setAcceptQueueSize(200); // Control connector controlConnector.setHost("127.0.0.1"); controlConnector.setPort(EsigateServer.controlPort); controlConnector.setName("control"); srv.setConnectors(new Connector[] {connector, controlConnector}); // War ProtectionDomain protectionDomain = EsigateServer.class.getProtectionDomain(); String warFile = protectionDomain.getCodeSource().getLocation().toExternalForm(); String currentDir = new File(protectionDomain.getCodeSource().getLocation().getPath()).getParent(); File workDir = resetTempDirectory(currentDir); WebAppContext context = new WebAppContext(warFile, EsigateServer.contextPath); context.setServer(srv); context.setTempDirectory(workDir); if (StringUtils.isNoneEmpty(sessionCookieName)) { context.getSessionHandler().getSessionCookieConfig().setName(sessionCookieName); } // Add extra classpath (allows to add extensions). if (EsigateServer.extraClasspath != null) { context.setExtraClasspath(EsigateServer.extraClasspath); } // Add the handlers HandlerCollection handlers = new HandlerList(); // control handler must be the first one. // Work in progress, currently disabled. handlers.addHandler(new ControlHandler(registry)); InstrumentedHandler ih = new InstrumentedHandler(registry); ih.setName("main"); ih.setHandler(context); handlers.addHandler(ih); srv.setHandler(handlers); srv.start(); srv.join(); } }
Example 13
Source File: ServerDaemon.java From cloudstack with Apache License 2.0 | 4 votes |
@Override public void start() throws Exception { // Thread pool final QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMinThreads(10); threadPool.setMaxThreads(500); // Jetty Server server = new Server(threadPool); // Setup Scheduler server.addBean(new ScheduledExecutorScheduler()); // Setup JMX final MBeanContainer mbeanContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer()); server.addBean(mbeanContainer); // HTTP config final HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.addCustomizer( new ForwardedRequestCustomizer() ); httpConfig.setSecureScheme("https"); httpConfig.setSecurePort(httpsPort); httpConfig.setOutputBufferSize(32768); httpConfig.setRequestHeaderSize(8192); httpConfig.setResponseHeaderSize(8192); httpConfig.setSendServerVersion(false); httpConfig.setSendDateHeader(false); // HTTP Connector createHttpConnector(httpConfig); // Setup handlers Pair<SessionHandler,HandlerCollection> pair = createHandlers(); server.setHandler(pair.second()); // Extra config options server.setStopAtShutdown(true); // HTTPS Connector createHttpsConnector(httpConfig); server.start(); // Must set the session timeout after the server has started pair.first().setMaxInactiveInterval(sessionTimeout * 60); server.join(); }
Example 14
Source File: CenterServerTools.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
public static Server start(CenterServer centerServer) throws Exception { cleanWorkDirectory(); HandlerList handlers = new HandlerList(); File war = new File(Config.dir_store(), x_program_center.class.getSimpleName() + ".war"); File dir = new File(Config.dir_servers_centerServer_work(true), x_program_center.class.getSimpleName()); if (war.exists()) { modified(war, dir); QuickStartWebApp webApp = new QuickStartWebApp(); webApp.setAutoPreconfigure(false); webApp.setDisplayName(x_program_center.class.getSimpleName()); webApp.setContextPath("/" + x_program_center.class.getSimpleName()); webApp.setResourceBase(dir.getAbsolutePath()); webApp.setDescriptor(new File(dir, "WEB-INF/web.xml").getAbsolutePath()); webApp.setExtraClasspath(calculateExtraClassPath(x_program_center.class)); webApp.getInitParams().put("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false"); webApp.getInitParams().put("org.eclipse.jetty.jsp.precompiled", "true"); webApp.getInitParams().put("org.eclipse.jetty.servlet.Default.dirAllowed", "false"); /* stat */ if (centerServer.getStatEnable()) { FilterHolder statFilterHolder = new FilterHolder(new WebStatFilter()); statFilterHolder.setInitParameter("exclusions", centerServer.getStatExclusions()); webApp.addFilter(statFilterHolder, "/*", EnumSet.of(DispatcherType.REQUEST)); ServletHolder statServletHolder = new ServletHolder(StatViewServlet.class); statServletHolder.setInitParameter("sessionStatEnable", "false"); webApp.addServlet(statServletHolder, "/druid/*"); } /* stat end */ handlers.addHandler(webApp); } else { throw new Exception("centerServer war not exist."); } QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMinThreads(CENTERSERVER_THREAD_POOL_SIZE_MIN); threadPool.setMaxThreads(CENTERSERVER_THREAD_POOL_SIZE_MAX); Server server = new Server(threadPool); server.setAttribute("maxFormContentSize", centerServer.getMaxFormContent() * 1024 * 1024); if (centerServer.getSslEnable()) { addHttpsConnector(server, centerServer.getPort()); } else { addHttpConnector(server, centerServer.getPort()); } GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setHandler(handlers); server.setHandler(gzipHandler); server.setDumpAfterStart(false); server.setDumpBeforeStop(false); server.setStopAtShutdown(true); server.start(); Thread.sleep(1000); System.out.println("****************************************"); System.out.println("* center server start completed."); System.out.println("* port: " + centerServer.getPort() + "."); System.out.println("****************************************"); return server; }
Example 15
Source File: WebServerTools.java From o2oa with GNU Affero General Public License v3.0 | 4 votes |
public static Server start(WebServer webServer) throws Exception { /** * 更新x_desktop的center指向 */ updateCenterConfigJson(); /** * 更新 favicon.ico */ updateFavicon(); /** * 创建index.html */ createIndexPage(); QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMinThreads(WEBSERVER_THREAD_POOL_SIZE_MIN); threadPool.setMaxThreads(WEBSERVER_THREAD_POOL_SIZE_MAX); Server server = new Server(threadPool); if (webServer.getSslEnable()) { addHttpsConnector(server, webServer.getPort()); } else { addHttpConnector(server, webServer.getPort()); } WebAppContext context = new WebAppContext(); context.setContextPath("/"); context.setBaseResource(Resource.newResource(new File(Config.base(), "servers/webServer"))); // context.setResourceBase("."); context.setParentLoaderPriority(true); context.setExtractWAR(false); // context.setDefaultsDescriptor(new File(Config.base(), // "commons/webdefault_w.xml").getAbsolutePath()); context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "" + webServer.getDirAllowed()); context.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false"); if (webServer.getCacheControlMaxAge() > 0) { context.setInitParameter("org.eclipse.jetty.servlet.Default.cacheControl", "max-age=" + webServer.getCacheControlMaxAge()); } context.setInitParameter("org.eclipse.jetty.servlet.Default.maxCacheSize", "256000000"); context.setInitParameter("org.eclipse.jetty.servlet.Default.maxCachedFileSize", "200000000"); context.setWelcomeFiles(new String[] { "default.html", "index.html" }); context.setGzipHandler(new GzipHandler()); context.setParentLoaderPriority(true); context.getMimeTypes().addMimeMapping("wcss", "application/json"); /* stat */ if (webServer.getStatEnable()) { FilterHolder statFilterHolder = new FilterHolder(new WebStatFilter()); statFilterHolder.setInitParameter("exclusions", webServer.getStatExclusions()); context.addFilter(statFilterHolder, "/*", EnumSet.of(DispatcherType.REQUEST)); ServletHolder statServletHolder = new ServletHolder(StatViewServlet.class); statServletHolder.setInitParameter("sessionStatEnable", "false"); context.addServlet(statServletHolder, "/druid/*"); } /* stat end */ server.setHandler(context); server.setDumpAfterStart(false); server.setDumpBeforeStop(false); server.setStopAtShutdown(true); server.start(); context.setMimeTypes(Config.mimeTypes()); System.out.println("****************************************"); System.out.println("* web server start completed."); System.out.println("* port: " + webServer.getPort() + "."); System.out.println("****************************************"); return server; }
Example 16
Source File: HttpServer2.java From knox with Apache License 2.0 | 4 votes |
public void setThreads(int min, int max) { QueuedThreadPool pool = (QueuedThreadPool) webServer.getThreadPool(); pool.setMinThreads(min); pool.setMaxThreads(max); }
Example 17
Source File: StreamingReceiver.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
private ThreadPool createThreadPool(KylinConfig kylinConfig) { QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMinThreads(kylinConfig.getStreamingReceiverHttpMinThreads()); threadPool.setMaxThreads(kylinConfig.getStreamingReceiverHttpMaxThreads()); return threadPool; }
Example 18
Source File: WebServer.java From Bats with Apache License 2.0 | 4 votes |
/** * Start the web server including setup. */ public void start() throws Exception { if (!config.getBoolean(ExecConstants.HTTP_ENABLE)) { return; } final boolean authEnabled = config.getBoolean(ExecConstants.USER_AUTHENTICATION_ENABLED); int port = config.getInt(ExecConstants.HTTP_PORT); final boolean portHunt = config.getBoolean(ExecConstants.HTTP_PORT_HUNT); final int acceptors = config.getInt(ExecConstants.HTTP_JETTY_SERVER_ACCEPTORS); final int selectors = config.getInt(ExecConstants.HTTP_JETTY_SERVER_SELECTORS); final int handlers = config.getInt(ExecConstants.HTTP_JETTY_SERVER_HANDLERS); final QueuedThreadPool threadPool = new QueuedThreadPool(2, 2); embeddedJetty = new Server(threadPool); ServletContextHandler webServerContext = createServletContextHandler(authEnabled); //Allow for Other Drillbits to make REST calls FilterHolder filterHolder = new FilterHolder(CrossOriginFilter.class); filterHolder.setInitParameter("allowedOrigins", "*"); //Allowing CORS for metrics only webServerContext.addFilter(filterHolder, STATUS_METRICS_PATH, null); embeddedJetty.setHandler(webServerContext); ServerConnector connector = createConnector(port, acceptors, selectors); threadPool.setMaxThreads(handlers + connector.getAcceptors() + connector.getSelectorManager().getSelectorCount()); embeddedJetty.addConnector(connector); for (int retry = 0; retry < PORT_HUNT_TRIES; retry++) { connector.setPort(port); try { embeddedJetty.start(); return; } catch (IOException e) { if (portHunt) { logger.info("Failed to start on port {}, trying port {}", port, ++port, e); } else { throw e; } } } throw new IOException("Failed to find a port"); }
Example 19
Source File: JettyServerWrapper.java From cougar with Apache License 2.0 | 4 votes |
public void initialiseConnectors() throws Exception { threadPool = new QueuedThreadPool(); threadPool.setMaxThreads(maxThreads); threadPool.setMinThreads(minThreads); threadPool.setName("JettyThread"); jettyServer = new Server(threadPool); jettyServer.setStopAtShutdown(true); MBeanContainer container = new MBeanContainer(mbeanServer); jettyServer.addBean(container); LowResourceMonitor lowResourcesMonitor = new LowResourceMonitor(jettyServer); lowResourcesMonitor.setPeriod(lowResourcesPeriod); lowResourcesMonitor.setLowResourcesIdleTimeout(lowResourcesIdleTime); lowResourcesMonitor.setMonitorThreads(lowResourcesMonitorThreads); lowResourcesMonitor.setMaxConnections(lowResourcesMaxConnections); lowResourcesMonitor.setMaxMemory(lowResourcesMaxMemory); lowResourcesMonitor.setMaxLowResourcesTime(lowResourcesMaxTime); jettyServer.addBean(lowResourcesMonitor); // US24803 - Needed for preventing Hashtable key collision DoS CVE-2012-2739 jettyServer.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", maxFormContentSize); List<Connector> connectors = new ArrayList<Connector>(); if (httpPort != -1) { httpConfiguration = createHttpConfiguration(); setBufferSizes(httpConfiguration); if (httpForwarded) { httpConfiguration.addCustomizer(new ForwardedRequestCustomizer()); } httpConnector = createHttpConnector(jettyServer, httpConfiguration, httpAcceptors, httpSelectors); httpConnector.setPort(httpPort); httpConnector.setReuseAddress(httpReuseAddress); httpConnector.setIdleTimeout(httpMaxIdle); httpConnector.setAcceptQueueSize(httpAcceptQueueSize); httpConnector.addBean(new ConnectorStatistics()); connectors.add(httpConnector); } if (httpsPort != -1) { SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStorePath(httpsKeystore.getFile().getCanonicalPath()); sslContextFactory.setKeyStoreType(httpsKeystoreType); sslContextFactory.setKeyStorePassword(httpsKeyPassword); if (StringUtils.isNotBlank(httpsCertAlias)) { sslContextFactory.setCertAlias(httpsCertAlias); } sslContextFactory.setKeyManagerPassword(httpsKeyPassword); // if you need it then you defo want it sslContextFactory.setWantClientAuth(httpsNeedClientAuth || httpsWantClientAuth); sslContextFactory.setNeedClientAuth(httpsNeedClientAuth); sslContextFactory.setRenegotiationAllowed(httpsAllowRenegotiate); httpsConfiguration = createHttpConfiguration(); setBufferSizes(httpsConfiguration); if (httpsForwarded) { httpsConfiguration.addCustomizer(new ForwardedRequestCustomizer()); } httpsConnector = createHttpsConnector(jettyServer, httpsConfiguration, httpsAcceptors, httpsSelectors, sslContextFactory); httpsConnector.setPort(httpsPort); httpsConnector.setReuseAddress(httpsReuseAddress); httpsConnector.setIdleTimeout(httpsMaxIdle); httpsConnector.setAcceptQueueSize(httpsAcceptQueueSize); httpsConnector.addBean(new ConnectorStatistics()); mbeanServer.registerMBean(getKeystoreCertificateChains(), new ObjectName("CoUGAR.https:name=keyStore")); // truststore is not required if we don't want client auth if (httpsWantClientAuth) { sslContextFactory.setTrustStorePath(httpsTruststore.getFile().getCanonicalPath()); sslContextFactory.setTrustStoreType(httpsTruststoreType); sslContextFactory.setTrustStorePassword(httpsTrustPassword); mbeanServer.registerMBean(getTruststoreCertificateChains(), new ObjectName("CoUGAR.https:name=trustStore")); } connectors.add(httpsConnector); } if (connectors.size() == 0) { throw new IllegalStateException("HTTP transport requires at least one port enabled to function correctly."); } jettyServer.setConnectors(connectors.toArray(new Connector[connectors.size()])); }
Example 20
Source File: JettyFactory.java From kumuluzee with MIT License | 3 votes |
private ThreadPool createThreadPool() { QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMinThreads(serverConfig.getMinThreads()); threadPool.setMaxThreads(serverConfig.getMaxThreads()); log.info("Starting KumuluzEE on Jetty with " + serverConfig.getMinThreads() + " minimum " + "and " + serverConfig.getMaxThreads() + " maximum threads"); return threadPool; }