geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akulshresh...@apache.org
Subject svn commit: r504777 - in /geronimo/server/trunk/modules: geronimo-core/src/main/java/org/apache/geronimo/pool/ geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/management/impl/ geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/ geronimo-mana...
Date Thu, 08 Feb 2007 03:27:33 GMT
Author: akulshreshtha
Date: Wed Feb  7 19:27:32 2007
New Revision: 504777

URL: http://svn.apache.org/viewvc?view=rev&rev=504777
Log:
GERONIMO-2517 Added resetStats to StatisticsProvider
GERONIMO-1293 Added implementation of resetStats() for tomcat

Modified:
    geronimo/server/trunk/modules/geronimo-core/src/main/java/org/apache/geronimo/pool/ThreadPool.java
    geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/management/impl/JVMImpl.java
    geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyContainerImpl.java
    geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/StatisticsProvider.java
    geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/ConnectorGBean.java
    geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
    geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/stats/ConnectorStats.java
    geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/stats/ModuleStats.java
    geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/StatTest.java

Modified: geronimo/server/trunk/modules/geronimo-core/src/main/java/org/apache/geronimo/pool/ThreadPool.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-core/src/main/java/org/apache/geronimo/pool/ThreadPool.java?view=diff&rev=504777&r1=504776&r2=504777
==============================================================================
--- geronimo/server/trunk/modules/geronimo-core/src/main/java/org/apache/geronimo/pool/ThreadPool.java
(original)
+++ geronimo/server/trunk/modules/geronimo-core/src/main/java/org/apache/geronimo/pool/ThreadPool.java
Wed Feb  7 19:27:32 2007
@@ -121,6 +121,10 @@
         return stats;
     }
 
+    public void resetStats() {
+        // TODO
+    }
+
     public static class PoolStatsImpl extends StatsImpl implements ThreadPoolStats {
         private BoundedRangeStatisticImpl threadsInUse = new BoundedRangeStatisticImpl(
                 "Threads In Use", "",

Modified: geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/management/impl/JVMImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/management/impl/JVMImpl.java?view=diff&rev=504777&r1=504776&r2=504777
==============================================================================
--- geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/management/impl/JVMImpl.java
(original)
+++ geronimo/server/trunk/modules/geronimo-j2ee/src/main/java/org/apache/geronimo/j2ee/management/impl/JVMImpl.java
Wed Feb  7 19:27:32 2007
@@ -174,6 +174,10 @@
         return stats;
     }
 
+    public void resetStats() {
+        // TODO
+    }
+
     public Properties getSystemProperties() {
         return System.getProperties();
     }

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?view=diff&rev=504777&r1=504776&r2=504777
==============================================================================
--- 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 Feb  7 19:27:32 2007
@@ -123,6 +123,10 @@
         return 0L;
     }
 
+    public void resetStats() {
+        // TODO 
+    }
+
     public Stats getStats() {
         if (getCollectStatistics()) {
 

Modified: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/StatisticsProvider.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/StatisticsProvider.java?view=diff&rev=504777&r1=504776&r2=504777
==============================================================================
--- geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/StatisticsProvider.java
(original)
+++ geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/StatisticsProvider.java
Wed Feb  7 19:27:32 2007
@@ -26,9 +26,16 @@
  */
 public interface StatisticsProvider {
     /**
-     * Gets the statistics collected for this class.
+     * 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
      */
     Stats getStats();
+    
+    /**
+     * Reset the startTime for all statistics
+     */
+    void resetStats();
 }

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/ConnectorGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/ConnectorGBean.java?view=diff&rev=504777&r1=504776&r2=504777
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/ConnectorGBean.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/ConnectorGBean.java
Wed Feb  7 19:27:32 2007
@@ -48,7 +48,8 @@
     private String connectHost;
     
 //  JSR77 stats
-    private ConnectorStats conStats = new ConnectorStats();
+    private ConnectorStats connStatsProvider = new ConnectorStats();
+    private boolean reset = true;
 
     public ConnectorGBean(String name, String protocol, String host, int port, TomcatContainer
container) throws Exception {
         super(); // TODO: make it an attribute
@@ -586,10 +587,18 @@
     public boolean isEventProvider() {
         return false;
     }
-
+    
+    public void resetStats() {
+        reset = true;
+    }
+    
     public Stats getStats() {
         String port = String.valueOf(getPort());
-        return conStats.getStats(port);
+        if (reset) {
+            reset = false;
+            return connStatsProvider.getStats(port);
+        }
+        else return connStatsProvider.updateStats(port);
     }
 
     public static final GBeanInfo GBEAN_INFO;

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?view=diff&rev=504777&r1=504776&r2=504777
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
Wed Feb  7 19:27:32 2007
@@ -129,6 +129,7 @@
     
 //  statistics
     private ModuleStats statsProvider;
+    private boolean reset = true;
 
     public TomcatWebAppContext(
             ClassLoader classLoader,
@@ -475,12 +476,15 @@
 //  JSR 77 statistics - The static values are initialized at the time of 
     // creration, getStats return fresh value everytime
     public Stats getStats() {
-        return statsProvider.getStats();
+        if (reset) {
+            reset = false;
+            return statsProvider.getStats();
+        }
+        else return statsProvider.updateStats();
     }
-    
-    // Is this needed ?
-    public void reset() {
-        statsProvider.reset();
+        
+    public void resetStats() {
+        reset = true;
     }
 
     public void doStart() throws Exception {

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?view=diff&rev=504777&r1=504776&r2=504777
==============================================================================
--- 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
Wed Feb  7 19:27:32 2007
@@ -60,12 +60,19 @@
     }
 
     public Stats getStats(String port) {
-        getStats(stats, port);
+        stats.setStartTime();
+        updateStats(stats, port);
+        return stats;
+
+    }
+    
+    public Stats updateStats(String port) {
+        updateStats(stats, port);
         return stats;
 
     }
 
-    private void getStats(WebConnectorStatsImpl stats, String port) {
+    private void updateStats(WebConnectorStatsImpl stats, String port) {
         Iterator iterator;
         Set set;
         ObjectName objectName;
@@ -92,9 +99,8 @@
                     break;
                 }
             }
-            // Any http connector !
-            stats.setStartTime(); // TODO provide a stats enable mechanism
             stats.setLastSampleTime();
+            // Any http connector !
             long maxTime = ((Long) (mBeanServer.getAttribute(grpName, "maxTime"))).longValue();
             long processingTime = ((Long) (mBeanServer.getAttribute(grpName, "processingTime"))).longValue();
             int requestCount = ((Integer) (mBeanServer.getAttribute(grpName, "requestCount"))).intValue();

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/stats/ModuleStats.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/stats/ModuleStats.java?view=diff&rev=504777&r1=504776&r2=504777
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/stats/ModuleStats.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/stats/ModuleStats.java
Wed Feb  7 19:27:32 2007
@@ -69,10 +69,10 @@
             if (objectName.getKeyProperty("path").indexOf(context.getPath()) > -1) {
                 mgrName = objectName;
                 break;
+                
             }
         }
-        // Initialize startTime for all statistics 
-        stats.setStartTime();
+
 //      initialize static values
         stats.setProcessingTime(context.getProcessingTime());
         stats.setStartupTime(context.getStartupTime());
@@ -80,15 +80,17 @@
     }
 
     public Stats getStats() {
+        // Initialize startTime for all statistics 
+        stats.setStartTime();
         // get transient statistics
         updateStats(stats);
         return stats;
-
     }
-
-    public void reset() {
-        // TODO - reset transient statistics
-        // set starTime and lastSampleTime to now, and
+    
+    public Stats updateStats() {
+        // get transient statistics
+        updateStats(stats);
+        return stats;
     }
 
     /*

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/StatTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/StatTest.java?view=diff&rev=504777&r1=504776&r2=504777
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/StatTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/StatTest.java
Wed Feb  7 19:27:32 2007
@@ -45,20 +45,31 @@
             assertEquals("Hello World", reader.readLine());
             //connection.disconnect();
         // Stats stats = (Stats) kernel.getAttribute(webModuleName, "stats");
-        Stats[] allStats = { webModule.getStats(), 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++) {
-                assertFalse(sttsNames[i].equals(stts[i].getName()));
-                aStts = stats.getStatistic(sttsNames[i]);
-                assertTrue("startTime was not set", aStts.getStartTime() != 0);
-                assertTrue("lastSampleTime was not set", aStts.getLastSampleTime() != 0);
-                //System.out.println(aStts);
+
+        int n = 3;
+        for (int k = 0; k < n; k++) {
+            if (k == n-1) {
+                connector.resetStats();
+                webModule.resetStats();
             }
+            //System.out.println("******* NOW IS " + System.currentTimeMillis()); 
+            Stats[] allStats = { webModule.getStats(), 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++) {
+                    assertFalse(sttsNames[i].equals(stts[i].getName()));
+                    aStts = stats.getStatistic(sttsNames[i]);
+                    assertTrue("startTime was not set", aStts.getStartTime() != 0);
+                    assertTrue("lastSampleTime was not set", aStts.getLastSampleTime() !=
0);
+                    //System.out.println("lastSampleTime = " + aStts.getLastSampleTime()
+ "  startTime = " + aStts.getStartTime());
+                    //System.out.println(aStts);
+                }
+            }
+            Thread.sleep(1000);  // collection interval
         }
         connection.disconnect();
     }



Mime
View raw message