camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: svn commit: r1021642 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/model/ThreadsDefinition.java test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
Date Wed, 13 Oct 2010 11:56:43 GMT
On Wed, Oct 13, 2010 at 8:33 AM, Willem Jiang <willem.jiang@gmail.com> wrote:
> Hi Claus,
>
> The ThreadsZeroInCoreAndMaxPoolTest hang in lots platforms with JDK5,
> I doubt the JDK5 can't handle the core thread with 0, maybe we should set
> the core thread to 1 if the configure is 0.
>

Just skip this test for now.

>
> On 10/12/10 3:14 PM, davsclaus@apache.org wrote:
>>
>> Author: davsclaus
>> Date: Tue Oct 12 07:14:13 2010
>> New Revision: 1021642
>>
>> URL: http://svn.apache.org/viewvc?rev=1021642&view=rev
>> Log:
>> CAMEL-3220: Fixed threads which now accepts 0 as core pool size.
>>
>> Added:
>>
>> camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
>>       - copied, changed from r1021617,
>> camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolTest.java
>> Modified:
>>
>> camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThreadsDefinition.java
>>
>> Modified:
>> camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThreadsDefinition.java
>> URL:
>> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThreadsDefinition.java?rev=1021642&r1=1021641&r2=1021642&view=diff
>>
>> ==============================================================================
>> ---
>> camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThreadsDefinition.java
>> (original)
>> +++
>> camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThreadsDefinition.java
>> Tue Oct 12 07:14:13 2010
>> @@ -70,32 +70,28 @@ public class ThreadsDefinition extends O
>>
>>      @Override
>>      public Processor createProcessor(RouteContext routeContext) throws
>> Exception {
>> -        // The threads name
>> +        // the threads name
>>          String name = getThreadName() != null ? getThreadName() :
>> "Threads";
>>
>>          // prefer any explicit configured executor service
>>          executorService =
>> ExecutorServiceHelper.getConfiguredExecutorService(routeContext, name,
>> this);
>> +        // if no explicit then create from the options
>>          if (executorService == null) {
>> -            // none was configured so create an executor based on the
>> other parameters
>> -            if (poolSize == null || poolSize<= 0) {
>> -                // use the cached thread pool
>> -                executorService =
>> routeContext.getCamelContext().getExecutorServiceStrategy().newDefaultThreadPool(this,
>> name);
>> -            } else {
>> -                ThreadPoolProfile profile =
>> routeContext.getCamelContext().getExecutorServiceStrategy().getDefaultThreadPoolProfile();
>> -                // use the default thread pool profile as base and then
>> override with values
>> -                // use a custom pool based on the settings
>> -                int max = getMaxPoolSize() != null ? getMaxPoolSize() :
>> profile.getMaxPoolSize();
>> -                long keepAlive = getKeepAliveTime() != null ?
>> getKeepAliveTime() : profile.getKeepAliveTime();
>> -                int maxQueue = getMaxQueueSize() != null ?
>> getMaxQueueSize() : profile.getMaxQueueSize();
>> -                TimeUnit tu = getTimeUnit() != null ? getTimeUnit() :
>> profile.getTimeUnit();
>> -                RejectedExecutionHandler rejected =
>> profile.getRejectedExecutionHandler();
>> -                if (rejectedPolicy != null) {
>> -                    rejected =
>> rejectedPolicy.asRejectedExecutionHandler();
>> -                }
>> -
>> -                executorService =
>> routeContext.getCamelContext().getExecutorServiceStrategy()
>> -                                        .newThreadPool(this,
name,
>> poolSize, max, keepAlive, tu, maxQueue, rejected, true);
>> +            ThreadPoolProfile profile =
>> routeContext.getCamelContext().getExecutorServiceStrategy().getDefaultThreadPoolProfile();
>> +            // use the default thread pool profile as base and then
>> override with values
>> +            // use a custom pool based on the settings
>> +            int core = getPoolSize() != null ? getPoolSize() :
>> profile.getPoolSize();
>> +            int max = getMaxPoolSize() != null ? getMaxPoolSize() :
>> profile.getMaxPoolSize();
>> +            long keepAlive = getKeepAliveTime() != null ?
>> getKeepAliveTime() : profile.getKeepAliveTime();
>> +            int maxQueue = getMaxQueueSize() != null ? getMaxQueueSize()
>> : profile.getMaxQueueSize();
>> +            TimeUnit tu = getTimeUnit() != null ? getTimeUnit() :
>> profile.getTimeUnit();
>> +            RejectedExecutionHandler rejected =
>> profile.getRejectedExecutionHandler();
>> +            if (rejectedPolicy != null) {
>> +                rejected = rejectedPolicy.asRejectedExecutionHandler();
>>              }
>> +
>> +            executorService =
>> routeContext.getCamelContext().getExecutorServiceStrategy()
>> +                                    .newThreadPool(this, name,
core, max,
>> keepAlive, tu, maxQueue, rejected, true);
>>          }
>>
>>          ThreadsProcessor thread = new
>> ThreadsProcessor(routeContext.getCamelContext(), executorService);
>>
>> Copied:
>> camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
>> (from r1021617,
>> camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolTest.java)
>> URL:
>> http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolTest.java&r1=1021617&r2=1021642&rev=1021642&view=diff
>>
>> ==============================================================================
>> ---
>> camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsCoreAndMaxPoolTest.java
>> (original)
>> +++
>> camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ThreadsZeroInCoreAndMaxPoolTest.java
>> Tue Oct 12 07:14:13 2010
>> @@ -22,7 +22,7 @@ import org.apache.camel.builder.RouteBui
>>  /**
>>   * @version $Revision$
>>   */
>> -public class ThreadsCoreAndMaxPoolTest extends ContextTestSupport {
>> +public class ThreadsZeroInCoreAndMaxPoolTest extends ContextTestSupport {
>>
>>      public void testThreadsCoreAndMaxPool() throws Exception {
>>          getMockEndpoint("mock:result").expectedMessageCount(1);
>> @@ -46,13 +46,13 @@ public class ThreadsCoreAndMaxPoolTest e
>>              @Override
>>              public void configure() throws Exception {
>>                  from("direct:start")
>> -                    // will use a a custom thread pool with 5 in core
and
>> 10 as max
>> -                    .threads(5, 10)
>> +                    // will use a a custom thread pool with 0 in core
and
>> 2 max
>> +                    .threads(0, 2)
>>                      .to("mock:result");
>>
>>                  from("direct:foo")
>> -                    // using the builder style
>> -
>>  .threads().poolSize(5).maxPoolSize(10).threadName("myPool")
>> +                    // only change thread name and max, but rely on
>> default settings
>> +                    .threads().maxPoolSize(20).threadName("myPool")
>>                      .to("mock:result");
>>              }
>>          };
>>
>>
>>
>
>
> --
> Willem
> ----------------------------------
> Open Source Integration: http://www.fusesource.com
> Blog:    http://willemjiang.blogspot.com (English)
>         http://jnn.javaeye.com (Chinese)
> Twitter: http://twitter.com/willemjiang
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message