Home » geronimo-2.2-source-release » org.apache.geronimo.management.geronimo.stats » [javadoc | source]

    1   /**
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   package org.apache.geronimo.management.geronimo.stats;
   18   
   19   import javax.management.j2ee.statistics.CountStatistic;
   20   import javax.management.j2ee.statistics.RangeStatistic;
   21   import javax.management.j2ee.statistics.TimeStatistic;
   22   
   23   import org.apache.geronimo.management.stats.CountStatisticImpl;
   24   import org.apache.geronimo.management.stats.RangeStatisticImpl;
   25   import org.apache.geronimo.management.stats.StatisticImpl;
   26   import org.apache.geronimo.management.stats.StatsImpl;
   27   import org.apache.geronimo.management.stats.TimeStatisticImpl;
   28   
   29   /**
   30    * Jetty implementation of the Geronimo stats interface WebContainerStats
   31    *
   32    * @version $Revision: 1.0$
   33    */
   34   public class JettyWebContainerStatsImpl extends StatsImpl implements JettyWebContainerStats {
   35       private RangeStatisticImpl activeRequestCount;
   36       private TimeStatisticImpl requestDuration;
   37       private CountStatisticImpl response1xx;
   38       private CountStatisticImpl response2xx;
   39       private CountStatisticImpl response3xx;
   40       private CountStatisticImpl response4xx;
   41       private CountStatisticImpl response5xx;
   42       private CountStatisticImpl statsOnMs;               // time elapsed since the stats collection
   43   
   44       public JettyWebContainerStatsImpl() {
   45           activeRequestCount = new RangeStatisticImpl("Active Request Count", StatisticImpl.UNIT_COUNT,
   46                   "The number of requests being processed concurrently");
   47           requestDuration = new TimeStatisticImpl("Request Duration", StatisticImpl.UNIT_TIME_MILLISECOND,
   48                   "The length of time that it's taken to handle individual requests");
   49           response1xx = new CountStatisticImpl("Response 1xx", StatisticImpl.UNIT_COUNT,
   50                   "The number of 1xx responses");
   51           response2xx = new CountStatisticImpl("Response 2xx", StatisticImpl.UNIT_COUNT,
   52                   "The number of 2xx responses");
   53           response3xx = new CountStatisticImpl("Response 3xx", StatisticImpl.UNIT_COUNT,
   54                   "The number of 3xx responses");
   55           response4xx = new CountStatisticImpl("Response 4xx", StatisticImpl.UNIT_COUNT,
   56                   "The number of 4xx responses");
   57           response5xx = new CountStatisticImpl("Response 5xx", StatisticImpl.UNIT_COUNT,
   58                   "The number of 5xx responses");
   59           statsOnMs = new CountStatisticImpl("Stats Duration", StatisticImpl.UNIT_TIME_MILLISECOND,
   60                   "The length of time that statistics have been collected.");
   61   
   62           addStat("ActiveRequestCount", activeRequestCount);
   63           addStat("RequestDuration", requestDuration);
   64           addStat("Responses1xx", response1xx);
   65           addStat("Responses2xx", response2xx);
   66           addStat("Responses3xx", response3xx);
   67           addStat("Responses4xx", response4xx);
   68           addStat("Responses5xx", response5xx);
   69           addStat("StatsDuration", statsOnMs); // TODO - remove this
   70       }
   71   
   72   /**
   73    * Public methods to return the interfaces for statistics.
   74    * These are used by the objects (such as the web console) that
   75    * retrieve the stats for presentation purposes.
   76    */
   77   
   78       public RangeStatistic getActiveRequestCount() {
   79           return activeRequestCount;
   80       }
   81   
   82       public TimeStatistic getRequestDuration() {
   83           return requestDuration;
   84       }
   85   
   86       /**
   87        * @return Gets the number of 1xx status returned by this
   88        * context since last call of stats reset.
   89        */
   90       public CountStatistic getResponses1xx() {
   91           return response1xx;
   92       }
   93   
   94       /**
   95        * @return Gets the number of 2xx status returned by this
   96        * context since last call of stats reset.
   97        */
   98       public CountStatistic getResponses2xx() {
   99           return response2xx;
  100       }
  101       
  102       /**
  103        * @return Gets the number of 3xx status returned by this
  104        * context since last call of stats reset.
  105        */
  106       public CountStatistic getResponses3xx() {
  107           return response3xx;
  108       }
  109       
  110       /**
  111        * @return Gets the number of 4xx status returned by this
  112        * context since last call of stats reset.
  113        */
  114       public CountStatistic getResponses4xx() {
  115           return response4xx;
  116       }
  117       
  118       /**
  119        * @return Gets the number of 5xx status returned by this
  120        * context since last call of stats reset.
  121        */
  122       public CountStatistic getResponses5xx() {
  123           return response5xx;
  124       }
  125       
  126       /**
  127        * @return Time in millis since statistics collection was started.
  128        */
  129       public CountStatistic getStatsOnMs() {
  130           return statsOnMs;
  131       }
  132   
  133   /**
  134    * Public methods to return the implementations for statistics.
  135    * These are used by the JettyContainerImpl to set the values.
  136    */
  137   
  138       public RangeStatisticImpl getActiveRequestCountImpl() {
  139           return activeRequestCount;
  140       }
  141   
  142       public TimeStatisticImpl getRequestDurationImpl() {
  143           return requestDuration;
  144       }
  145   
  146       /**
  147        * @return Gets the number of 1xx status returned by this
  148        * context since last call of stats reset.
  149        */
  150       public CountStatisticImpl getResponses1xxImpl() {
  151           return response1xx;
  152       }
  153   
  154       /**
  155        * @return Gets the number of 2xx status returned by this
  156        * context since last call of stats reset.
  157        */
  158       public CountStatisticImpl getResponses2xxImpl() {
  159           return response2xx;
  160       }
  161       
  162       /**
  163        * @return Gets the number of 3xx status returned by this
  164        * context since last call of stats reset.
  165        */
  166       public CountStatisticImpl getResponses3xxImpl() {
  167           return response3xx;
  168       }
  169       
  170       /**
  171        * @return Gets the number of 4xx status returned by this
  172        * context since last call of stats reset.
  173        */
  174       public CountStatisticImpl getResponses4xxImpl() {
  175           return response4xx;
  176       }
  177       
  178       /**
  179        * @return Gets the number of 5xx status returned by this
  180        * context since last call of stats reset.
  181        */
  182       public CountStatisticImpl getResponses5xxImpl() {
  183           return response5xx;
  184       }
  185       
  186       /**
  187        * @return Time in millis since statistics collection was started.
  188        */
  189       public CountStatisticImpl getStatsOnMsImpl() {
  190           return statsOnMs;
  191       }
  192   }

Home » geronimo-2.2-source-release » org.apache.geronimo.management.geronimo.stats » [javadoc | source]