Save This Page
Home » geronimo-2.2-source-release » org.apache.geronimo.management.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.stats;
   19   
   20   import javax.management.j2ee.statistics.CountStatistic;
   21   import javax.management.j2ee.statistics.TimeStatistic;
   22   
   23   import org.apache.geronimo.management.geronimo.stats.WebModuleStats;
   24   
   25   /**
   26    * Geronimo implementation of the JSR-77 style WebModule interface. This
   27    * is not required by JSR-77, but provides useful statistics for a web app
   28    * 
   29    * @version $Revison$ $Date: 2007-02-04 06:48:10 -0800 (Sun, 04 Feb 2007) $
   30    */
   31   public class WebModuleStatsImpl extends StatsImpl implements WebModuleStats {
   32       // Static data
   33   
   34       private CountStatisticImpl processingTime;
   35   
   36       private CountStatisticImpl startupTime;
   37   
   38       private CountStatisticImpl tldScanTime;
   39   
   40       // transient data
   41       private TimeStatisticImpl sessionAliveTime; // total, max, count
   42   
   43       private CountStatisticImpl sessionCount;
   44   
   45       private CountStatisticImpl activeSessionCount;
   46   
   47       private CountStatisticImpl rejectedSessionCount;
   48   
   49       private CountStatisticImpl expiredSessionCount;
   50   
   51       public WebModuleStatsImpl() {
   52           processingTime = new CountStatisticImpl("Processing Time", StatisticImpl.UNIT_TIME_MILLISECOND,
   53                   "Time to process all the requests ", 0);
   54           startupTime = new CountStatisticImpl("Startup Time", StatisticImpl.UNIT_TIME_MILLISECOND,
   55                   "Time to start this application", 0);
   56           tldScanTime = new CountStatisticImpl("TLD Scan Time", StatisticImpl.UNIT_TIME_MILLISECOND,
   57                   "Time to scan TLDs ", 0);
   58           sessionAliveTime = new TimeStatisticImpl("Session Alive Time", StatisticImpl.UNIT_TIME_SECOND,
   59                   "The time for session");
   60           sessionCount = new CountStatisticImpl("Session Count", StatisticImpl.UNIT_COUNT,
   61                   "total number of sessions created ", 0);
   62           activeSessionCount = new CountStatisticImpl("Active Session Count", StatisticImpl.UNIT_COUNT,
   63                   "currently active sessions ", 0);
   64           rejectedSessionCount = new CountStatisticImpl("Rejected Session Count", StatisticImpl.UNIT_COUNT,
   65                   "rejected sessions ", 0);
   66           expiredSessionCount = new CountStatisticImpl("Expired Session Count", StatisticImpl.UNIT_COUNT,
   67                   "expired sessions ", 0);
   68           addStat("processingTime", processingTime);
   69           addStat("startupTime", startupTime);
   70           addStat("tldScanTime", tldScanTime);
   71           addStat("sessionAliveTime", sessionAliveTime); // better name
   72           addStat("sessionCount", sessionCount);
   73           addStat("activeSessionCount", activeSessionCount);
   74           addStat("rejectedSessionCount", rejectedSessionCount);
   75           addStat("expiredSessionCount", expiredSessionCount);
   76       }
   77   
   78       public CountStatistic getProcessingTime() {
   79           return processingTime;
   80       }
   81   
   82       public CountStatistic getStartupTime() {
   83           return startupTime;
   84       }
   85   
   86       public CountStatistic getTldScanTime() {
   87           return tldScanTime;
   88       }
   89   
   90       public TimeStatistic getSessionAliveTime() {
   91           return sessionAliveTime;
   92       }
   93   
   94       public CountStatistic getSessionCount() {
   95           return sessionCount;
   96       }
   97   
   98       public CountStatistic getActiveSessionCount() {
   99           return activeSessionCount;
  100       }
  101   
  102       public CountStatistic getExpiredSessionCount() {
  103           return expiredSessionCount;
  104       }
  105   
  106       public CountStatistic getRejectedSessionCount() {
  107           return rejectedSessionCount;
  108       }
  109   
  110       /**
  111        * These setters are used by native implementation
  112        */
  113   
  114       public void setProcessingTime(long processingTime) {
  115           this.processingTime.setCount(processingTime);
  116       }
  117   
  118       // This is static data, need not be refreshed
  119       public void setStartupTime(long startupTime) {
  120           this.startupTime.setCount(startupTime);
  121       }
  122   
  123       public void setTldScanTime(long tldScanTime) {
  124           this.tldScanTime.setCount(tldScanTime);
  125       }
  126   
  127       public void setSessionAliveTime(int count, long minTime, long maxTime, long totalTime) {
  128           this.sessionAliveTime.setCount(count);
  129           this.sessionAliveTime.setMinTime(minTime);
  130           this.sessionAliveTime.setMaxTime(maxTime);
  131           this.sessionAliveTime.setTotalTime(totalTime);
  132       }
  133   
  134       public void setSessionCount(int sessionCount) {
  135           this.sessionCount.setCount(sessionCount);
  136       }
  137   
  138       public void setActiveSessionCount(int activeSessionCount) {
  139           this.activeSessionCount.setCount(activeSessionCount);
  140       }
  141   
  142       public void setExpiredSessionCount(int expiredSessionCount) {
  143           this.expiredSessionCount.setCount(expiredSessionCount);
  144       }
  145   
  146       public void setRejectedSessionCount(int rejectedSessionCount) {
  147           this.rejectedSessionCount.setCount(rejectedSessionCount);
  148       }
  149       
  150       // Is this needed ?
  151       public void setLastSampleTime(long time) {
  152           sessionAliveTime.setLastSampleTime(time);
  153           activeSessionCount.setLastSampleTime(time);
  154           expiredSessionCount.setLastSampleTime(time);
  155           rejectedSessionCount.setLastSampleTime(time);
  156       }
  157   
  158   }

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