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

HTTPListenerStatsImpl

public final class HTTPListenerStatsImpl extends Object implements com.sun.enterprise.admin.monitor.stats.HTTPListenerStats
Implementation of the HTTPListenerStats interface All the methods defined in this interface are serviced by querying Tomcat's MBeans for ThreadPool or GlobalRequestProcessor
author
Murali Vempaty
since
S1AS8.0
version
1.0

Fields Summary
private static final Logger
_logger
private com.sun.enterprise.admin.monitor.stats.GenericStatsImpl
baseStatsImpl
private MBeanServer
server
private ObjectName
tpName
private ObjectName
grpName
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
bytesReceived
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
bytesSent
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
errorCount
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
maxTime
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
processingTime
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
requestCount
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
curThreadCount
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
curThreadsBusy
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
maxThreads
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
maxSpareThreads
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
minSpareThreads
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
count2xx
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
count3xx
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
count4xx
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
count5xx
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
countOther
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
count200
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
count302
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
count304
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
count400
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
count401
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
count403
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
count404
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
count503
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
countOpenConnections
private com.sun.enterprise.admin.monitor.stats.MutableCountStatistic
maxOpenConnections
Constructors Summary
public HTTPListenerStatsImpl(String domain, int port)
Creates a new instance of HTTPListenerStatsImpl The ObjectNames of the ThreadPool & GlobalRequestProcessor MBeans follow the pattern: :type=ThreadPool,name=http :type=GlobalRequestProcessor,name=http for example: server:type=ThreadPool,name=http1043

param
domain domain in which Tomcat's MBeans are registered This is usually the name of the virtual-server, to which this listener belongs
param
port port at which the listener is receiving requests

	

                                                                                                          
         

        baseStatsImpl = new GenericStatsImpl(
            com.sun.enterprise.admin.monitor.stats.HTTPListenerStats.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();
        
        // construct the ObjectNames of the GlobalRequestProcessor & 
        // ThreadPool MBeans
        // TODO: use an ObjectNameFactory to construct the ObjectNames
        // of the MBeans, instead of hardcoding
        String objNameStr = domain + ":type=Selector,name=http" + port;
        try {
            tpName = 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);
        }

        objNameStr = domain + ":type=GlobalRequestProcessor"
                + ",name=http" + port;
        try {
            grpName = 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.CountStatisticgetBytesReceived()

        bytesReceived.setCount(getBytesReceivedLong());
        return (CountStatistic)bytesReceived.unmodifiableView();
    
longgetBytesReceivedLong()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "bytesReceived");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetBytesSent()

        bytesSent.setCount(getBytesSentLong());
        return (CountStatistic)bytesSent.unmodifiableView();
    
longgetBytesSentLong()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "bytesSent");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCount200()
Returns the number of responses with a status code equal to 200 sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code equal to 200

        count200.setCount(getCount200Long());
        return (CountStatistic)count200.unmodifiableView();
    
longgetCount200Long()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "count200");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCount2xx()
Returns the number of responses with a status code in the 2xx range sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code in the 2xx range

        count2xx.setCount(getCount2xxLong());
        return (CountStatistic)count2xx.unmodifiableView();
    
longgetCount2xxLong()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "count2xx");
        return StatsUtil.getLongValue(countObj);

    
public javax.management.j2ee.statistics.CountStatisticgetCount302()
Returns the number of responses with a status code equal to 302 sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code equal to 302

        count302.setCount(getCount302Long());
        return (CountStatistic)count302.unmodifiableView();
    
longgetCount302Long()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "count302");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCount304()
Returns the number of responses with a status code equal to 304 sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code equal to 304

        count304.setCount(getCount304Long());
        return (CountStatistic)count304.unmodifiableView();
    
longgetCount304Long()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "count304");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCount3xx()
Returns the number of responses with a status code in the 3xx range sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code in the 3xx range

        count3xx.setCount(getCount3xxLong());
        return (CountStatistic)count3xx.unmodifiableView();
    
longgetCount3xxLong()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "count3xx");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCount400()
Returns the number of responses with a status code equal to 400 sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code equal to 400

        count400.setCount(getCount400Long());
        return (CountStatistic)count400.unmodifiableView();
    
longgetCount400Long()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "count400");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCount401()
Returns the number of responses with a status code equal to 401 sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code equal to 401

        count401.setCount(getCount401Long());
        return (CountStatistic)count401.unmodifiableView();
    
longgetCount401Long()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "count401");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCount403()
Returns the number of responses with a status code equal to 403 sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code equal to 403

        count403.setCount(getCount403Long());
        return (CountStatistic)count403.unmodifiableView();
    
longgetCount403Long()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "count403");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCount404()
Returns the number of responses with a status code equal to 404 sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code equal to 404

        count404.setCount(getCount404Long());
        return (CountStatistic)count404.unmodifiableView();
    
longgetCount404Long()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "count404");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCount4xx()
Returns the number of responses with a status code in the 4xx range sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code in the 4xx range

        count4xx.setCount(getCount4xxLong());
        return (CountStatistic)count4xx.unmodifiableView();
    
longgetCount4xxLong()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "count4xx");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCount503()
Returns the number of responses with a status code equal to 503 sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code equal to 503

        count503.setCount(getCount503Long());
        return (CountStatistic)count503.unmodifiableView();
    
longgetCount503Long()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "count503");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCount5xx()
Returns the number of responses with a status code in the 5xx range sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code in the 5xx range

        count5xx.setCount(getCount5xxLong());
        return (CountStatistic)count5xx.unmodifiableView();
    
longgetCount5xxLong()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "count5xx");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCountOpenConnections()
Returns the number of open connections managed by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of open connections

        countOpenConnections.setCount(getCountOpenConnectionsLong());
        return (CountStatistic)countOpenConnections.unmodifiableView();
    
longgetCountOpenConnectionsLong()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "countOpenConnections");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCountOther()
Returns the number of responses with a status code outside the 2xx, 3xx, 4xx, and 5xx range, sent by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Number of responses with a status code outside the 2xx, 3xx, 4xx, and 5xx range

        countOther.setCount(getCountOtherLong());
        return (CountStatistic)countOther.unmodifiableView();
    
longgetCountOtherLong()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "countOther");
        return StatsUtil.getLongValue(countObj);
    
public javax.management.j2ee.statistics.CountStatisticgetCurrentThreadCount()

        Object countObj = StatsUtil.getStatistic(server, tpName,
                                                 "currentThreadCountStats");
        curThreadCount.setCount(StatsUtil.getLongValue(countObj));
        return (CountStatistic)curThreadCount.unmodifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetCurrentThreadsBusy()

        Object countObj = StatsUtil.getStatistic(server, tpName,
                                                 "currentThreadsBusyStats");
        curThreadsBusy.setCount(StatsUtil.getLongValue(countObj));
        return (CountStatistic)curThreadsBusy.unmodifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetErrorCount()

        Object countObj = StatsUtil.getStatistic(server, grpName, "errorCount");
        errorCount.setCount(StatsUtil.getLongValue(countObj));
        return (CountStatistic)errorCount.unmodifiableView();
    
longgetLastRequestCompletionTime()
Gets the time (in milliseconds since January 1, 1970, 00:00:00) when the last request serviced by the HTTP listener associated with this HTTPListenerStatsImpl was completed.

return
The time when the last request was completed.

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "lastRequestCompletionTime");
        return StatsUtil.getLongValue(countObj);
    
java.lang.StringgetLastRequestMethod()
Gets the HTTP method of the last request serviced by the HTTP listener associated with this HTTPListenerStatsImpl.

return
The HTTP method of the last request serviced

        return (String) StatsUtil.getStatistic(server, grpName,
                                               "lastRequestMethod");
    
java.lang.StringgetLastRequestURI()
Gets the URI of the last request serviced by the HTTP listener associated with this HTTPListenerStatsImpl.

return
The URI of the last request serviced

        return (String) StatsUtil.getStatistic(server, grpName,
                                               "lastRequestURI");
    
public javax.management.j2ee.statistics.CountStatisticgetMaxOpenConnections()
Returns the maximum number of open connections managed by the HTTP listener whose statistics are exposed by this HTTPListenerStats.

return
Maximum number of open connections

        maxOpenConnections.setCount(getMaxOpenConnectionsLong());
        return (CountStatistic)maxOpenConnections.unmodifiableView();
    
longgetMaxOpenConnectionsLong()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "maxOpenConnections");
        return StatsUtil.getLongValue(countObj);

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

        Object countObj = StatsUtil.getStatistic(server, tpName,
                                                 "maxSpareThreadsStats");
        maxSpareThreads.setCount(StatsUtil.getLongValue(countObj));
        return (CountStatistic)maxSpareThreads.unmodifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetMaxThreads()

        Object countObj = StatsUtil.getStatistic(server, tpName,
                                                 "maxThreadsStats");
        maxThreads.setCount(StatsUtil.getLongValue(countObj));
        return (CountStatistic)maxThreads.unmodifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetMaxTime()

        Object countObj = StatsUtil.getStatistic(server, grpName, "maxTime");
        maxTime.setCount(StatsUtil.getLongValue(countObj));
        return (CountStatistic)maxTime.unmodifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetMinSpareThreads()

        Object countObj = StatsUtil.getStatistic(server, tpName,
                                                 "minSpareThreadsStats");
        minSpareThreads.setCount(StatsUtil.getLongValue(countObj));
        return (CountStatistic)minSpareThreads.unmodifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetProcessingTime()

        Object countObj = StatsUtil.getStatistic(server, grpName, "processingTime");
        processingTime.setCount(StatsUtil.getLongValue(countObj));
        return (CountStatistic)processingTime.unmodifiableView();
    
public javax.management.j2ee.statistics.CountStatisticgetRequestCount()

        requestCount.setCount(getRequestCountLong());
        return (CountStatistic)requestCount.unmodifiableView();
    
longgetRequestCountLong()

        Object countObj = StatsUtil.getStatistic(server, grpName,
                                                 "requestCount");
        return StatsUtil.getLongValue(countObj);
    
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();
    
private voidinitializeStatistics()

        
        // Initialize the MutableCountStatistic for BytesReceived
        CountStatistic c = new CountStatisticImpl("BytesReceived");
        bytesReceived = new MutableCountStatisticImpl(c);
        
        // Initialize the MutableCountStatistic for BytesSent
        c = new CountStatisticImpl("BytesSent");
        bytesSent = new MutableCountStatisticImpl(c);

        // Initialize the MutableCountStatistic for ErrorCount
        c = new CountStatisticImpl("ErrorCount");
        errorCount = new MutableCountStatisticImpl(c);
        
        // Initialize the MutableCountStatistic for MaxTime
        c = new CountStatisticImpl("MaxTime", "milliseconds");
        maxTime = new MutableCountStatisticImpl(c);
        
        // Initialize the MutableCountStatistic for ProcessingTime
        c = new CountStatisticImpl("ProcessingTime", "milliseconds");
        processingTime = new MutableCountStatisticImpl(c);
        
        // Initialize the MutableCountStatistic for RequestCount
        c = new CountStatisticImpl("RequestCount");
        requestCount = new MutableCountStatisticImpl(c);

        // Initialize the MutableCountStatistic for CurrentThreadCount
        c = new CountStatisticImpl("CurrentThreadCount");
        curThreadCount = new MutableCountStatisticImpl(c);
        
        // Initialize the MutableCountStatistic for CurrentThreadsBusy
        c = new CountStatisticImpl("CurrentThreadsBusy");
        curThreadsBusy = new MutableCountStatisticImpl(c);

        // Initialize the MutableCountStatistic for MaxThreads
        c = new CountStatisticImpl("MaxThreads");
        maxThreads = new MutableCountStatisticImpl(c);
        
        // Initialize the MutableCountStatistic for MaxSpareThreads
        c = new CountStatisticImpl("MaxSpareThreads");
        maxSpareThreads = new MutableCountStatisticImpl(c);
        
        // Initialize the MutableCountStatistic for MinSpareThreads
        c = new CountStatisticImpl("MinSpareThreads");
        minSpareThreads = new MutableCountStatisticImpl(c);

        // Init Count2xx
        c = new CountStatisticImpl("Count2xx");
        count2xx = new MutableCountStatisticImpl(c);

        // Init Count3xx
        c = new CountStatisticImpl("Count3xx");
        count3xx = new MutableCountStatisticImpl(c);

        // Init Count4xx
        c = new CountStatisticImpl("Count4xx");
        count4xx = new MutableCountStatisticImpl(c);

        // Init Count5xx
        c = new CountStatisticImpl("Count5xx");
        count5xx = new MutableCountStatisticImpl(c);

        // Init CountOther
        c = new CountStatisticImpl("CountOther");
        countOther = new MutableCountStatisticImpl(c);

        // Init Count200
        c = new CountStatisticImpl("Count200");
        count200 = new MutableCountStatisticImpl(c);

        // Init Count302
        c = new CountStatisticImpl("Count302");
        count302 = new MutableCountStatisticImpl(c);

        // Init Count304
        c = new CountStatisticImpl("Count304");
        count304 = new MutableCountStatisticImpl(c);

        // Init Count400
        c = new CountStatisticImpl("Count400");
        count400 = new MutableCountStatisticImpl(c);

        // Init Count401
        c = new CountStatisticImpl("Count401");
        count401 = new MutableCountStatisticImpl(c);

        // Init Count403
        c = new CountStatisticImpl("Count403");
        count403 = new MutableCountStatisticImpl(c);

        // Init Count404
        c = new CountStatisticImpl("Count404");
        count404 = new MutableCountStatisticImpl(c);

        // Init Count503
        c = new CountStatisticImpl("Count503");
        count503 = new MutableCountStatisticImpl(c);

        // Init CountOpenConnections
        c = new CountStatisticImpl("CountOpenConnections");
        countOpenConnections = new MutableCountStatisticImpl(c);

        // Init MaxOpenConnections
        c = new CountStatisticImpl("MaxOpenConnections");
        maxOpenConnections = new MutableCountStatisticImpl(c);