View Javadoc

1   package org.apache.geronimo.jetty;
2   
3   import javax.management.j2ee.statistics.CountStatistic;
4   import javax.management.j2ee.statistics.RangeStatistic;
5   import javax.management.j2ee.statistics.TimeStatistic;
6   
7   import org.apache.geronimo.management.stats.CountStatisticImpl;
8   import org.apache.geronimo.management.stats.RangeStatisticImpl;
9   import org.apache.geronimo.management.stats.StatisticImpl;
10  import org.apache.geronimo.management.stats.StatsImpl;
11  import org.apache.geronimo.management.stats.TimeStatisticImpl;
12  
13  /**
14   * Jetty implementation of the Geronimo stats interface WebContainerStats
15   *
16   * @version $Revision: 1.0$
17   */
18  public class JettyWebContainerStatsImpl extends StatsImpl implements JettyWebContainerStats {
19      private CountStatisticImpl totalConnectionCount;
20      private RangeStatisticImpl openConnectionCount;
21      private RangeStatisticImpl connectionRequestCount;
22      private TimeStatisticImpl connectionDuration;
23      private CountStatisticImpl totalErrorCount;
24      private CountStatisticImpl totalRequestCount;
25      private RangeStatisticImpl activeRequestCount;
26      private TimeStatisticImpl requestDuration;
27      private boolean statsOn=false;
28  
29      public JettyWebContainerStatsImpl() {
30          totalConnectionCount = new CountStatisticImpl("Total Connections", StatisticImpl.UNIT_COUNT,
31                  "The total number of connections since last reset");
32          openConnectionCount = new RangeStatisticImpl("Open Connections", StatisticImpl.UNIT_COUNT,
33                  "The number of connections open at present");
34          connectionRequestCount = new RangeStatisticImpl("Connection Request Count", StatisticImpl.UNIT_COUNT,
35                  "The number of requests handled by a particular connection");
36          connectionDuration = new TimeStatisticImpl("Connection Duration", StatisticImpl.UNIT_TIME_MILLISECOND,
37                  "The legnth of time that individual connections have been open");
38          totalErrorCount = new CountStatisticImpl("Error Count", StatisticImpl.UNIT_COUNT,
39                  "The number of reponses that were errors since statistics gathering started");
40          totalRequestCount = new CountStatisticImpl("Request Count", StatisticImpl.UNIT_COUNT,
41                  "The number of requests that were handled since statistics gathering started");
42          activeRequestCount = new RangeStatisticImpl("Active Request Count", StatisticImpl.UNIT_COUNT,
43                  "The number of requests being processed concurrently");
44          requestDuration = new TimeStatisticImpl("Request Duration", StatisticImpl.UNIT_TIME_MILLISECOND,
45                  "The length of time that it's taken to handle individual requests");
46  
47          addStat("TotalConnectionCount", totalConnectionCount);
48          addStat("OpenConnectionCount", openConnectionCount);
49          addStat("ConnectionRequestCount", connectionRequestCount);
50          addStat("ConnectionDuration", connectionDuration);
51          addStat("TotalErrorCount", totalErrorCount);
52          addStat("TotalRequestCount", totalRequestCount);
53          addStat("ActiveRequestCount", activeRequestCount);
54          addStat("RequestDuration", requestDuration);
55      }
56  
57      public CountStatistic getTotalConnectionCount() {
58          return totalConnectionCount;
59      }
60  
61      public RangeStatistic getOpenConnectionCount() {
62          return openConnectionCount;
63      }
64  
65      public RangeStatistic getConnectionRequestCount() {
66          return connectionRequestCount;
67      }
68  
69      public TimeStatistic getConnectionDuration() {
70          return connectionDuration;
71      }
72  
73      public CountStatistic getTotalErrorCount() {
74          return totalErrorCount;
75      }
76  
77      public CountStatistic getTotalRequestCount() {
78          return totalRequestCount;
79      }
80  
81      public RangeStatistic getActiveRequestCount() {
82          return activeRequestCount;
83      }
84  
85      public TimeStatistic getRequestDuration() {
86          return requestDuration;
87      }
88  
89      public boolean isStatsOn() {
90          return statsOn;
91      }
92  
93      public void setStatsOn(boolean on) {
94          statsOn = on;
95      }
96  
97      public CountStatisticImpl getTotalConnectionCountImpl() {
98          return totalConnectionCount;
99      }
100 
101     public RangeStatisticImpl getOpenConnectionCountImpl() {
102         return openConnectionCount;
103     }
104 
105     public RangeStatisticImpl getConnectionRequestCountImpl() {
106         return connectionRequestCount;
107     }
108 
109     public TimeStatisticImpl getConnectionDurationImpl() {
110         return connectionDuration;
111     }
112 
113     public CountStatisticImpl getTotalErrorCountImpl() {
114         return totalErrorCount;
115     }
116 
117     public CountStatisticImpl getTotalRequestCountImpl() {
118         return totalRequestCount;
119     }
120 
121     public RangeStatisticImpl getActiveRequestCountImpl() {
122         return activeRequestCount;
123     }
124 
125     public TimeStatisticImpl getRequestDurationImpl() {
126         return requestDuration;
127     }
128 }