[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting ...
Ron Sigal
ron_sigal at yahoo.com
Thu Feb 15 03:54:42 EST 2007
User: rsigal
Date: 07/02/15 03:54:42
Modified: src/main/org/jboss/remoting Tag: remoting_2_x
ServerInvoker.java
Log:
JBREM-658: (1) Synchronized creation of thread pool. (2) Added queue size parameter for thread pool.
Revision Changes Path
No revision
No revision
1.52.2.27 +65 -30 JBossRemoting/src/main/org/jboss/remoting/ServerInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ServerInvoker.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/ServerInvoker.java,v
retrieving revision 1.52.2.26
retrieving revision 1.52.2.27
diff -u -b -r1.52.2.26 -r1.52.2.27
--- ServerInvoker.java 31 Jan 2007 13:37:04 -0000 1.52.2.26
+++ ServerInvoker.java 15 Feb 2007 08:54:42 -0000 1.52.2.27
@@ -65,7 +65,7 @@
* @author <a href="mailto:tom.elrod at jboss.com">Tom Elrod</a>
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
*
- * @version $Revision: 1.52.2.26 $
+ * @version $Revision: 1.52.2.27 $
*/
public abstract class ServerInvoker extends AbstractInvoker implements ServerInvokerMBean
{
@@ -156,6 +156,12 @@
public static final int MAX_NUM_ONEWAY_THREADS = 100;
/**
+ * 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";
+
+ /**
* The default lease period for clients. This is the number of milliseconds that a client will be
* required to renew their lease with the server. The default value is 5 seconds.
*/
@@ -177,8 +183,10 @@
* Indicated the max number of threads used within oneway thread pool.
*/
private int maxNumberThreads = MAX_NUM_ONEWAY_THREADS;
+ private int maxOnewayThreadPoolQueueSize = -1;
private String onewayThreadPoolClass = null;
private ThreadPool onewayThreadPool;
+ private Object onewayThreadPoolLock = new Object();
private boolean created = false;
private MBeanServer mbeanServer = null;
@@ -195,7 +203,6 @@
private boolean leaseManagement = false;
private Map clientLeases = new HashMap();
-
protected Map handlers = new HashMap();
// If there is only one handler we store a direct reference to it, as an optimisation
@@ -414,15 +421,20 @@
*/
public ThreadPool getOnewayThreadPool()
{
+ synchronized (onewayThreadPoolLock)
+ {
if(onewayThreadPool == null)
{
// if no thread pool class set, then use default BasicThreadPool
if(onewayThreadPoolClass == null || onewayThreadPoolClass.length() == 0)
{
- BasicThreadPool pool = new BasicThreadPool("JBossRemoting Client Oneway");
+ BasicThreadPool pool = new BasicThreadPool("JBossRemoting Server Oneway");
pool.setMaximumPoolSize(maxNumberThreads);
- pool.setBlockingMode(BlockingMode.WAIT);
+ if (maxOnewayThreadPoolQueueSize > 0)
+ pool.setMaximumQueueSize(maxOnewayThreadPoolQueueSize);
+ pool.setBlockingMode(BlockingMode.RUN);
onewayThreadPool = pool;
+ log.debug(this + " created new thread pool");
}
else
{
@@ -454,8 +466,13 @@
}
}
}
+ else
+ {
+ log.trace("reusing oneway thread pool");
+ }
return onewayThreadPool;
}
+ }
/**
* Sets the oneway thread pool to use.
@@ -893,6 +910,24 @@
}
}
+ String param = (String) configuration.get(MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE);
+
+ if (param != null && param.length() > 0)
+ {
+ try
+ {
+ maxOnewayThreadPoolQueueSize = Integer.parseInt((String) param);
+ }
+ catch (NumberFormatException e)
+ {
+ log.error("maxOnewayThreadPoolQueueSize parameter has invalid format: " + param);
+ }
+ }
+ else
+ {
+ log.error("maxOnewayThreadPoolQueueSize parameter must be in integer format: " + param);
+ }
+
onewayThreadPoolClass = (String)config.get(ONEWAY_THREAD_POOL_CLASS_KEY);
String locatorHost = locator.getHost();
More information about the jboss-cvs-commits
mailing list