[ 
https://issues.apache.org/jira/browse/POOL-409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17609014#comment-17609014
 ] 

Thomas Freller commented on POOL-409:
-------------------------------------

I've done a bit of testing and built a own class in my package called 
BasicDataSourceEnh. This Class inherit BasicDataSource and looks like the 
following Code

 
{code:java}
public class BasicDataSourceEnh extends BasicDataSource{   
   public BasicDataSourceEnh(){
      super();
   }
   
   public String getInfo(){
      return super.getConnectionPool().toString();
   }
}{code}
 

So I'm able to use the Hint you gave to me. The Output is very interesting and 
cause even a Exception so something is going wrong in pool2 

Here is the output.

 
{code:java}
17:28:29.552 [main] INFO  myClass.Worker - Current DBPool Stats Active 
(current/max): 0/5 Idle (min/current/max): 0/0/0
<---- Output of getInfo() ---->
GenericObjectPool [maxTotal=5, blockWhenExhausted=true, 
maxWaitDuration=PT-0.001S, lifo=true, fairness=false, testOnCreate=false, 
testOnBorrow=true, testOnReturn=false, testWhileIdle=false, 
durationBetweenEvictionRuns=PT10S, numTestsPerEvictionRun=3, 
minEvictableIdleTimeDuration=PT30S, softMinEvictableIdleTimeDuration=PT-0.001S, 
evictionPolicy=org.apache.commons.pool2.impl.DefaultEvictionPolicy@6d026701, 
closeLock=java.lang.Object@78aa1f72, closed=false, 
evictionLock=java.lang.Object@1f75a668, 
evictor=org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor@35399441, 
evictionIterator=null, factoryClassLoader=java.lang.ref.WeakReference@4b7dc788, 
oname=null, creationStackTrace=java.lang.Exception
        at 
org.apache.commons.pool2.impl.BaseGenericObjectPool.<init>(BaseGenericObjectPool.java:407)
        at 
org.apache.commons.pool2.impl.GenericObjectPool.<init>(GenericObjectPool.java:147)
        at 
org.apache.commons.dbcp2.BasicDataSource.createObjectPool(BasicDataSource.java:611)
        at 
org.apache.commons.dbcp2.BasicDataSource.createConnectionPool(BasicDataSource.java:480)
        at 
org.apache.commons.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:543)
        at 
org.apache.commons.dbcp2.BasicDataSource.setLogWriter(BasicDataSource.java:2055)
        at db_pool.MySQLConPool.<init>(MySQLConPool.java:55)
        at ssl_worker.SSL_Worker.main(Worker.java:177)
, borrowedCount=38, returnedCount=38, createdCount=38, destroyedCount=38, 
destroyedByEvictorCount=0, destroyedByBorrowValidationCount=0, 
activeTimes=StatsStore [[24, 9, 10, 12, 9, 10, 9, 10, 10, 11, 11, 10, 12, 14, 
15, 20, 11, 1003, 0, 26, 7, 15, 15, 11, 21, 11, 11, 11, 11, 12, 13, 10, 11, 13, 
12, 13, 1004, 1]], size=100, index=38], idleTimes=StatsStore [[4, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0]], size=100, index=38], waitTimes=StatsStore [[8, 5, 3, 8, 
2, 3, 4, 3, 5, 3, 2, 2, 2, 1, 8, 2, 4, 3, 3, 3, 10, 4, 3, 5, 7, 2, 3, 2, 4, 2, 
1, 3, 3, 2, 2, 5, 2, 3]], size=100, index=38], maxBorrowWaitDuration=PT0.01S, 
swallowedExceptionListener=org.apache.commons.dbcp2.SwallowedExceptionLogger@6304101a,
 factoryType=null, maxIdle=0, minIdle=0, 
factory=org.apache.commons.dbcp2.PoolableConniectionFactory@5170bcf4, 
allObjects={}, createCount=0, idleObjects=[], abandonedConfig=null]{code}
As you can see there are a few problems:

 
 * org.apache.commons.pool2.impl.DefaultEvictionPolicy@6d026701   => consider 
to implement toString()   => not Critical to me (only hint)
 * org.apache.commons.pool2.impl.BaseGenericObjectPool$Evictor@35399441 
=>consider to implement toString()   => not Critical to me (only hint)
 * java.lang.ref.WeakReference@4b7dc788 =>Problem of Java not yours   => not 
Critical to me#
 * (!){color:#de350b} *Im worry about the Stack Trace*  {color:#172b4d}is this 
something critical or a problem of the Class loader or is there a Exception 
printed? This is confusing to me.{color}{color}

> BasicDataSource should support GenericObjectPool->getStatsString()
> ------------------------------------------------------------------
>
>                 Key: POOL-409
>                 URL: https://issues.apache.org/jira/browse/POOL-409
>             Project: Commons Pool
>          Issue Type: Improvement
>    Affects Versions: 2.11.1
>            Reporter: Thomas Freller
>            Priority: Major
>              Labels: improvement
>   Original Estimate: 2h
>  Remaining Estimate: 2h
>
> Hello,
> I'm developing a Application that is running on a default JRE without an 
> Webserver/JMX.
> For optimizing Database connections it would be very useful if i could access
>  
> BasicDataSource->GenericObjectPool->{*}getStatsString(){*}
>  
> I don't see any reason why this Method is protected and not public in 
> GenericObjectPool.
> Then BasicDataSource shoud provide a method getStatsString() or the values 
> that represent the statistic data.
>  
> If there is any other easy way to access this data within my Java Code I'll 
> implement this if you could give me an example how to get this working 
> easily. I don't want do configure any jmx stuff.
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to