[jboss-cvs] JBossAS SVN: r69815 - branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 13 04:47:03 EST 2008


Author: vicky.kak at jboss.com
Date: 2008-02-13 04:47:03 -0500 (Wed, 13 Feb 2008)
New Revision: 69815

Modified:
   branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java
Log:
JBAS-5210 changes.

Modified: branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java
===================================================================
--- branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java	2008-02-13 09:45:17 UTC (rev 69814)
+++ branches/Branch_4_2/connector/src/main/org/jboss/resource/connectionmanager/InternalManagedConnectionPool.java	2008-02-13 09:47:03 UTC (rev 69815)
@@ -179,7 +179,11 @@
       try
       {
          if (permits.attempt(poolParams.blockingTimeout))
-         {
+         {        	
+        	long poolBlockTime =  System.currentTimeMillis() - startWait ;
+        	connectionCounter.updateBlockTime(poolBlockTime);
+        	if(connectionCounter.getMaxWaitTime() < poolBlockTime)
+        	   connectionCounter.setMaxWaitTime(poolBlockTime);
             //We have a permit to get a connection. Is there one in the pool already?
             ConnectionListener cl = null;
             do
@@ -305,7 +309,8 @@
       }
       catch (InterruptedException ie)
       {
-         long end = System.currentTimeMillis() - startWait;
+         long end = System.currentTimeMillis() - startWait;     	
+    	 connectionCounter.updateBlockTime(end);    	 
          throw new ResourceException("Interrupted while requesting permit! Waited " + end + " ms");
       }
    }
@@ -452,6 +457,7 @@
             ConnectionListener cl = (ConnectionListener) cls.get(0);
             if (cl.isTimedOut(timeout))
             {
+               connectionCounter.incTimedOut();
                // We need to destroy this one
                cls.remove(0);
                if (destroy == null)
@@ -559,6 +565,26 @@
       return connectionCounter.getCount();
    }
 
+   public long getTotalBlockTime()
+   {	     
+	  return connectionCounter.getTotalBlockTime();	     
+   }
+	   
+   public int getTimedOut()
+   {
+	  return connectionCounter.getTimedOut();
+   }
+	   
+   public long getAverageBlockTime()
+   {
+      return connectionCounter.getTotalBlockTime() / getConnectionCreatedCount();	            
+   }
+   
+   public long getMaxWaitTime()
+   {
+	   return connectionCounter.getMaxWaitTime();
+   }
+   
    public int getConnectionCreatedCount()
    {
       return connectionCounter.getCreatedCount();
@@ -790,6 +816,15 @@
       private int created = 0;
 
       private int destroyed = 0;
+      
+      // Total wait time to get Connection from Pool.
+      private long totalBlockTime;
+      
+      // Idle timed out Connection Count.
+      private int timedOut;
+      
+      
+      private long maxWaitTime;
 
       synchronized int getGuaranteedCount()
       {
@@ -820,5 +855,40 @@
       {
          ++destroyed;
       }
+      
+      synchronized void updateBlockTime(long latest)
+      {    
+          totalBlockTime += latest;         
+      }
+
+      long getTotalBlockTime(){
+       
+          return totalBlockTime;
+          
+      }
+  
+      int getTimedOut(){
+          
+          return timedOut;
+          
+      }
+       
+      synchronized void incTimedOut(){
+          
+          ++timedOut;
+          
+      }
+
+      long getMaxWaitTime(){
+          
+          return maxWaitTime;
+          
+      }
+       
+      synchronized void setMaxWaitTime(long maxWaitTime){
+          
+    	  this.maxWaitTime = timedOut;
+          
+      }
    }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list