[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/socket ...

Tom Elrod tom.elrod at jboss.com
Fri Nov 3 13:58:40 EST 2006


  User: telrod  
  Date: 06/11/03 13:58:40

  Modified:    src/main/org/jboss/remoting/transport/socket  Tag:
                        remoting_2_x SocketServerInvoker.java
  Log:
  JBREM-607 - adding idle timeout for server threads
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.30.2.2  +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.30.2.1
  retrieving revision 1.30.2.2
  diff -u -b -r1.30.2.1 -r1.30.2.2
  --- SocketServerInvoker.java	3 Nov 2006 15:56:32 -0000	1.30.2.1
  +++ SocketServerInvoker.java	3 Nov 2006 18:58:40 -0000	1.30.2.2
  @@ -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.30.2.1 $
  + * @version $Revision: 1.30.2.2 $
    * @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