You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ak...@apache.org on 2007/10/04 16:47:01 UTC
svn commit: r581936 - in /geronimo/server/trunk/modules:
geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/
geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/connector/
geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/ geronimo-ma...
Author: akulshreshtha
Date: Thu Oct 4 07:46:56 2007
New Revision: 581936
URL: http://svn.apache.org/viewvc?rev=581936&view=rev
Log:
GERONIMO-3490 Adding JSR77 stats for Jetty connectors. This a substantially modified version
of the patch submitted by Viet H. N.
Added:
geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStats.java (with props)
geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStatsImpl.java (with props)
geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/StatTest.java (with props)
geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStats.java (with props)
geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStatsImpl.java
- copied, changed from r581647, geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/WebConnectorStatsImpl.java
Modified:
geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/connector/JettyConnector.java
geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java
geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebConnectorStats.java
geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/StatsImpl.java
geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/WebConnectorStatsImpl.java
geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/stats/ConnectorStats.java
Added: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStats.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStats.java?rev=581936&view=auto
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStats.java (added)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStats.java Thu Oct 4 07:46:56 2007
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.jetty6;
+
+import org.apache.geronimo.management.geronimo.stats.WebConnectorStats;
+
+import javax.management.j2ee.statistics.RangeStatistic;
+import javax.management.j2ee.statistics.TimeStatistic;
+import javax.management.j2ee.statistics.CountStatistic;
+
+public interface JettyWebConnectorStats extends WebConnectorStats {
+ /**
+ * Gets the number of connections since statistics gathering started.
+ */
+ CountStatistic getConnectionsCount();
+
+ /**
+ * Gets the number of request count since statistics gathering started.
+ */
+ CountStatistic getRequestCount();
+
+ /**
+ * Gets the avg, min, max, and total connection duration time since
+ * statistics gathering started.
+ */
+ TimeStatistic getConnectionsDuration();
+
+ /**
+ * Gets the min, max, current number of connection requests since statistics gathering started.
+ */
+ RangeStatistic getConnectionsRequest();
+}
Propchange: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStats.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStats.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStats.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStatsImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStatsImpl.java?rev=581936&view=auto
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStatsImpl.java (added)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStatsImpl.java Thu Oct 4 07:46:56 2007
@@ -0,0 +1,116 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.geronimo.jetty6;
+
+import org.apache.geronimo.management.stats.CountStatisticImpl;
+import org.apache.geronimo.management.stats.RangeStatisticImpl;
+import org.apache.geronimo.management.stats.StatisticImpl;
+import org.apache.geronimo.management.stats.TimeStatisticImpl;
+import org.apache.geronimo.management.stats.StatsImpl;
+import org.apache.geronimo.management.stats.WebConnectorStatsImpl;
+
+import javax.management.j2ee.statistics.RangeStatistic;
+import javax.management.j2ee.statistics.TimeStatistic;
+import javax.management.j2ee.statistics.CountStatistic;
+
+/**
+ * Jetty Web Connector class for JSR-77 stats.
+ */
+public class JettyWebConnectorStatsImpl extends WebConnectorStatsImpl implements JettyWebConnectorStats {
+ private CountStatisticImpl connectionsCount;
+ private CountStatisticImpl requestCount;
+ private TimeStatisticImpl connectionsDuration;
+ private RangeStatisticImpl connectionsRequest;
+
+ public JettyWebConnectorStatsImpl() {
+ connectionsCount = new CountStatisticImpl("Connections Count", StatisticImpl.UNIT_COUNT,
+ "Total number of connections made to server", 0);
+ requestCount = new CountStatisticImpl("Request Count", StatisticImpl.UNIT_COUNT,
+ "Total number of requests made to server", 0);
+ connectionsDuration = new TimeStatisticImpl("Connections Duration", StatisticImpl.UNIT_TIME_MILLISECOND,
+ "Duration of a connection");
+ connectionsRequest = new RangeStatisticImpl("Connections Request", StatisticImpl.UNIT_COUNT,
+ "Range for connections requested during the observed period", 0); // all 0's
+
+ addStat("ConnectionsCount", connectionsCount);
+ addStat("RequestCount", requestCount);
+ addStat("ConnectionsDuration", connectionsDuration);
+ addStat("ConnectionsRequest", connectionsRequest);
+ }
+
+ /**
+ * Gets the number of connections since statistics gathering started.
+ */
+ public CountStatistic getConnectionsCount() {
+ return connectionsCount;
+ }
+
+ /**
+ * Gets the number of request count since statistics gathering started.
+ */
+ public CountStatistic getRequestCount() {
+ return requestCount;
+ }
+
+ /**
+ * Gets the avg, min, max, and total connection duration time since
+ * statistics gathering started.
+ */
+ public TimeStatistic getConnectionsDuration() {
+ return connectionsDuration;
+ }
+
+ /**
+ * Gets the min, max, current number of connection requests since statistics gathering started.
+ */
+ public RangeStatistic getConnectionsRequest() {
+ return connectionsRequest;
+ }
+
+ /**
+ * Gets the number of connections since statistics gathering started.
+ */
+ public CountStatisticImpl getConnectionsCountImpl() {
+ return connectionsCount;
+ }
+
+ /**
+ * Gets the number of request count since statistics gathering started.
+ */
+ public CountStatisticImpl getRequestCountImpl() {
+ return requestCount;
+ }
+
+ /**
+ * Gets the avg, min, max, and total connection duration time since
+ * statistics gathering started.
+ */
+ public TimeStatisticImpl getConnectionsDurationImpl() {
+ return connectionsDuration;
+ }
+
+ /**
+ * Gets the min, max, current number of connection requests since statistics gathering started.
+ */
+ public RangeStatisticImpl getConnectionsRequestImpl() {
+ return connectionsRequest;
+ }
+}
Propchange: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStatsImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStatsImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebConnectorStatsImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/connector/JettyConnector.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/connector/JettyConnector.java?rev=581936&r1=581935&r2=581936&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/connector/JettyConnector.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/connector/JettyConnector.java Thu Oct 4 07:46:56 2007
@@ -21,12 +21,16 @@
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
+import javax.management.j2ee.statistics.Stats;
+
import org.apache.geronimo.gbean.GBeanInfo;
import org.apache.geronimo.gbean.GBeanInfoBuilder;
import org.apache.geronimo.gbean.GBeanLifecycle;
import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
import org.apache.geronimo.jetty6.JettyContainer;
import org.apache.geronimo.jetty6.JettyWebConnector;
+import org.apache.geronimo.jetty6.JettyWebConnectorStatsImpl;
+import org.apache.geronimo.management.StatisticsProvider;
import org.apache.geronimo.system.threads.ThreadPool;
import org.mortbay.jetty.AbstractConnector;
@@ -35,10 +39,11 @@
*
* @version $Rev$ $Date$
*/
-public abstract class JettyConnector implements GBeanLifecycle, JettyWebConnector {
+public abstract class JettyConnector implements GBeanLifecycle, JettyWebConnector, StatisticsProvider {
public final static String CONNECTOR_CONTAINER_REFERENCE = "JettyContainer";
private final JettyContainer container;
protected final AbstractConnector listener;
+ private JettyWebConnectorStatsImpl stats; // data structure for jsr77 stats
private String connectHost;
/**
@@ -61,6 +66,7 @@
JettyThreadPool jettyThreadPool = new JettyThreadPool(threadPool, name);
listener.setThreadPool(jettyThreadPool);
}
+ stats = new JettyWebConnectorStatsImpl();
}
//TODO: support the jetty6 specific methods
@@ -173,7 +179,6 @@
}
}
-
public void setRedirectPort(int port) {
throw new UnsupportedOperationException("No redirect port on " + this.getClass().getName());
}
@@ -208,6 +213,58 @@
}
}
}
+
+ public void statsOn(Boolean on) {
+ listener.setStatsOn(on);
+ if (on) stats.setStartTime();
+ }
+
+ /**
+ * Gets the statistics collected for this class.
+ * The first call to this method initializes the startTime for
+ * all statistics.
+ *
+ * @return gets collected for this class
+ */
+ public Stats getStats() {
+ if(listener.getStatsOn()) {
+ stats.setLastSampleTime();
+ // connections open
+ stats.getOpenConnectionCountImpl().setCurrent(listener.getConnectionsOpen());
+ stats.getOpenConnectionCountImpl().setHighWaterMark(listener.getConnectionsOpenMax());
+ stats.getOpenConnectionCountImpl().setLowWaterMark(listener.getConnectionsOpenMin());
+ // connections count
+ stats.getConnectionsCountImpl().setCount(listener.getConnections());
+ // request count
+ stats.getRequestCountImpl().setCount(listener.getRequests());
+ // connections durations
+ stats.getConnectionsDurationImpl().setCount(listener.getConnectionsDurationAve());
+ stats.getConnectionsDurationImpl().setMaxTime(listener.getConnectionsDurationMax());
+ stats.getConnectionsDurationImpl().setMinTime(listener.getConnectionsDurationMin());
+ stats.getConnectionsDurationImpl().setTotalTime(listener.getConnectionsDurationTotal());
+ // requests per connection (connection requests)
+ stats.getConnectionsRequestImpl().setCurrent(listener.getConnectionsRequestsAve());
+ stats.getConnectionsRequestImpl().setHighWaterMark(listener.getConnectionsRequestsMax());
+ stats.getConnectionsRequestImpl().setLowWaterMark(listener.getConnectionsRequestsMin());
+ }
+ return stats;
+ }
+
+ /**
+ * Reset the startTime for all statistics
+ */
+ public void resetStats() {
+ listener.statsReset();
+ stats.setStartTime(); // sets atartTime for all stats to Now
+ }
+
+ public boolean isStateManageable() {
+ return true;
+ }
+
+ public boolean isStatisticsProvider() {
+ return listener.getStatsOn();
+ }
public static final GBeanInfo GBEAN_INFO;
@@ -215,6 +272,7 @@
GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic("Jetty HTTP Connector", JettyConnector.class);
infoFactory.addReference(CONNECTOR_CONTAINER_REFERENCE, JettyContainer.class, NameFactory.GERONIMO_SERVICE);
infoFactory.addReference("ThreadPool", ThreadPool.class, NameFactory.GERONIMO_SERVICE);
+ // infoFactory.addOperation("statsOn", new Class[] { Boolean.class }, "void");
// removed 'minThreads' from persistent and manageable String[]
// removed 'tcpNoDelay' from persistent String[]
// added 'protocol' to persistent and manageable String[]
Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java?rev=581936&r1=581935&r2=581936&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java Thu Oct 4 07:46:56 2007
@@ -57,7 +57,7 @@
public class AbstractWebModuleTest extends TestSupport {
protected ClassLoader cl;
protected final static String securityRealmName = "demo-properties-realm";
- private HTTPSocketConnector connector;
+ protected HTTPSocketConnector connector;
protected JettyContainerImpl container;
private TransactionManager transactionManager;
private ConnectionTrackingCoordinator connectionTrackingCoordinator;
Added: geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/StatTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/StatTest.java?rev=581936&view=auto
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/StatTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/StatTest.java Thu Oct 4 07:46:56 2007
@@ -0,0 +1,88 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.jetty6;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import javax.management.ObjectName;
+import javax.management.j2ee.statistics.Statistic;
+import javax.management.j2ee.statistics.Stats;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class StatTest extends AbstractWebModuleTest {
+
+ private ObjectName webModuleName;
+
+ public void testStats() throws Exception {
+ JettyWebAppContext app;
+ app = setUpAppContext(null, null, null, null, null, null, null, "war1/");
+
+ setUpStaticContentServlet(app);
+
+ // start statistics collection
+ assertTrue("Stats should be off initially", !connector.isStatisticsProvider());
+ connector.statsOn(true);
+ container.setCollectStatistics(true);
+
+ int n = 4; // no of connections
+ for (int k = 0; k < n; k++) {
+ HttpURLConnection connection = (HttpURLConnection) new URL(connector.getConnectUrl() + "/test/hello.txt")
+ .openConnection();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ assertEquals(HttpURLConnection.HTTP_OK, connection.getResponseCode());
+ assertEquals("Hello World", reader.readLine());
+
+ Stats[] allStats = {connector.getStats()};
+ Stats stats;
+ for (int j = 0; j < allStats.length; j++) {
+ stats = allStats[j];
+ Statistic[] stts = stats.getStatistics();
+ Statistic aStts;
+ String[] sttsNames = stats.getStatisticNames();
+ for (int i = 0; i < sttsNames.length; i++) {
+ // check that the names match the getter methods
+ String sttsName = sttsNames[i];
+ assertFalse(sttsName.equals(stts[i].getName()));
+ try {
+ stats.getClass().getMethod("get" + sttsName, new Class[0]);
+ } catch (NoSuchMethodException e) {
+ continue; // ignore this statistics JSR77.6.10.1.1
+ }
+ aStts = stats.getStatistic(sttsName);
+ assertTrue("startTime was not set for " + sttsName, aStts.getStartTime() != 0);
+ assertTrue("lastSampleTime was not set for " + sttsName, aStts.getLastSampleTime() != 0);
+ /* System.out.println(" lastSampleTime = " + aStts.getLastSampleTime() +
+ " startTime = " + aStts.getStartTime());
+ System.out.println(aStts);*/
+ }
+ }
+ if (k == n-2) connector.resetStats(); // test reset
+ connection.disconnect();
+ Thread.sleep(1000); // connection interval
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+}
Propchange: geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/StatTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/StatTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/StatTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStats.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStats.java?rev=581936&view=auto
==============================================================================
--- geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStats.java (added)
+++ geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStats.java Thu Oct 4 07:46:56 2007
@@ -0,0 +1,62 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.geronimo.management.geronimo.stats;
+
+import javax.management.j2ee.statistics.Stats;
+import javax.management.j2ee.statistics.RangeStatistic;
+import javax.management.j2ee.statistics.TimeStatistic;
+import javax.management.j2ee.statistics.CountStatistic;
+
+/**
+ * Statistics exposed by a Tomcat web connector (http, https)
+ *
+ * @version $Rev$ $Date$
+ */
+public interface TomcatWebConnectorStats extends WebConnectorStats {
+
+ /**
+ * Gets the Time statistics (count, total, Max, Min) for requests (includes
+ * figures across all requests since statistics gathering started)
+ */
+ TimeStatistic getRequestTime();
+
+ /**
+ * Gets the number of errors that have been returned since statistics
+ * gathering started.
+ */
+ CountStatistic getErrorCount();
+
+ /**
+ * Gets the number of requests being processed concurrently (as well as the
+ * min and max since statistics gathering started).
+ */
+ RangeStatistic getActiveRequestCount();
+
+ /**
+ * Gets the number of threads currently available (as well as min and max
+ * since statistics gathering started.
+ * current - The number of threads currently in the pool (currentThreadCount)
+ * - the number of threads currently serving requests (currentThreadBusy)
+ * HiMark - The maximum number of unused threads that will be allowed to exist
+ * until the thread pool starts stopping the unnecessary threads(maxSpareThread)
+ * UpperBound - The max number of threads created by the connector (maxThreads)
+ * LowerBound - The number of threads created by the connector in the begining (minSpareThread)
+ */
+ // This could be a container statistics
+ RangeStatistic getSpareThreadCount();
+}
Propchange: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStats.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStats.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStats.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Copied: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStatsImpl.java (from r581647, geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/WebConnectorStatsImpl.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStatsImpl.java?p2=geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStatsImpl.java&p1=geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/WebConnectorStatsImpl.java&r1=581647&r2=581936&rev=581936&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/WebConnectorStatsImpl.java (original)
+++ geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/TomcatWebConnectorStatsImpl.java Thu Oct 4 07:46:56 2007
@@ -15,13 +15,18 @@
* limitations under the License.
*/
-package org.apache.geronimo.management.stats;
+package org.apache.geronimo.management.geronimo.stats;
import javax.management.j2ee.statistics.CountStatistic;
import javax.management.j2ee.statistics.RangeStatistic;
import javax.management.j2ee.statistics.TimeStatistic;
-import org.apache.geronimo.management.geronimo.stats.WebConnectorStats;
+import org.apache.geronimo.management.stats.StatsImpl;
+import org.apache.geronimo.management.stats.StatisticImpl;
+import org.apache.geronimo.management.stats.CountStatisticImpl;
+import org.apache.geronimo.management.stats.RangeStatisticImpl;
+import org.apache.geronimo.management.stats.BoundedRangeStatisticImpl;
+import org.apache.geronimo.management.stats.TimeStatisticImpl;
/**
* Geronimo implementation of the JSR-77 style WebConnectorStats interface. This
@@ -31,7 +36,7 @@
* @version $Revision$ $Date$
*/
-public class WebConnectorStatsImpl extends StatsImpl implements WebConnectorStats {
+public class TomcatWebConnectorStatsImpl extends StatsImpl implements TomcatWebConnectorStats {
private TimeStatisticImpl requestTime; // total, max, count
private CountStatisticImpl activeRequestCount;
@@ -45,13 +50,13 @@
// these come from ThreadPool
private RangeStatisticImpl openConnectionCount;
- private CountStatistic busyThreadCount;
+ private CountStatisticImpl busyThreadCount;
// TODO - change the name to BoundedRangeStatisticsImpl
private BoundedRangeStatisticImpl busyThreads;
// TODO - spareThreads metrics = current - busy, maxSpareThreads, minSpareThreads
- public WebConnectorStatsImpl() {
+ public TomcatWebConnectorStatsImpl() {
requestTime = new TimeStatisticImpl("Request Time", StatisticImpl.UNIT_TIME_MILLISECOND,
"The time to process all requests");
activeRequestCount = new CountStatisticImpl("Active Request Count", StatisticImpl.UNIT_COUNT,
Modified: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebConnectorStats.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebConnectorStats.java?rev=581936&r1=581935&r2=581936&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebConnectorStats.java (original)
+++ geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebConnectorStats.java Thu Oct 4 07:46:56 2007
@@ -17,10 +17,8 @@
package org.apache.geronimo.management.geronimo.stats;
-import javax.management.j2ee.statistics.Stats;
import javax.management.j2ee.statistics.RangeStatistic;
-import javax.management.j2ee.statistics.TimeStatistic;
-import javax.management.j2ee.statistics.CountStatistic;
+import javax.management.j2ee.statistics.Stats;
/**
* Statistics exposed by a Tomcat web connector (http, https)
@@ -29,52 +27,10 @@
*/
public interface WebConnectorStats extends Stats {
- /**
- * Gets the Time statistics (count, total, Max, Min) for requests (includes
- * figures across all requests since statistics gathering started)
- */
- TimeStatistic getRequestTime();
-
- /**
- * Gets the number of errors that have been returned since statistics
- * gathering started.
- */
- CountStatistic getErrorCount();
-
- /**
- * Gets the number of requests being processed concurrently (as well as the
- * min and max since statistics gathering started).
- */
- RangeStatistic getActiveRequestCount();
-
+ // TODO - check if some other stats can be merged
/**
* Gets the number of connections currently open (as well as the min and max
* since statistics gathering started).
*/
RangeStatistic getOpenConnectionCount();
-
- /**
- * Gets the number of threads currently available (as well as min and max
- * since statistics gathering started.
- * current - The number of threads currently in the pool (currentThreadCount)
- * - the number of threads currently serving requests (currentThreadBusy)
- * HiMark - The maximum number of unused threads that will be allowed to exist
- * until the thread pool starts stopping the unnecessary threads(maxSpareThread)
- * UpperBound - The max number of threads created by the connector (maxThreads)
- * LowerBound - The number of threads created by the connector in the begining (minSpareThread)
- */
- // This could be a container statistics
- RangeStatistic getSpareThreadCount();
-
- /**
- * Gets the number of requests handled by a particular connection (as well
- * as the min(?) and max since statistics gathering started).
- */
- // RangeStatistic getConnectionRequestCount();
-
- /**
- * Gets the legnth of time that connections have been open (includes figures
- * across all connections open at present)
- */
- // TimeStatistic getConnectionDuration();
}
Modified: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/StatsImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/StatsImpl.java?rev=581936&r1=581935&r2=581936&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/StatsImpl.java (original)
+++ geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/StatsImpl.java Thu Oct 4 07:46:56 2007
@@ -26,10 +26,11 @@
* Geronimo implementation of the JSR-77 Stats interface. Dynamically tracks
* available statistics for its subclasses, to make it easy to iterate
* available statistics without knowing exactly what kind of class you're
- * looking at. Not sure when you'd want to do that, but hey.
+ * looking at.
*
* @version $Rev$ $Date$
*/
+
public class StatsImpl implements Stats, Serializable {
private final Map <String,StatisticImpl> stats = new HashMap<String,StatisticImpl>();
@@ -50,6 +51,9 @@
stats.remove(name);
}
+ /**
+ * Set the startTime for all statistics to System.currentTimeMillis()
+ */
public void setStartTime() {
long now = System.currentTimeMillis();
for (StatisticImpl item : stats.values()) {
@@ -57,6 +61,19 @@
}
}
+ /**
+ * Set the startTime for all statistics to the given value
+ * @param time
+ */
+ public void setStartTime(long time) {
+ for (StatisticImpl item : stats.values()) {
+ item.setStartTime(time);
+ }
+ }
+
+ /**
+ * Set the lastSampleTime for all statistics to System.currentTimeMillis()
+ */
public void setLastSampleTime() {
long now = System.currentTimeMillis();
for (StatisticImpl item : stats.values()) {
@@ -64,14 +81,26 @@
}
}
+ /*
+ * Gets a Statistic by name
+ * @see javax.management.j2ee.statistics.Stats#getStatistic(java.lang.String)
+ */
public Statistic getStatistic(String statisticName) {
return (Statistic)stats.get(statisticName);
}
+ /*
+ * Returns a list of names of statistics
+ * @see javax.management.j2ee.statistics.Stats#getStatisticNames()
+ */
public String[] getStatisticNames() {
return (String[]) stats.keySet().toArray(new String[stats.size()]);
}
+ /*
+ * Returns a list of all the Statistic objects supported by this Stats object
+ * @see javax.management.j2ee.statistics.Stats#getStatistics()
+ */
public Statistic[] getStatistics() {
String[] names = getStatisticNames();
Statistic[] result = new Statistic[names.length];
Modified: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/WebConnectorStatsImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/WebConnectorStatsImpl.java?rev=581936&r1=581935&r2=581936&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/WebConnectorStatsImpl.java (original)
+++ geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/stats/WebConnectorStatsImpl.java Thu Oct 4 07:46:56 2007
@@ -17,9 +17,7 @@
package org.apache.geronimo.management.stats;
-import javax.management.j2ee.statistics.CountStatistic;
import javax.management.j2ee.statistics.RangeStatistic;
-import javax.management.j2ee.statistics.TimeStatistic;
import org.apache.geronimo.management.geronimo.stats.WebConnectorStats;
@@ -31,105 +29,20 @@
* @version $Revision$ $Date$
*/
-public class WebConnectorStatsImpl extends StatsImpl implements WebConnectorStats {
- private TimeStatisticImpl requestTime; // total, max, count
-
- private CountStatisticImpl activeRequestCount;
-
- private CountStatisticImpl errorCount;
-
- private CountStatisticImpl bytesSentCount;
-
- private CountStatisticImpl bytesReceivedCount;
-
+public class WebConnectorStatsImpl extends StatsImpl implements WebConnectorStats {
// these come from ThreadPool
private RangeStatisticImpl openConnectionCount;
- private CountStatistic busyThreadCount;
-
- // TODO - change the name to BoundedRangeStatisticsImpl
- private BoundedRangeStatisticImpl busyThreads;
- // TODO - spareThreads metrics = current - busy, maxSpareThreads, minSpareThreads
-
public WebConnectorStatsImpl() {
- requestTime = new TimeStatisticImpl("Request Time", StatisticImpl.UNIT_TIME_MILLISECOND,
- "The time to process all requests");
- activeRequestCount = new CountStatisticImpl("Active Request Count", StatisticImpl.UNIT_COUNT,
- "currently active requests ", 0);
- errorCount = new CountStatisticImpl("Error Count", StatisticImpl.UNIT_COUNT,
- "The numbet of Errors during the observed period", 0);
- bytesSentCount = new CountStatisticImpl("Bytes Sent", StatisticImpl.UNIT_COUNT,
- "The number of bytes sent during the observerd period", 0);
- bytesReceivedCount = new CountStatisticImpl("Bytes Received", StatisticImpl.UNIT_COUNT,
- "The number of bytes received during the observerd period", 0);
openConnectionCount = new RangeStatisticImpl("" + "Open Connections", StatisticImpl.UNIT_COUNT,
"Range for connections opened during the observed period", 0); // all 0's
- busyThreads = new BoundedRangeStatisticImpl("Busy Threads", StatisticImpl.UNIT_COUNT,
- "BoundedRange for Threads currently busy serving requests", 0, 0, 0);
- addStat("RequestTime", requestTime); // better name
- addStat("activeRequestCount", activeRequestCount);
- addStat("errorCount", errorCount);
- addStat("bytesSent", bytesSentCount);
- addStat("bytesReceived", bytesReceivedCount);
- addStat("openConnectionCount", openConnectionCount);
- addStat("busyThreads", busyThreads);
- }
-
- public RangeStatistic getActiveRequestCount() {
- // TODO
- return null;
- }
-
- public TimeStatistic getRequestTime() {
- return requestTime;
- }
-
- public CountStatistic getErrorCount() {
- return errorCount;
- }
-
- public CountStatistic getBytesSentCount() {
- return bytesSentCount;
+ addStat("OpenConnectionCount", openConnectionCount);
}
- public CountStatistic getBytesReceivedCount() {
- return bytesReceivedCount;
- }
public RangeStatistic getOpenConnectionCount() {
return openConnectionCount;
}
-
- // TODO - Move this to container statistics
- public RangeStatistic getSpareThreadCount() {
- return null;
- }
-
- /**
- * These setters are used by native implementation
- */
- public void setBytesReceivedCount(long bytesReceived) {
- this.bytesReceivedCount.setCount(bytesReceived);
- }
-
- public void setBytesSentCount(long bytesSent) {
- this.bytesSentCount.setCount(bytesSent);
- }
-
- public void setActiveRequestCount(int activeRequestCount) {
- this.activeRequestCount.setCount(activeRequestCount);
- }
-
- public void setErrorCount(int errorCount) {
- this.errorCount.setCount(errorCount);
- }
-
- public void setRequestTime(int count, long minTime, long maxTime, long totalTime) {
- this.requestTime.setCount(count);
- this.requestTime.setMinTime(minTime);
- this.requestTime.setMaxTime(maxTime);
- this.requestTime.setTotalTime(totalTime);
- }
public void setOpenConnection(long current, long highMark, long lowMark) {
openConnectionCount.setCurrent(current);
@@ -137,33 +50,11 @@
openConnectionCount.setLowWaterMark(lowMark);
}
- public void setBusyThreads(long current, long highWaterMark, long lowWaterMark,
- long upperBound, long lowerBound) {
- busyThreads.setCurrent(current);
- busyThreads.setHighWaterMark(highWaterMark);
- busyThreads.setLowWaterMark(lowWaterMark); //0?
- busyThreads.setLowerBound(lowerBound); //0?
- busyThreads.setUpperBound(upperBound); // always maxThreads
- }
-
/**
* Used to access the native implementation in order to call setters
* TODO implement these if needed by console
*/
- public RangeStatisticImpl getActiveRequestCountImpl() {
- return null;
- }
-
- public TimeStatisticImpl getRequestDurationImpl() {
- return null;
- }
-
- public CountStatisticImpl getTotalErrorCountImpl() {
- return null;
- }
-
- public CountStatistic getTotalRequestCountImpl() {
- return null;
+ public RangeStatisticImpl getOpenConnectionCountImpl() {
+ return openConnectionCount;
}
-
}
Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/stats/ConnectorStats.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/stats/ConnectorStats.java?rev=581936&r1=581935&r2=581936&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/stats/ConnectorStats.java (original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/stats/ConnectorStats.java Thu Oct 4 07:46:56 2007
@@ -24,11 +24,11 @@
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.j2ee.statistics.Stats;
+import org.apache.geronimo.management.geronimo.stats.TomcatWebConnectorStatsImpl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tomcat.util.modeler.Registry;
-import org.apache.geronimo.management.stats.WebConnectorStatsImpl;
/**
* This will query MBeanServer and provide jsr77 Stats for connectors.
@@ -45,7 +45,7 @@
private ObjectName tpName;
- private WebConnectorStatsImpl stats = new WebConnectorStatsImpl();
+ private TomcatWebConnectorStatsImpl stats = new TomcatWebConnectorStatsImpl();
public ConnectorStats() {
// Retrieve the MBean server
@@ -72,7 +72,7 @@
}
- private void updateStats(WebConnectorStatsImpl stats, String port) {
+ private void updateStats(TomcatWebConnectorStatsImpl stats, String port) {
Iterator iterator;
Set set;
ObjectName objectName;