Search in sources :

Example 6 with ThreadPoolConfig

use of org.glassfish.grizzly.threadpool.ThreadPoolConfig in project Payara by payara.

the class GenericGrizzlyListener method configureThreadPoolConfig.

protected ThreadPoolConfig configureThreadPoolConfig(final NetworkListener networkListener, final ThreadPool threadPool) {
    final int maxQueueSize = threadPool.getMaxQueueSize() == null ? Integer.MAX_VALUE : Integer.parseInt(threadPool.getMaxQueueSize());
    final int minThreads = Integer.parseInt(threadPool.getMinThreadPoolSize());
    final int maxThreads = Integer.parseInt(threadPool.getMaxThreadPoolSize());
    final int timeout = Integer.parseInt(threadPool.getIdleThreadTimeoutSeconds());
    final ThreadPoolConfig poolConfig = ThreadPoolConfig.defaultConfig();
    poolConfig.setPoolName(networkListener.getThreadPool() + "::" + networkListener.getName());
    poolConfig.setCorePoolSize(minThreads);
    poolConfig.setMaxPoolSize(maxThreads);
    poolConfig.setQueueLimit(maxQueueSize);
    // we specify the classloader that loaded this class to ensure
    // we present the same initial classloader no matter what mode
    // GlassFish is being run in.
    // See http://java.net/jira/browse/GLASSFISH-19639
    poolConfig.setInitialClassLoader(this.getClass().getClassLoader());
    poolConfig.setKeepAliveTime(timeout < 0 ? Long.MAX_VALUE : timeout, TimeUnit.SECONDS);
    if (transactionTimeoutMillis > 0 && !Utils.isDebugVM()) {
        poolConfig.setTransactionTimeout(obtainDelayedExecutor(), transactionTimeoutMillis, TimeUnit.MILLISECONDS);
    }
    return poolConfig;
}
Also used : ThreadPoolConfig(org.glassfish.grizzly.threadpool.ThreadPoolConfig)

Aggregations

ThreadPoolConfig (org.glassfish.grizzly.threadpool.ThreadPoolConfig)6 TransportFilter (org.glassfish.grizzly.filterchain.TransportFilter)3 FilterChainBuilder (org.glassfish.grizzly.filterchain.FilterChainBuilder)2 TCPNIOTransportBuilder (org.glassfish.grizzly.nio.transport.TCPNIOTransportBuilder)2 ThreadPoolMonitor (com.sun.enterprise.v3.services.impl.monitor.ThreadPoolMonitor)1 ThreadPoolStatsProvider (com.sun.enterprise.v3.services.impl.monitor.stats.ThreadPoolStatsProvider)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 PluginPoint (org.glassfish.external.probe.provider.PluginPoint)1 ByteBufferManager (org.glassfish.grizzly.memory.ByteBufferManager)1 RoundRobinConnectionDistributor (org.glassfish.grizzly.nio.RoundRobinConnectionDistributor)1 TCPNIOTransport (org.glassfish.grizzly.nio.transport.TCPNIOTransport)1