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


Java QueuedThreadPool.setMinThreads方法代碼示例

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


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

示例1: startInJvmProxy

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
/**
 * To test that the CF client is able to go through a proxy, we point the CC client to a broken url that can only be resolved by going
 * through an inJVM proxy which rewrites the URI. This method starts this inJvm proxy.
 *
 * @throws Exception
 */
private static void startInJvmProxy() throws Exception {
    inJvmProxyPort = getNextAvailablePort(8080);
    inJvmProxyServer = new Server(new InetSocketAddress("127.0.0.1", inJvmProxyPort)); // forcing use of loopback
    // that will be used both for Httpclient proxy and SocketDestHelper
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMinThreads(1);
    inJvmProxyServer.setThreadPool(threadPool);

    HandlerCollection handlers = new HandlerCollection();
    inJvmProxyServer.setHandler(handlers);

    ServletHandler servletHandler = new ServletHandler();
    handlers.addHandler(servletHandler);
    nbInJvmProxyRcvReqs = new AtomicInteger();
    ChainedProxyServlet chainedProxyServlet = new ChainedProxyServlet(httpProxyConfiguration, nbInJvmProxyRcvReqs);
    servletHandler.addServletWithMapping(new ServletHolder(chainedProxyServlet), "/*");

    // Setup proxy handler to handle CONNECT methods
    ConnectHandler proxyHandler;
    proxyHandler = new ChainedProxyConnectHandler(httpProxyConfiguration, nbInJvmProxyRcvReqs);
    handlers.addHandler(proxyHandler);

    inJvmProxyServer.start();
}
 
開發者ID:SAP,項目名稱:cf-java-client-sap,代碼行數:31,代碼來源:CloudFoundryClientTest.java

示例2: 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

示例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: startInJvmProxy

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
/**
 * To test that the CF client is able to go through a proxy, we point the CC client to a broken url
 * that can only be resolved by going through an inJVM proxy which rewrites the URI.
 * This method starts this inJvm proxy.
 * @throws Exception
 */
private static void startInJvmProxy() throws Exception {
	inJvmProxyPort = getNextAvailablePort(8080);
	inJvmProxyServer = new Server(new InetSocketAddress("127.0.0.1", inJvmProxyPort)); //forcing use of loopback that will be used both for Httpclient proxy and SocketDestHelper
	QueuedThreadPool threadPool = new QueuedThreadPool();
	threadPool.setMinThreads(1);
	inJvmProxyServer.setThreadPool(threadPool);

	HandlerCollection handlers = new HandlerCollection();
	inJvmProxyServer.setHandler(handlers);

	ServletHandler servletHandler = new ServletHandler();
	handlers.addHandler(servletHandler);
	nbInJvmProxyRcvReqs = new AtomicInteger();
	//		ChainedProxyServlet chainedProxyServlet = new ChainedProxyServlet(httpProxyConfiguration, nbInJvmProxyRcvReqs);
	//		servletHandler.addServletWithMapping(new ServletHolder(chainedProxyServlet), "/*");

	// Setup proxy handler to handle CONNECT methods
	ConnectHandler proxyHandler;
	//		proxyHandler = new ChainedProxyConnectHandler(httpProxyConfiguration, nbInJvmProxyRcvReqs);
	//		handlers.addHandler(proxyHandler);

	inJvmProxyServer.start();
}
 
開發者ID:stephen-kruger,項目名稱:cloudfoundry-liteclient-lib,代碼行數:30,代碼來源:CloudFoundryClientTest.java

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: configureServerPerformance

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private Server configureServerPerformance(ServerConfig config) {
    // Using thread pool for benchmark - this is not necessarily needed in ordinary setups
    // Normal use is just: 
    // Server server = new Server(PORT);
    QueuedThreadPool pool = new QueuedThreadPool();
    pool.setDetailedDump(false);
    
    
    switch(config.serverPerformance()) {
        case HIGHEST:
            pool.setMaxThreads(Runtime.getRuntime().availableProcessors() * 8);
            pool.setMinThreads(Runtime.getRuntime().availableProcessors() * 8);
            break;
        case HIGH:
            pool.setMaxThreads(Runtime.getRuntime().availableProcessors() * 2);
            pool.setMinThreads(Math.min(Runtime.getRuntime().availableProcessors(), 4));
            break;
        case MEDIUM:
            pool.setMaxThreads(Math.min(Runtime.getRuntime().availableProcessors(), 4));
            pool.setMinThreads(4);
            break;
        case LOW:
            pool.setMaxThreads(4);// A minimum of 4 threads are needed for Jetty to run
            pool.setMinThreads(4);
            break;
        case CUSTOM:
            pool.setMaxThreads(config.ioThreads());
            pool.setMinThreads(config.ioThreads());
            break;
    }
    
    Server server = new Server(pool);
    ServerConnector connector = new ServerConnector(server);
    connector.setAcceptQueueSize(config.backlog());
    connector.setPort(config.port());
    server.setConnectors(new ServerConnector[] {connector});
    
    return server;
}
 
開發者ID:MTDdk,項目名稱:jawn,代碼行數:40,代碼來源:JettyServer.java

示例10: JettyHttpServer

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

示例11: CastServer

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
@Inject
public CastServer(
        LocalHandler mLocalHandler,
        ProxyHandler mProxyHandler,
        ArtHandler mArtHandler,
        RootHandler mRootHandler,
        WifiManager mWifiManager
) {
    super(SERVER_PORT);
    ContextHandler localContext = new ContextHandler("/track/local");
    localContext.setHandler(mLocalHandler);
    ContextHandler proxyContext = new ContextHandler("/track/proxy");
    proxyContext.setHandler(mProxyHandler);
    ContextHandler artContext = new ContextHandler("/artwork");
    artContext.setHandler(mArtHandler);
    ContextHandlerCollection handlerCollection = new ContextHandlerCollection();
    handlerCollection.setHandlers(new Handler[]{
            localContext,
            proxyContext,
            artContext,
            mRootHandler,
    });
    setHandler(handlerCollection);
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMinThreads(2);
    threadPool.setMaxThreads(16);
    threadPool.setMaxIdleTimeMs(3 * 60000);
    setThreadPool(threadPool);
    mWifiLock = mWifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL_HIGH_PERF, "CastServer");
}
 
開發者ID:OpenSilk,項目名稱:Orpheus,代碼行數:31,代碼來源:CastServer.java

示例12: createQueuedThreadPool

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
/**
 * 創建QueuedThreadPool
 * 
 * @return QueuedThreadPool
 */
public static QueuedThreadPool createQueuedThreadPool() {
	QueuedThreadPool threadPool = new QueuedThreadPool();

	threadPool.setMinThreads(setting.getInt("min", "threads", 100));
	threadPool.setMaxThreads(setting.getInt("max", "threads", 500));

	return threadPool;
}
 
開發者ID:looly,項目名稱:hulu,代碼行數:14,代碼來源:JettySetting.java

示例13: threadPool

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private ThreadPool threadPool() {
  QueuedThreadPool pool = new QueuedThreadPool();
  pool.setName("HTTP");
  pool.setMinThreads(2);
  pool.setMaxThreads(10);
  pool.setMaxQueued(50);
  return pool;
}
 
開發者ID:afrojer,項目名稱:gitiles,代碼行數:9,代碼來源:DevServer.java

示例14: createThreadPool

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
/**
 * Creates a Jetty thread pool.
 * 
 * @return A Jetty thread pool.
 */
private ThreadPool createThreadPool()
{
	final QueuedThreadPool threadPool = new QueuedThreadPool();
	threadPool.setMinThreads( getThreadPoolMinThreads() );
	threadPool.setMaxThreads( getThreadPoolMaxThreads() );
	threadPool.setThreadsPriority( getThreadPoolThreadsPriority() );
	threadPool.setIdleTimeout( getThreadPoolIdleTimeout() );
	threadPool.setStopTimeout( getThreadPoolStopTimeout() );
	// threadPool.setDaemon( daemon );
	// threadPool.setDetailedDump( detailedDump );
	return threadPool;
}
 
開發者ID:tliron,項目名稱:restlet-jetty9,代碼行數:18,代碼來源:JettyServerHelper.java

示例15: createThreadPool

import org.eclipse.jetty.util.thread.QueuedThreadPool; //導入方法依賴的package包/類
private ThreadPool createThreadPool() {
    QueuedThreadPool pool = new QueuedThreadPool(50);
    pool.setMinThreads(8);
    return pool;
}
 
開發者ID:kawasima,項目名稱:enkan,代碼行數:6,代碼來源:JettyAdapter.java


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