[jboss-cvs] JBossAS SVN: r99369 - in projects/jboss-threads/trunk: jbossmc/src/main/resources/schema and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Jan 13 16:52:41 EST 2010


Author: david.lloyd at jboss.com
Date: 2010-01-13 16:52:40 -0500 (Wed, 13 Jan 2010)
New Revision: 99369

Modified:
   projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/BoundedQueueThreadPoolExecutorMetaData.java
   projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/QueuelessThreadPoolExecutorMetaData.java
   projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ScheduledThreadPoolExecutorMetaData.java
   projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ThreadsHelper.java
   projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/UnboundedQueueThreadPoolExecutorMetaData.java
   projects/jboss-threads/trunk/jbossmc/src/main/resources/schema/jboss-threads_2_0.xsd
   projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/JBossScheduledThreadPoolExecutor.java
   projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/JBossThreadPoolExecutor.java
   projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/QueueExecutor.java
   projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/QueuelessExecutor.java
   projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/ThreadFactoryExecutor.java
   projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/management/BoundedQueueThreadPoolExecutorMBean.java
   projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/management/ThreadPoolExecutorMBean.java
Log:
Use maxThreads as the default threadpool-size attribute; only add coreThreads when an executor has a notion of both

Modified: projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/BoundedQueueThreadPoolExecutorMetaData.java
===================================================================
--- projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/BoundedQueueThreadPoolExecutorMetaData.java	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/BoundedQueueThreadPoolExecutorMetaData.java	2010-01-13 21:52:40 UTC (rev 99369)
@@ -70,7 +70,7 @@
         return coreThreads;
     }
 
-    @XmlElement(name = "core-threads", required = true)
+    @XmlElement(name = "core-threads")
     public void setCoreThreads(final ScaledCountMetaData coreThreads) {
         this.coreThreads = coreThreads;
     }
@@ -88,7 +88,7 @@
         return maxThreads;
     }
 
-    @XmlElement(name = "max-threads")
+    @XmlElement(name = "max-threads", required = true)
     public void setMaxThreads(final ScaledCountMetaData maxThreads) {
         this.maxThreads = maxThreads;
     }

Modified: projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/QueuelessThreadPoolExecutorMetaData.java
===================================================================
--- projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/QueuelessThreadPoolExecutorMetaData.java	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/QueuelessThreadPoolExecutorMetaData.java	2010-01-13 21:52:40 UTC (rev 99369)
@@ -28,7 +28,7 @@
 public final class QueuelessThreadPoolExecutorMetaData {
     private String name;
     private boolean blocking;
-    private ScaledCountMetaData coreThreads;
+    private ScaledCountMetaData maxThreads;
     private TimeMetaData keepaliveTime;
     private TaskFilterMetaData taskFilter;
     private RefMetaData threadFactory;
@@ -52,13 +52,13 @@
         this.blocking = blocking;
     }
 
-    public ScaledCountMetaData getCoreThreads() {
-        return coreThreads;
+    public ScaledCountMetaData getMaxThreads() {
+        return maxThreads;
     }
 
-    @XmlElement(name = "core-threads", required = true)
-    public void setCoreThreads(final ScaledCountMetaData coreThreads) {
-        this.coreThreads = coreThreads;
+    @XmlElement(name = "max-threads", required = true)
+    public void setMaxThreads(final ScaledCountMetaData maxThreads) {
+        this.maxThreads = maxThreads;
     }
 
     public TimeMetaData getKeepaliveTime() {

Modified: projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ScheduledThreadPoolExecutorMetaData.java
===================================================================
--- projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ScheduledThreadPoolExecutorMetaData.java	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ScheduledThreadPoolExecutorMetaData.java	2010-01-13 21:52:40 UTC (rev 99369)
@@ -30,7 +30,7 @@
 public final class ScheduledThreadPoolExecutorMetaData {
 
     private String name;
-    private ScaledCountMetaData coreThreads;
+    private ScaledCountMetaData maxThreads;
     private TimeMetaData keepaliveTime;
     private TaskFilterMetaData taskFilter;
     private RefMetaData threadFactory;
@@ -44,13 +44,13 @@
         this.name = name;
     }
 
-    public ScaledCountMetaData getCoreThreads() {
-        return coreThreads;
+    public ScaledCountMetaData getMaxThreads() {
+        return maxThreads;
     }
 
-    @XmlElement(name = "core-threads", required = true)
-    public void setCoreThreads(final ScaledCountMetaData coreThreads) {
-        this.coreThreads = coreThreads;
+    @XmlElement(name = "max-threads")
+    public void setMaxThreads(final ScaledCountMetaData maxThreads) {
+        this.maxThreads = maxThreads;
     }
 
     public TimeMetaData getKeepaliveTime() {

Modified: projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ThreadsHelper.java
===================================================================
--- projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ThreadsHelper.java	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/ThreadsHelper.java	2010-01-13 21:52:40 UTC (rev 99369)
@@ -306,7 +306,7 @@
         if (maxThreads != null) {
             builder.addConstructorParameter(Integer.class.getName(), Integer.valueOf(calculateScaledCount(maxThreads)));
         } else {
-            builder.addConstructorParameter(Integer.class.getName(), Integer.valueOf(1));
+            builder.addConstructorParameter(Integer.class.getName(), Integer.valueOf(Integer.MAX_VALUE));
         }
         builder.addConstructorParameter(Boolean.class.getName(), Boolean.valueOf(metaData.isBlocking()));
         final TaskFilterMetaData taskFilter = metaData.getTaskFilter();
@@ -330,7 +330,7 @@
         builder.ignoreStart();
         builder.setStop("shutdown");
         builder.ignoreDestroy();
-        final int coreThreads = calculateScaledCount(metaData.getCoreThreads());
+        final int coreThreads = calculateScaledCount(metaData.getMaxThreads());
         builder.addConstructorParameter("int", Integer.valueOf(coreThreads));
         builder.addConstructorParameter("int", Integer.valueOf(coreThreads));
         final TimeMetaData keepaliveTime = metaData.getKeepaliveTime();
@@ -370,11 +370,14 @@
         builder.ignoreStart();
         builder.setStop("shutdown");
         builder.ignoreDestroy();
-        builder.addConstructorParameter("int", Integer.valueOf(calculateScaledCount(metaData.getCoreThreads())));
+        final ScaledCountMetaData coreThreads = metaData.getCoreThreads();
         final ScaledCountMetaData maxThreads = metaData.getMaxThreads();
-        if (maxThreads != null) {
+        if (coreThreads != null) {
+            builder.addConstructorParameter("int", Integer.valueOf(calculateScaledCount(coreThreads)));
+        } else {
             builder.addConstructorParameter("int", Integer.valueOf(calculateScaledCount(maxThreads)));
         }
+        builder.addConstructorParameter("int", Integer.valueOf(calculateScaledCount(maxThreads)));
         final TimeMetaData keepaliveTime = metaData.getKeepaliveTime();
         if (keepaliveTime != null) {
             builder.addConstructorParameter("long", Long.valueOf(keepaliveTime.getTime()));
@@ -450,6 +453,12 @@
         } else {
             builder.addConstructorParameter("long", builder.createValue(Long.valueOf(Long.MAX_VALUE)));
         }
+        final ScaledCountMetaData maxThreads = metaData.getMaxThreads();
+        if (maxThreads != null) {
+            builder.addPropertyMetaData("maxThreads", Integer.valueOf(calculateScaledCount(maxThreads)));
+        } else {
+            builder.addPropertyMetaData("maxThreads", Integer.valueOf(Integer.MAX_VALUE));
+        }
         if (metaData.isBlocking()) {
             builder.addPropertyMetaData("blocking", Boolean.TRUE);
         }
@@ -464,8 +473,8 @@
         builder.ignoreStart();
         builder.setStop("shutdown");
         builder.ignoreDestroy();
-        final ScaledCountMetaData coreThreads = metaData.getCoreThreads();
-        builder.addConstructorParameter("int", Integer.valueOf(calculateScaledCount(coreThreads)));
+        final ScaledCountMetaData coreThreads = metaData.getMaxThreads();
+        builder.addConstructorParameter("int", coreThreads == null ? Integer.valueOf(1) : Integer.valueOf(calculateScaledCount(coreThreads)));
         final RefMetaData threadFactory = metaData.getThreadFactory();
         if (threadFactory != null) {
             builder.addConstructorParameter(ThreadFactory.class.getName(), builder.createInject(threadFactory.getName()));

Modified: projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/UnboundedQueueThreadPoolExecutorMetaData.java
===================================================================
--- projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/UnboundedQueueThreadPoolExecutorMetaData.java	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/jbossmc/src/main/java/org/jboss/threads/metadata/UnboundedQueueThreadPoolExecutorMetaData.java	2010-01-13 21:52:40 UTC (rev 99369)
@@ -29,7 +29,7 @@
 @XmlType(name = "unbounded-queue-thread-pool-executor", propOrder = {})
 public final class UnboundedQueueThreadPoolExecutorMetaData {
     private String name;
-    private ScaledCountMetaData coreThreads;
+    private ScaledCountMetaData maxThreads;
     private TimeMetaData keepaliveTime;
     private TaskFilterMetaData taskFilter;
     private RefMetaData threadFactory;
@@ -43,13 +43,13 @@
         this.name = name;
     }
 
-    public ScaledCountMetaData getCoreThreads() {
-        return coreThreads;
+    public ScaledCountMetaData getMaxThreads() {
+        return maxThreads;
     }
 
-    @XmlElement(name = "core-threads", required = true)
-    public void setCoreThreads(final ScaledCountMetaData coreThreads) {
-        this.coreThreads = coreThreads;
+    @XmlElement(name = "max-threads", required = true)
+    public void setMaxThreads(final ScaledCountMetaData maxThreads) {
+        this.maxThreads = maxThreads;
     }
 
     public TimeMetaData getKeepaliveTime() {

Modified: projects/jboss-threads/trunk/jbossmc/src/main/resources/schema/jboss-threads_2_0.xsd
===================================================================
--- projects/jboss-threads/trunk/jbossmc/src/main/resources/schema/jboss-threads_2_0.xsd	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/jbossmc/src/main/resources/schema/jboss-threads_2_0.xsd	2010-01-13 21:52:40 UTC (rev 99369)
@@ -168,7 +168,7 @@
 
                 The "name" attribute is the bean name of the created executor.
 
-                The nested "core-threads" element must be used to specify the core thread pool size.  The nested
+                The nested "max-threads" element must be used to specify the thread pool size.  The nested
                 "keepalive-time" element may used to specify the amount of time that pool threads should
                 be kept running when idle; if not specified, threads will run until the executor is shut down.
                 The optional "task-filter" element may be used to specify a filter for each executed task. The
@@ -177,7 +177,7 @@
             </xsd:documentation>
         </xsd:annotation>
         <xsd:all>
-            <xsd:element name="core-threads" type="scaled-count"/>
+            <xsd:element name="max-threads" type="scaled-count"/>
             <xsd:element name="keepalive-time" type="time" minOccurs="0"/>
             <xsd:element name="task-filter" type="task-filter" minOccurs="0"/>
             <xsd:element name="thread-factory" type="ref" minOccurs="0"/>
@@ -201,14 +201,14 @@
                 The "blocking" attribute specifies whether the submitter thread will block if no space is available in
                 this executor.
 
-                The required "core-threads" element specifies the core thread pool size.
-                The optional "max-threads" element may be used to specify the maximum thread pool size; if not specified,
-                it will default to be equal to the core pool size.  The required "queue-length" element specifies the
-                queue length.  The nested "keepalive-time" element may used to specify the amount of time that threads
-                beyond the core pool size should be kept running when idle.  The optional "task-filter" element may be
-                used to specify a filter for each executed task.  The optional "thread-factory" element specifies the
-                bean name of a specific thread factory to use to create worker threads.  The optional "handoff-executor"
-                element specifies an executor to delegate tasks to in the event that a task cannot be accepted.
+                The optional "core-threads" element may be used to specify the core thread pool size which is smaller
+                than the maximum pool size.  The required "max-threads" element specifies the maximum thread pool size.
+                The required "queue-length" element specifies the queue length.  The nested "keepalive-time" element may
+                used to specify the amount of time that threads beyond the core pool size should be kept running when idle.
+                The optional "task-filter" element may be used to specify a filter for each executed task.  The optional
+                "thread-factory" element specifies the bean name of a specific thread factory to use to create worker
+                threads.  The optional "handoff-executor" element specifies an executor to delegate tasks to in the
+                event that a task cannot be accepted.
             </xsd:documentation>
         </xsd:annotation>
         <xsd:all>
@@ -236,7 +236,7 @@
                 The "name" attribute is the bean name of the created executor.  The "blocking" attribute specifies
                 whether the submitter thread will block if no space is available in this executor.
 
-                The "core-threads" element specifies the number of threads to use for this executor before
+                The "max-threads" element specifies the number of threads to use for this executor before
                 tasks cannot be accepted anymore.  The optional "keepalive-time" is used to specify the amount of time
                 that threads should be kept running when idle; by default threads run indefinitely.  The optional
                 "task-filter" element may be used to specify a filter for each executed task.  The optional
@@ -246,7 +246,7 @@
             </xsd:documentation>
         </xsd:annotation>
         <xsd:all>
-            <xsd:element name="core-threads" type="scaled-count"/>
+            <xsd:element name="max-threads" type="scaled-count"/>
             <xsd:element name="keepalive-time" type="time" minOccurs="0"/>
             <xsd:element name="task-filter" type="task-filter" minOccurs="0"/>
             <xsd:element name="thread-factory" type="ref" minOccurs="0"/>
@@ -261,12 +261,12 @@
             <xsd:documentation>
                 A scheduled thread pool executor.  The "name" attribute is the bean name of the created executor.  The
                 "thread-factory" attribute specifies the bean name of the thread factory to use to create worker
-                threads.  The nested "core-threads" element may be used to specify the thread pool size.  The nested
+                threads.  The nested "max-threads" element may be used to specify the thread pool size.  The nested
                 "keepalive-time" element is used to specify the amount of time that threads should be kept running when idle.
             </xsd:documentation>
         </xsd:annotation>
         <xsd:all>
-            <xsd:element name="core-threads" type="scaled-count"/>
+            <xsd:element name="max-threads" type="scaled-count"/>
             <xsd:element name="keepalive-time" type="time" minOccurs="0"/>
             <xsd:element name="task-filter" type="task-filter" minOccurs="0"/>
             <xsd:element name="thread-factory" type="ref" minOccurs="0"/>

Modified: projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/JBossScheduledThreadPoolExecutor.java
===================================================================
--- projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/JBossScheduledThreadPoolExecutor.java	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/JBossScheduledThreadPoolExecutor.java	2010-01-13 21:52:40 UTC (rev 99369)
@@ -80,6 +80,14 @@
         return getLargestPoolSize();
     }
 
+    public int getMaxThreads() {
+        return getCorePoolSize();
+    }
+
+    public void setMaxThreads(final int newSize) {
+        setCorePoolSize(newSize);
+    }
+
     public RejectedExecutionHandler getRejectedExecutionHandler() {
         return ((CountingRejectHandler)super.getRejectedExecutionHandler()).getDelegate();
     }

Modified: projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/JBossThreadPoolExecutor.java
===================================================================
--- projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/JBossThreadPoolExecutor.java	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/JBossThreadPoolExecutor.java	2010-01-13 21:52:40 UTC (rev 99369)
@@ -73,14 +73,22 @@
         setAllowCoreThreadTimeout(allow);
     }
 
-    public int getMaxPoolSize() {
+    public int getMaxThreads() {
         return getMaximumPoolSize();
     }
 
-    public void setMaxPoolSize(final int newSize) {
+    public void setMaxThreads(final int newSize) {
         setMaximumPoolSize(newSize);
     }
 
+    public int getCoreThreads() {
+        return getCorePoolSize();
+    }
+
+    public void setCoreThreads(final int newSize) {
+        setCorePoolSize(newSize);
+    }
+
     public long getKeepAliveTime() {
         return getKeepAliveTime(TimeUnit.MILLISECONDS);
     }

Modified: projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/QueueExecutor.java
===================================================================
--- projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/QueueExecutor.java	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/QueueExecutor.java	2010-01-13 21:52:40 UTC (rev 99369)
@@ -56,8 +56,8 @@
     private final DirectExecutor taskExecutor;
 
     // all protected by poolLock...
-    private int corePoolSize;
-    private int maxPoolSize;
+    private int coreThreads;
+    private int maxThreads;
     private int largestPoolSize;
     private int rejectCount;
     private boolean allowCoreThreadTimeout;
@@ -76,8 +76,8 @@
     /**
      * Create a new instance.
      *
-     * @param corePoolSize the number of threads to create before enqueueing tasks
-     * @param maxPoolSize the maximum number of threads to create
+     * @param coreThreads the number of threads to create before enqueueing tasks
+     * @param maxThreads the maximum number of threads to create
      * @param keepAliveTime the amount of time that an idle thread should remain active
      * @param keepAliveTimeUnit the unit of time for {@code keepAliveTime}
      * @param queue the queue to use for tasks
@@ -86,7 +86,7 @@
      * @param handoffExecutor the executor which is called when blocking is disabled and a task cannot be accepted, or {@code null} to reject the task
      * @param taskExecutor the executor to use to execute tasks
      */
-    public QueueExecutor(final int corePoolSize, final int maxPoolSize, final long keepAliveTime, final TimeUnit keepAliveTimeUnit, final Queue<Runnable> queue, final ThreadFactory threadFactory, final boolean blocking, final Executor handoffExecutor, final DirectExecutor taskExecutor) {
+    public QueueExecutor(final int coreThreads, final int maxThreads, final long keepAliveTime, final TimeUnit keepAliveTimeUnit, final Queue<Runnable> queue, final ThreadFactory threadFactory, final boolean blocking, final Executor handoffExecutor, final DirectExecutor taskExecutor) {
         if (threadFactory == null) {
             throw new NullPointerException("threadFactory is null");
         }
@@ -103,8 +103,8 @@
             // configurable...
             this.keepAliveTime = keepAliveTime;
             this.keepAliveTimeUnit = keepAliveTimeUnit;
-            this.corePoolSize = corePoolSize;
-            this.maxPoolSize = maxPoolSize > corePoolSize ? maxPoolSize : corePoolSize;
+            this.coreThreads = coreThreads;
+            this.maxThreads = maxThreads > coreThreads ? maxThreads : coreThreads;
             this.queue = queue;
             this.blocking = blocking;
             this.handoffExecutor = handoffExecutor;
@@ -117,8 +117,8 @@
     /**
      * Create a new instance.
      *
-     * @param corePoolSize the number of threads to create before enqueueing tasks
-     * @param maxPoolSize the maximum number of threads to create
+     * @param coreThreads the number of threads to create before enqueueing tasks
+     * @param maxThreads the maximum number of threads to create
      * @param keepAliveTime the amount of time that an idle thread should remain active
      * @param keepAliveTimeUnit the unit of time for {@code keepAliveTime}
      * @param queue the queue to use for tasks
@@ -126,15 +126,15 @@
      * @param blocking {@code true} if the executor should block when the queue is full and no threads are available, {@code false} to use the handoff executor
      * @param handoffExecutor the executor which is called when blocking is disabled and a task cannot be accepted, or {@code null} to reject the task
      */
-    public QueueExecutor(final int corePoolSize, final int maxPoolSize, final long keepAliveTime, final TimeUnit keepAliveTimeUnit, final Queue<Runnable> queue, final ThreadFactory threadFactory, final boolean blocking, final Executor handoffExecutor) {
-        this(corePoolSize, maxPoolSize, keepAliveTime, keepAliveTimeUnit, queue, threadFactory, blocking, handoffExecutor, JBossExecutors.directExecutor());
+    public QueueExecutor(final int coreThreads, final int maxThreads, final long keepAliveTime, final TimeUnit keepAliveTimeUnit, final Queue<Runnable> queue, final ThreadFactory threadFactory, final boolean blocking, final Executor handoffExecutor) {
+        this(coreThreads, maxThreads, keepAliveTime, keepAliveTimeUnit, queue, threadFactory, blocking, handoffExecutor, JBossExecutors.directExecutor());
     }
 
     /**
      * Create a new instance.
      *
-     * @param corePoolSize the number of threads to create before enqueueing tasks
-     * @param maxPoolSize the maximum number of threads to create
+     * @param coreThreads the number of threads to create before enqueueing tasks
+     * @param maxThreads the maximum number of threads to create
      * @param keepAliveTime the amount of time that an idle thread should remain active
      * @param keepAliveTimeUnit the unit of time for {@code keepAliveTime}
      * @param queueLength the fixed queue length to use for tasks
@@ -142,8 +142,8 @@
      * @param blocking {@code true} if the executor should block when the queue is full and no threads are available, {@code false} to use the handoff executor
      * @param handoffExecutor the executor which is called when blocking is disabled and a task cannot be accepted, or {@code null} to reject the task
      */
-    public QueueExecutor(final int corePoolSize, final int maxPoolSize, final long keepAliveTime, final TimeUnit keepAliveTimeUnit, final int queueLength, final ThreadFactory threadFactory, final boolean blocking, final Executor handoffExecutor) {
-        this(corePoolSize, maxPoolSize, keepAliveTime, keepAliveTimeUnit, new ArrayQueue<Runnable>(queueLength), threadFactory, blocking, handoffExecutor);
+    public QueueExecutor(final int coreThreads, final int maxThreads, final long keepAliveTime, final TimeUnit keepAliveTimeUnit, final int queueLength, final ThreadFactory threadFactory, final boolean blocking, final Executor handoffExecutor) {
+        this(coreThreads, maxThreads, keepAliveTime, keepAliveTimeUnit, new ArrayQueue<Runnable>(queueLength), threadFactory, blocking, handoffExecutor);
     }
 
     /**
@@ -165,7 +165,7 @@
                 }
                 // Try core thread first, then queue, then extra thread
                 final int count = threadCount;
-                if (count < corePoolSize) {
+                if (count < coreThreads) {
                     startNewThread(task);
                     threadCount = count + 1;
                     return;
@@ -177,7 +177,7 @@
                     return;
                 }
                 // extra threads?
-                if (count < maxPoolSize) {
+                if (count < maxThreads) {
                     startNewThread(task);
                     threadCount = count + 1;
                     return;
@@ -317,31 +317,31 @@
     }
 
     /** {@inheritDoc} */
-    public int getCorePoolSize() {
+    public int getCoreThreads() {
         final Lock lock = this.lock;
         lock.lock();
         try {
-            return corePoolSize;
+            return coreThreads;
         } finally {
             lock.unlock();
         }
     }
 
     /** {@inheritDoc} */
-    public void setCorePoolSize(final int corePoolSize) {
+    public void setCoreThreads(final int coreThreads) {
         final Lock lock = this.lock;
         lock.lock();
         try {
-            final int oldLimit = this.corePoolSize;
-            if (maxPoolSize < corePoolSize) {
+            final int oldLimit = this.coreThreads;
+            if (maxThreads < coreThreads) {
                 // don't let the max thread limit be less than the core thread limit.
                 // the called method will signal as needed
-                setMaxPoolSize(corePoolSize);
-            } else if (oldLimit < corePoolSize) {
+                setMaxThreads(coreThreads);
+            } else if (oldLimit < coreThreads) {
                 // we're growing the number of core threads
                 // therefore signal anyone waiting to add tasks; there might be more threads to add
                 removeCondition.signalAll();
-            } else if (oldLimit > corePoolSize) {
+            } else if (oldLimit > coreThreads) {
                 // we're shrinking the number of core threads
                 // therefore signal anyone waiting to remove tasks so the pool can shrink properly
                 enqueueCondition.signalAll();
@@ -349,38 +349,38 @@
                 // we aren't changing anything...
                 return;
             }
-            this.corePoolSize = corePoolSize;
+            this.coreThreads = coreThreads;
         } finally {
             lock.unlock();
         }
     }
 
     /** {@inheritDoc} */
-    public int getMaxPoolSize() {
+    public int getMaxThreads() {
         final Lock lock = this.lock;
         lock.lock();
         try {
-            return maxPoolSize;
+            return maxThreads;
         } finally {
             lock.unlock();
         }
     }
 
     /** {@inheritDoc} */
-    public void setMaxPoolSize(final int maxPoolSize) {
+    public void setMaxThreads(final int maxThreads) {
         final Lock lock = this.lock;
         lock.lock();
         try {
-            final int oldLimit = this.maxPoolSize;
-            if (maxPoolSize < corePoolSize) {
+            final int oldLimit = this.maxThreads;
+            if (maxThreads < coreThreads) {
                 // don't let the max thread limit be less than the core thread limit.
                 // the called method will signal as needed
-                setCorePoolSize(maxPoolSize);
-            } else if (oldLimit < maxPoolSize) {
+                setCoreThreads(maxThreads);
+            } else if (oldLimit < maxThreads) {
                 // we're growing the number of extra threads
                 // therefore signal anyone waiting to add tasks; there might be more threads to add
                 removeCondition.signalAll();
-            } else if (oldLimit > maxPoolSize) {
+            } else if (oldLimit > maxThreads) {
                 // we're shrinking the number of extra threads
                 // therefore signal anyone waiting to remove tasks so the pool can shrink properly
                 enqueueCondition.signalAll();
@@ -388,7 +388,7 @@
                 // we aren't changing anything...
                 return;
             }
-            this.maxPoolSize = maxPoolSize;
+            this.maxThreads = maxThreads;
         } finally {
             lock.unlock();
         }
@@ -533,9 +533,9 @@
                 for (;;) {
                     // these parameters may change on each iteration
                     final int threadCount = this.threadCount;
-                    final int coreThreadLimit = corePoolSize;
+                    final int coreThreadLimit = coreThreads;
                     final boolean allowCoreThreadTimeout = this.allowCoreThreadTimeout;
-                    if (stop || threadCount > maxPoolSize) {
+                    if (stop || threadCount > maxThreads) {
                         // too many threads.  Handle a task if there is one, otherwise exit
                         return pollTask();
                     } else if (!allowCoreThreadTimeout && threadCount < coreThreadLimit) {

Modified: projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/QueuelessExecutor.java
===================================================================
--- projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/QueuelessExecutor.java	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/QueuelessExecutor.java	2010-01-13 21:52:40 UTC (rev 99369)
@@ -27,6 +27,7 @@
 import java.util.List;
 import java.util.concurrent.AbstractExecutorService;
 import java.util.concurrent.ExecutorService;
+import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.Executor;
 import java.util.concurrent.TimeUnit;
@@ -74,7 +75,7 @@
      * Configuration value.
      * Protected by {@link #lock}
      */
-    private long idleTimeout;
+    private long keepAliveTime;
 
     /**
      * Configuration value.
@@ -96,33 +97,13 @@
     private int largestPoolSize;
     private int rejectedCount;
 
-    public QueuelessExecutor(final ThreadFactory threadFactory, final DirectExecutor taskExecutor, final Executor handoffExecutor, final long idleTimeout) {
+    public QueuelessExecutor(final ThreadFactory threadFactory, final DirectExecutor taskExecutor, final Executor handoffExecutor, final long keepAliveTime) {
         this.threadFactory = threadFactory;
         this.taskExecutor = taskExecutor;
         this.handoffExecutor = handoffExecutor;
-        this.idleTimeout = idleTimeout;
+        this.keepAliveTime = keepAliveTime;
     }
 
-    public long getIdleTimeout() {
-        final Lock lock = this.lock;
-        lock.lock();
-        try {
-            return idleTimeout;
-        } finally {
-            lock.unlock();
-        }
-    }
-
-    public void setIdleTimeout(final long idleTimeout) {
-        final Lock lock = this.lock;
-        lock.lock();
-        try {
-            this.idleTimeout = idleTimeout;
-        } finally {
-            lock.unlock();
-        }
-    }
-
     public int getMaxThreads() {
         final Lock lock = this.lock;
         lock.lock();
@@ -133,37 +114,7 @@
         }
     }
 
-    public void setMaxThreads(final int maxThreads) {
-        final Lock lock = this.lock;
-        lock.lock();
-        try {
-            this.maxThreads = maxThreads;
-        } finally {
-            lock.unlock();
-        }
-    }
-
-    public int getRunningThreads() {
-        final Lock lock = this.lock;
-        lock.lock();
-        try {
-            return runningThreads.size();
-        } finally {
-            lock.unlock();
-        }
-    }
-
-    public int getCorePoolSize() {
-        final Lock lock = this.lock;
-        lock.lock();
-        try {
-            return maxThreads;
-        } finally {
-            lock.unlock();
-        }
-    }
-
-    public void setCorePoolSize(final int newSize) {
+    public void setMaxThreads(final int newSize) {
         if (newSize < 1) {
             throw new IllegalArgumentException("Pool size must be at least 1");
         }
@@ -180,7 +131,7 @@
         final Lock lock = this.lock;
         lock.lock();
         try {
-            return idleTimeout;
+            return keepAliveTime;
         } finally {
             lock.unlock();
         }
@@ -190,7 +141,7 @@
         final Lock lock = this.lock;
         lock.lock();
         try {
-            idleTimeout = milliseconds;
+            keepAliveTime = milliseconds;
         } finally {
             lock.unlock();
         }
@@ -403,6 +354,8 @@
         }
         if (executor != null) {
             executor.execute(command);
+        } else {
+            throw new RejectedExecutionException();
         }
     }
 
@@ -423,7 +376,7 @@
         }
 
         private boolean awaitTimed(Condition condition, long idleSince) {
-            final long end = clipHigh(System.currentTimeMillis() + idleTimeout);
+            final long end = clipHigh(System.currentTimeMillis() + keepAliveTime);
             long remaining = end - idleSince;
             if (remaining < 0L) {
                 return false;

Modified: projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/ThreadFactoryExecutor.java
===================================================================
--- projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/ThreadFactoryExecutor.java	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/ThreadFactoryExecutor.java	2010-01-13 21:52:40 UTC (rev 99369)
@@ -27,9 +27,9 @@
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.atomic.AtomicInteger;
-import org.jboss.threads.management.ThreadExecutorMBean;
+import org.jboss.threads.management.BoundedThreadPoolExecutorMBean;
 
-class ThreadFactoryExecutor implements Executor, ThreadExecutorMBean {
+class ThreadFactoryExecutor implements Executor, BoundedThreadPoolExecutorMBean {
 
     private final ThreadFactory factory;
     private final Semaphore limitSemaphore;
@@ -147,6 +147,16 @@
         return rejected.get();
     }
 
+    public long getKeepAliveTime() {
+        return 0L;
+    }
+
+    public void setKeepAliveTime(final long milliseconds) {
+        if (milliseconds != 0L) {
+            throw new IllegalArgumentException("Keep-alive may only be set to 0ms");
+        }
+    }
+
     public String toString() {
         return String.format("%s (%s)", super.toString(), factory);
     }

Modified: projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/management/BoundedQueueThreadPoolExecutorMBean.java
===================================================================
--- projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/management/BoundedQueueThreadPoolExecutorMBean.java	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/management/BoundedQueueThreadPoolExecutorMBean.java	2010-01-13 21:52:40 UTC (rev 99369)
@@ -30,9 +30,7 @@
 
     void setAllowCoreThreadTimeout(boolean allow);
 
-    int getMaxPoolSize();
+    int getCoreThreads();
 
-    void setMaxPoolSize(int newSize);
-
-
+    void setCoreThreads(int newSize);
 }

Modified: projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/management/ThreadPoolExecutorMBean.java
===================================================================
--- projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/management/ThreadPoolExecutorMBean.java	2010-01-13 21:41:36 UTC (rev 99368)
+++ projects/jboss-threads/trunk/main/src/main/java/org/jboss/threads/management/ThreadPoolExecutorMBean.java	2010-01-13 21:52:40 UTC (rev 99369)
@@ -26,9 +26,9 @@
  *
  */
 public interface ThreadPoolExecutorMBean extends ThreadExecutorMBean {
-    int getCorePoolSize();
+    int getMaxThreads();
 
-    void setCorePoolSize(int newSize);
+    void setMaxThreads(int newSize);
 
     long getKeepAliveTime();
 




More information about the jboss-cvs-commits mailing list