Search in sources :

Example 1 with ThreadPoolFactory

use of com.sun.corba.ee.spi.threadpool.ThreadPoolFactory in project Payara by payara.

the class S1ASThreadPoolManager method createThreadPools.

private static void createThreadPools(org.glassfish.grizzly.config.dom.ThreadPool threadpoolBean, int index) {
    String threadpoolId = null;
    // , numberOfQueuesValue;
    String minThreadsValue, maxThreadsValue, timeoutValue;
    int minThreads = DEFAULT_MIN_THREAD_COUNT;
    int maxThreads = DEFAULT_MAX_THREAD_COUNT;
    int idleTimeoutInSeconds = 120000;
    try {
        threadpoolId = threadpoolBean.getName();
    } catch (NullPointerException npe) {
        if (_logger.isLoggable(Level.WARNING)) {
            _logger.log(Level.WARNING, "ThreadPoolBean may be null ", npe);
        }
    }
    try {
        minThreadsValue = threadpoolBean.getMinThreadPoolSize();
        minThreads = Integer.parseInt(minThreadsValue);
    } catch (NullPointerException npe) {
        if (_logger.isLoggable(Level.WARNING)) {
            _logger.log(Level.WARNING, "ThreadPoolBean may be null ", npe);
            _logger.log(Level.WARNING, "Using default value for steady-threadpool-size = " + minThreads);
        }
    } catch (NumberFormatException nfe) {
        if (_logger.isLoggable(Level.WARNING)) {
            _logger.log(Level.WARNING, "enterprise_util.excep_orbmgr_numfmt", nfe);
            _logger.log(Level.WARNING, "Using default value for min-threadpool-size = " + minThreads);
        }
    }
    try {
        maxThreadsValue = threadpoolBean.getMaxThreadPoolSize();
        maxThreads = Integer.parseInt(maxThreadsValue);
    } catch (NullPointerException npe) {
        if (_logger.isLoggable(Level.WARNING)) {
            _logger.log(Level.WARNING, "ThreadPoolBean may be null ", npe);
            _logger.log(Level.WARNING, "Using default value for max-threadpool-size = " + maxThreads);
        }
    } catch (NumberFormatException nfe) {
        if (_logger.isLoggable(Level.WARNING)) {
            _logger.log(Level.WARNING, "enterprise_util.excep_orbmgr_numfmt", nfe);
            _logger.log(Level.WARNING, "Using default value for max-threadpool-size = " + maxThreads);
        }
    }
    try {
        timeoutValue = threadpoolBean.getIdleThreadTimeoutSeconds();
        idleTimeoutInSeconds = Integer.parseInt(timeoutValue);
    } catch (NullPointerException npe) {
        if (_logger.isLoggable(Level.WARNING)) {
            _logger.log(Level.WARNING, "ThreadPoolBean may be null ", npe);
            _logger.log(Level.WARNING, "Using default value for idle-thread-timeout-in-seconds = " + idleTimeoutInSeconds);
        }
    } catch (NumberFormatException nfe) {
        if (_logger.isLoggable(Level.WARNING)) {
            _logger.log(Level.WARNING, "enterprise_util.excep_orbmgr_numfmt", nfe);
            _logger.log(Level.WARNING, "Using default value for idle-thread-timeout-in-seconds = " + idleTimeoutInSeconds);
        }
    }
    // Currently this value is not used but when multi-queue threadpools are
    // implemented this could be used to decide which one to instantiate and
    // number of queues in the multi-queue threadpool
    /*
        try {
            numberOfQueuesValue = threadpoolBean.getNumWorkQueues();
            numberOfQueues = Integer.parseInt(numberOfQueuesValue);
        } catch (NullPointerException npe) {
            if (_logger.isLoggable(Level.WARNING)) {
                _logger.log(Level.WARNING, "ThreadPoolBean may be null ", npe);
                _logger.log(Level.WARNING,
                        "Using default value for num-work-queues = " +
                                numberOfQueues);
            }
        } catch (NumberFormatException nfe) {
            if (_logger.isLoggable(Level.WARNING)) {
                _logger.log(Level.WARNING, "enterprise_util.excep_orbmgr_numfmt", nfe);
                _logger.log(Level.WARNING,
                        "Using default value for num-work-queues = " +
                                numberOfQueues);
            }
        }
*/
    // Mutiplied the idleTimeoutInSeconds by 1000 to convert to milliseconds
    ThreadPoolFactory threadPoolFactory = new ThreadPoolFactory();
    ThreadPool threadpool = threadPoolFactory.create(minThreads, maxThreads, idleTimeoutInSeconds * 1000L, threadpoolId, _iiopUtils.getCommonClassLoader());
    // Add the threadpool instance to the threadpoolList
    threadpoolList.add(threadpool);
    // Associate the threadpoolId to the index passed
    idToIndexTable.put(threadpoolId, Integer.valueOf(index));
    // Associate the threadpoolId to the index passed
    indexToIdTable.put(Integer.valueOf(index), threadpoolId);
}
Also used : ThreadPool(com.sun.corba.ee.spi.threadpool.ThreadPool) ThreadPoolFactory(com.sun.corba.ee.spi.threadpool.ThreadPoolFactory)

Aggregations

ThreadPool (com.sun.corba.ee.spi.threadpool.ThreadPool)1 ThreadPoolFactory (com.sun.corba.ee.spi.threadpool.ThreadPoolFactory)1