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

Ron Sigal ron_sigal at yahoo.com
Tue Nov 28 15:30:23 EST 2006


  User: rsigal  
  Date: 06/11/28 15:30:23

  Modified:    src/main/org/jboss/remoting  Tag: remoting_2_x Client.java
  Log:
  JBREM-640:  Added parameter for one way invocation thread pool  max queue size.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.53.2.6  +66 -7     JBossRemoting/src/main/org/jboss/remoting/Client.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Client.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/Client.java,v
  retrieving revision 1.53.2.5
  retrieving revision 1.53.2.6
  diff -u -b -r1.53.2.5 -r1.53.2.6
  --- Client.java	28 Nov 2006 18:45:36 -0000	1.53.2.5
  +++ Client.java	28 Nov 2006 20:30:23 -0000	1.53.2.6
  @@ -63,7 +63,7 @@
    *
    * @author <a href="mailto:jhaynie at vocalocity.net">Jeff Haynie</a>
    * @author <a href="mailto:telrod at e2technologies.net">Tom Elrod</a>
  - * @version $Revision: 1.53.2.5 $
  + * @version $Revision: 1.53.2.6 $
    */
   public class Client implements Externalizable
   {
  @@ -133,12 +133,25 @@
      public static final String CALLBACK_SERVER_PORT = "callbackServerPort";
      
      
  +   /**
  +    * Key for the configuration map that determines the threadpool size for
  +    * asynchrouous invocations.
  +    */
      public static final String MAX_NUM_ONEWAY_THREADS = "maxNumThreadsOneway";
   
  +   
  +   /**
  +    * Key for the configuration map that determines the queue size for waiting
  +    * asynchronous invocations.
  +    */
  +   public static final String MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE = "maxOnewayThreadPoolQueueSize";
  +   
  +   
      /**
       * Indicated the max number of threads used within oneway thread pool.
       */
      private int maxNumberThreads = MAX_NUM_ONEWAY_THREADS_DEFAULT;
  +   private int maxOnewayThreadPoolQueueSize = -1;
      private static final Logger log = Logger.getLogger(Client.class);
      private ClientInvoker invoker;
      private ClassLoader classloader;
  @@ -667,6 +680,32 @@
      }
   
      /**
  +    * Sets the maximum queue size to use within client pool for
  +    * one way invocations on the client side (meaning oneway invocation
  +    * is handled by thread in this pool and user's call returns immediately)
  +    * Default value is MAX_NUM_ONEWAY_THREADS.
  +    *
  +    * @param numOfThreads
  +    */
  +   public void setMaxOnewayThreadPoolQueueSize(int maxOnewayThreadPoolQueueSize)
  +   {
  +      this.maxOnewayThreadPoolQueueSize = maxOnewayThreadPoolQueueSize;
  +   }
  +
  +   /**
  +    * Gets the maximum queue size to use within client pool for
  +    * one way invocations on the client side (meaning oneway invocation
  +    * is handled by thread in this pool and user's call returns immediately)
  +    * Default value is MAX_NUM_ONEWAY_THREADS.
  +    *
  +    * @return
  +    */
  +   public int getMaxOnewayThreadPoolQueueSize()
  +   {
  +      return this.maxOnewayThreadPoolQueueSize;
  +   }
  +
  +   /**
       * Sets the maximum number of threads to use within client pool for
       * one way invocations on the client side (meaning oneway invocation
       * is handled by thread in this pool and user's call returns immediately)
  @@ -706,23 +745,43 @@
         if (onewayThreadPool == null)
         {
            BasicThreadPool pool = new BasicThreadPool("JBossRemoting Client Oneway");
  -         Object maxNumberThreadsObject = configuration.get(MAX_NUM_ONEWAY_THREADS);
  -         if (maxNumberThreadsObject instanceof String)
  +         
  +         Object param = configuration.get(MAX_NUM_ONEWAY_THREADS);
  +         if (param instanceof String)
  +         {
  +            try
  +            {
  +               maxNumberThreads = Integer.parseInt((String) param);
  +            }
  +            catch (NumberFormatException  e)
  +            {
  +               log.error("maxNumberThreads parameter has invalid format: " + param);
  +            }
  +         }
  +         else
  +         {
  +            log.error("maxNumberThreads parameter must be in integer format: " + param);
  +         }
  +         param = configuration.get(MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE);
  +         if (param instanceof String)
            {
               try
               {
  -               maxNumberThreads = Integer.parseInt((String) maxNumberThreadsObject);
  +               maxOnewayThreadPoolQueueSize = Integer.parseInt((String) param);
               }
               catch (NumberFormatException  e)
               {
  -               log.error("maxNumberThreads parameter has invalid format: " + maxNumberThreadsObject);
  +               log.error("maxOnewayThreadPoolQueueSize parameter has invalid format: " + param);
               }
            }
            else
            {
  -            log.error("maxNumberThreads parameter must be in integer format");
  +            log.error("maxOnewayThreadPoolQueueSize parameter must be in integer format: " + param);
            }
  +         
            pool.setMaximumPoolSize(maxNumberThreads);
  +         if (maxOnewayThreadPoolQueueSize > 0)
  +            pool.setMaximumQueueSize(maxOnewayThreadPoolQueueSize);
            pool.setBlockingMode(BlockingMode.WAIT);
            onewayThreadPool = pool;
         }
  
  
  



More information about the jboss-cvs-commits mailing list