mirror of https://github.com/apache/jmeter.git
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
git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1520926 13f79535-47bb-0310-9956-ffa450edef68
Former-commit-id: d1b40b8228
This commit is contained in:
parent
05805f7377
commit
c1a37fa924
|
|
@ -635,6 +635,16 @@ wmlParser.types=text/vnd.wap.wml
|
|||
# To set the Monitor Health Visualiser buffer size, enter the desired value
|
||||
# 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
|
||||
#---------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -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 AbstractJDBCTestElement extends AbstractTestElement implem
|
|||
// 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 AbstractJDBCTestElement extends AbstractTestElement implem
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -364,6 +364,7 @@ Previously the default was 1, which could cause unexpected additional traffic.
|
|||
<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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue