jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1759668 - in /jmeter/trunk: bin/jmeter.properties src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java xdocs/changes.xml xdocs/usermanual/properties_reference.xml
Date Wed, 07 Sep 2016 19:26:18 GMT
Author: fschumacher
Date: Wed Sep  7 19:26:17 2016
New Revision: 1759668

URL: http://svn.apache.org/viewvc?rev=1759668&view=rev
Log:
Remove cache for prepared statements, as it didn't work with the current
jdbc pool implementation and current jdbc drivers should support caching
of prepared statements themselves.

Bugzilla Id: 60085

Modified:
    jmeter/trunk/bin/jmeter.properties
    jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
    jmeter/trunk/xdocs/changes.xml
    jmeter/trunk/xdocs/usermanual/properties_reference.xml

Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1759668&r1=1759667&r2=1759668&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Wed Sep  7 19:26:17 2016
@@ -821,9 +821,6 @@ wmlParser.types=text/vnd.wap.wml
 # JDBC Request configuration
 #---------------------------------------------------------------------------
 
-# Max number of PreparedStatements per Connection for PreparedStatement cache
-#jdbcsampler.maxopenpreparedstatements=100
-
 # String used to indicate a null value
 #jdbcsampler.nullmarker=]NULL[
 
@@ -1245,4 +1242,4 @@ system.properties=system.properties
 
 # Force throuput controllers that work in percentage mode to be a 100%
 # Disabled by default
-#testplan_validation.tpc_force_100_pct=false
\ No newline at end of file
+#testplan_validation.tpc_force_100_pct=false

Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java?rev=1759668&r1=1759667&r2=1759668&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
(original)
+++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
Wed Sep  7 19:26:17 2016
@@ -36,13 +36,10 @@ import java.sql.Timestamp;
 import java.sql.Types;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.commons.collections.map.LRUMap;
 import org.apache.jmeter.samplers.SampleResult;
 import org.apache.jmeter.save.CSVSaveService;
 import org.apache.jmeter.testelement.AbstractTestElement;
@@ -69,9 +66,6 @@ public abstract class AbstractJDBCTestEl
     // String used to indicate a null value
     private static final String NULL_MARKER =
         JMeterUtils.getPropDefault("jdbcsampler.nullmarker","]NULL["); // $NON-NLS-1$
-    
-    private static final int MAX_OPEN_PREPARED_STATEMENTS =
-        JMeterUtils.getPropDefault("jdbcsampler.maxopenpreparedstatements", 100); 
 
     private static final String INOUT = "INOUT"; // $NON-NLS-1$
 
@@ -131,14 +125,6 @@ public abstract class AbstractJDBCTestEl
     private String queryTimeout = ""; // $NON-NLS-1$
 
     /**
-     *  Cache of PreparedStatements stored in a per-connection basis. Each entry of this
-     *  cache is another Map mapping the statement string to the actual PreparedStatement.
-     *  At one time a Connection is only held by one thread
-     */
-    private static final Map<Connection, Map<String, PreparedStatement>> perConnCache
=
-            new ConcurrentHashMap<>();
-
-    /**
      * Creates a JDBCSampler.
      */
     protected AbstractJDBCTestElement() {
@@ -446,50 +432,16 @@ public abstract class AbstractJDBCTestEl
     }
 
     private PreparedStatement getPreparedStatement(Connection conn, boolean callable) throws
SQLException {
-        Map<String, PreparedStatement> preparedStatementMap = perConnCache.get(conn);
-        if (null == preparedStatementMap ) {
-            @SuppressWarnings("unchecked") // LRUMap is not generic
-            Map<String, PreparedStatement> lruMap = new LRUMap(MAX_OPEN_PREPARED_STATEMENTS)
{
-                private static final long serialVersionUID = 1L;
-                @Override
-                protected boolean removeLRU(LinkEntry entry) {
-                    PreparedStatement preparedStatement = (PreparedStatement)entry.getValue();
-                    close(preparedStatement);
-                    return true;
-                }
-            };
-            preparedStatementMap = Collections.<String, PreparedStatement>synchronizedMap(lruMap);
-            // As a connection is held by only one thread, we cannot already have a 
-            // preparedStatementMap put by another thread
-            perConnCache.put(conn, preparedStatementMap);
-        }
-        PreparedStatement pstmt = preparedStatementMap.get(getQuery());
-        if (null == pstmt) {
-            if (callable) {
-                pstmt = conn.prepareCall(getQuery());
-            } else {
-                pstmt = conn.prepareStatement(getQuery());
-            }
-            pstmt.setQueryTimeout(getIntegerQueryTimeout());
-            // PreparedStatementMap is associated to one connection so 
-            //  2 threads cannot use the same PreparedStatement map at the same time
-            preparedStatementMap.put(getQuery(), pstmt);
+        PreparedStatement pstmt;
+        if (callable) {
+            pstmt = conn.prepareCall(getQuery());
         } else {
-            int timeoutInS = getIntegerQueryTimeout();
-            if(pstmt.getQueryTimeout() != timeoutInS) {
-                pstmt.setQueryTimeout(getIntegerQueryTimeout());
-            }
+            pstmt = conn.prepareStatement(getQuery());
         }
-        pstmt.clearParameters();
+        pstmt.setQueryTimeout(getIntegerQueryTimeout());
         return pstmt;
     }
 
-    private static void closeAllStatements(Collection<PreparedStatement> collection)
{
-        for (PreparedStatement pstmt : collection) {
-            close(pstmt);
-        }
-    }
-
     /**
      * Gets a Data object from a ResultSet.
      *
@@ -759,7 +711,6 @@ public abstract class AbstractJDBCTestEl
      */
     @Override
     public void testStarted(String host) {
-        cleanCache();
     }
 
     /**
@@ -777,17 +728,6 @@ public abstract class AbstractJDBCTestEl
      */
     @Override
     public void testEnded(String host) {
-        cleanCache();
-    }
-    
-    /**
-     * Clean cache of PreparedStatements
-     */
-    private static void cleanCache() {
-        for (Map<String, PreparedStatement> element : perConnCache.values()) {
-            closeAllStatements(element.values());
-        }
-        perConnCache.clear();
     }
 
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1759668&r1=1759667&r2=1759668&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Wed Sep  7 19:26:17 2016
@@ -141,6 +141,7 @@ Summary
     <li><bug>60079</bug>Report / Dashboard : Add a new "Response Time Overview"
graph</li>
     <li><bug>60080</bug>Report / Dashboard : Add a new "Connect Time Over
Time " graph. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
     <li><bug>60091</bug>Report / Dashboard : Have a new report containing
min/max and percentiles graphs.</li>
+    <li><bug>60085</bug>Remove cache for prepared statements, as it didn't
work with the current jdbc pool implementation and current jdbc drivers should support caching
of prepared statements themselves.</li>
 </ul>
 
 <ch_section>Non-functional changes</ch_section>

Modified: jmeter/trunk/xdocs/usermanual/properties_reference.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/usermanual/properties_reference.xml?rev=1759668&r1=1759667&r2=1759668&view=diff
==============================================================================
--- jmeter/trunk/xdocs/usermanual/properties_reference.xml (original)
+++ jmeter/trunk/xdocs/usermanual/properties_reference.xml Wed Sep  7 19:26:17 2016
@@ -487,7 +487,6 @@ Other parsers:<br/>
 </section>
 <section name="&sect-num;.26 JDBC Request configuration" anchor="jdbc_request">
 <properties>
-<property name="jdbcsampler.maxopenpreparedstatements"> Max number of PreparedStatements
per Connection for PreparedStatement cache<br/>, defaults to:100</property>
 <property name="jdbcsampler.nullmarker"> String used to indicate a null value<br/>,
defaults to:]NULL[</property>
 </properties>
 </section>



Mime
View raw message