Author: kfujino
Date: Mon Nov 21 02:28:42 2016
New Revision: 1770604

URL: http://svn.apache.org/viewvc?rev=1770604&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=58816
Implement the statistics of jdbc-pool.
The stats infos are borrowedCount, returnedCount, createdCount and 
releasedCount.

Modified:
    
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/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=1770604&r1=1770603&r2=1770604&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
 Mon Nov 21 02:28:42 2016
@@ -712,6 +712,55 @@ public class DataSourceProxy implements
             throw new RuntimeException(x);
         }
     }
+
+    /**
+     * The total number of connections borrowed from this pool.
+     * @return the borrowed connection count
+     */
+    public long getBorrowedCount() {
+        try {
+            return createPool().getBorrowedCount();
+        } catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    /**
+     * The total number of connections returned to this pool.
+     * @return the returned connection count
+     */
+    public long getReturnedCount() {
+        try {
+            return createPool().getReturnedCount();
+        } catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    /**
+     * The total number of connections created by this pool.
+     * @return the created connection count
+     */
+    public long getCreatedCount() {
+        try {
+            return createPool().getCreatedCount();
+        } catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
+    /**
+     * The total number of connections released from this pool.
+     * @return the released connection count
+     */
+    public long getReleasedCount() {
+        try {
+            return createPool().getReleasedCount();
+        } catch (SQLException x) {
+            throw new RuntimeException(x);
+        }
+    }
+
     //=========================================================
     //  PROPERTIES / CONFIGURATION
     //=========================================================

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=1770604&r1=1770603&r2=1770604&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
 Mon Nov 21 02:28:42 2016
@@ -167,6 +167,26 @@ public class ConnectionPool extends Noti
         return pool.getWaitCount();
     }
 
+    @Override
+    public long getBorrowedCount() {
+        return pool.getBorrowedCount();
+    }
+
+    @Override
+    public long getReturnedCount() {
+        return pool.getReturnedCount();
+    }
+
+    @Override
+    public long getCreatedCount() {
+        return pool.getCreatedCount();
+    }
+
+    @Override
+    public long getReleasedCount() {
+        return pool.getReleasedCount();
+    }
+
     //=================================================================
     //       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=1770604&r1=1770603&r2=1770604&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
 Mon Nov 21 02:28:42 2016
@@ -35,6 +35,14 @@ public interface ConnectionPoolMBean ext
 
     public int getWaitCount();
 
+    public long getBorrowedCount();
+
+    public long getReturnedCount();
+
+    public long getCreatedCount();
+
+    public long getReleasedCount();
+
     //=================================================================
     //       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=1770604&r1=1770603&r2=1770604&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
 Mon Nov 21 02:28:42 2016
@@ -330,6 +330,26 @@
                     is="true"
              writeable="false"/>
 
+    <attribute    name="borrowedCount"
+           description="The total number of connections borrowed from this 
pool"
+                  type="java.lang.Long"
+             writeable="false"/>
+
+    <attribute    name="createdCount"
+           description="The total number of connections created by this pool"
+                  type="java.lang.Long"
+             writeable="false"/>
+
+    <attribute    name="returnedCount"
+           description="The total number of connections returned to this pool"
+                  type="java.lang.Long"
+             writeable="false"/>
+
+    <attribute    name="releasedCount"
+           description="The total number of connections released from this 
pool"
+                  type="java.lang.Long"
+             writeable="false"/>
+
     <operation    name="checkIdle"
                   description="forces a check of idle connections"
                   impact="ACTION"

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=1770604&r1=1770603&r2=1770604&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Mon Nov 21 02:28:42 2016
@@ -90,6 +90,11 @@
   </subsection>
   <subsection name="jdbc-pool">
     <changelog>
+      <add>
+        <bug>58816</bug>: Implement the statistics of jdbc-pool. The stats 
infos
+        are <code>borrowedCount</code>, <code>returnedCount</code>,
+        <code>createdCount</code> and <code>releasedCount</code>. (kfujino)
+      </add>
       <fix>
         <bug>60194</bug>: If <code>validationQuery</code> is not specified,
         connection validation is done by calling the <code>isValid()</code>



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

Reply via email to