當前位置: 首頁>>代碼示例>>Java>>正文


Java QueuedThreadPool.setMaxThreads方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.util.thread.QueuedThreadPool.setMaxThreads方法的典型用法代碼示例。如果您正苦於以下問題:Java QueuedThreadPool.setMaxThreads方法的具體用法?Java QueuedThreadPool.setMaxThreads怎麽用?Java QueuedThreadPool.setMaxThreads使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.util.thread.QueuedThreadPool的用法示例。


在下文中一共展示了QueuedThreadPool.setMaxThreads方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createThreadPool

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
/**
 * Creates a new thread pool for the server and hooks it's properties to the configuration events
 *
 * @return a new thread pool
 */
private static QueuedThreadPool createThreadPool() {

    final QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMinThreads(Configuration.getInteger("jetty.threads.min", 10));
    threadPool.setMaxThreads(Configuration.getInteger("jetty.threads.max", 80));
    Configuration.addListener(ConfigChangeListener.forConfigProperty("jetty.threads.min", (k, v) -> {
        threadPool.setMinThreads(Integer.parseInt(v));
        restartThreadPool(threadPool);
        LOG.info("Successfully resized threadpool " + k + "=" + v);
    }));
    Configuration.addListener(ConfigChangeListener.forConfigProperty("jetty.threads.max", (k, v) -> {
        threadPool.setMaxThreads(Integer.parseInt(v));
        restartThreadPool(threadPool);
        LOG.info("Successfully resized threadpool " + k + "=" + v);
    }));
    return threadPool;
}
 
開發者ID:gmuecke,項目名稱:boutique-de-jus,代碼行數:23,代碼來源:BoutiqueDeJusWebServer.java

示例2: getDashboardJettyServer

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
/**
 * Creates the Jetty server instance for the admin Dashboard and configures it with the @Named("DashboardContext").
 * @param port where the service is available
 * @param acceptorThreads no. of acceptors
 * @param maxWorkerThreads max no. of worker threads
 * @return Jetty Server instance
 */
@Named("DashboardJettyServer")
@Provides
@Singleton
Server getDashboardJettyServer(@Named("Dashboard.service.port") int port,
		@Named("Dashboard.service.acceptors") int acceptorThreads,
		@Named("Dashboard.service.selectors") int selectorThreads,
		@Named("Dashboard.service.workers") int maxWorkerThreads,
		@Named("DashboardContext") 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;
}
 
開發者ID:flipkart-incubator,項目名稱:flux,代碼行數:26,代碼來源:ContainerModule.java

示例3: setRuntimeParameters

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private void setRuntimeParameters(Server server, Application application) {
	ThreadPool pool = server.getThreadPool();
	if (pool instanceof QueuedThreadPool) {
		QueuedThreadPool qtp = (QueuedThreadPool)pool;
		cn.batchfile.getty.application.ThreadPool config = application.getThreadPool();
		if (config != null && config.getMaxThreads() > 0) {
			qtp.setMaxThreads(config.getMaxThreads());
		}
		if (config != null && config.getMinThreads() > 0) {
			qtp.setMinThreads(config.getMinThreads());
		}
		if (config != null && config.getIdleTimeout() > 0) {
			qtp.setIdleTimeout(config.getIdleTimeout());
		}
	}
}
 
開發者ID:lane-cn,項目名稱:getty,代碼行數:17,代碼來源:ApplicationInstanceManager.java

示例4: assembleJettyServer

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
@Provides
private Server assembleJettyServer(JaxRsServerConfig config,
                                   ServletContextHandler context) {
    final QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMaxThreads(config.maxThreads());

    final Server server = new Server(threadPool);
    server.setHandler(context);

    // Setup JMX
    //MBeanContainer mbContainer=new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
    //server.addBean(mbContainer);

    setupConnectors(config, server);
    return server;
}
 
開發者ID:benhardy,項目名稱:lilrest,代碼行數:17,代碼來源:JaxRsServerModule.java

示例5: createServer

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private Server createServer() {
	final QueuedThreadPool threadPool = new QueuedThreadPool();
	threadPool.setMaxThreads(500);

	final Server server = new Server(threadPool);
	server.addBean(new ScheduledExecutorScheduler());

	final ServerConnector http = createHttpServerConnector(server);
       server.addConnector(http);

	server.setHandler(createServletContextHandler());
	server.setDumpAfterStart(false);
	server.setDumpBeforeStop(false);
	server.setStopAtShutdown(true);

	return server;
}
 
開發者ID:cloudstore,項目名稱:cloudstore,代碼行數:18,代碼來源:LocalServer.java

示例6: createServer

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
protected Server createServer() {
		final QueuedThreadPool threadPool = new QueuedThreadPool();
		threadPool.setMaxThreads(500);

		final Server server = new Server(threadPool);
		server.addBean(new ScheduledExecutorScheduler());

		final HttpConfiguration http_config = createHttpConfigurationForHTTP();

//        ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
//        http.setPort(8080);
//        http.setIdleTimeout(30000);
//        server.addConnector(http);

		server.setHandler(createServletContextHandler());
		server.setDumpAfterStart(false);
		server.setDumpBeforeStop(false);
		server.setStopAtShutdown(true);

		final HttpConfiguration https_config = createHttpConfigurationForHTTPS(http_config);
		server.addConnector(createServerConnectorForHTTPS(server, https_config));

		return server;
	}
 
開發者ID:cloudstore,項目名稱:cloudstore,代碼行數:25,代碼來源:CloudStoreServer.java

示例7: buildConnector

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
@Override
public Connector buildConnector(Server server, InetAddress inetAddress, int port) {
	// create the NIO connector
	SelectChannelConnector connector = new SelectChannelConnector();
	if (inetAddress != null) {
		connector.setHost(inetAddress.getHostAddress());
	}
	connector.setPort(port);

	// turn on statistics
	connector.setStatsOn(true);
	// set whether or not to reuse the addresses
	connector.setReuseAddress(true);

	// configure the thread pool for accepting connections
	QueuedThreadPool threadPool = new QueuedThreadPool();
	threadPool.setMinThreads(WEB_SERVER_MIN_THREADS);
	threadPool.setMaxThreads(WEB_SERVER_MAX_THREADS);
	threadPool.setName("simplejmx-web-server");
	connector.setThreadPool(threadPool);
	connector.setAcceptors(WEB_SERVER_MIN_THREADS);

	return connector;
}
 
開發者ID:j256,項目名稱:simplejmx,代碼行數:25,代碼來源:Jetty8ConnectorFactory.java

示例8: configureThreadPool

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private ThreadPool configureThreadPool(final int port) {
	final QueuedThreadPool threadPool = new QueuedThreadPool(threadPoolCapacity);
	threadPool.setMinThreads(minThreadCount);
	threadPool.setMaxThreads(maxThreadCount);
	threadPool.setName("Jetty thread pool [" + port + "]");
	threadPool.setDetailedDump(true);
	return threadPool;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:9,代碼來源:JettyManager.java

示例9: startServer

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public static void startServer() throws ServletException {
    QueuedThreadPool threadPool = new QueuedThreadPool(10);
    threadPool.setDaemon(true);
    threadPool.setMaxThreads(10);
    Server server = new Server(threadPool);
    server.addBean(new ScheduledExecutorScheduler("JettyScheduler", true), true);
    ServerConnector http = new ServerConnector(server, new HttpConnectionFactory());
    http.setPort(2992);
    server.addConnector(http);

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    context.setBaseResource(Resource.newClassPathResource("/org/lwjglx/debug/static"));
    context.setWelcomeFiles(new String[] { "index.html" });
    server.setHandler(context);

    WebSocketUpgradeFilter wsfilter = WebSocketUpgradeFilter.configureContext(context);
    // wsfilter.getFactory().getPolicy().setIdleTimeout(5000);
    wsfilter.addMapping(new ServletPathSpec("/ws"), new ProfilingConnectionCreator());

    ServletHolder holderDefault = new ServletHolder("default", DefaultServlet.class);
    holderDefault.setInitParameter("dirAllowed", "true");
    context.addServlet(holderDefault, "/");

    try {
        server.start();
    } catch (Exception e) {
        throw new AssertionError("Could not start profiling server", e);
    }
}
 
開發者ID:LWJGLX,項目名稱:debug,代碼行數:31,代碼來源:Profiling.java

示例10: start

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
@Override
public void start() {
    if (isStarted()) {
        return;
    }
    jettyServer = new org.eclipse.jetty.server.Server();
    int port = serverConfig.getPort();
    DispatcherServlet.addHttpHandler(port, new WebServiceHandler());

    int threads = serverConfig.getServerBusinessPoolSize();
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setName("JSF-WS-BZ");
    threadPool.setDaemon(true);
    threadPool.setMaxThreads(threads);
    threadPool.setMinThreads(threads);
    jettyServer.setThreadPool(threadPool);

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setHost(serverConfig.getHost());
    connector.setPort(serverConfig.getPort());
    jettyServer.addConnector(connector);

    ServletHandler servletHandler = new ServletHandler();
    ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
    servletHolder.setInitOrder(2);

    jettyServer.setHandler(servletHandler);

    try {
        jettyServer.start();
    } catch (Exception e) {
        throw new InitErrorException("Failed to start jetty server at port " + port
                + ", cause: " + e.getMessage(), e);
    }
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:36,代碼來源:HttpWsServer.java

示例11: doStart

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
@Override
protected void doStart() throws Exception {
    if (!hasThreadPool()) {
        // if there is no thread pool then create a default thread pool using daemon threads
        QueuedThreadPool qtp = new QueuedThreadPool();
        // 16 max threads is the default in the http client
        qtp.setMaxThreads(16);
        qtp.setDaemon(true);
        // let the thread names indicate they are from the client
        qtp.setName("CamelJettyClient(" + ObjectHelper.getIdentityHashCode(this) + ")");
        setThreadPoolOrExecutor(qtp);
    }
    super.doStart();
}
 
開發者ID:nkasvosve,項目名稱:beyondj,代碼行數:15,代碼來源:CamelHttpClient.java

示例12: startProxy

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
public int startProxy() throws Exception {
  seenByProxy.clear();
  InetAddress address = InetAddress.getLoopbackAddress();
  httpProxyPort = NetworkUtils.getNextAvailablePort(address);

  // Setup Threadpool
  QueuedThreadPool threadPool = new QueuedThreadPool();
  threadPool.setMaxThreads(500);

  server = new Server(threadPool);

  // HTTP Configuration
  HttpConfiguration httpConfig = new HttpConfiguration();
  httpConfig.setSecureScheme("https");
  httpConfig.setSendServerVersion(true);
  httpConfig.setSendDateHeader(false);

  // Handler Structure
  HandlerCollection handlers = new HandlerCollection();
  handlers.setHandlers(new Handler[] {proxyHandler(), new DefaultHandler()});
  server.setHandler(handlers);

  ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
  http.setPort(httpProxyPort);
  server.addConnector(http);
  server.start();

  return httpProxyPort;
}
 
開發者ID:SonarSource,項目名稱:sonar-scanner-maven,代碼行數:30,代碼來源:Proxy.java

示例13: configureThreadPool

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
protected void configureThreadPool(QueuedThreadPool pool) {
    // override QueuedThreadPool defaults
    pool.setMaxThreads(jettyThreadPoolSettings.getMaxThreads());
    pool.setMinThreads(jettyThreadPoolSettings.getMinThreads());
    pool.setIdleTimeout(jettyThreadPoolSettings.getIdleTimeout());
    pool.setDetailedDump(jettyThreadPoolSettings.isDetailedDump());
}
 
開發者ID:fastnsilver,項目名稱:xlator,代碼行數:8,代碼來源:JettyConfig.java

示例14: getAPIJettyServer

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
/**
 * Creates the Jetty server instance for the Flux API endpoint.
 * @param port where the service is available.
 * @return Jetty Server instance
 */
@Named("APIJettyServer")
@Provides
@Singleton
Server getAPIJettyServer(@Named("Api.service.port") int port,
						 @Named("APIResourceConfig")ResourceConfig resourceConfig,
						 @Named("Api.service.acceptors") int acceptorThreads,
						 @Named("Api.service.selectors") int selectorThreads,
						 @Named("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;
}
 
開發者ID:flipkart-incubator,項目名稱:flux,代碼行數:35,代碼來源:ContainerModule.java

示例15: run

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
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(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);
    }
}
 
開發者ID:yahoo,項目名稱:athenz,代碼行數:40,代碼來源:InstanceProviderContainer.java


注:本文中的org.eclipse.jetty.util.thread.QueuedThreadPool.setMaxThreads方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。