[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/socket ...
Tom Elrod
tom.elrod at jboss.com
Fri Nov 3 14:04:40 EST 2006
User: telrod
Date: 06/11/03 14:04:40
Modified: src/main/org/jboss/remoting/transport/socket
SocketServerInvoker.java
Log:
JBREM-607 - adding idle server thread cleanup for thread pool on server side.
Revision Changes Path
1.32 +47 -1 JBossRemoting/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SocketServerInvoker.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- SocketServerInvoker.java 3 Nov 2006 16:19:16 -0000 1.31
+++ SocketServerInvoker.java 3 Nov 2006 19:04:40 -0000 1.32
@@ -45,7 +45,7 @@
*
* @author <a href="mailto:jhaynie at vocalocity.net">Jeff Haynie</a>
* @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
- * @version $Revision: 1.31 $
+ * @version $Revision: 1.32 $
* @jmx:mbean
*/
public class SocketServerInvoker extends ServerInvoker implements Runnable, SocketServerInvokerMBean
@@ -732,6 +732,52 @@
}
}
}
+
+ // now check idle server threads in the thread pool
+ svrThreadArray = null;
+ synchronized(threadpool)
+ {
+ if(threadpool.size() > 0)
+ {
+ // now need to check the tread pool to remove threads
+ svrThreadArray = threadpool.toArray();
+ }
+ }
+
+ if(trace)
+ {
+ if(svrThreadArray != null)
+ {
+ log.trace("Number of ServerThread in thead pool = " + svrThreadArray.length);
+}
+ }
+
+ if(svrThreadArray != null)
+ {
+ long currentTime = System.currentTimeMillis();
+
+ for(int x = 0; x < svrThreadArray.length; x++)
+ {
+ ServerThread svrThread = (ServerThread)svrThreadArray[x];
+ long idleTime = currentTime - svrThread.getLastRequestTimestamp();
+
+ if(trace)
+ {
+ log.trace("Idle time for ServerThread (" + svrThread + ") is " + idleTime);
+ }
+
+ long idleTimeout = getIdleTimeout() * 1000;
+ if(idleTime > idleTimeout)
+ {
+ if(trace)
+ {
+ log.trace("Idle timeout reached for ServerThread (" + svrThread + ") and will be removed from thread pool.");
+ }
+ threadpool.remove(svrThread);
+ svrThread.shutdown();
+ }
+ }
+ }
}
}
More information about the jboss-cvs-commits
mailing list