You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Np Shah <np...@tcs.com> on 2010/12/23 19:21:12 UTC

[pool] Queries regarding using org.apache.commons.pool (1.5.5)

Hi All,

I am using, org.apache.commons.pool (1.5.5) for Connection Pooling to
connect to the Maingrame system Using TCP/IP protocol.This pooling  convers
every aspect of our connection   pooling requirement.

I am using TCPVConnectionFactory which extends BasePoolableObjectFactory
with Following methods have been overriden mainly.
public Object makeObject()
public boolean validateObject(Object obj)
public void destroyObject(Object obj)

TCPVConnectionPool which extends GenericObjectPool for this activity and
just calls supers method.

During load testing we have encounter following issue issue that.(e.g 10
threads run parellely for 10 times) .

 Ideally, I was expecting that same  socketConnection(TCPVConnection)
 created will not be used by other  requres until connection is not
 returned to the pool. But it is not  happening.Same Connection is assigned
 to multiple request at the same time.  Is there a synchronization issue
 when no.reaches its maximum active limit. or I am using wrong class for
 implemntation of connection pool.


 I am doing certain operation on TCP/IP layer once connection is
 achieved.so if same connection has been assigned the operation is  getting
 mixed.

 Following is the Spring configuration We are using.
 <bean id="tcpvConnPool" class="tcpvadapter.core.TCPVConnectionPool">
        <constructor-arg>
            <bean class="core.TCPVConnectionFactory">
                <constructor-arg ref="tcpvConfig" />
                <property name="lastUsedTimeLimit" value="25000" />
                <property name="numOfRequestsLimit" value="50" />
                <property name="numOfTrials" value="3" />
            </bean>
        </constructor-arg>
        <property name="maxActive" value="5" />
         <!--    Might be adjusted as per requirement.   -->
        <property name="testOnReturn" value="true" />
        <property name="testOnBorrow" value="true" />
    </bean>

Thanks & regards
Nirav P Shah
Tata Consultancy Services
Mailto: np.shah@tcs.com
Website: http://www.tcs.com

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [pool] Queries regarding using org.apache.commons.pool (1.5.5)

Posted by Np Shah <np...@tcs.com>.
Hi Phil,

Thanks for your prompt reply.

Mentioned below second point was the issue.

2) Make sure your code is not holding onto and reusing references to
instances checked out of the pool.

I was using Singleton object and in that Pool object was singleton
attirbute, so it was being used by multiple instance.

Thanks & regards
Nirav P Shah
Tata Consultancy Services
Mailto: np.shah@tcs.com
Website: http://www.tcs.com
____________________________________________
Experience certainty. IT Services
Business Solutions
Outsourcing
____________________________________________

-----Phil Steitz wrote: -----
To: Commons Users List <us...@commons.apache.org>
From: Phil Steitz <ph...@gmail.com>
Date: 12/24/2010 12:18AM
Subject: Re: [pool] Queries regarding using org.apache.commons.pool (1.5.5)


On Thu, Dec 23, 2010 at 1:21 PM, Np Shah <np...@tcs.com> wrote:

>
> Hi All,
>
> Hi Nirav,


> I am using, org.apache.commons.pool (1.5.5) for Connection Pooling to
> connect to the Maingrame system Using TCP/IP protocol.This pooling
convers
> every aspect of our connection   pooling requirement.
>
> I am using TCPVConnectionFactory which extends BasePoolableObjectFactory
> with Following methods have been overriden mainly.
> public Object makeObject()
> public boolean validateObject(Object obj)
> public void destroyObject(Object obj)
>
> TCPVConnectionPool which extends GenericObjectPool for this activity and
> just calls supers method.
>

Looks OK so far.


>
> During load testing we have encounter following issue issue that.(e.g 10
> threads run parellely for 10 times) .
>
>  Ideally, I was expecting that same  socketConnection(TCPVConnection)
>  created will not be used by other  requres until connection is not
>  returned to the pool.



That should be the case, as long as your code does not pass around or hold
references to the objects it checks out of the pool.

But it is not  happening.Same Connection is assigned
>  to multiple request at the same time.  Is there a synchronization issue
>  when no.reaches its maximum active limit. or I am using wrong class for
>  implemntation of connection pool.
>
>
GenericObjectPool should work.   There are three things to look at, with
the
first the most likely culprit:

1) make sure that your code is not calling returnObject(object) multiple
times on the same instance without a borrow in between.  For example, the
following will cause obj to be added to the pool *twice*

obj = pool.borrowObject();
try {
  - do something with obj
  pool.returnObject(obj)
} catch (exception ex) {
   - handle some problem
} finally {
  pool.returnObject(obj)
}

GenericObjectPool does not test returning objects for equality against
instances already idle in the pool.  It is up to the pool client to ensure
that returnObject is not called repeatedly on the same object instance.
Doing this results in multiple references to the same instance in the pool,
which can result in multiple clients getting references to the same
instance.

2) Make sure your code is not holding onto and reusing references to
instances checked out of the pool.

3) Make sure your factory creates unique instances

Phil

>
>  I am doing certain operation on TCP/IP layer once connection is
>  achieved.so if same connection has been assigned the operation is
getting
>  mixed.
>
>  Following is the Spring configuration We are using.
>  <bean id="tcpvConnPool" class="tcpvadapter.core.TCPVConnectionPool">
>        <constructor-arg>
>            <bean class="core.TCPVConnectionFactory">
>                <constructor-arg ref="tcpvConfig" />
>                <property name="lastUsedTimeLimit" value="25000" />
>                <property name="numOfRequestsLimit" value="50" />
>                <property name="numOfTrials" value="3" />
>            </bean>
>        </constructor-arg>
>        <property name="maxActive" value="5" />
>         <!--    Might be adjusted as per requirement.   -->
>        <property name="testOnReturn" value="true" />
>        <property name="testOnBorrow" value="true" />
>    </bean>
>
> Thanks & regards
> Nirav P Shah
> Tata Consultancy Services
> Mailto: np.shah@tcs.com
> Website: http://www.tcs.com
>
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [pool] Queries regarding using org.apache.commons.pool (1.5.5)

Posted by Phil Steitz <ph...@gmail.com>.
On Thu, Dec 23, 2010 at 1:21 PM, Np Shah <np...@tcs.com> wrote:

>
> Hi All,
>
> Hi Nirav,


> I am using, org.apache.commons.pool (1.5.5) for Connection Pooling to
> connect to the Maingrame system Using TCP/IP protocol.This pooling  convers
> every aspect of our connection   pooling requirement.
>
> I am using TCPVConnectionFactory which extends BasePoolableObjectFactory
> with Following methods have been overriden mainly.
> public Object makeObject()
> public boolean validateObject(Object obj)
> public void destroyObject(Object obj)
>
> TCPVConnectionPool which extends GenericObjectPool for this activity and
> just calls supers method.
>

Looks OK so far.


>
> During load testing we have encounter following issue issue that.(e.g 10
> threads run parellely for 10 times) .
>
>  Ideally, I was expecting that same  socketConnection(TCPVConnection)
>  created will not be used by other  requres until connection is not
>  returned to the pool.



That should be the case, as long as your code does not pass around or hold
references to the objects it checks out of the pool.

But it is not  happening.Same Connection is assigned
>  to multiple request at the same time.  Is there a synchronization issue
>  when no.reaches its maximum active limit. or I am using wrong class for
>  implemntation of connection pool.
>
>
GenericObjectPool should work.   There are three things to look at, with the
first the most likely culprit:

1) make sure that your code is not calling returnObject(object) multiple
times on the same instance without a borrow in between.  For example, the
following will cause obj to be added to the pool *twice*

obj = pool.borrowObject();
try {
  - do something with obj
  pool.returnObject(obj)
} catch (exception ex) {
   - handle some problem
} finally {
  pool.returnObject(obj)
}

GenericObjectPool does not test returning objects for equality against
instances already idle in the pool.  It is up to the pool client to ensure
that returnObject is not called repeatedly on the same object instance.
Doing this results in multiple references to the same instance in the pool,
which can result in multiple clients getting references to the same
instance.

2) Make sure your code is not holding onto and reusing references to
instances checked out of the pool.

3) Make sure your factory creates unique instances

Phil

>
>  I am doing certain operation on TCP/IP layer once connection is
>  achieved.so if same connection has been assigned the operation is  getting
>  mixed.
>
>  Following is the Spring configuration We are using.
>  <bean id="tcpvConnPool" class="tcpvadapter.core.TCPVConnectionPool">
>        <constructor-arg>
>            <bean class="core.TCPVConnectionFactory">
>                <constructor-arg ref="tcpvConfig" />
>                <property name="lastUsedTimeLimit" value="25000" />
>                <property name="numOfRequestsLimit" value="50" />
>                <property name="numOfTrials" value="3" />
>            </bean>
>        </constructor-arg>
>        <property name="maxActive" value="5" />
>         <!--    Might be adjusted as per requirement.   -->
>        <property name="testOnReturn" value="true" />
>        <property name="testOnBorrow" value="true" />
>    </bean>
>
> Thanks & regards
> Nirav P Shah
> Tata Consultancy Services
> Mailto: np.shah@tcs.com
> Website: http://www.tcs.com
>
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>