From commits-return-5739-apmail-jmeter-commits-archive=jmeter.apache.org@jmeter.apache.org Wed Jul 13 18:45:45 2016 Return-Path: X-Original-To: apmail-jmeter-commits-archive@minotaur.apache.org Delivered-To: apmail-jmeter-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A2986198BB for ; Wed, 13 Jul 2016 18:45:45 +0000 (UTC) Received: (qmail 76008 invoked by uid 500); 13 Jul 2016 18:45:45 -0000 Delivered-To: apmail-jmeter-commits-archive@jmeter.apache.org Received: (qmail 75975 invoked by uid 500); 13 Jul 2016 18:45:45 -0000 Mailing-List: contact commits-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jmeter.apache.org Delivered-To: mailing list commits@jmeter.apache.org Received: (qmail 75966 invoked by uid 99); 13 Jul 2016 18:45:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jul 2016 18:45:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 1710A1A023C for ; Wed, 13 Jul 2016 18:45:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.374 X-Spam-Level: X-Spam-Status: No, score=0.374 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id yPL-OBt1vwSd for ; Wed, 13 Jul 2016 18:45:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 814245FD50 for ; Wed, 13 Jul 2016 18:45:43 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id D2FD7E0175 for ; Wed, 13 Jul 2016 18:45:42 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id CE51F3A0A8D for ; Wed, 13 Jul 2016 18:45:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1752509 - in /jmeter/trunk: src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java xdocs/changes.xml Date: Wed, 13 Jul 2016 18:45:42 -0000 To: commits@jmeter.apache.org From: fschumacher@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160713184542.CE51F3A0A8D@svn01-us-west.apache.org> Author: fschumacher Date: Wed Jul 13 18:45:42 2016 New Revision: 1752509 URL: http://svn.apache.org/viewvc?rev=1752509&view=rev Log: Differentiate the timing for JDBC Sampler. Use latency and connect time. Contributed by Thomas Peyrard (thomas.peyrard at murex.com) Closes #211 on github. Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/AbstractJDBCTestElement.java jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java jmeter/trunk/xdocs/changes.xml 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=1752509&r1=1752508&r2=1752509&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 Jul 13 18:45:42 2016 @@ -143,21 +143,35 @@ public abstract class AbstractJDBCTestEl */ protected AbstractJDBCTestElement() { } - + /** * Execute the test element. - * - * @param conn a {@link SampleResult} in case the test should sample; null if only execution is requested + * + * @param conn a {@link Connection} * @return the result of the execute command * @throws SQLException if a database error occurs - * @throws UnsupportedEncodingException when the result can not be converted to the required charset * @throws IOException when I/O error occurs * @throws UnsupportedOperationException if the user provided incorrect query type */ protected byte[] execute(Connection conn) throws SQLException, IOException, UnsupportedOperationException { + return execute(conn, new SampleResult()); + } + + /** + * Execute the test element. + * Use the sample given as argument to set time to first byte in the "latency" field of the SampleResult. + * + * @param conn a {@link Connection} + * @param sample a {@link SampleResult} to save the latency + * @return the result of the execute command + * @throws SQLException if a database error occurs + * @throws IOException when I/O error occurs + * @throws UnsupportedOperationException if the user provided incorrect query type + */ + protected byte[] execute(Connection conn, SampleResult sample) throws SQLException, IOException, UnsupportedOperationException { log.debug("executing jdbc"); Statement stmt = null; - + try { // Based on query return value, get results String _queryType = getQueryType(); @@ -167,6 +181,7 @@ public abstract class AbstractJDBCTestEl ResultSet rs = null; try { rs = stmt.executeQuery(getQuery()); + sample.latencyEnd(); return getStringFromResultSet(rs).getBytes(ENCODING); } finally { close(rs); @@ -177,12 +192,14 @@ public abstract class AbstractJDBCTestEl // A CallableStatement can return more than 1 ResultSets // plus a number of update counts. boolean hasResultSet = cstmt.execute(); + sample.latencyEnd(); String sb = resultSetsToString(cstmt,hasResultSet, out); return sb.getBytes(ENCODING); } else if (UPDATE.equals(_queryType)) { stmt = conn.createStatement(); stmt.setQueryTimeout(getIntegerQueryTimeout()); stmt.executeUpdate(getQuery()); + sample.latencyEnd(); int updateCount = stmt.getUpdateCount(); String results = updateCount + " updates"; return results.getBytes(ENCODING); @@ -192,6 +209,7 @@ public abstract class AbstractJDBCTestEl ResultSet rs = null; try { rs = pstmt.executeQuery(); + sample.latencyEnd(); return getStringFromResultSet(rs).getBytes(ENCODING); } finally { close(rs); @@ -200,19 +218,24 @@ public abstract class AbstractJDBCTestEl PreparedStatement pstmt = getPreparedStatement(conn); setArguments(pstmt); pstmt.executeUpdate(); + sample.latencyEnd(); String sb = resultSetsToString(pstmt,false,null); return sb.getBytes(ENCODING); } else if (ROLLBACK.equals(_queryType)){ conn.rollback(); + sample.latencyEnd(); return ROLLBACK.getBytes(ENCODING); } else if (COMMIT.equals(_queryType)){ conn.commit(); + sample.latencyEnd(); return COMMIT.getBytes(ENCODING); } else if (AUTOCOMMIT_FALSE.equals(_queryType)){ conn.setAutoCommit(false); + sample.latencyEnd(); return AUTOCOMMIT_FALSE.getBytes(ENCODING); } else if (AUTOCOMMIT_TRUE.equals(_queryType)){ conn.setAutoCommit(true); + sample.latencyEnd(); return AUTOCOMMIT_TRUE.getBytes(ENCODING); } else { // User provided incorrect query type throw new UnsupportedOperationException("Unexpected query type: "+_queryType); Modified: jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java?rev=1752509&r1=1752508&r2=1752509&view=diff ============================================================================== --- jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java (original) +++ jmeter/trunk/src/protocol/jdbc/org/apache/jmeter/protocol/jdbc/sampler/JDBCSampler.java Wed Jul 13 18:45:42 2016 @@ -83,11 +83,10 @@ public class JDBCSampler extends Abstrac try { conn = DataSourceElement.getConnection(getDataSource()); } finally { - // FIXME: there is separate connect time field now - res.latencyEnd(); // use latency to measure connection time + res.connectEnd(); } res.setResponseHeaders(conn.toString()); - res.setResponseData(execute(conn)); + res.setResponseData(execute(conn, res)); } catch (SQLException ex) { final String errCode = Integer.toString(ex.getErrorCode()); res.setResponseMessage(ex.toString()); Modified: jmeter/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1752509&r1=1752508&r2=1752509&view=diff ============================================================================== --- jmeter/trunk/xdocs/changes.xml (original) +++ jmeter/trunk/xdocs/changes.xml Wed Jul 13 18:45:42 2016 @@ -84,6 +84,8 @@ Summary

Other samplers

    +
  • PR 211. Differentiate the timing for JDBC Sampler. Use latency and connect time. + Contributed by Thomas Peyrard (thomas.peyrard at murex.com)

Controllers