FileDocCategorySizeDatePackage
JVMThreadStatsImpl.javaAPI DocGlassfish v2 API9129Fri May 04 22:24:20 BST 2007com.sun.enterprise.admin.monitor.stats.spi

JVMThreadStatsImpl

public class JVMThreadStatsImpl extends Object implements com.sun.enterprise.admin.monitor.stats.JVMThreadStats

Fields Summary
private com.sun.enterprise.admin.monitor.stats.GenericStatsImpl
baseStatsImpl
private static final String
STATS_INTERFACE_NAME
private ThreadMXBean
bean
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
curThreadCpuTime
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
daemonThreadCount
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
peakThreadCount
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
threadCount
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
totalStartedThreadCount
final long
initTime
static String
DELIMITER
private static final com.sun.enterprise.util.i18n.StringManager
localStrMgr
Constructors Summary
public JVMThreadStatsImpl()
Creates a new instance of JVMThreadStatsImpl


           
      
        initTime = System.currentTimeMillis ();
        try {
            baseStatsImpl = new GenericStatsImpl(STATS_INTERFACE_NAME, this);
        } catch(Exception e) {
            
        }
        
        bean = ManagementFactory.getThreadMXBean();
        // initialize all the MutableStatistic Classes
        initializeStatistics();
    
Methods Summary
public com.sun.enterprise.admin.monitor.stats.StringStatisticgetAllThreadIds()

        long[] ids = bean.getAllThreadIds();
        String idString = new String();
        for(int i = 0; i < ids.length; i++)
        {
            idString = idString.concat(String.valueOf(ids[i]));
            idString = idString.concat(DELIMITER);
        }

        return new StringStatisticImpl(idString, 
                   localStrMgr.getString("monitor.stats.live_threads"), 
                   localStrMgr.getString("monitor.stats.string_units"), 
                   localStrMgr.getString("monitor.stats.live_threads_desc"), 
                   initTime,
                   System.currentTimeMillis()); 
    
public javax.management.j2ee.statistics.CountStatisticgetCurrentThreadCPUTime()

        
        curThreadCpuTime.setCount(bean.getCurrentThreadCpuTime());
        return (CountStatistic) curThreadCpuTime.unmodifiableView ();
    
public javax.management.j2ee.statistics.CountStatisticgetDaemonThreadCount()

        daemonThreadCount.setCount(bean.getDaemonThreadCount());
        return (CountStatistic) daemonThreadCount.unmodifiableView();
    
public com.sun.enterprise.admin.monitor.stats.StringStatisticgetMonitorDeadlockedThreads()

        long[] ids = bean.findMonitorDeadlockedThreads();
        String idString = new String();
        if(ids != null) {
            for(int i = 0; i < ids.length; i++) {
                idString = idString.concat(String.valueOf(ids[i]));
                idString = idString.concat(DELIMITER);
            }
        }
        if((ids == null) || (ids.length == 0)) {
            idString = idString.concat(
                localStrMgr.getString("monitor.stats.no_thread_deadlock"));
        }
        return new StringStatisticImpl(idString, 
                   localStrMgr.getString("monitor.stats.dlocked_threads"), 
                   localStrMgr.getString("monitor.stats.string_units"), 
                   localStrMgr.getString("monitor.stats.dlocked_threads_desc"), 
                   initTime,
                   System.currentTimeMillis()); 

    
public javax.management.j2ee.statistics.CountStatisticgetPeakThreadCount()

        peakThreadCount.setCount(bean.getPeakThreadCount());
        return (CountStatistic) peakThreadCount.unmodifiableView();
    
public javax.management.j2ee.statistics.StatisticgetStatistic(java.lang.String str)
queries for a Statistic by name.

return
Statistic

        return baseStatsImpl.getStatistic(str);
    
public java.lang.String[]getStatisticNames()
returns an array of names of all the Statistics, that can be retrieved from this implementation of Stats

return
String[]

        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();
    
public javax.management.j2ee.statistics.CountStatisticgetThreadCount()

        threadCount.setCount(bean.getThreadCount());
        return (CountStatistic) threadCount.unmodifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetTotalStartedThreadCount()

        totalStartedThreadCount.setCount(bean.getTotalStartedThreadCount());
        return (CountStatistic) totalStartedThreadCount.unmodifiableView();
    
private voidinitializeStatistics()

        
        // Initialize the MutableCountStatistic for CurrentThreadCpuTime
        CountStatistic c = new CountStatisticImpl( 
                localStrMgr.getString("thread_cpu_time"),
                localStrMgr.getString("monitor.stats.nano_sec_units"),
                localStrMgr.getString("thread_cpu_time_desc"));
        curThreadCpuTime = new MutableCountStatisticImpl(c);

        // Initialize the MutableCountStatistic for DaemonThreadCount
        c= new CountStatisticImpl(
            localStrMgr.getString("monitor.stats.daemon_thread_count"),
            StatisticImpl.DEFAULT_UNIT,
            localStrMgr.getString("monitor.stats.daemon_thread_count_desc"));
        daemonThreadCount = new MutableCountStatisticImpl(c);

        // Initialize the MutableCountStatistic for PeakThreadCount
        c = new CountStatisticImpl(
            localStrMgr.getString("monitor.stats.peak_thread_count"),
            StatisticImpl.DEFAULT_UNIT,
            localStrMgr.getString("monitor.stats.peak_thread_count_desc"));
        peakThreadCount = new MutableCountStatisticImpl(c);
        
        // Initialize the MutableCountStatistic for ThreadCount
        c = new CountStatisticImpl(
                localStrMgr.getString("monitor.stats.thread_count"),
                StatisticImpl.DEFAULT_UNIT,
                localStrMgr.getString("monitor.stats.thread_count_desc"));
        threadCount = new MutableCountStatisticImpl(c);
        
        // Initialize the MutableCountStatistic for TotalStartedThreadCount
        c = new CountStatisticImpl(
            localStrMgr.getString("monitor.stats.started_thread_count"),
            StatisticImpl.DEFAULT_UNIT,
            localStrMgr.getString("monitor.stats.started_thread_count_desc"));
        totalStartedThreadCount = new MutableCountStatisticImpl(c);