geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jb...@apache.org
Subject svn commit: r585698 - in /geronimo/server/trunk: modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/ modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/ modules/geronimo-management/src/main/java/org/apache/geronimo/managemen...
Date Wed, 17 Oct 2007 20:59:40 GMT
Author: jbohn
Date: Wed Oct 17 13:59:34 2007
New Revision: 585698

URL: http://svn.apache.org/viewvc?rev=585698&view=rev
Log:
GERONIMO-3490 make JettyContainer and WebManagerPortlet utilize the LazyStatisticsProvider
interface introduced in rev. 585308.  Also updated to use setStartTime() and setLastSampleTime()
from StatsImpl.

Modified:
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainer.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainerImpl.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebContainerStatsImpl.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/StatTest.java
    geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebContainerStats.java
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/webmanager/WebManagerPortlet.java
    geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/webmanager/normal.jsp

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainer.java?rev=585698&r1=585697&r2=585698&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainer.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainer.java
Wed Oct 17 13:59:34 2007
@@ -42,9 +42,9 @@
 
     void resetStats();
 
-    void setCollectStatistics(boolean on);
+    void setStatsOn(boolean on);
 
-    boolean getCollectStatistics();
+    public boolean isStatsOn();
 
     long getCollectStatisticsStarted();
 

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainerImpl.java?rev=585698&r1=585697&r2=585698&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainerImpl.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainerImpl.java
Wed Oct 17 13:59:34 2007
@@ -26,7 +26,7 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
-import org.apache.geronimo.management.StatisticsProvider;
+import org.apache.geronimo.management.LazyStatisticsProvider;
 import org.apache.geronimo.management.geronimo.NetworkConnector;
 import org.apache.geronimo.management.geronimo.WebManager;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
@@ -47,7 +47,7 @@
 /**
  * @version $Rev$ $Date$
  */
-public class JettyContainerImpl implements JettyContainer, SoapHandler, GBeanLifecycle, StatisticsProvider
{
+public class JettyContainerImpl implements JettyContainer, SoapHandler, GBeanLifecycle, LazyStatisticsProvider
{
     /**
      * The default value of JETTY_HOME variable
      */
@@ -69,6 +69,7 @@
     private DefaultHandler defaultHandler = new DefaultHandler();
     private RequestLogHandler requestLogHandler = new RequestLogHandler();
     private boolean statsHandlerInPlace = false;
+    private boolean statsOn=false;
 
     public JettyContainerImpl(String objectName, WebManager manager, String jettyHome, ServerInfo
serverInfo) {
         this.objectName = objectName;
@@ -125,21 +126,18 @@
 
     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);
+        stats.setStartTime();
     }
 
-    public void setCollectStatistics(boolean on) {
+    public long getCollectStatisticsStarted() {
+        return statsHandler.getStatsOnMs();
+    }
+
+    public boolean isStatsOn() {
+        return statsOn;
+    }
+    
+    public void setStatsOn(boolean on) {
         try {
             if (on) {
                 // set the statistics handler if not already done so
@@ -147,7 +145,7 @@
                     handlerCollection.addHandler(statsHandler);
                     statsHandlerInPlace = true;
                 }
-                // clear previous data and set start times
+                // clear previous data and set start time
                 resetStats();
                 // start the handler
                 statsHandler.start();
@@ -159,64 +157,41 @@
                     statsHandlerInPlace=false;
                 }
             }
-            stats.setStatsOn(on);
+            statsOn = on;
         } catch(Exception e) {
             e.printStackTrace();
         }
     }
 
-    public boolean getCollectStatistics() {
-        return statsHandler.isRunning();
-    }
-
-    public long getCollectStatisticsStarted() {
-        return statsHandler.getStatsOnMs();
-    }
-
     public Stats getStats() {
-        if (getCollectStatistics()) {
-            long currentTime = System.currentTimeMillis();
+        if (isStatsOn()) {
+            stats.setLastSampleTime();
             /* 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());
-            stats.getStatsOnMsImpl().setLastSampleTime(currentTime);
         }
         return stats;
     }
@@ -322,7 +297,7 @@
 
     static {
         GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic("Jetty Web Container",
JettyContainerImpl.class);
-        infoBuilder.addAttribute("collectStatistics", Boolean.TYPE, true);
+        infoBuilder.addAttribute("statsOn", Boolean.TYPE, true);
         infoBuilder.addAttribute("collectStatisticsStarted", Long.TYPE, false);
         infoBuilder.addOperation("resetStats");
 
@@ -334,7 +309,7 @@
 
         infoBuilder.addInterface(SoapHandler.class);
         infoBuilder.addInterface(JettyContainer.class);
-        infoBuilder.addInterface(StatisticsProvider.class);
+        infoBuilder.addInterface(LazyStatisticsProvider.class);
         infoBuilder.setConstructor(new String[]{"objectName", "WebManager", "jettyHome",
"ServerInfo"});
 
         GBEAN_INFO = infoBuilder.getBeanInfo();

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebContainerStatsImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebContainerStatsImpl.java?rev=585698&r1=585697&r2=585698&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebContainerStatsImpl.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebContainerStatsImpl.java
Wed Oct 17 13:59:34 2007
@@ -43,8 +43,6 @@
     private CountStatisticImpl response5xx;
     private CountStatisticImpl statsOnMs;               // time elapsed since the stats collection
 
-    private boolean statsOn=false;
-
     public JettyWebContainerStatsImpl() {
         totalRequestCount = new CountStatisticImpl("Request Count", StatisticImpl.UNIT_COUNT,
                 "The number of requests that were handled since statistics gathering started");
@@ -77,14 +75,6 @@
         addStat("Response4xx", response4xx);
         addStat("Response5xx", response5xx);
         addStat("StatsDuration", statsOnMs);
-    }
-
-    public boolean isStatsOn() {
-        return statsOn;
-    }
-
-    public void setStatsOn(boolean on) {
-        statsOn = on;
     }
 
 /**

Modified: 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=585698&r1=585697&r2=585698&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/StatTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/StatTest.java
Wed Oct 17 13:59:34 2007
@@ -45,7 +45,6 @@
         assertTrue("Stats should be off initially", !connector.isStatsOn());
         connector.setStatsOn(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")

Modified: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebContainerStats.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebContainerStats.java?rev=585698&r1=585697&r2=585698&view=diff
==============================================================================
--- geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebContainerStats.java
(original)
+++ geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/geronimo/stats/WebContainerStats.java
Wed Oct 17 13:59:34 2007
@@ -84,9 +84,4 @@
      */
     CountStatistic getStatsOnMs();
 
-    /**
-     * Gets the current state of statistics collection (on or off)
-     */
-    boolean isStatsOn();
-
 }

Modified: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/webmanager/WebManagerPortlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/webmanager/WebManagerPortlet.java?rev=585698&r1=585697&r2=585698&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/webmanager/WebManagerPortlet.java
(original)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/java/org/apache/geronimo/console/webmanager/WebManagerPortlet.java
Wed Oct 17 13:59:34 2007
@@ -24,6 +24,7 @@
 import org.apache.geronimo.management.geronimo.WebManager;
 import org.apache.geronimo.management.geronimo.stats.WebContainerStats;
 import org.apache.geronimo.management.StatisticsProvider;
+import org.apache.geronimo.management.LazyStatisticsProvider;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -64,7 +65,7 @@
                     if (actionRequest.getParameter("stats") != null) {
                         Boolean stats = actionRequest.getParameter("stats").equals("true")
? Boolean.TRUE : Boolean.FALSE;
                         if(server.equals(WEB_SERVER_JETTY)) {
-                            setProperty(container, "collectStatistics", stats);
+                            setProperty(container, "statsOn", stats);
                         }
                         else if (server.equals(WEB_SERVER_TOMCAT)) {
                             //todo:   Any Tomcat specific processing?
@@ -110,9 +111,28 @@
                 if (containers != null) {
                     WebContainer container = containers[0];  //todo: handle multiple
                     if(container.isStatisticsProvider()) {
-                        WebContainerStats webStats = (WebContainerStats) ((StatisticsProvider)container).getStats();
-                        if (webStats.isStatsOn()) {
-                            renderRequest.setAttribute("statsOn", Boolean.TRUE);
+                        boolean populateStats = false;
+                        renderRequest.setAttribute("statsSupported", Boolean.TRUE);  // indicate
that statistics are supported for this container
+
+                        if (container instanceof LazyStatisticsProvider) {
+                            renderRequest.setAttribute("statsLazy", Boolean.TRUE);   // indicate
that enable/disable should be shown for this container
+
+                            if (((LazyStatisticsProvider)container).isStatsOn()) {
+                                renderRequest.setAttribute("statsOn", Boolean.TRUE); // indicate
that stats are to be displayed
+                                populateStats = true;      // this is a Lazy provider and
stats are enabled so populate the stats
+                            } else {
+                                renderRequest.setAttribute("statsOn", Boolean.FALSE);  //
indicate that stats are currently disabled
+                                renderRequest.setAttribute("statsMessage", "Statistics are
not currently being collected.");
+                            }
+                        } else {
+                            renderRequest.setAttribute("statsLazy", Boolean.FALSE);  // indicate
that enable/disable should not be shown for this container
+                            renderRequest.setAttribute("statsOn", Boolean.TRUE);     // indicate
that stats are to be displayed
+                            populateStats=true;     // this is not a lazy provider so just
populate the stats
+                        }
+
+                        if (populateStats) {
+                            // get the detailed stats
+                            WebContainerStats webStats = (WebContainerStats) ((StatisticsProvider)container).getStats();
                             renderRequest.setAttribute("totalRequestCount", new Long(webStats.getTotalRequestCount().getCount()));
                             renderRequest.setAttribute("activeRequestCountCurrent", new Long(webStats.getActiveRequestCount().getCurrent()));
                             renderRequest.setAttribute("activeRequestCountLow", new Long(webStats.getActiveRequestCount().getLowWaterMark()));
@@ -127,12 +147,9 @@
                             renderRequest.setAttribute("response4xx", new Long(webStats.getResponses4xx().getCount()));
                             renderRequest.setAttribute("response5xx", new Long(webStats.getResponses5xx().getCount()));
                             renderRequest.setAttribute("elapsedTime", TimeUtils.formatDuration(webStats.getStatsOnMs().getCount()));
-                        } else {
-                            renderRequest.setAttribute("statsSupported", Boolean.TRUE);
-                            renderRequest.setAttribute("statsMessage", "Statistics are not
currently being collected.");
                         }
                     } else {
-                        renderRequest.setAttribute("statsSupported", Boolean.FALSE);
+                        renderRequest.setAttribute("statsSupported", Boolean.FALSE);   //
indicate that statistics are not supported for this container
                         renderRequest.setAttribute("statsMessage", "Web statistics are not
supported for the current web container.");
                     }
                 } else {

Modified: geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/webmanager/normal.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/webmanager/normal.jsp?rev=585698&r1=585697&r2=585698&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/webmanager/normal.jsp
(original)
+++ geronimo/server/trunk/plugins/console/console-base-portlets/src/main/webapp/WEB-INF/view/webmanager/normal.jsp
Wed Oct 17 13:59:34 2007
@@ -84,7 +84,9 @@
   <tr><td colspan="5" align="left">&nbsp;</td></tr>
   <tr>
     <td colspan="5" align="left"> 
-      <a href="<portlet:actionURL><portlet:param name="stats" value="false"/></portlet:actionURL>">disable</a>&nbsp;

+      <c:if test="${statsLazy}">
+        <a href="<portlet:actionURL><portlet:param name="stats" value="false"/></portlet:actionURL>">disable</a>&nbsp;

+      </c:if>
       <a href="<portlet:renderURL/>">refresh</a>&nbsp; 
       <a href="<portlet:actionURL><portlet:param name="resetStats" value="true"/></portlet:actionURL>">reset</a>

     </td>
@@ -93,7 +95,7 @@
 </c:if>
 <c:if test="${!statsOn}">
   ${statsMessage}<br/><br/>
-  <c:if test="${statsSupported}">
+  <c:if test="${statsLazy}">
     <a href="<portlet:actionURL><portlet:param name="stats" value="true"/></portlet:actionURL>">enable</a>
   </c:if>
 </c:if>



Mime
View raw message