001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.management.geronimo.stats;
017:
018: import javax.management.j2ee.statistics.CountStatistic;
019: import javax.management.j2ee.statistics.RangeStatistic;
020: import javax.management.j2ee.statistics.TimeStatistic;
021:
022: import org.apache.geronimo.management.stats.CountStatisticImpl;
023: import org.apache.geronimo.management.stats.RangeStatisticImpl;
024: import org.apache.geronimo.management.stats.StatisticImpl;
025: import org.apache.geronimo.management.stats.StatsImpl;
026: import org.apache.geronimo.management.stats.TimeStatisticImpl;
027:
028: /**
029: * Jetty implementation of the Geronimo stats interface WebContainerStats
030: *
031: * @version $Revision: 1.0$
032: */
033: public class JettyWebContainerStatsImpl extends StatsImpl implements
034: JettyWebContainerStats {
035: private RangeStatisticImpl activeRequestCount;
036: private TimeStatisticImpl requestDuration;
037: private CountStatisticImpl response1xx;
038: private CountStatisticImpl response2xx;
039: private CountStatisticImpl response3xx;
040: private CountStatisticImpl response4xx;
041: private CountStatisticImpl response5xx;
042: private CountStatisticImpl statsOnMs; // time elapsed since the stats collection
043:
044: public JettyWebContainerStatsImpl() {
045: activeRequestCount = new RangeStatisticImpl(
046: "Active Request Count", StatisticImpl.UNIT_COUNT,
047: "The number of requests being processed concurrently");
048: requestDuration = new TimeStatisticImpl("Request Duration",
049: StatisticImpl.UNIT_TIME_MILLISECOND,
050: "The length of time that it's taken to handle individual requests");
051: response1xx = new CountStatisticImpl("Response 1xx",
052: StatisticImpl.UNIT_COUNT, "The number of 1xx responses");
053: response2xx = new CountStatisticImpl("Response 2xx",
054: StatisticImpl.UNIT_COUNT, "The number of 2xx responses");
055: response3xx = new CountStatisticImpl("Response 3xx",
056: StatisticImpl.UNIT_COUNT, "The number of 3xx responses");
057: response4xx = new CountStatisticImpl("Response 4xx",
058: StatisticImpl.UNIT_COUNT, "The number of 4xx responses");
059: response5xx = new CountStatisticImpl("Response 5xx",
060: StatisticImpl.UNIT_COUNT, "The number of 5xx responses");
061: statsOnMs = new CountStatisticImpl("Stats Duration",
062: StatisticImpl.UNIT_TIME_MILLISECOND,
063: "The length of time that statistics have been collected.");
064:
065: addStat("ActiveRequestCount", activeRequestCount);
066: addStat("RequestDuration", requestDuration);
067: addStat("Responses1xx", response1xx);
068: addStat("Responses2xx", response2xx);
069: addStat("Responses3xx", response3xx);
070: addStat("Responses4xx", response4xx);
071: addStat("Responses5xx", response5xx);
072: addStat("StatsDuration", statsOnMs); // TODO - remove this
073: }
074:
075: /**
076: * Public methods to return the interfaces for statistics.
077: * These are used by the objects (such as the web console) that
078: * retrieve the stats for presentation purposes.
079: */
080:
081: public RangeStatistic getActiveRequestCount() {
082: return activeRequestCount;
083: }
084:
085: public TimeStatistic getRequestDuration() {
086: return requestDuration;
087: }
088:
089: /**
090: * @return Gets the number of 1xx status returned by this
091: * context since last call of stats reset.
092: */
093: public CountStatistic getResponses1xx() {
094: return response1xx;
095: }
096:
097: /**
098: * @return Gets the number of 2xx status returned by this
099: * context since last call of stats reset.
100: */
101: public CountStatistic getResponses2xx() {
102: return response2xx;
103: }
104:
105: /**
106: * @return Gets the number of 3xx status returned by this
107: * context since last call of stats reset.
108: */
109: public CountStatistic getResponses3xx() {
110: return response3xx;
111: }
112:
113: /**
114: * @return Gets the number of 4xx status returned by this
115: * context since last call of stats reset.
116: */
117: public CountStatistic getResponses4xx() {
118: return response4xx;
119: }
120:
121: /**
122: * @return Gets the number of 5xx status returned by this
123: * context since last call of stats reset.
124: */
125: public CountStatistic getResponses5xx() {
126: return response5xx;
127: }
128:
129: /**
130: * @return Time in millis since statistics collection was started.
131: */
132: public CountStatistic getStatsOnMs() {
133: return statsOnMs;
134: }
135:
136: /**
137: * Public methods to return the implementations for statistics.
138: * These are used by the JettyContainerImpl to set the values.
139: */
140:
141: public RangeStatisticImpl getActiveRequestCountImpl() {
142: return activeRequestCount;
143: }
144:
145: public TimeStatisticImpl getRequestDurationImpl() {
146: return requestDuration;
147: }
148:
149: /**
150: * @return Gets the number of 1xx status returned by this
151: * context since last call of stats reset.
152: */
153: public CountStatisticImpl getResponses1xxImpl() {
154: return response1xx;
155: }
156:
157: /**
158: * @return Gets the number of 2xx status returned by this
159: * context since last call of stats reset.
160: */
161: public CountStatisticImpl getResponses2xxImpl() {
162: return response2xx;
163: }
164:
165: /**
166: * @return Gets the number of 3xx status returned by this
167: * context since last call of stats reset.
168: */
169: public CountStatisticImpl getResponses3xxImpl() {
170: return response3xx;
171: }
172:
173: /**
174: * @return Gets the number of 4xx status returned by this
175: * context since last call of stats reset.
176: */
177: public CountStatisticImpl getResponses4xxImpl() {
178: return response4xx;
179: }
180:
181: /**
182: * @return Gets the number of 5xx status returned by this
183: * context since last call of stats reset.
184: */
185: public CountStatisticImpl getResponses5xxImpl() {
186: return response5xx;
187: }
188:
189: /**
190: * @return Time in millis since statistics collection was started.
191: */
192: public CountStatisticImpl getStatsOnMsImpl() {
193: return statsOnMs;
194: }
195: }
|