You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jb...@apache.org on 2007/10/03 03:00:20 UTC
svn commit: r581452 - in /geronimo/server/branches/2.0:
applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/jmxmanager/
modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/
modules/geronimo-management/s...
Author: jbohn
Date: Tue Oct 2 18:00:19 2007
New Revision: 581452
URL: http://svn.apache.org/viewvc?rev=581452&view=rev
Log:
GERONIMO-2775 late binding of StatisticsHandler and removing from handler collection on stop, changing StatsOnMs to counter, and adding stats startTime and lastSample time to stats. Merged 581420 from trunk
Modified:
geronimo/server/branches/2.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/jmxmanager/JMXManagerHelper.java
geronimo/server/branches/2.0/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainerImpl.java
geronimo/server/branches/2.0/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebContainerStatsImpl.java
geronimo/server/branches/2.0/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebContainerStats.java
Modified: geronimo/server/branches/2.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/jmxmanager/JMXManagerHelper.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/jmxmanager/JMXManagerHelper.java?rev=581452&r1=581451&r2=581452&view=diff
==============================================================================
--- geronimo/server/branches/2.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/jmxmanager/JMXManagerHelper.java (original)
+++ geronimo/server/branches/2.0/applications/console/geronimo-console-standard/src/main/java/org/apache/geronimo/console/jmxmanager/JMXManagerHelper.java Tue Oct 2 18:00:19 2007
@@ -40,6 +40,7 @@
import javax.management.j2ee.statistics.Stats;
import javax.management.j2ee.statistics.TimeStatistic;
+import org.apache.geronimo.console.util.TimeUtils;
import org.apache.geronimo.gbean.AbstractName;
import org.apache.geronimo.gbean.AbstractNameQuery;
import org.apache.geronimo.gbean.GAttributeInfo;
@@ -405,12 +406,12 @@
long count = tStat.getCount();
mbeanStat.add(new String[] { "Count",
Long.toString(count) });
- Date maxTime = new Date(tStat.getMaxTime());
+ String maxTime = TimeUtils.formatDuration(tStat.getMaxTime());
mbeanStat.add(new String[] { "Max Time",
- maxTime.toString() });
- Date minTime = new Date(tStat.getMinTime());
+ maxTime });
+ String minTime = TimeUtils.formatDuration(tStat.getMinTime());
mbeanStat.add(new String[] { "Min Time",
- minTime.toString() });
+ minTime });
long totalTime = tStat.getTotalTime();
mbeanStat.add(new String[] { "Total Time",
Long.toString(totalTime) });
Modified: geronimo/server/branches/2.0/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainerImpl.java?rev=581452&r1=581451&r2=581452&view=diff
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainerImpl.java (original)
+++ geronimo/server/branches/2.0/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainerImpl.java Tue Oct 2 18:00:19 2007
@@ -68,6 +68,7 @@
private ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection();
private DefaultHandler defaultHandler = new DefaultHandler();
private RequestLogHandler requestLogHandler = new RequestLogHandler();
+ private boolean statsHandlerInPlace = false;
public JettyContainerImpl(String objectName, WebManager manager, String jettyHome, ServerInfo serverInfo) {
this.objectName = objectName;
@@ -93,9 +94,6 @@
handlers[2] = requestLogHandler;
handlerCollection.setHandlers(handlers);
server.setHandler(handlerCollection);
- handlerCollection.addHandler(statsHandler);
-
- statsHandler.setServer(server);
stats = new JettyWebContainerStatsImpl();
this.manager = manager;
@@ -127,17 +125,41 @@
public void resetStats() {
statsHandler.statsReset();
+ // Set the start time for each statistic
+ long startTime = System.currentTimeMillis();
+ stats.getTotalRequestCountImpl().setStartTime(startTime);
+ stats.getActiveRequestCountImpl().setStartTime(startTime);
+ stats.getRequestDurationAvgImpl().setStartTime(startTime);
+ stats.getRequestDurationImpl().setStartTime(startTime);
+ stats.getResponses1xxImpl().setStartTime(startTime);
+ stats.getResponses2xxImpl().setStartTime(startTime);
+ stats.getResponses3xxImpl().setStartTime(startTime);
+ stats.getResponses4xxImpl().setStartTime(startTime);
+ stats.getResponses5xxImpl().setStartTime(startTime);
+ stats.getStatsOnMsImpl().setStartTime(startTime);
}
public void setCollectStatistics(boolean on) {
try {
- if(on) {
- statsHandler.start();
+ if (on) {
+ // set the statistics handler if not already done so
+ if (!statsHandlerInPlace) {
+ handlerCollection.addHandler(statsHandler);
+ statsHandlerInPlace = true;
+ }
+ // clear previous data and set start times
+ resetStats();
+ // start the handler
+ statsHandler.start();
} else {
- statsHandler.stop();
+ statsHandler.stop();
+ // hack because stats collection really doesn't really stop when statsHandler.stop() is invoked
+ if (statsHandlerInPlace) {
+ handlerCollection.removeHandler(statsHandler);
+ statsHandlerInPlace=false;
+ }
}
stats.setStatsOn(on);
- statsHandler.statsReset();
} catch(Exception e) {
e.printStackTrace();
}
@@ -153,35 +175,48 @@
public Stats getStats() {
if (getCollectStatistics()) {
-
+ long currentTime = System.currentTimeMillis();
/* set active request count */
stats.getTotalRequestCountImpl().setCount((long)statsHandler.getRequests());
-
+ stats.getTotalRequestCountImpl().setLastSampleTime(currentTime);
+
+
/* set active request range values */
stats.getActiveRequestCountImpl().setCurrent((long)statsHandler.getRequestsActive());
stats.getActiveRequestCountImpl().setLowWaterMark((long)statsHandler.getRequestsActiveMin());
stats.getActiveRequestCountImpl().setHighWaterMark((long)statsHandler.getRequestsActiveMax());
-
+ stats.getActiveRequestCountImpl().setLastSampleTime(currentTime);
+
/* set request duration average time */
stats.getRequestDurationAvgImpl().setCount((long)statsHandler.getRequestsDurationAve()); // Normally this would be calculated
-
+ stats.getRequestDurationAvgImpl().setLastSampleTime(currentTime);
+
/* set request duration time values */
// stats.getRequestDurationImpl().setCount((long)statsHandler.getRequestsDurationCount()); Not yet supported by Jetty
stats.getRequestDurationImpl().setMaxTime((long)statsHandler.getRequestsDurationMax());
stats.getRequestDurationImpl().setMinTime((long)statsHandler.getRequestsDurationMin());
stats.getRequestDurationImpl().setTotalTime((long)statsHandler.getRequestsDurationTotal());
-
+ stats.getRequestDurationImpl().setLastSampleTime(currentTime);
+
/* set request count values*/
stats.getResponses1xxImpl().setCount((long)statsHandler.getResponses1xx());
+ stats.getResponses1xxImpl().setLastSampleTime(currentTime);
+
stats.getResponses2xxImpl().setCount((long)statsHandler.getResponses2xx());
+ stats.getResponses2xxImpl().setLastSampleTime(currentTime);
+
stats.getResponses3xxImpl().setCount((long)statsHandler.getResponses3xx());
+ stats.getResponses3xxImpl().setLastSampleTime(currentTime);
+
stats.getResponses4xxImpl().setCount((long)statsHandler.getResponses4xx());
+ stats.getResponses4xxImpl().setLastSampleTime(currentTime);
+
stats.getResponses5xxImpl().setCount((long)statsHandler.getResponses5xx());
-
+ stats.getResponses5xxImpl().setLastSampleTime(currentTime);
+
/* set elapsed time for stats collection */
stats.getStatsOnMsImpl().setCount((long)statsHandler.getStatsOnMs());
- } else {
- // should probably set the stats object to all zero/null values to avoid unpredicable results
+ stats.getStatsOnMsImpl().setLastSampleTime(currentTime);
}
return stats;
}
@@ -249,7 +284,7 @@
}
public File resolveToJettyHome(String workDir) {
- if(workDir == null) {
+ if (workDir == null) {
return null;
}
return new File(jettyHomeDir, workDir);
@@ -261,9 +296,10 @@
public void doStart() throws Exception {
jettyHomeDir = new File(serverInfo.resolveServerPath(jettyHome != null ? jettyHome : DEFAULT_JETTY_HOME));
- if(!jettyHomeDir.exists()) {
+ if (!jettyHomeDir.exists()) {
jettyHomeDir.mkdirs();
}
+ // start the server
server.start();
}
Modified: geronimo/server/branches/2.0/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebContainerStatsImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebContainerStatsImpl.java?rev=581452&r1=581451&r2=581452&view=diff
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebContainerStatsImpl.java (original)
+++ geronimo/server/branches/2.0/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebContainerStatsImpl.java Tue Oct 2 18:00:19 2007
@@ -41,7 +41,7 @@
private CountStatisticImpl response3xx;
private CountStatisticImpl response4xx;
private CountStatisticImpl response5xx;
- private TimeStatisticImpl statsOnMs; // time elapsed since the stats collection
+ private CountStatisticImpl statsOnMs; // time elapsed since the stats collection
private boolean statsOn=false;
@@ -52,7 +52,7 @@
"The number of requests being processed concurrently");
requestDuration = new TimeStatisticImpl("Request Duration", StatisticImpl.UNIT_TIME_MILLISECOND,
"The length of time that it's taken to handle individual requests");
- requestDurationAvg = new CountStatisticImpl("Request Duration Average", StatisticImpl.UNIT_COUNT,
+ requestDurationAvg = new CountStatisticImpl("Request Duration Average", StatisticImpl.UNIT_TIME_MILLISECOND,
"The average length of time that it's taken to handle individual requests");
response1xx = new CountStatisticImpl("Response 1xx", StatisticImpl.UNIT_COUNT,
"The number of 1xx responses");
@@ -64,7 +64,7 @@
"The number of 4xx responses");
response5xx = new CountStatisticImpl("Response 5xx", StatisticImpl.UNIT_COUNT,
"The number of 5xx responses");
- statsOnMs = new TimeStatisticImpl("Stats Duration", StatisticImpl.UNIT_TIME_MILLISECOND,
+ statsOnMs = new CountStatisticImpl("Stats Duration", StatisticImpl.UNIT_TIME_MILLISECOND,
"The length of time that statistics have been collected.");
addStat("TotalRequestCount", totalRequestCount);
@@ -152,7 +152,7 @@
/**
* @return Time in millis since statistics collection was started.
*/
- public TimeStatistic getStatsOnMs() {
+ public CountStatistic getStatsOnMs() {
return statsOnMs;
}
@@ -220,7 +220,7 @@
/**
* @return Time in millis since statistics collection was started.
*/
- public TimeStatisticImpl getStatsOnMsImpl() {
+ public CountStatisticImpl getStatsOnMsImpl() {
return statsOnMs;
}
}
Modified: geronimo/server/branches/2.0/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebContainerStats.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebContainerStats.java?rev=581452&r1=581451&r2=581452&view=diff
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebContainerStats.java (original)
+++ geronimo/server/branches/2.0/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebContainerStats.java Tue Oct 2 18:00:19 2007
@@ -82,7 +82,7 @@
/**
* Gets the time duration that stats have been active.
*/
- TimeStatistic getStatsOnMs();
+ CountStatistic getStatsOnMs();
/**
* Gets the current state of statistics collection (on or off)