[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ojb-user
Subject:    Re: Pool Info?
From:       Armin Waibel <arminw () apache ! org>
Date:       2005-02-10 21:34:14
Message-ID: 420BD356.9020903 () apache ! org
[Download RAW message or body]

Hi Bob,

> Also, based on the configuration, I would expect the connection to be 
shutdown after my 60 second Thread.sleep, but as you can see, the
connection is still listed as active. Am I looking in the right place?
> 

You are locking in the right place! The PB-pool is not intended to
support automatic cleanup of abandoned PB instances, because abandoned
PB instances are a software bug (you forget to close a PB instance in
your code).
If you need such an service I recommend to write your on service like
- when lookup an PB instance add it to an service class "PBTrace"
- PBTrance implements PBStateListener and will be add to each PB
instance as a temporary listener
- On PB.close call PBTrace was notified by OJB and can remove the
current PB from the list of active PB.
- Since PBTrace has a list of all active PB handles you can implement
automatic cleanup

regards,
Armin

Bob Damato wrote:
> Ok, I think I understand now. Here's what I've found. When I run the following code \
>                 ...
> --------------------------------------
> PersistenceBroker pb = ...   <--- get a broker but don't close
> Properties p = ((PersistenceBrokerFactoryDefaultImpl)PersistenceBrokerFactoryFactory.instance()).getPoolConfiguration();
>  Iterator i = p.keySet().iterator();
> while (i.hasNext())
> {
> 	String key = i.next().toString();
> 	System.out.println(key + ": " + p.getProperty(key));
> }
> System.out.println("Active connections: " + \
> PersistenceBrokerFactoryFactory.instance().activePersistenceBroker()); \
> Thread.sleep(60000); System.out.println("Active connections: " + \
>                 PersistenceBrokerFactoryFactory.instance().activePersistenceBroker());	
>                 
> --------------------------------------
> 
> ...I see some configuration options that I don't know how to set (marked with a -). \
> These aren't in my OJB.properties file and adding them didn't seem to work. 
> + whenExhaustedAction: 1
> + maxIdle: -1
> + maxActive: 100                            
> + maxWait: 20000
> - removeAbandoned: false
> - numTestsPerEvictionRun: 10
> - testWhileIdle: false
> + minEvictableIdleTimeMillis: 10000
> - testOnReturn: false
> - logAbandoned: false  
> - removeAbandonedTimeout: 300
> + timeBetweenEvictionRunsMillis: 5000
> - testOnBorrow: false
> Active connections: 1
> Active connections: 1
> 
> Also, based on the configuration, I would expect the connection to be shutdown \
> after my 60 second Thread.sleep, but as you can see, the connection is still listed \
> as active. Am I looking in the right place? 
> 
> -----Original Message-----
> From: Armin Waibel [mailto:arminw@apache.org]
> Sent: Thursday, February 10, 2005 1:45 PM
> To: OJB Users List
> Subject: Re: Pool Info?
> 
> 
> Hi Bob,
> 
> Bob Damato wrote:
> 
> > Hello Armin, Thank you for the information. I extended the \
> > ConnectionFactoryPooledImpl and I was able to gain access to the connection pool \
> > information.  
> > Another question: Is there a way that I can set up the pool to notify me
> > (log entry, email, electric shock etc) if a broker is evicted from the pool?
> > 
> 
> 
> you have to differ between the connection-pool and the PB pool. The 
> PB-pool was setup in PersistenceBrokerFactoryDefaultImpl.
> Think commons-pool does not provide any Listener to get notification of 
> pooling actions.
> 
> I think you can ask for the number of active PB directly in OJB doing
> 
> int active = 
> PersistenceBrokerFactoryFactory.instance().activePersistenceBroker()
> 
> If you need more detailed control have a look in 
> PersistenceBrokerFactoryDefaultImpl and extend it if possible.
> 
> I will try to implement some basic monitor methods for connection/PB 
> pool in OJB 1.1 - suggestions are welcome.
> 
> regards,
> Armin
> 
> 
> > -----Original Message-----
> > From: Armin Waibel [mailto:arminw@apache.org]
> > Sent: Wednesday, February 09, 2005 4:07 PM
> > To: OJB Users List
> > Subject: Re: Pool Info?
> > 
> > 
> > Hi Bob,
> > 
> > currently there are no methods to access the used commons-pool instances 
> > in ConnectionFactoryPooledImpl. I recommend to extend 
> > ConnectionFactoryPooledImpl and override method #createConnectionPool.
> > 
> > public ObjectPool createConnectionPool(JdbcConnectionDescriptor jcd)
> > {
> > ObjectPool pool = super.createConnectionPool...
> > // add 'pool' instance to list or map, ObjectPool has methods to
> > // lookup active connections, idle connections ...
> > return pool;
> > }
> > 
> > regards,
> > Armin
> > 
> > Bob Damato wrote:
> > 
> > 
> > > I'm using ConnectionFactoryPooledImpl and I'm trying to find run time \
> > > information about the pool such as the current number of connections "checked \
> > > out", and the number of connections that were timed out etc. Is there any way \
> > > to get this data? 
> > > 
> > > 
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> > For additional commands, e-mail: ojb-user-help@db.apache.org
> > 
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
> 
> 
> 


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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic