Search in sources :

Example 1 with ThreadPools

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

Example 2 with 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);
}
Also used : ThreadPools(com.sun.enterprise.config.serverbeans.ThreadPools) SingleConfigCode(org.jvnet.hk2.config.SingleConfigCode) JavaConfig(com.sun.enterprise.config.serverbeans.JavaConfig) Config(com.sun.enterprise.config.serverbeans.Config) NetworkConfig(org.glassfish.grizzly.config.dom.NetworkConfig)

Example 3 with ThreadPools

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

ThreadPools (com.sun.enterprise.config.serverbeans.ThreadPools)3 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)2 ThreadPool (org.glassfish.grizzly.config.dom.ThreadPool)2 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)2 Config (com.sun.enterprise.config.serverbeans.Config)1 JavaConfig (com.sun.enterprise.config.serverbeans.JavaConfig)1 PropertyVetoException (java.beans.PropertyVetoException)1 NetworkListeners (org.glassfish.grizzly.config.dom.NetworkListeners)1 SingleConfigCode (org.jvnet.hk2.config.SingleConfigCode)1