use of org.glassfish.grizzly.config.dom.ThreadPool 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