commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk Verbeeck <>
Subject Re: [Pool] clustering and seeding
Date Sat, 20 Sep 2003 14:00:05 GMT
Seeding a pool can be done by using the addObject method.

Pools are used to manage objects that do processing, have internal state 
and can only be used by one thread at a time.
Things like parsers, handlers, all kinds of connections/connectors, ...
Static data used by multiple threads at the same should be put in a kind 
of cache. (refactored out of the processing objects)
Your factory then can quickly create the needed processing objects by 
getting the needed data from the cache.

You can start with a simple singleton or hashtable. In a distributed 
system you can use a more advanced cache to manage the data.
Something like JCS - Java Caching System:

In a J2EE environment then you can also try to use entity beans for your 
data needs but carefully test your J2EE server to see if it has a good 


Steve Maring wrote:

>I've created a synchronized factory that is
>responsible for creating object pools and returning
>pool instances to clients wanting to borrow objects
>from the pool.  However, I was wondering if anyone
>could comment of best practices for seeding and
>Some of my pools contain objects that represent the
>result sets of common long running queries.  Of
>coarse, if the pool receives multiple requests to
>borrow objects out of these pools before a makeObject
>can complete, I see an explosion of resources while
>all the requests end up running makeObject and
>ultimately end up throwing away most of those objects
>from the pool once things cool down.  I'd like to
>prime the object pool in the same synchronized method
>that creates the pool.  However, executing a number of
>threads to borrowObject in order to seed the pool
>seems a bit odd.  Is there a more elegant way to
>invoke the makeObject?
>I'm deploying these object pools into a clustered J2EE
>app.  Therefore, every node in the cluster ends up
>with it's own object pool.  This is not a terrible
>thing for non-keyed object pools, but makes the notion
>of a KeyedObjectPool seem kind of silly.  Can anyone
>recommend a strategy for singleton object pools across
>a cluster?
>Many Thanks.
>Steve Maring
>Tampa, FL
>Do you Yahoo!?
>Yahoo! SiteBuilder - Free, easy-to-use web site design software
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message