geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akulshresh...@apache.org
Subject svn commit: r585308 - in /geronimo/server/trunk/modules: geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/connector/ geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/ geronimo-management/src/main/java/org/apache/geronimo/management/
Date Wed, 17 Oct 2007 00:51:35 GMT
Author: akulshreshtha
Date: Tue Oct 16 17:51:30 2007
New Revision: 585308

URL: http://svn.apache.org/viewvc?rev=585308&view=rev
Log:
GERONIMO-3490 Adding LazyStatisticsProvider interface to deal with components that provide
              statistics on demand.

Added:
    geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/LazyStatisticsProvider.java
  (with props)
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/StatTest.java

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=585308&r1=585307&r2=585308&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
Tue Oct 16 17:51:30 2007
@@ -30,7 +30,7 @@
 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.management.LazyStatisticsProvider;
 import org.apache.geronimo.system.threads.ThreadPool;
 import org.mortbay.jetty.AbstractConnector;
 
@@ -39,7 +39,7 @@
  *
  * @version $Rev$ $Date$
  */
-public abstract class JettyConnector implements GBeanLifecycle, JettyWebConnector, StatisticsProvider
{
+public abstract class JettyConnector implements GBeanLifecycle, JettyWebConnector, LazyStatisticsProvider
{
     public final static String CONNECTOR_CONTAINER_REFERENCE = "JettyContainer";
     private final JettyContainer container;
     protected final AbstractConnector listener;
@@ -214,7 +214,11 @@
         }
     }
     
-    public void statsOn(Boolean on) {
+    public boolean isStatsOn() {
+	return listener.getStatsOn();
+    }
+    
+    public void setStatsOn(boolean on) {
         listener.setStatsOn(on);
         if (on) stats.setStartTime();
     }
@@ -227,7 +231,7 @@
      * @return gets collected for this class
      */
     public Stats getStats() {
-        if(listener.getStatsOn()) {
+        if(isStatsOn()) {
             stats.setLastSampleTime();
             // connections open
             stats.getOpenConnectionCountImpl().setCurrent(listener.getConnectionsOpen());
@@ -263,7 +267,7 @@
     }
 
     public boolean isStatisticsProvider() {
-        return listener.getStatsOn();
+        return true;
     }
 
     public static final GBeanInfo GBEAN_INFO;
@@ -272,7 +276,8 @@
         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");
+        // this is needed because the getters/setters are not added automatically
+        infoFactory.addOperation("setStatsOn", 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/StatTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/StatTest.java?rev=585308&r1=585307&r2=585308&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
Tue Oct 16 17:51:30 2007
@@ -25,6 +25,7 @@
 import javax.management.ObjectName;
 import javax.management.j2ee.statistics.Statistic;
 import javax.management.j2ee.statistics.Stats;
+import org.apache.geronimo.management.LazyStatisticsProvider;
 
 /**
  * @version $Rev$ $Date$
@@ -40,10 +41,11 @@
         setUpStaticContentServlet(app);
         
         // start statistics collection
-        assertTrue("Stats should be off initially", !connector.isStatisticsProvider());
-        connector.statsOn(true);
+        if (connector instanceof LazyStatisticsProvider) {
+        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")

Added: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/LazyStatisticsProvider.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/LazyStatisticsProvider.java?rev=585308&view=auto
==============================================================================
--- geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/LazyStatisticsProvider.java
(added)
+++ geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/LazyStatisticsProvider.java
Tue Oct 16 17:51:30 2007
@@ -0,0 +1,30 @@
+/**
+ *  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.management;
+
+import javax.management.j2ee.statistics.Stats;
+
+/**
+ * This is a representation of the StatisticsProvider type defined in the J2EE Management
specification.
+ *
+ * @version $Rev$ $Date$
+ */
+public interface LazyStatisticsProvider extends StatisticsProvider{
+    boolean isStatsOn();
+    void setStatsOn(boolean on);
+}

Propchange: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/LazyStatisticsProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/LazyStatisticsProvider.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-management/src/main/java/org/apache/geronimo/management/LazyStatisticsProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message