On Aug 20, 2012, at 10:55 AM, Romain Manni-Bucau wrote:

> that's because we use a linked blocking queue
> 
> maybe we should make it configurable, not sure...


Made it configurable.  Code is basically:

    public static AsynchronousPool create(AppContext appContext) {
        final Options options = appContext.getOptions();

        final String id = appContext.getId();
        final int corePoolSize = options.get("AsynchronousPool.CorePoolSize", 
10);
        final int maximumPoolSize = 
Math.max(options.get("AsynchronousPool.MaximumPoolSize", 20), corePoolSize);
        final Duration keepAliveTime = 
options.get("AsynchronousPool.KeepAliveTime", new Duration(60, 
TimeUnit.SECONDS));
        final BlockingQueue queue = options.get("AsynchronousPool.QueueType", 
QueueType.LINKED).create(options);

        return new AsynchronousPool(id, corePoolSize, maximumPoolSize, 
keepAliveTime, queue);
    }

    private static enum QueueType {
        ARRAY,
        DELAY,
        LINKED,
        PRIORITY,
        SYNCHRONOUS;

        public BlockingQueue create(Options options) {
            switch (this) {
                case ARRAY: {
                    return new 
ArrayBlockingQueue(options.get("AsynchronousPool.QueueSize", 100));
                }
                case DELAY: {
                    return new DelayQueue();
                }
                case LINKED: {
                    return new 
LinkedBlockingQueue(options.get("AsynchronousPool.QueueSize", 
Integer.MAX_VALUE));
                }
                case PRIORITY: {
                    return new PriorityBlockingQueue();
                }
                case SYNCHRONOUS: {
                    return new 
SynchronousQueue(options.get("AsynchronousPool.QueueFair", false));
                }
                default: {
                    // The Options class will throw an error if the user 
supplies an unknown enum string
                    // The only way we can reach this is if we add a new 
QueueType element and forget to
                    // implement it in the above switch statement.
                    throw new IllegalArgumentException("Unknown QueueType type: 
" + this);
                }
            }
        }
    }




> 
> 2012/8/20 David Blevins <david.blev...@gmail.com>
> 
>> 
>> On Aug 20, 2012, at 9:23 AM, Bjorn Danielsson wrote:
>> 
>>> I found out that this setting is what causes the exception:
>>> 
>>> AsynchronousPool.KeepAliveTime = 60
>>> 
>>> Without it, everything is fine!
>>> 
>>> I simply added all three properties for testing, though I really
>>> have no need to tweak KeepAliveTime. But just for the sake of
>>> completeness: what's the intended format for that property?
>> 
>> Should be fixed now.  Forgot that the default TimeUnit needed to be
>> supplied in code in case the user did not supply it.  The format looks like
>> this:
>> 
>> http://tomee.apache.org/configuring-durations.html
>> 
>>> Another strange thing that you mentioned earlier Romain, is
>>> that in my tests the pool size never grows to MaximumPoolSize.
>>> It always stays at CorePoolSize. I use test methods that sleep
>>> for 10 seconds and log the timestamps and the Thread names,
>>> and the results are consistent. I even tried spinning instead
>>> of sleeping, but it made no difference.
>> 
>> I've noticed that too in the past.  These arguments go straight into this
>> object:
>> 
>> 
>> http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html
>> 
>> The section on "Core and maximum pool sizes" seems to imply that it can
>> grow and shrink, however, I've only ever noticed fixed pool size behavior.
>> 
>> 
>> -David
>> 
>>> Romain Manni-Bucau <rmannibu...@gmail.com> wrote:
>>>> i don't manage to reproduce it,
>>>> 
>>>> i simply put in conf/system.properties:
>>>> 
>>>> AsynchronousPool.CorePoolSize = 50
>>>> AsynchronousPool.MaximumPoolSize = 100
>>>> 
>>>> 
>>>> and in the log i get:
>>>> 
>>>> INFO: Using 'AsynchronousPool.CorePoolSize=50'
>>>> 20 août 2012 16:21:40 org.apache.openejb.util.OptionsLog info
>>>> INFO: Using 'AsynchronousPool.MaximumPoolSize=100'
>>>> 
>>>> and no exception,
>>>> 
>>>> maybe you are not completely up to date?
>>>> 
>>>> *Romain Manni-Bucau*
>>>> *Twitter: @rmannibucau*
>>>> *Blog: http://rmannibucau.wordpress.com*
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 2012/8/20 Bjorn Danielsson <bjorn-apa...@lists.cuspycode.com>
>>>> 
>>>>> I built from the latest source (r1374989) and tried the new
>>>>> configuration, but I get strange errors. Just by placing the
>>>>> default values in system.properties in a freshly unpacked
>>>>> TomEE-plus, I got this exception:
>>>>> 
>>>>> INFO: Assembling app: openejb
>>>>> Aug 20, 2012 3:56:28 PM org.apache.openejb.util.OptionsLog info
>>>>> INFO: Using 'AsynchronousPool.CorePoolSize=10'
>>>>> Aug 20, 2012 3:56:28 PM org.apache.openejb.util.OptionsLog info
>>>>> INFO: Using 'AsynchronousPool.MaximumPoolSize=20'
>>>>> Aug 20, 2012 3:56:28 PM org.apache.openejb.util.OptionsLog info
>>>>> INFO: Using 'AsynchronousPool.KeepAliveTime=60'
>>>>> Aug 20, 2012 3:56:28 PM org.apache.openejb.assembler.classic.Assembler
>>>>> destroyApplication
>>>>> INFO: Undeploying app: openejb
>>>>> Aug 20, 2012 3:56:29 PM org.apache.openejb.assembler.classic.Assembler
>>>>> buildContainerSystem
>>>>> SEVERE: Application could not be deployed:  openejb
>>>>> org.apache.openejb.OpenEJBException: Creating application failed:
>> openejb:
>>>>> null
>>>>>       at
>>>>> 
>> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:929)
>>>>>       at
>>>>> 
>> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:521)
>>>>>       at
>>>>> 
>> org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:422)
>>>>>       at
>>>>> 
>> org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:330)
>>>>>       at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:144)
>>>>>       at org.apache.openejb.OpenEJB.init(OpenEJB.java:290)
>>>>>       at
>>>>> 
>> org.apache.tomee.catalina.TomcatLoader.initialize(TomcatLoader.java:231)
>>>>>       at
>>>>> org.apache.tomee.catalina.TomcatLoader.init(TomcatLoader.java:131)
>>>>>       at
>>>>> 
>> org.apache.tomee.catalina.ServerListener.lifecycleEvent(ServerListener.java:113)
>>>>>       at
>>>>> 
>> org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
>>>>>       at
>>>>> 
>> org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
>>>>>       at
>>>>> 
>> org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)
>>>>>       at
>>>>> org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:110)
>>>>>       at org.apache.catalina.startup.Catalina.load(Catalina.java:624)
>>>>>       at org.apache.catalina.startup.Catalina.load(Catalina.java:649)
>>>>>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>       at
>>>>> 
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>>>>>       at
>>>>> 
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>>>>>       at java.lang.reflect.Method.invoke(Method.java:601)
>>>>>       at
>> org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
>>>>>       at
>> org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:450)
>>>>> Caused by: java.lang.NullPointerException
>>>>>       at
>>>>> 
>> java.util.concurrent.ThreadPoolExecutor.<init>(ThreadPoolExecutor.java:1281)
>>>>>       at
>>>>> 
>> java.util.concurrent.ThreadPoolExecutor.<init>(ThreadPoolExecutor.java:1198)
>>>>>       at
>>>>> 
>> org.apache.openejb.async.AsynchronousPool.<init>(AsynchronousPool.java:51)
>>>>>       at
>>>>> 
>> org.apache.openejb.async.AsynchronousPool.create(AsynchronousPool.java:66)
>>>>>       at
>>>>> 
>> org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:589)
>>>>>       ... 20 more
>>>>> 
>>>>> I also tried deploying my webapp and moved the properties to
>>>>> WEB-INF/application.properties, and that produced a similar
>>>>> exception with the same cause, but for my app instead of openejb
>>>>> and with some differences in the lifecycle call chain.
>>>>> 
>>>>> --
>>>>> Björn Danielsson
>>>>> Cuspy Code AB
>>>>> 
>>>>> 
>>>>> Romain Manni-Bucau <rmannibu...@gmail.com> wrote:
>>>>>> FYI, with last David refactoring the config is a bit different from
>> the
>>>>> one
>>>>>> i did, just to keep a track in this thread (jira is up to date),
>>>>> properties
>>>>>> are and can be put in application.properties (META-INF or WEB-INF):
>>>>>> 
>>>>>> AsynchronousPool.CorePoolSize
>>>>>> AsynchronousPool.MaximumPoolSize
>>>>>> AsynchronousPool.KeepAliveTime
>>>>>> 
>>>>>> *Romain Manni-Bucau*
>>>>>> *Twitter: @rmannibucau*
>>>>>> *Blog: http://rmannibucau.wordpress.com*
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 2012/8/20 zeeman <hamz...@fastmail.us>
>>>>>> 
>>>>>>> Great, thanks.
>>>>>>> 
>>>>>>> 
>>>>>>> 
>>>>>>> --
>>>>>>> View this message in context:
>>>>>>> 
>>>>> 
>> http://openejb.979440.n4.nabble.com/Number-of-simultaneous-Asynchronous-threads-tp4656891p4656908.html
>>>>>>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>>>>>> 
>>>>> 
>>> 
>> 
>> 

Reply via email to