directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvermill...@apache.org
Subject svn commit: r465286 - in /directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx: IoServiceManager.java IoServiceManagerMBean.java
Date Wed, 18 Oct 2006 16:12:09 GMT
Author: jvermillard
Date: Wed Oct 18 09:12:07 2006
New Revision: 465286

URL: http://svn.apache.org/viewvc?view=rev&rev=465286
Log:
DIRMINA-280 & DIRMINA-281 
- removed polling argument for startStatcollecting
- added getter and setter for statCollectingPollingTime
- new IoServiceManager constructor fro setting polling time and auto-startup when MBean registered

Modified:
    directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManager.java
    directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManagerMBean.java

Modified: directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManager.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManager.java?view=diff&rev=465286&r1=465285&r2=465286
==============================================================================
--- directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManager.java
(original)
+++ directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManager.java
Wed Oct 18 09:12:07 2006
@@ -23,6 +23,10 @@
 import java.net.SocketAddress;
 import java.util.Iterator;
 
+import javax.management.MBeanRegistration;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
 import org.apache.mina.common.IoService;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.management.IoSessionStat;
@@ -33,16 +37,31 @@
  * @author The Apache Directory Project (mina-dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-public class IoServiceManager implements IoServiceManagerMBean
+public class IoServiceManager implements IoServiceManagerMBean, MBeanRegistration
 {
     private IoService service;
 
     private StatCollector collector = null;
 
+    private int milliSecondsPolling; 
 
-    public IoServiceManager( IoService service )
+    private boolean autoStartCollecting = false;
+    
+    public IoServiceManager( IoService service , int milliSecondsPolling, boolean autoStartCollecting)
     {
+    	this.autoStartCollecting = autoStartCollecting;
         this.service = service;
+        this.milliSecondsPolling = milliSecondsPolling;
+    }
+
+    public IoServiceManager( IoService service, int milliSecondsPolling ) 
+    {
+    	this( service, milliSecondsPolling, false );
+    }
+
+    public IoServiceManager( IoService service ) 
+    {
+    	this( service, 5000, false );
     }
 
 
@@ -60,18 +79,26 @@
     }
 
 
-    public void startCollectingStats( int millisecondsPolling )
+    public void startCollectingStats()
     {
         if ( collector != null && collector.isRunning() )
         {
             throw new RuntimeException( "Already collecting stats" );
         }
 
-        collector = new StatCollector( service, millisecondsPolling );
+        collector = new StatCollector( service, milliSecondsPolling );
         collector.start();
-
     }
-
+    
+    public int getStatsPollingInterval()
+    {
+    	return milliSecondsPolling;
+    }
+    
+    public void setStatsPollingInterval( int millisecondsPolling ) 
+    {
+    	this.milliSecondsPolling = millisecondsPolling;
+    }
 
     public void stopCollectingStats()
     {
@@ -247,4 +274,34 @@
         }
 
     }
-}
+
+	public ObjectName preRegister( MBeanServer server, ObjectName name ) throws Exception 
+	{
+		return name;
+	}
+
+	public void postRegister( Boolean registrationDone ) 
+	{
+		if( registrationDone ) 
+		{
+			if( autoStartCollecting ) 
+			{
+				startCollectingStats();
+			}
+				
+		}
+	}
+	
+	public void preDeregister() throws Exception 
+	{
+		if ( collector != null && collector.isRunning() ) 
+		{
+			stopCollectingStats();
+		}
+	}
+
+	public void postDeregister() 
+	{
+	}
+
+}
\ No newline at end of file

Modified: directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManagerMBean.java
URL: http://svn.apache.org/viewvc/directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManagerMBean.java?view=diff&rev=465286&r1=465285&r2=465286
==============================================================================
--- directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManagerMBean.java
(original)
+++ directory/trunks/mina/integration-jmx/src/main/java/org/apache/mina/integration/jmx/IoServiceManagerMBean.java
Wed Oct 18 09:12:07 2006
@@ -33,9 +33,21 @@
     
     /**
      * start collecting throughput statistics for all the managed sessions 
+     */
+    void startCollectingStats();
+    
+    
+    /**
+     * get the polling interval for collecting statistics
+     * @return configurated polling time in milliseconds
+     */
+    int getStatsPollingInterval();
+    
+    /**
+     * set the polling interval for collecting statistics
      * @param millisecondsPolling polling time in milliseconds like 5000 for computing throughput
every 5 seconds
      */
-    void startCollectingStats(int millisecondsPolling);
+    void setStatsPollingInterval( int millisecondsPolling );
     
     /**
      * stop collecting throughput statistics 



Mime
View raw message