Search in sources :

Example 16 with ThreadPool

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);
            }
        }
    }
}
Also used : ThreadPools(com.sun.enterprise.config.serverbeans.ThreadPools) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ThreadPool(org.glassfish.grizzly.config.dom.ThreadPool) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig) NetworkListeners(org.glassfish.grizzly.config.dom.NetworkListeners)

Aggregations

ThreadPool (org.glassfish.grizzly.config.dom.ThreadPool)16 ActionReport (org.glassfish.api.ActionReport)6 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)6 PropertyVetoException (java.beans.PropertyVetoException)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)5 Config (com.sun.enterprise.config.serverbeans.Config)3 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)3 ThreadPools (com.sun.enterprise.config.serverbeans.ThreadPools)2 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)2 UnknownHostException (java.net.UnknownHostException)2 Http (org.glassfish.grizzly.config.dom.Http)2 NetworkListeners (org.glassfish.grizzly.config.dom.NetworkListeners)2 Protocol (org.glassfish.grizzly.config.dom.Protocol)2 Ssl (org.glassfish.grizzly.config.dom.Ssl)2 Transport (org.glassfish.grizzly.config.dom.Transport)2 Test (org.junit.Test)2 AdminService (com.sun.enterprise.config.serverbeans.AdminService)1 HttpService (com.sun.enterprise.config.serverbeans.HttpService)1 MonitoringService (com.sun.enterprise.config.serverbeans.MonitoringService)1 ServerRef (com.sun.enterprise.config.serverbeans.ServerRef)1