Quantcast

[pool] preparePool that only registers key, doesn't create new object

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[pool] preparePool that only registers key, doesn't create new object

Martin Klepsch
Hey,

With a KeyedObjectPool I can use `setMinIdlePerKey` &  `preparePool` to
"bootstrap" an object pool. Now `preparePool` creates new objects
synchronously and the evictor thread doesn't seem to ensure min idle
objects if there are none yet (since it can't know the keys I guess).

Because of that I run into the situation that the evictor thread creates
objects for keys that are currently being created by `preparePool`. It's
not an absolute deal breaker but it would be nice to be able to register
keys without synchronously creating the minimum idle objects. Instead I'd
like to wait for the evictor thread to pick up newly registered keys and
create the required objects for it.

Unfortunately `register` is private and I don't see another way to trigger
key-registering. (Calling `preparePool` with `minIdlePerKey` set to 0 will
short circuit and not register the key).

Any suggestions welcome!

Cheers :)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [pool] preparePool that only registers key, doesn't create new object

garydgregory
Anyone care to opine?

G

On Fri, Jan 20, 2017 at 7:38 AM, Martin Klepsch <
[hidden email]> wrote:

> Hey,
>
> With a KeyedObjectPool I can use `setMinIdlePerKey` &  `preparePool` to
> "bootstrap" an object pool. Now `preparePool` creates new objects
> synchronously and the evictor thread doesn't seem to ensure min idle
> objects if there are none yet (since it can't know the keys I guess).
>
> Because of that I run into the situation that the evictor thread creates
> objects for keys that are currently being created by `preparePool`. It's
> not an absolute deal breaker but it would be nice to be able to register
> keys without synchronously creating the minimum idle objects. Instead I'd
> like to wait for the evictor thread to pick up newly registered keys and
> create the required objects for it.
>
> Unfortunately `register` is private and I don't see another way to trigger
> key-registering. (Calling `preparePool` with `minIdlePerKey` set to 0 will
> short circuit and not register the key).
>
> Any suggestions welcome!
>
> Cheers :)
>



--
E-Mail: [hidden email] | [hidden email]
Java Persistence with Hibernate, Second Edition
<https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
JUnit in Action, Second Edition
<https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
Spring Batch in Action
<https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [pool] preparePool that only registers key, doesn't create new object

Mark Thomas
On 05/02/17 22:21, Gary Gregory wrote:
> Anyone care to opine?

I think there is a bug in ensureMinIdle. If the objectDeque is null, it
needs to obtain a reference to the objectDeque once created in the for
loop. Otherwise the call from preparePool will always create
minIdlePerKey objects regardless of any objects created by the evictor.

Mark

>
> G
>
> On Fri, Jan 20, 2017 at 7:38 AM, Martin Klepsch <
> [hidden email]> wrote:
>
>> Hey,
>>
>> With a KeyedObjectPool I can use `setMinIdlePerKey` &  `preparePool` to
>> "bootstrap" an object pool. Now `preparePool` creates new objects
>> synchronously and the evictor thread doesn't seem to ensure min idle
>> objects if there are none yet (since it can't know the keys I guess).
>>
>> Because of that I run into the situation that the evictor thread creates
>> objects for keys that are currently being created by `preparePool`. It's
>> not an absolute deal breaker but it would be nice to be able to register
>> keys without synchronously creating the minimum idle objects. Instead I'd
>> like to wait for the evictor thread to pick up newly registered keys and
>> create the required objects for it.
>>
>> Unfortunately `register` is private and I don't see another way to trigger
>> key-registering. (Calling `preparePool` with `minIdlePerKey` set to 0 will
>> short circuit and not register the key).
>>
>> Any suggestions welcome!
>>
>> Cheers :)
>>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [pool] preparePool that only registers key, doesn't create new object

Mark Thomas
On 06/02/17 10:55, Mark Thomas wrote:
> On 05/02/17 22:21, Gary Gregory wrote:
>> Anyone care to opine?
>
> I think there is a bug in ensureMinIdle. If the objectDeque is null, it
> needs to obtain a reference to the objectDeque once created in the for
> loop. Otherwise the call from preparePool will always create
> minIdlePerKey objects regardless of any objects created by the evictor.

Fixed in r1782329 for 2.4.3 onwards.

Mark


>
> Mark
>
>>
>> G
>>
>> On Fri, Jan 20, 2017 at 7:38 AM, Martin Klepsch <
>> [hidden email]> wrote:
>>
>>> Hey,
>>>
>>> With a KeyedObjectPool I can use `setMinIdlePerKey` &  `preparePool` to
>>> "bootstrap" an object pool. Now `preparePool` creates new objects
>>> synchronously and the evictor thread doesn't seem to ensure min idle
>>> objects if there are none yet (since it can't know the keys I guess).
>>>
>>> Because of that I run into the situation that the evictor thread creates
>>> objects for keys that are currently being created by `preparePool`. It's
>>> not an absolute deal breaker but it would be nice to be able to register
>>> keys without synchronously creating the minimum idle objects. Instead
>>> I'd
>>> like to wait for the evictor thread to pick up newly registered keys and
>>> create the required objects for it.
>>>
>>> Unfortunately `register` is private and I don't see another way to
>>> trigger
>>> key-registering. (Calling `preparePool` with `minIdlePerKey` set to 0
>>> will
>>> short circuit and not register the key).
>>>
>>> Any suggestions welcome!
>>>
>>> Cheers :)
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...