You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kf...@apache.org on 2016/11/29 02:47:21 UTC

svn commit: r1771838 - in /tomcat/tc7.0.x/trunk: modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ webapps/docs/

Author: kfujino
Date: Tue Nov 29 02:47:21 2016
New Revision: 1771838

URL: http://svn.apache.org/viewvc?rev=1771838&view=rev
Log:
Add the statistics for released connection by an idle check and removeAbandoned.

Modified:
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPoolMBean.java
    tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/mbeans-descriptors.xml
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java?rev=1771838&r1=1771837&r2=1771838&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/ConnectionPool.java Tue Nov 29 02:47:21 2016
@@ -138,6 +138,8 @@ public class ConnectionPool {
     private final AtomicLong createdCount = new AtomicLong(0);
     private final AtomicLong releasedCount = new AtomicLong(0);
     private final AtomicLong reconnectedCount = new AtomicLong(0);
+    private final AtomicLong removeAbandonedCount = new AtomicLong(0);
+    private final AtomicLong releasedIdleCount = new AtomicLong(0);
 
     //===============================================================================
     //         PUBLIC METHODS
@@ -558,6 +560,7 @@ public class ConnectionPool {
                 jmxPool.notify(org.apache.tomcat.jdbc.pool.jmx.ConnectionPool.NOTIFY_ABANDON, trace);
             }
             //release the connection
+            removeAbandonedCount.incrementAndGet();
             release(con);
         } finally {
             con.unlock();
@@ -1023,6 +1026,7 @@ public class ConnectionPool {
                         continue;
                     long time = con.getTimestamp();
                     if (shouldReleaseIdle(now, con, time)) {
+                        releasedIdleCount.incrementAndGet();
                         release(con);
                         idle.remove(con);
                         setToNull = true;
@@ -1223,6 +1227,22 @@ public class ConnectionPool {
     }
 
     /**
+     * The total number of connections released by remove abandoned.
+     * @return the PoolCleaner removed abandoned connection count
+     */
+    public long getRemoveAbandonedCount() {
+        return removeAbandonedCount.get();
+    }
+
+    /**
+     * The total number of connections released by eviction.
+     * @return the PoolCleaner evicted idle connection count
+     */
+    public long getReleasedIdleCount() {
+        return releasedIdleCount.get();
+    }
+
+    /**
      * Tread safe wrapper around a future for the regular queue
      * This one retrieves the pooled connection object
      * and performs the initialization according to

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java?rev=1771838&r1=1771837&r2=1771838&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/DataSourceProxy.java Tue Nov 29 02:47:21 2016
@@ -762,6 +762,29 @@ public class DataSourceProxy implements
     }
 
     /**
+     * The total number of connections released by remove abandoned.
+     * @return the PoolCleaner removed abandoned connection count
+     */
+    public long getRemoveAbandonedCount() {
+        try {
+            return createPool().getRemoveAbandonedCount();
+        } catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    /**
+     * The total number of connections released by eviction.
+     * @return the PoolCleaner evicted idle connection count
+     */
+    public long getReleasedIdleCount() {
+        try {
+            return createPool().getReleasedIdleCount();
+        } catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }
+    /**
      * The total number of connections reconnected by this pool.
      * @return the reconnected connection count
      */

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java?rev=1771838&r1=1771837&r2=1771838&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPool.java Tue Nov 29 02:47:21 2016
@@ -191,6 +191,17 @@ public class ConnectionPool extends Noti
     public long getReconnectedCount() {
         return pool.getReconnectedCount();
     }
+
+    @Override
+    public long getRemoveAbandonedCount() {
+        return pool.getRemoveAbandonedCount();
+    }
+
+    @Override
+    public long getReleasedIdleCount() {
+        return pool.getReleasedIdleCount();
+    }
+
     //=================================================================
     //       POOL OPERATIONS
     //=================================================================

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPoolMBean.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPoolMBean.java?rev=1771838&r1=1771837&r2=1771838&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPoolMBean.java (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/jmx/ConnectionPoolMBean.java Tue Nov 29 02:47:21 2016
@@ -44,6 +44,11 @@ public interface ConnectionPoolMBean ext
     public long getReleasedCount();
 
     public long getReconnectedCount();
+
+    public long getRemoveAbandonedCount();
+
+    public long getReleasedIdleCount();
+
     //=================================================================
     //       POOL OPERATIONS
     //=================================================================

Modified: tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/mbeans-descriptors.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/mbeans-descriptors.xml?rev=1771838&r1=1771837&r2=1771838&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/mbeans-descriptors.xml (original)
+++ tomcat/tc7.0.x/trunk/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/mbeans-descriptors.xml Tue Nov 29 02:47:21 2016
@@ -355,7 +355,16 @@
                   type="java.lang.Long"
              writeable="false"/>
 
-    <operation    name="checkIdle"
+    <attribute    name="removeAbandonedCount"
+           description="The total number of connections released by remove abandoned."
+                  type="java.lang.Long"
+             writeable="false"/>
+
+    <attribute    name="releasedIdleCount"
+           description="The total number of connections released by eviction."
+                  type="java.lang.Long"
+             writeable="false"/>
+                 <operation    name="checkIdle"
                   description="forces a check of idle connections"
                   impact="ACTION"
                   returnType="void" />

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1771838&r1=1771837&r2=1771838&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Nov 29 02:47:21 2016
@@ -121,8 +121,9 @@
       <add>
         <bug>58816</bug>: Implement the statistics of jdbc-pool. The stats infos
         are <code>borrowedCount</code>, <code>returnedCount</code>,
-        <code>createdCount</code>, <code>releasedCount</code> and
-        <code>reconnectedCount</code>. (kfujino)
+        <code>createdCount</code>, <code>releasedCount</code>,
+        <code>reconnectedCount</code>, <code>releasedIdleCount</code> and
+        <code>removeAbandonedCount</code>. (kfujino)
       </add>
       <fix>
         <bug>60194</bug>: If <code>validationQuery</code> is not specified,



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org