directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pro...@apache.org
Subject svn commit: r406387 - in /directory/trunks/mina/core/src/main/java/org/apache/mina/filter: ThreadPoolFilter.java ThreadPoolFilterMBean.java
Date Sun, 14 May 2006 17:51:35 GMT
Author: proyal
Date: Sun May 14 10:51:34 2006
New Revision: 406387

URL: http://svn.apache.org/viewcvs?rev=406387&view=rev
Log:
DIRMINA-29 - MBean for the ThreadPoolFilter

Added:
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilterMBean.java
Modified:
    directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilter.java

Modified: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilter.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilter.java?rev=406387&r1=406386&r2=406387&view=diff
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilter.java
(original)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilter.java
Sun May 14 10:51:34 2006
@@ -52,11 +52,11 @@
  * all workers are daemon threads which means that any workers still alive
  * when the JVM terminates will die automatically.
  * </p>
- * 
+ *
  * @author The Apache Directory Project (mina-dev@directory.apache.org)
  * @version $Rev$, $Date$
  */
-public class ThreadPoolFilter extends IoFilterAdapter
+public class ThreadPoolFilter extends IoFilterAdapter implements ThreadPoolFilterMBean
 {
     /**
      * Default maximum size of thread pool (16).
@@ -75,7 +75,7 @@
      */
     private static final Queue threadIdReuseQueue = new Queue();
     private static int threadId = 0;
-    
+
     private static int acquireThreadId()
     {
         synchronized( threadIdReuseQueue )
@@ -91,7 +91,7 @@
             }
         }
     }
-    
+
     private static void releaseThreadId( int id )
     {
         synchronized( threadIdReuseQueue )
@@ -124,7 +124,7 @@
     {
         this( "IoThreadPool" );
     }
-    
+
     /**
      * Creates a new instance of this filter with the specified thread name prefix
      * and other default settings.
@@ -164,7 +164,7 @@
             throw new IllegalArgumentException( "threadNamePrefix is empty." );
         }
         this.threadNamePrefix = threadNamePrefix;
-        
+
         synchronized( poolSizeLock )
         {
             for( Iterator i = allWorkers.iterator(); i.hasNext(); )
@@ -173,7 +173,7 @@
             }
         }
     }
-    
+
     public int getPoolSize()
     {
         synchronized( poolSizeLock )
@@ -204,7 +204,7 @@
         this.keepAliveTime = keepAliveTime;
     }
 
-    public void onPreAdd( IoFilterChain parent, String name, NextFilter nextFilter ) 
+    public void onPreAdd( IoFilterChain parent, String name, NextFilter nextFilter )
         throws Exception
     {
         if( leader == null )
@@ -215,7 +215,7 @@
 
     /**
      * Starts handling new events. This will be called automatically if not
-     * already called the first time this filter is added to a filter chain. 
+     * already called the first time this filter is added to a filter chain.
      */
     public void start()
     {
@@ -239,13 +239,13 @@
             {
                 allWorkers = new ArrayList( this.allWorkers );
             }
-            
+
             // You may not interrupt the current thread.
             if( allWorkers.remove( Thread.currentThread() ) )
             {
                 expectedPoolSize = 1;
             }
-            
+
             for( Iterator i = allWorkers.iterator(); i.hasNext(); )
             {
                 Worker worker = ( Worker ) i.next();
@@ -254,7 +254,7 @@
                     worker.interrupt();
                     try
                     {
-                        // This timeout will help us from 
+                        // This timeout will help us from
                         // infinite lock-up and interrupt workers again.
                         worker.join( 100 );
                     }
@@ -264,7 +264,7 @@
                 }
             }
         }
-        
+
         this.allSessionBuffers.clear();
         this.unfetchedSessionBuffers.clear();
         this.buffers.clear();
@@ -314,12 +314,12 @@
             }
         }
     }
-    
+
     /**
      * Implement this method to fetch (or pop) a {@link SessionBuffer} from
      * the given <tt>unfetchedSessionBuffers</tt>.  The default implementation
      * simply pops the buffer from it.  You could prioritize the fetch order.
-     * 
+     *
      * @return A non-null {@link SessionBuffer}
      */
     protected SessionBuffer fetchSessionBuffer( Queue unfetchedSessionBuffers )
@@ -363,12 +363,12 @@
         {
             this.session = session;
         }
-        
+
         public IoSession getSession()
         {
             return session;
         }
-        
+
         public Queue getEventQueue()
         {
             return eventQueue;
@@ -389,7 +389,7 @@
             increasePoolSize( this );
             setDaemon( true );
         }
-        
+
         public void updateName()
         {
             this.setName( threadNamePrefix + '-' + id );
@@ -408,7 +408,7 @@
                 leader = this;
                 promotionLock.notify();
             }
-            
+
             return true;
         }
 
@@ -518,7 +518,7 @@
 
             long startTime = System.currentTimeMillis();
             long currentTime = System.currentTimeMillis();
-            
+
             synchronized( promotionLock )
             {
                 while( this != leader && !shuttingDown )
@@ -533,7 +533,7 @@
                     {
                         keepAliveTime = Integer.MAX_VALUE;
                     }
-                    
+
                     // Break the loop if there's no remaining keep-alive time.
                     if( keepAliveTime <= 0 )
                     {
@@ -623,24 +623,24 @@
         public static final EventType EXCEPTION = new EventType( "EXCEPTION" );
 
         private final String value;
-        
+
         private EventType( String value )
         {
             this.value = value;
         }
-        
+
         public String toString()
         {
             return value;
         }
     }
-    
+
     protected static class Event
     {
         private final EventType type;
         private final NextFilter nextFilter;
         private final Object data;
-        
+
         public Event( EventType type, NextFilter nextFilter, Object data )
         {
             this.type = type;
@@ -652,25 +652,25 @@
         {
             return data;
         }
-        
+
 
         public NextFilter getNextFilter()
         {
             return nextFilter;
         }
-        
+
 
         public EventType getType()
         {
             return type;
         }
     }
-    
+
     public void sessionCreated( NextFilter nextFilter, IoSession session )
     {
         nextFilter.sessionCreated( session );
     }
-    
+
     public void sessionOpened( NextFilter nextFilter,
                               IoSession session )
     {

Added: directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilterMBean.java
URL: http://svn.apache.org/viewcvs/directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilterMBean.java?rev=406387&view=auto
==============================================================================
--- directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilterMBean.java
(added)
+++ directory/trunks/mina/core/src/main/java/org/apache/mina/filter/ThreadPoolFilterMBean.java
Sun May 14 10:51:34 2006
@@ -0,0 +1,18 @@
+package org.apache.mina.filter;
+
+public interface ThreadPoolFilterMBean
+{
+    String getThreadNamePrefix();
+
+    void setThreadNamePrefix( String threadNamePrefix );
+
+    int getPoolSize();
+
+    int getMaximumPoolSize();
+
+    int getKeepAliveTime();
+
+    void setMaximumPoolSize( int maximumPoolSize );
+
+    void setKeepAliveTime( int keepAliveTime );
+}



Mime
View raw message