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     */
017    package org.apache.geronimo.jetty6;
018    
019    import javax.management.j2ee.statistics.CountStatistic;
020    import javax.management.j2ee.statistics.RangeStatistic;
021    import javax.management.j2ee.statistics.TimeStatistic;
022    
023    import org.apache.geronimo.management.stats.CountStatisticImpl;
024    import org.apache.geronimo.management.stats.RangeStatisticImpl;
025    import org.apache.geronimo.management.stats.StatisticImpl;
026    import org.apache.geronimo.management.stats.StatsImpl;
027    import org.apache.geronimo.management.stats.TimeStatisticImpl;
028    
029    /**
030     * Jetty implementation of the Geronimo stats interface WebContainerStats
031     *
032     * @version $Revision: 1.0$
033     */
034    public class JettyWebContainerStatsImpl extends StatsImpl implements JettyWebContainerStats {
035        private CountStatisticImpl totalConnectionCount;
036        private RangeStatisticImpl openConnectionCount;
037        private RangeStatisticImpl connectionRequestCount;
038        private TimeStatisticImpl connectionDuration;
039        private CountStatisticImpl totalErrorCount;
040        private CountStatisticImpl totalRequestCount;
041        private RangeStatisticImpl activeRequestCount;
042        private TimeStatisticImpl requestDuration;
043        private boolean statsOn=false;
044    
045        public JettyWebContainerStatsImpl() {
046            totalConnectionCount = new CountStatisticImpl("Total Connections", StatisticImpl.UNIT_COUNT,
047                    "The total number of connections since last reset");
048            openConnectionCount = new RangeStatisticImpl("Open Connections", StatisticImpl.UNIT_COUNT,
049                    "The number of connections open at present");
050            connectionRequestCount = new RangeStatisticImpl("Connection Request Count", StatisticImpl.UNIT_COUNT,
051                    "The number of requests handled by a particular connection");
052            connectionDuration = new TimeStatisticImpl("Connection Duration", StatisticImpl.UNIT_TIME_MILLISECOND,
053                    "The legnth of time that individual connections have been open");
054            totalErrorCount = new CountStatisticImpl("Error Count", StatisticImpl.UNIT_COUNT,
055                    "The number of reponses that were errors since statistics gathering started");
056            totalRequestCount = new CountStatisticImpl("Request Count", StatisticImpl.UNIT_COUNT,
057                    "The number of requests that were handled since statistics gathering started");
058            activeRequestCount = new RangeStatisticImpl("Active Request Count", StatisticImpl.UNIT_COUNT,
059                    "The number of requests being processed concurrently");
060            requestDuration = new TimeStatisticImpl("Request Duration", StatisticImpl.UNIT_TIME_MILLISECOND,
061                    "The length of time that it's taken to handle individual requests");
062    
063            addStat("TotalConnectionCount", totalConnectionCount);
064            addStat("OpenConnectionCount", openConnectionCount);
065            addStat("ConnectionRequestCount", connectionRequestCount);
066            addStat("ConnectionDuration", connectionDuration);
067            addStat("TotalErrorCount", totalErrorCount);
068            addStat("TotalRequestCount", totalRequestCount);
069            addStat("ActiveRequestCount", activeRequestCount);
070            addStat("RequestDuration", requestDuration);
071        }
072    
073        public CountStatistic getTotalConnectionCount() {
074            return totalConnectionCount;
075        }
076    
077        public RangeStatistic getOpenConnectionCount() {
078            return openConnectionCount;
079        }
080    
081        public RangeStatistic getConnectionRequestCount() {
082            return connectionRequestCount;
083        }
084    
085        public TimeStatistic getConnectionDuration() {
086            return connectionDuration;
087        }
088    
089        public CountStatistic getTotalErrorCount() {
090            return totalErrorCount;
091        }
092    
093        public CountStatistic getTotalRequestCount() {
094            return totalRequestCount;
095        }
096    
097        public RangeStatistic getActiveRequestCount() {
098            return activeRequestCount;
099        }
100    
101        public TimeStatistic getRequestDuration() {
102            return requestDuration;
103        }
104    
105        public boolean isStatsOn() {
106            return statsOn;
107        }
108    
109        public void setStatsOn(boolean on) {
110            statsOn = on;
111        }
112    
113        public CountStatisticImpl getTotalConnectionCountImpl() {
114            return totalConnectionCount;
115        }
116    
117        public RangeStatisticImpl getOpenConnectionCountImpl() {
118            return openConnectionCount;
119        }
120    
121        public RangeStatisticImpl getConnectionRequestCountImpl() {
122            return connectionRequestCount;
123        }
124    
125        public TimeStatisticImpl getConnectionDurationImpl() {
126            return connectionDuration;
127        }
128    
129        public CountStatisticImpl getTotalErrorCountImpl() {
130            return totalErrorCount;
131        }
132    
133        public CountStatisticImpl getTotalRequestCountImpl() {
134            return totalRequestCount;
135        }
136    
137        public RangeStatisticImpl getActiveRequestCountImpl() {
138            return activeRequestCount;
139        }
140    
141        public TimeStatisticImpl getRequestDurationImpl() {
142            return requestDuration;
143        }
144    }