You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Donie Kelly <do...@tecnomen.ie> on 2003/03/19 12:07:46 UTC

[Pool] Newbie question on pools (modified subject)

Hi
Sorry about posting without proper subject. I'm resending in case a lot of
you are using filtering.
 
Donie
 
-----Original Message-----
From: Donie Kelly [mailto:donie.kelly@tecnomen.ie]
Sent: 19 March 2003 11:03
To: Jakarta Commons (E-mail)
Subject: Newbie question on pools
 
Hi all
 
I've looked through the source and all the javadocs and I cannot find a way
to do the following with the pool library. Note I have marked that I can
achieve parts of the intended functions:
 
1)      Get a connection from the pool (I can do this)
2)      Use the connection (I can do this)
3)      Return the connection to the pool (I can do this)
4)      When I get a connection and I have detected it has failed how can I
mark it for removal as it may have been dropped by the server at the other
end of the connection (HOW TO??)
 
 
I understand that I can use the pool ObjectPoolFactory to test connections
on retrieval and submission to the pool but this is an overhead I don't
want. I want the pool to drop the connection when the application has
decided it is bad. I know the other way is desirable and I will probably
implement this by using the evictor thread but surely it's important for the
application to be able to decide that the connection is useless??
 
The connection I'm pooling is a Corba connection object.
Thanks for any insights or help.
 
Donie 
 

Re: [Pool] Newbie question on pools (modified subject)

Posted by Rodney Waldhoff <rw...@apache.org>.
In addition to all the things Craig lists, if you're using the
commons-pool API directly, you can use pool.invalidateObject() to have the
pool dispose of a previously active object. (E.g., if you know that some
object you've borrowed has gone bad.)

On Wed, 19 Mar 2003, Craig R. McClanahan wrote:

>
>
> On Wed, 19 Mar 2003, Donie Kelly wrote:
>
> > Date: Wed, 19 Mar 2003 11:07:46 -0000
> > From: Donie Kelly <do...@tecnomen.ie>
> > Reply-To: Jakarta Commons Users List <co...@jakarta.apache.org>
> > To: 'Jakarta Commons Users List' <co...@jakarta.apache.org>
> > Subject: [Pool] Newbie question on pools (modified subject)
> >
> > Hi
> > Sorry about posting without proper subject. I'm resending in case a lot of
> > you are using filtering.
> >
> > Donie
> >
> > -----Original Message-----
> > From: Donie Kelly [mailto:donie.kelly@tecnomen.ie]
> > Sent: 19 March 2003 11:03
> > To: Jakarta Commons (E-mail)
> > Subject: Newbie question on pools
> >
> > Hi all
> >
> > I've looked through the source and all the javadocs and I cannot find a way
> > to do the following with the pool library. Note I have marked that I can
> > achieve parts of the intended functions:
> >
> > 1)      Get a connection from the pool (I can do this)
> > 2)      Use the connection (I can do this)
> > 3)      Return the connection to the pool (I can do this)
> > 4)      When I get a connection and I have detected it has failed how can I
> > mark it for removal as it may have been dropped by the server at the other
> > end of the connection (HOW TO??)
> >
> >
>
> If you are using the [pool] APIs directly, you can set the testOnBorrow
> and/or testOnReturn properties to validate objects as they are being
> borrowed, or as they are being returned.  See the [pool] API docs on
> GenericObjectPool for more info.
>
> If you are using something like BasicDataSource from [dbcp] for database
> connection pools, these APIs let you define a 'validationQuery' parameter
> that represents an SQL SELECT statement.  The pool will ensure that this
> statement executes with no failures before letting you borrow it, throwing
> the connection away if not.  There are other tweaks for things like
> periodically testing the idle connections in the pool as well.
>
> > I understand that I can use the pool ObjectPoolFactory to test connections
> > on retrieval and submission to the pool but this is an overhead I don't
> > want. I want the pool to drop the connection when the application has
> > decided it is bad. I know the other way is desirable and I will probably
> > implement this by using the evictor thread but surely it's important for the
> > application to be able to decide that the connection is useless??
> >
>
> If you don't want the overhead of testOnBorrow (it's a price I feel
> willing to pay, because the app should not even have to worry about things
> like this), then you probably want to explore the testOnReturn thing
> instead.
>
> > The connection I'm pooling is a Corba connection object.
> > Thanks for any insights or help.
> >
> > Donie
> >
> >
>
> Craig
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

Re: [Pool] Newbie question on pools (modified subject)

Posted by Stephen Westbom <sw...@yahoo.com>.
I had a similar problem when I was building a pool of EJB Homes, I don't like
the overhead of testing on every use.  

I put my pool object in a wrapper class that has a boolean value that you can
set on it.  When the object is returned to the pool the test on return logic is
to throw out the object if the boolean is set to true.

I hope this helps.

Stephen

--- "Craig R. McClanahan" <cr...@apache.org> wrote:
> 
> 
> On Wed, 19 Mar 2003, Donie Kelly wrote:
> 
> > Date: Wed, 19 Mar 2003 11:07:46 -0000
> > From: Donie Kelly <do...@tecnomen.ie>
> > Reply-To: Jakarta Commons Users List <co...@jakarta.apache.org>
> > To: 'Jakarta Commons Users List' <co...@jakarta.apache.org>
> > Subject: [Pool] Newbie question on pools (modified subject)
> >
> > Hi
> > Sorry about posting without proper subject. I'm resending in case a lot of
> > you are using filtering.
> >
> > Donie
> >
> > -----Original Message-----
> > From: Donie Kelly [mailto:donie.kelly@tecnomen.ie]
> > Sent: 19 March 2003 11:03
> > To: Jakarta Commons (E-mail)
> > Subject: Newbie question on pools
> >
> > Hi all
> >
> > I've looked through the source and all the javadocs and I cannot find a way
> > to do the following with the pool library. Note I have marked that I can
> > achieve parts of the intended functions:
> >
> > 1)      Get a connection from the pool (I can do this)
> > 2)      Use the connection (I can do this)
> > 3)      Return the connection to the pool (I can do this)
> > 4)      When I get a connection and I have detected it has failed how can I
> > mark it for removal as it may have been dropped by the server at the other
> > end of the connection (HOW TO??)
> >
> >
> 
> If you are using the [pool] APIs directly, you can set the testOnBorrow
> and/or testOnReturn properties to validate objects as they are being
> borrowed, or as they are being returned.  See the [pool] API docs on
> GenericObjectPool for more info.
> 
> If you are using something like BasicDataSource from [dbcp] for database
> connection pools, these APIs let you define a 'validationQuery' parameter
> that represents an SQL SELECT statement.  The pool will ensure that this
> statement executes with no failures before letting you borrow it, throwing
> the connection away if not.  There are other tweaks for things like
> periodically testing the idle connections in the pool as well.
> 
> > I understand that I can use the pool ObjectPoolFactory to test connections
> > on retrieval and submission to the pool but this is an overhead I don't
> > want. I want the pool to drop the connection when the application has
> > decided it is bad. I know the other way is desirable and I will probably
> > implement this by using the evictor thread but surely it's important for
> the
> > application to be able to decide that the connection is useless??
> >
> 
> If you don't want the overhead of testOnBorrow (it's a price I feel
> willing to pay, because the app should not even have to worry about things
> like this), then you probably want to explore the testOnReturn thing
> instead.
> 
> > The connection I'm pooling is a Corba connection object.
> > Thanks for any insights or help.
> >
> > Donie
> >
> >
> 
> Craig
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com

Re: [Pool] Newbie question on pools (modified subject)

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Wed, 19 Mar 2003, Donie Kelly wrote:

> Date: Wed, 19 Mar 2003 11:07:46 -0000
> From: Donie Kelly <do...@tecnomen.ie>
> Reply-To: Jakarta Commons Users List <co...@jakarta.apache.org>
> To: 'Jakarta Commons Users List' <co...@jakarta.apache.org>
> Subject: [Pool] Newbie question on pools (modified subject)
>
> Hi
> Sorry about posting without proper subject. I'm resending in case a lot of
> you are using filtering.
>
> Donie
>
> -----Original Message-----
> From: Donie Kelly [mailto:donie.kelly@tecnomen.ie]
> Sent: 19 March 2003 11:03
> To: Jakarta Commons (E-mail)
> Subject: Newbie question on pools
>
> Hi all
>
> I've looked through the source and all the javadocs and I cannot find a way
> to do the following with the pool library. Note I have marked that I can
> achieve parts of the intended functions:
>
> 1)      Get a connection from the pool (I can do this)
> 2)      Use the connection (I can do this)
> 3)      Return the connection to the pool (I can do this)
> 4)      When I get a connection and I have detected it has failed how can I
> mark it for removal as it may have been dropped by the server at the other
> end of the connection (HOW TO??)
>
>

If you are using the [pool] APIs directly, you can set the testOnBorrow
and/or testOnReturn properties to validate objects as they are being
borrowed, or as they are being returned.  See the [pool] API docs on
GenericObjectPool for more info.

If you are using something like BasicDataSource from [dbcp] for database
connection pools, these APIs let you define a 'validationQuery' parameter
that represents an SQL SELECT statement.  The pool will ensure that this
statement executes with no failures before letting you borrow it, throwing
the connection away if not.  There are other tweaks for things like
periodically testing the idle connections in the pool as well.

> I understand that I can use the pool ObjectPoolFactory to test connections
> on retrieval and submission to the pool but this is an overhead I don't
> want. I want the pool to drop the connection when the application has
> decided it is bad. I know the other way is desirable and I will probably
> implement this by using the evictor thread but surely it's important for the
> application to be able to decide that the connection is useless??
>

If you don't want the overhead of testOnBorrow (it's a price I feel
willing to pay, because the app should not even have to worry about things
like this), then you probably want to explore the testOnReturn thing
instead.

> The connection I'm pooling is a Corba connection object.
> Thanks for any insights or help.
>
> Donie
>
>

Craig