use of com.sun.enterprise.config.serverbeans.ThreadPools in project Payara by payara.
the class GrizzlyConfigSchemaMigrator method ensureAdminThreadPool.
private void ensureAdminThreadPool() throws TransactionFailure {
final ThreadPools threadPools = currentConfig.getThreadPools();
boolean adminThreadPoolFound = false;
for (ThreadPool pool : threadPools.getThreadPool()) {
adminThreadPoolFound |= "admin-thread-pool".equals(pool.getName());
}
if (!adminThreadPoolFound) {
ConfigSupport.apply(new SingleConfigCode<ThreadPools>() {
@Override
public Object run(ThreadPools param) throws PropertyVetoException, TransactionFailure {
final ThreadPool pool = param.createChild(ThreadPool.class);
param.getThreadPool().add(pool);
pool.setName("admin-thread-pool");
pool.setMaxThreadPoolSize("50");
pool.setMaxQueueSize("256");
return null;
}
}, threadPools);
}
}
use of com.sun.enterprise.config.serverbeans.ThreadPools in project Payara by payara.
the class GrizzlyConfigSchemaMigrator method createThreadPools.
private ThreadPools createThreadPools() throws TransactionFailure {
return (ThreadPools) ConfigSupport.apply(new SingleConfigCode<Config>() {
public Object run(Config param) throws PropertyVetoException, TransactionFailure {
final ThreadPools threadPools = param.createChild(ThreadPools.class);
param.setThreadPools(threadPools);
return threadPools;
}
}, currentConfig);
}
use of com.sun.enterprise.config.serverbeans.ThreadPools in project Payara by payara.
the class GrizzlyConfigSchemaMigrator method normalizeThreadPools.
private void normalizeThreadPools() throws TransactionFailure {
ThreadPools threadPools = currentConfig.getThreadPools();
if (threadPools == null) {
threadPools = createThreadPools();
} else {
final List<ThreadPool> list = threadPools.getThreadPool();
boolean httpListenerFound = false;
for (ThreadPool pool : list) {
httpListenerFound |= HTTP_THREAD_POOL.equals(pool.getThreadPoolId()) || HTTP_THREAD_POOL.equals(pool.getName());
if (pool.getName() == null) {
ConfigSupport.apply(new SingleConfigCode<ThreadPool>() {
public Object run(ThreadPool param) {
param.setName(param.getThreadPoolId());
param.setThreadPoolId(null);
if (param.getMinThreadPoolSize() == null || Integer.parseInt(param.getMinThreadPoolSize()) < 2) {
param.setMinThreadPoolSize("2");
}
return null;
}
}, pool);
}
}
if (!httpListenerFound) {
ConfigSupport.apply(new SingleConfigCode<ThreadPools>() {
public Object run(ThreadPools param) throws TransactionFailure {
final ThreadPool pool = param.createChild(ThreadPool.class);
pool.setName(HTTP_THREAD_POOL);
param.getThreadPool().add(pool);
return null;
}
}, threadPools);
}
}
final NetworkConfig networkConfig = currentConfig.getNetworkConfig();
if (networkConfig != null) {
final NetworkListeners networkListeners = networkConfig.getNetworkListeners();
if (networkListeners != null) {
if (networkListeners.getThreadPool() != null && !networkListeners.getThreadPool().isEmpty()) {
ConfigSupport.apply(new SingleConfigCode<ThreadPools>() {
public Object run(ThreadPools param) throws TransactionFailure {
migrateThreadPools(param);
return null;
}
}, threadPools);
}
}
}
}
Aggregations