[jboss-cvs] JBossAS SVN: r71782 - trunk/connector/src/main/org/jboss/resource/connectionmanager.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 8 05:30:58 EDT 2008
Author: adrian at jboss.org
Date: 2008-04-08 05:30:57 -0400 (Tue, 08 Apr 2008)
New Revision: 71782
Modified:
trunk/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java
Log:
Port latest changes to IMCP to head
Modified: trunk/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java 2008-04-08 09:30:09 UTC (rev 71781)
+++ trunk/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java 2008-04-08 09:30:57 UTC (rev 71782)
@@ -177,6 +177,9 @@
if (permits.attempt(poolParams.blockingTimeout))
{
+ long poolBlockTime = System.currentTimeMillis() - startWait ;
+ connectionCounter.updateBlockTime(poolBlockTime);
+
//We have a permit to get a connection. Is there one in the pool already?
ConnectionListener cl = null;
do
@@ -297,6 +300,7 @@
catch (InterruptedException ie)
{
long end = System.currentTimeMillis() - startWait;
+ connectionCounter.updateBlockTime(end);
throw new ResourceException("Interrupted while requesting permit! Waited " + end + " ms");
}
}
@@ -362,6 +366,8 @@
cl.used();
if (cls.contains(cl) == false)
cls.add(cl);
+ else
+ log.warn("Attempt to return connection twice (ignored): " + cl, new Throwable("STACKTRACE"));
}
if (cl.hasPermit())
@@ -550,22 +556,26 @@
return connectionCounter.getCount();
}
- public long getTotalBlockTime(){
-
+ public long getTotalBlockTime()
+ {
return connectionCounter.getTotalBlockTime();
-
}
- public int getTimedOut(){
-
+ public int getTimedOut()
+ {
return connectionCounter.getTimedOut();
}
- public long getAverageBlockTime(){
-
+ public long getAverageBlockTime()
+ {
return connectionCounter.getTotalBlockTime() / getConnectionCreatedCount();
-
}
+
+ public long getMaxWaitTime()
+ {
+ return connectionCounter.getMaxWaitTime();
+ }
+
public int getConnectionCreatedCount()
{
return connectionCounter.getCreatedCount();
@@ -575,6 +585,17 @@
{
return connectionCounter.getDestroyedCount();
}
+
+ Set getConnectionListeners()
+ {
+ synchronized (cls)
+ {
+ Set result = new HashSet();
+ result.addAll(cls);
+ result.addAll(checkedOut);
+ return result;
+ }
+ }
/**
* Create a connection event listener
@@ -622,7 +643,7 @@
}
catch (Throwable t)
{
- log.warn("Exception destroying ManagedConnection " + cl, t);
+ log.debug("Exception destroying ManagedConnection " + cl, t);
}
}
@@ -821,9 +842,14 @@
private int destroyed = 0;
+ // Total wait time to get Connection from Pool.
private long totalBlockTime;
+ // Idle timed out Connection Count.
private int timedOut;
+
+ // The maximum wait time */
+ private long maxWaitTime;
synchronized int getGuaranteedCount()
{
@@ -855,28 +881,31 @@
++destroyed;
}
- synchronized void updateBlockTime(long latest){
-
+ synchronized void updateBlockTime(long latest)
+ {
totalBlockTime += latest;
-
+ if (maxWaitTime < latest)
+ maxWaitTime = latest;
}
- long getTotalBlockTime(){
-
+ long getTotalBlockTime()
+ {
return totalBlockTime;
-
}
- int getTimedOut(){
-
+ int getTimedOut()
+ {
return timedOut;
-
}
- synchronized void incTimedOut(){
-
+ synchronized void incTimedOut()
+ {
++timedOut;
-
}
+
+ long getMaxWaitTime()
+ {
+ return maxWaitTime;
+ }
}
}
More information about the jboss-cvs-commits
mailing list