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;
}
Aggregations