FileDocCategorySizeDatePackage
ThreadPoolStatsImpl.javaAPI DocGlassfish v2 API10264Tue May 08 12:31:50 BST 2007com.sun.enterprise.iiop

ThreadPoolStatsImpl

public class ThreadPoolStatsImpl extends ORBCommonStatsImpl implements com.sun.enterprise.admin.monitor.stats.ThreadPoolStats
This is the implementation for the ThreadPoolStats and provides the implementation required to get the statistics for a threadpool
author
Pramod Gopinath

Fields Summary
private com.sun.corba.ee.spi.monitoring.MonitoredObject
threadPool
private com.sun.corba.ee.spi.monitoring.MonitoredObject
workQueue
private String
threadPoolName
private com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl
numberOfBusyThreads
private com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl
numberOfAvailableThreads
private com.sun.enterprise.admin.monitor.stats.MutableBoundedRangeStatisticImpl
currentNumberOfThreads
private com.sun.enterprise.admin.monitor.stats.MutableBoundedRangeStatisticImpl
averageWorkCompletionTime
private com.sun.enterprise.admin.monitor.stats.MutableCountStatisticImpl
totalWorkItemsAdded
private com.sun.enterprise.admin.monitor.stats.MutableBoundedRangeStatisticImpl
numberOfWorkItemsInQueue
private com.sun.enterprise.admin.monitor.stats.MutableBoundedRangeStatisticImpl
averageTimeInQueue
private static final String
stringNumberOfBusyThreads
private static final String
stringNumberOfAvailableThreads
private static final String
stringCurrentNumberOfThreads
private static final String
stringAverageWorkCompletionTime
private static final String
stringTotalWorkItemsAdded
private static final String
stringNumberOfWorkItemsInQueue
private static final String
stringAverageTimeInQueue
Constructors Summary
public ThreadPoolStatsImpl(com.sun.corba.ee.spi.monitoring.MonitoredObject threadPool)



         
        this.threadPool     = threadPool;
        this.threadPoolName = threadPool.getName();

        getWorkQueueForThreadPool();

        initializeStats();
    
Methods Summary
public javax.management.j2ee.statistics.RangeStatisticgetAverageTimeInQueue()

        long avgTimeInQueue = ((Long) workQueue.getAttribute( 
	    stringAverageTimeInQueue ).getValue()).longValue();

        averageTimeInQueue.setCount( avgTimeInQueue );

        return (RangeStatistic) averageTimeInQueue.modifiableView();
    
public javax.management.j2ee.statistics.RangeStatisticgetAverageWorkCompletionTime()

        long avgWorkCompletionTime = ((Long) threadPool.getAttribute( 
	    stringAverageWorkCompletionTime ).getValue()).longValue();

        averageWorkCompletionTime.setCount( avgWorkCompletionTime );

        return (RangeStatistic) averageWorkCompletionTime.modifiableView();
    
public javax.management.j2ee.statistics.BoundedRangeStatisticgetCurrentNumberOfThreads()

        long numCurrentThreads = ((Long) threadPool.getAttribute( 
            stringCurrentNumberOfThreads ).getValue()).longValue();

        currentNumberOfThreads.setCount( numCurrentThreads );

        return (BoundedRangeStatistic) currentNumberOfThreads.modifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetNumberOfAvailableThreads()

        long numAvailableThreads = ((Long) threadPool.getAttribute( 
            stringNumberOfAvailableThreads ).getValue()).longValue();

        numberOfAvailableThreads.setCount( numAvailableThreads ); 

        return (CountStatistic) numberOfAvailableThreads.modifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetNumberOfBusyThreads()

        long numBusyThreads = ((Long) threadPool.getAttribute( 
            stringNumberOfBusyThreads ).getValue()).longValue();

        numberOfBusyThreads.setCount( numBusyThreads );

        return (CountStatistic) numberOfBusyThreads.modifiableView();
    
public javax.management.j2ee.statistics.BoundedRangeStatisticgetNumberOfWorkItemsInQueue()

        long totWorkItemsInQueue = ((Long) workQueue.getAttribute( 
	    stringNumberOfWorkItemsInQueue ).getValue()).longValue();

        numberOfWorkItemsInQueue.setCount( totWorkItemsInQueue );

        return (BoundedRangeStatistic) numberOfWorkItemsInQueue.modifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetTotalWorkItemsAdded()

        long totWorkItemsAdded = ((Long) workQueue.getAttribute( 
	    stringTotalWorkItemsAdded ).getValue()).longValue();


        totalWorkItemsAdded.setCount( totWorkItemsAdded );

        return (CountStatistic) totalWorkItemsAdded.modifiableView();
    
private voidgetWorkQueueForThreadPool()

        Object[] workQueues = threadPool.getChildren().toArray();    
        workQueue = (MonitoredObject) workQueues[ 0 ];
    
private voidinitializeStats()

    	super.initialize("com.sun.enterprise.admin.monitor.stats.ThreadPoolStats");

        final long time = System.currentTimeMillis();

        numberOfBusyThreads = 
            new MutableCountStatisticImpl( 
                new CountStatisticImpl( 0, stringNumberOfBusyThreads, "COUNT", 
                    threadPool.getAttribute( stringNumberOfBusyThreads ).
                    getAttributeInfo().getDescription(),
                    time, time ));

        numberOfAvailableThreads = 
            new MutableCountStatisticImpl( 
                new CountStatisticImpl( 0, stringNumberOfAvailableThreads, "count", 
                    threadPool.getAttribute( stringNumberOfAvailableThreads ).
                    getAttributeInfo().getDescription(), 
                    time, time ));

        currentNumberOfThreads = 
            new MutableBoundedRangeStatisticImpl(
                new BoundedRangeStatisticImpl( 0, 0, 0, java.lang.Long.MAX_VALUE, 0,
                    stringCurrentNumberOfThreads, "count",
                    threadPool.getAttribute( stringCurrentNumberOfThreads ).
                    getAttributeInfo().getDescription(), 
                    time, time ));

        averageWorkCompletionTime = 
            new MutableBoundedRangeStatisticImpl(
                new BoundedRangeStatisticImpl( 0, 0, 0, java.lang.Long.MAX_VALUE, 0,
                    stringAverageWorkCompletionTime, "Milliseconds",
                    threadPool.getAttribute( stringAverageWorkCompletionTime ).
                    getAttributeInfo().getDescription(), 
                    time, time ));

        MonitoredObject workQueue = threadPool.getChild( 
            ORBConstants.WORKQUEUE_DEFAULT_NAME );

        totalWorkItemsAdded = 
            new MutableCountStatisticImpl(
                new CountStatisticImpl( 0, stringTotalWorkItemsAdded, "count",
                    workQueue.getAttribute( stringTotalWorkItemsAdded ).
                    getAttributeInfo().getDescription(), 
                    time, time ));

            numberOfWorkItemsInQueue = 
            new MutableBoundedRangeStatisticImpl(
                new BoundedRangeStatisticImpl( 0, 0,0, java.lang.Long.MAX_VALUE, 0,
                    stringNumberOfWorkItemsInQueue, "count",
                    workQueue.getAttribute( stringNumberOfWorkItemsInQueue ).
                    getAttributeInfo( ).getDescription(), 
                    time, time ));

        averageTimeInQueue = 
            new MutableBoundedRangeStatisticImpl(
                new BoundedRangeStatisticImpl( 0, 0, 0, java.lang.Long.MAX_VALUE, 0,
                    stringAverageTimeInQueue, "Milliseconds",
                    workQueue.getAttribute( stringAverageTimeInQueue ).
                    getAttributeInfo( ).getDescription(), 
                    time, time ));