FileDocCategorySizeDatePackage
PWCThreadPoolStatsImpl.javaAPI DocGlassfish v2 API8684Fri May 04 22:36:08 BST 2007com.sun.enterprise.web.stats

PWCThreadPoolStatsImpl

public final class PWCThreadPoolStatsImpl extends Object implements com.sun.enterprise.admin.monitor.stats.PWCThreadPoolStats
author
Jan Luehe

Fields Summary
private static final Logger
_logger
private com.sun.enterprise.admin.monitor.stats.GenericStatsImpl
baseStatsImpl
private MBeanServer
server
private ObjectName
threadPoolName
private com.sun.enterprise.admin.monitor.stats.StringStatistic
id
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
countThreadsIdle
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
countThreads
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
maxThreads
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
countQueued
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
peakQueued
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
maxQueued
Constructors Summary
public PWCThreadPoolStatsImpl(String domain)

	

       
       
        baseStatsImpl = new GenericStatsImpl(
            com.sun.enterprise.admin.monitor.stats.PWCThreadPoolStats.class,
            this);
        
        // get an instance of the MBeanServer
        ArrayList servers = MBeanServerFactory.findMBeanServer(null);
        if(!servers.isEmpty())
            server = (MBeanServer)servers.get(0);
        else
            server = MBeanServerFactory.createMBeanServer();
        
        String objNameStr = domain + ":type=Selector,*";
        try {
            threadPoolName = new ObjectName(objNameStr);
        } catch (Throwable t) {
            String msg = _logger.getResourceBundle().getString(
                                    "webcontainer.objectNameCreationError");
            msg = MessageFormat.format(msg, new Object[] { objNameStr });
            _logger.log(Level.SEVERE, msg, t);
        }

        // initialize all the MutableStatistic Classes
        initializeStatistics();
    
Methods Summary
public javax.management.j2ee.statistics.CountStatisticgetCountQueued()
Gets the current number of requests waiting for a thread.

return
Number of requests waiting for a thread

        return null;
    
public javax.management.j2ee.statistics.CountStatisticgetCountThreads()
Gets the current number of threads.

return
Current number of threads

        countThreads.setCount(
            StatsUtil.getAggregateStatistic(server, threadPoolName,
                                            "countThreadsStats"));
        return (CountStatistic)countThreads.unmodifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetCountThreadsIdle()
Gets the number of threads that are currently idle.

return
Number of currently idle threads

        countThreadsIdle.setCount(
            StatsUtil.getAggregateStatistic(server, threadPoolName,
                                            "countThreadsIdleStats"));
        return (CountStatistic)countThreadsIdle.unmodifiableView();
    
public com.sun.enterprise.admin.monitor.stats.StringStatisticgetId()
Gets the ID of the thread pool.

return
ID of the thread pool

        return id;
    
public javax.management.j2ee.statistics.CountStatisticgetMaxQueued()
Gets the maximum number of requests that may be queued up

return
Maximum number of requests that may be queued up

        return null;
    
public javax.management.j2ee.statistics.CountStatisticgetMaxThreads()
Gets the maximum number of threads allowed in the thread pool.

return
Maximum number of threads allowed in the thread pool

        maxThreads.setCount(StatsUtil.getAggregateStatistic(server,
                                                            threadPoolName,
                                                            "maxThreadsStats"));
        return (CountStatistic)maxThreads.unmodifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetPeakQueued()
Gets the largest number of requests that were ever queued up simultaneously for the use of a thread since the server was started.

return
Largest number of requests that were ever queued up waiting for a thread

        return null;
    
public javax.management.j2ee.statistics.StatisticgetStatistic(java.lang.String name)
Queries for a statistic with the given name.

name
Name of the statistic to query for
return
Statistic for the given name

        return baseStatsImpl.getStatistic(name);
    
public java.lang.String[]getStatisticNames()
Gets array of all statistic names exposed by this implementation of

return
Array of statistic names

        return baseStatsImpl.getStatisticNames();
    
public javax.management.j2ee.statistics.Statistic[]getStatistics()
This method can be used to retrieve all the Statistics, exposed by this implementation of Stats

return
Statistic[]

        return baseStatsImpl.getStatistics();
    
private voidinitializeStatistics()

        
        long startTime = System.currentTimeMillis();
        id = new StringStatisticImpl("",
                                     "id",
                                     "String",
                                     "ID of the thread pool",
                                     startTime,
                                     startTime);

        CountStatistic c = new CountStatisticImpl("CountThreadsIdle");
        countThreadsIdle = new MutableCountStatisticImpl(c);

        c = new CountStatisticImpl("CountThreads");
        countThreads = new MutableCountStatisticImpl(c);

        c = new CountStatisticImpl("MaxThreads");
        maxThreads = new MutableCountStatisticImpl(c);

        c = new CountStatisticImpl("CountQueued");
        countQueued = new MutableCountStatisticImpl(c);

        c = new CountStatisticImpl("PeakQueued");
        peakQueued = new MutableCountStatisticImpl(c);

        c = new CountStatisticImpl("MaxQueued");
        maxQueued = new MutableCountStatisticImpl(c);