You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2013/09/08 23:00:29 UTC
svn commit: r1520926 - in /jmeter/trunk: bin/jmeter.properties
src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
xdocs/changes.xml
Author: pmouawad
Date: Sun Sep 8 21:00:28 2013
New Revision: 1520926
URL: http://svn.apache.org/r1520926
Log:
Bug 55518 - Add ability to limit number of cached PreparedStatements per connection when "Prepared Select Statement", "Prepared Update Statement" or "Callable Statement" query type is selected
Bugzilla Id: 55518
Modified:
jmeter/trunk/bin/jmeter.properties
jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java
jmeter/trunk/xdocs/changes.xml
Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1520926&r1=1520925&r2=1520926&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Sun Sep 8 21:00:28 2013
@@ -636,6 +636,16 @@ wmlParser.types=text/vnd.wap.wml
# monitor.buffer.size=800
#---------------------------------------------------------------------------
+# 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[
+
+#---------------------------------------------------------------------------
# OS Process Sampler configuration
#---------------------------------------------------------------------------
# Polling to see if process has finished its work, used when a timeout is configured on sampler
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=1520926&r1=1520925&r2=1520926&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 Sun Sep 8 21:00:28 2013
@@ -30,6 +30,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -61,6 +62,9 @@ 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$
@@ -323,7 +327,15 @@ public abstract class AbstractJDBCTestEl
private PreparedStatement getPreparedStatement(Connection conn, boolean callable) throws SQLException {
Map<String, PreparedStatement> preparedStatementMap = perConnCache.get(conn);
if (null == preparedStatementMap ) {
- preparedStatementMap = new ConcurrentHashMap<String, PreparedStatement>();
+ preparedStatementMap = Collections.<String, PreparedStatement>synchronizedMap(
+ new org.apache.commons.collections.map.LRUMap(MAX_OPEN_PREPARED_STATEMENTS) {
+ @Override
+ protected boolean removeLRU(LinkEntry entry) {
+ PreparedStatement preparedStatement = (PreparedStatement)entry.getValue();
+ close(preparedStatement);
+ return true;
+ }
+ });
// As a connection is held by only one thread, we cannot already have a
// preparedStatementMap put by another thread
perConnCache.put(conn, preparedStatementMap);
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1520926&r1=1520925&r2=1520926&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sun Sep 8 21:00:28 2013
@@ -364,6 +364,7 @@ Previously the default was 1, which coul
<li><bugzilla>54896</bugzilla> - JUnit sampler gives only "failed to create an instance of the class" message with constructor problems.</li>
<li><bugzilla>55084</bugzilla> - Add timeout support for JDBC Request. Contributed by Mikhail Epikhin (epihin-m at yandex.ru)</li>
<li><bugzilla>55403</bugzilla> - Enhancement to OS sampler: Support for timeout</li>
+<li><bugzilla>55518</bugzilla> - Add ability to limit number of cached PreparedStatements per connection when "Prepared Select Statement", "Prepared Update Statement" or "Callable Statement" query type is selected</li>
</ul>
<h3>Controllers</h3>