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