Search in sources :

Example 1 with ThreadPoolStatsProvider

use of com.sun.enterprise.v3.services.impl.monitor.stats.ThreadPoolStatsProvider in project Payara by payara.

the class GrizzlyMonitoring method updateGlobalThreadPoolStatsProvider.

/**
 * Updates the global thread pool stats provider with the most current
 * total values.
 */
public void updateGlobalThreadPoolStatsProvider() {
    final ThreadPoolStatsProvider globalThreadPoolStatsProvider = threadPoolStatsProvidersMap.get("");
    // Exit method if global stats provider not registered
    if (globalThreadPoolStatsProvider == null) {
        return;
    }
    int coreThreadTotal = 0;
    int maxThreadTotal = 0;
    // Calculate the totals for each of the metrics
    for (Map.Entry<String, ThreadPoolStatsProvider> threadPoolStatsProvider : threadPoolStatsProvidersMap.entrySet()) {
        if (!threadPoolStatsProvider.getKey().equals("")) {
            // Get the pool config so we can check the thread pool name
            ThreadPoolConfig threadPoolConfig = (ThreadPoolConfig) threadPoolStatsProvider.getValue().getStatsObject();
            if (threadPoolConfig != null) {
                // Safe to cast from long to int, as the values cannot
                // actually be higher than max int.
                coreThreadTotal += (int) (long) threadPoolStatsProvider.getValue().getCoreThreadsCount().getCount();
                maxThreadTotal += (int) (long) threadPoolStatsProvider.getValue().getMaxThreadsCount().getCount();
            }
        }
    }
    // Now that we've calculated the global core and max values, set them
    globalThreadPoolStatsProvider.setCoreThreadsEvent("", coreThreadTotal);
    globalThreadPoolStatsProvider.setMaxThreadsEvent("", maxThreadTotal);
}
Also used : ThreadPoolStatsProvider(com.sun.enterprise.v3.services.impl.monitor.stats.ThreadPoolStatsProvider) ThreadPoolConfig(org.glassfish.grizzly.threadpool.ThreadPoolConfig) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) PluginPoint(org.glassfish.external.probe.provider.PluginPoint)

Example 2 with ThreadPoolStatsProvider

use of com.sun.enterprise.v3.services.impl.monitor.stats.ThreadPoolStatsProvider in project Payara by payara.

the class GrizzlyMonitoring method registerThreadPoolStatsProvider.

/**
 * Register thread-pool statistics provider for a network listener
 *
 * @param name network listener name
 */
public void registerThreadPoolStatsProvider(String name) {
    ThreadPoolStatsProvider threadPoolStatsProvider = new ThreadPoolStatsProvider(name);
    ThreadPoolStatsProvider oldthreadPoolStatsProvider = threadPoolStatsProvidersMap.put(name, threadPoolStatsProvider);
    if (oldthreadPoolStatsProvider != null) {
        StatsProviderManager.unregister(oldthreadPoolStatsProvider);
    }
    StatsProviderManager.register(CONFIG_ELEMENT, PluginPoint.SERVER, subtreePrefix(name) + "/thread-pool", threadPoolStatsProvider);
}
Also used : ThreadPoolStatsProvider(com.sun.enterprise.v3.services.impl.monitor.stats.ThreadPoolStatsProvider)

Example 3 with ThreadPoolStatsProvider

use of com.sun.enterprise.v3.services.impl.monitor.stats.ThreadPoolStatsProvider in project Payara by payara.

the class GrizzlyMonitoring method registerThreadPoolStatsProviderGlobal.

/**
 * Register server wide thread-pool statistics provider
 */
public void registerThreadPoolStatsProviderGlobal(String name) {
    ThreadPoolStatsProvider threadPoolStatsProvider = new ThreadPoolStatsProviderGlobal(name);
    ThreadPoolStatsProvider oldthreadPoolStatsProvider = threadPoolStatsProvidersMap.put(name, threadPoolStatsProvider);
    if (oldthreadPoolStatsProvider != null) {
        StatsProviderManager.unregister(oldthreadPoolStatsProvider);
    }
    StatsProviderManager.register(CONFIG_ELEMENT, PluginPoint.SERVER, subtreePrefix(name) + "/global-thread-pool-stats", threadPoolStatsProvider);
    updateGlobalThreadPoolStatsProvider();
}
Also used : ThreadPoolStatsProvider(com.sun.enterprise.v3.services.impl.monitor.stats.ThreadPoolStatsProvider) ThreadPoolStatsProviderGlobal(com.sun.enterprise.v3.services.impl.monitor.stats.ThreadPoolStatsProviderGlobal)

Example 4 with ThreadPoolStatsProvider

use of com.sun.enterprise.v3.services.impl.monitor.stats.ThreadPoolStatsProvider in project Payara by payara.

the class GrizzlyMonitoring method unregisterThreadPoolStatsProvider.

/**
 * Unregister thread-pool statistics provider for a network listener
 *
 * @param name network listener name
 */
public void unregisterThreadPoolStatsProvider(String name) {
    final ThreadPoolStatsProvider threadPoolStatsProvider = threadPoolStatsProvidersMap.remove(name);
    if (threadPoolStatsProvider != null) {
        // Unregister it from the global thread pool stats provider
        threadPoolStatsProvider.unregisterThreadPool(name);
        StatsProviderManager.unregister(threadPoolStatsProvider);
        updateGlobalThreadPoolStatsProvider();
    }
}
Also used : ThreadPoolStatsProvider(com.sun.enterprise.v3.services.impl.monitor.stats.ThreadPoolStatsProvider)

Aggregations

ThreadPoolStatsProvider (com.sun.enterprise.v3.services.impl.monitor.stats.ThreadPoolStatsProvider)4 ThreadPoolStatsProviderGlobal (com.sun.enterprise.v3.services.impl.monitor.stats.ThreadPoolStatsProviderGlobal)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 PluginPoint (org.glassfish.external.probe.provider.PluginPoint)1 ThreadPoolConfig (org.glassfish.grizzly.threadpool.ThreadPoolConfig)1