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   
   18   package org.apache.geronimo.management.geronimo.stats;
   19   
   20   import javax.management.j2ee.statistics.CountStatistic;
   21   import javax.management.j2ee.statistics.RangeStatistic;
   22   import javax.management.j2ee.statistics.TimeStatistic;
   23   
   24   import org.apache.geronimo.management.stats.StatsImpl;
   25   import org.apache.geronimo.management.stats.StatisticImpl;
   26   import org.apache.geronimo.management.stats.CountStatisticImpl;
   27   import org.apache.geronimo.management.stats.RangeStatisticImpl;
   28   import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl;
   29   import org.apache.geronimo.management.stats.TimeStatisticImpl;
   30   
   31   /**
   32    * Geronimo implementation of the JSR-77 style WebConnectorStats interface. This
   33    * is not required by JSR-77, but provides useful statistics. This will be
   34    * discovered by mejb using 'stats' attribute.
   35    * 
   36    * @version $Revision: 581936 $ $Date: 2007-10-04 07:46:56 -0700 (Thu, 04 Oct 2007) $
   37    */
   38   
   39   public class TomcatWebConnectorStatsImpl extends StatsImpl implements TomcatWebConnectorStats {
   40       private TimeStatisticImpl requestTime; // total, max, count
   41   
   42       private CountStatisticImpl activeRequestCount;
   43   
   44       private CountStatisticImpl errorCount;
   45   
   46       private CountStatisticImpl bytesSentCount;
   47   
   48       private CountStatisticImpl bytesReceivedCount;
   49       
   50       // these come from ThreadPool
   51       private RangeStatisticImpl openConnectionCount; 
   52       
   53       private CountStatisticImpl busyThreadCount;
   54       
   55       // TODO - change the name to BoundedRangeStatisticsImpl
   56       private BoundedRangeStatisticImpl busyThreads;
   57       // TODO - spareThreads metrics = current - busy, maxSpareThreads, minSpareThreads 
   58   
   59       public TomcatWebConnectorStatsImpl() {
   60           requestTime = new TimeStatisticImpl("Request Time", StatisticImpl.UNIT_TIME_MILLISECOND,
   61                   "The time to process all requests");
   62           activeRequestCount = new CountStatisticImpl("Active Request Count", StatisticImpl.UNIT_COUNT,
   63                   "currently active requests ", 0);
   64           errorCount = new CountStatisticImpl("Error Count", StatisticImpl.UNIT_COUNT,
   65                   "The numbet of Errors during the observed period", 0);
   66           bytesSentCount = new CountStatisticImpl("Bytes Sent", StatisticImpl.UNIT_COUNT,
   67                   "The number of bytes sent during the observerd period", 0);
   68           bytesReceivedCount = new CountStatisticImpl("Bytes Received", StatisticImpl.UNIT_COUNT,
   69                   "The number of bytes received during the observerd period", 0);
   70           openConnectionCount = new RangeStatisticImpl("" + "Open Connections", StatisticImpl.UNIT_COUNT,
   71                   "Range for connections opened during the observed period", 0); // all 0's
   72           busyThreads = new BoundedRangeStatisticImpl("Busy Threads", StatisticImpl.UNIT_COUNT,
   73                   "BoundedRange for Threads currently busy serving requests", 0, 0, 0);
   74           addStat("RequestTime", requestTime); // better name
   75           addStat("activeRequestCount", activeRequestCount);
   76           addStat("errorCount", errorCount);
   77           addStat("bytesSent", bytesSentCount);
   78           addStat("bytesReceived", bytesReceivedCount);
   79           addStat("openConnectionCount", openConnectionCount);
   80           addStat("busyThreads", busyThreads);
   81       }
   82   
   83       public RangeStatistic getActiveRequestCount() {
   84           // TODO 
   85           return null;
   86       }
   87   
   88       public TimeStatistic getRequestTime() {
   89           return requestTime;
   90       }
   91   
   92       public CountStatistic getErrorCount() {
   93           return errorCount;
   94       }
   95   
   96       public CountStatistic getBytesSentCount() {
   97           return bytesSentCount;
   98       }
   99   
  100       public CountStatistic getBytesReceivedCount() {
  101           return bytesReceivedCount;
  102       }
  103      
  104       public RangeStatistic getOpenConnectionCount() {
  105           return openConnectionCount;
  106       }
  107       
  108       // TODO - Move this to container statistics
  109       public RangeStatistic getSpareThreadCount() {
  110           return null;
  111       }
  112       
  113       /**
  114        * These setters are used by native implementation
  115        */
  116       public void setBytesReceivedCount(long bytesReceived) {
  117           this.bytesReceivedCount.setCount(bytesReceived);
  118       }
  119   
  120       public void setBytesSentCount(long bytesSent) {
  121           this.bytesSentCount.setCount(bytesSent);
  122       }
  123   
  124       public void setActiveRequestCount(int activeRequestCount) {
  125           this.activeRequestCount.setCount(activeRequestCount);
  126       }
  127   
  128       public void setErrorCount(int errorCount) {
  129           this.errorCount.setCount(errorCount);
  130       }
  131   
  132       public void setRequestTime(int count, long minTime, long maxTime, long totalTime) {
  133           this.requestTime.setCount(count);
  134           this.requestTime.setMinTime(minTime);
  135           this.requestTime.setMaxTime(maxTime);
  136           this.requestTime.setTotalTime(totalTime);
  137       }
  138    
  139       public void setOpenConnection(long current, long highMark, long lowMark) {
  140           openConnectionCount.setCurrent(current);
  141           openConnectionCount.setHighWaterMark(highMark);
  142           openConnectionCount.setLowWaterMark(lowMark);
  143       }
  144       
  145       public void setBusyThreads(long current, long highWaterMark, long lowWaterMark,
  146               long upperBound, long lowerBound) {
  147           busyThreads.setCurrent(current);
  148           busyThreads.setHighWaterMark(highWaterMark);
  149           busyThreads.setLowWaterMark(lowWaterMark); //0?
  150           busyThreads.setLowerBound(lowerBound); //0?
  151           busyThreads.setUpperBound(upperBound);  // always maxThreads
  152       }
  153       
  154       /**
  155        * Used to access the native implementation in order to call setters
  156        * TODO implement these if needed by console
  157        */
  158       public RangeStatisticImpl getActiveRequestCountImpl() {
  159           return null;
  160       }
  161   
  162       public TimeStatisticImpl getRequestDurationImpl() {
  163           return null;
  164       }
  165   
  166       public CountStatisticImpl getTotalErrorCountImpl() {
  167           return null;
  168       }
  169   
  170       public CountStatistic getTotalRequestCountImpl() {
  171           return null;
  172       }
  173   
  174   }

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