You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2014/02/27 02:49:50 UTC
svn commit: r1572390 - in /jmeter/trunk: bin/jmeter.properties
src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
xdocs/changes.xml
Author: sebb
Date: Thu Feb 27 01:49:50 2014
New Revision: 1572390
URL: http://svn.apache.org/r1572390
Log:
File uploads fail every other attempt using timers.
Enable idle timeouts for servers that don't send Keep-Alive headers.
Bugzilla Id: 56119
Modified:
jmeter/trunk/bin/jmeter.properties
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
jmeter/trunk/xdocs/changes.xml
Modified: jmeter/trunk/bin/jmeter.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.properties?rev=1572390&r1=1572389&r2=1572390&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter.properties (original)
+++ jmeter/trunk/bin/jmeter.properties Thu Feb 27 01:49:50 2014
@@ -382,6 +382,14 @@ log_level.jorphan=INFO
# Number of retries to attempt (default 0)
#httpclient4.retrycount=0
+# Idle connection timeout (ms) to apply if the server does not send Keep-Alive headers
+#httpclient4.idletimeout=0
+# Note: this is currently an experimental fix
+
+#---------------------------------------------------------------------------
+# Apache HttpComponents HTTPClient configuration (HTTPClient 3.1)
+#---------------------------------------------------------------------------
+
# Number of retries to attempt (default 0)
#httpclient3.retrycount=0
Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java?rev=1572390&r1=1572389&r2=1572390&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java Thu Feb 27 01:49:50 2014
@@ -73,6 +73,7 @@ import org.apache.http.client.methods.Ht
import org.apache.http.client.params.ClientPNames;
import org.apache.http.client.params.CookiePolicy;
import org.apache.http.client.protocol.ResponseContentEncoding;
+import org.apache.http.conn.ConnectionKeepAliveStrategy;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
@@ -85,6 +86,7 @@ import org.apache.http.entity.mime.Multi
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.impl.client.AbstractHttpClient;
+import org.apache.http.impl.client.DefaultConnectionKeepAliveStrategy;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
import org.apache.http.message.BasicNameValuePair;
@@ -129,11 +131,27 @@ public class HTTPHC4Impl extends HTTPHCA
private static final boolean STRICT_RFC_2616 = JMeterUtils.getPropDefault("jmeter.httpclient.strict_rfc2616", false);
- /** retry count to be used (default 1); 0 = disable retries */
+ /** retry count to be used (default 0); 0 = disable retries */
private static final int RETRY_COUNT = JMeterUtils.getPropDefault("httpclient4.retrycount", 0);
+ /** Idle timeout to be applied to connections if no Keep-Alive header is sent by the server (default 0 = disable) */
+ private static final int IDLE_TIMEOUT = JMeterUtils.getPropDefault("httpclient4.idletimeout", 0);
+
private static final String CONTEXT_METRICS = "jmeter_metrics"; // TODO hack for metrics related to HTTPCLIENT-1081, to be removed later
+ private static final ConnectionKeepAliveStrategy IDLE_STRATEGY = new DefaultConnectionKeepAliveStrategy(){
+ @Override
+ public long getKeepAliveDuration(HttpResponse response, HttpContext context) {
+ long duration = super.getKeepAliveDuration(response, context);
+ if (duration <= 0) {// none found by the superclass
+ log.debug("Setting keepalive to " + IDLE_TIMEOUT);
+ return IDLE_TIMEOUT;
+ }
+ return duration; // return the super-class value
+ }
+
+ };
+
/**
* Special interceptor made to keep metrics when connection is released for some method like HEAD
* Otherwise calling directly ((HttpConnection) localContext.getAttribute(ExecutionContext.HTTP_CONNECTION)).getMetrics();
@@ -629,6 +647,9 @@ public class HTTPHC4Impl extends HTTPHCA
return new DefaultHttpRequestRetryHandler(RETRY_COUNT, false); // set retry count
}
};
+ if (IDLE_TIMEOUT > 0) {
+ ((AbstractHttpClient) httpClient).setKeepAliveStrategy(IDLE_STRATEGY );
+ }
((AbstractHttpClient) httpClient).addResponseInterceptor(new ResponseContentEncoding());
((AbstractHttpClient) httpClient).addResponseInterceptor(METRICS_SAVER); // HACK
((AbstractHttpClient) httpClient).addRequestInterceptor(METRICS_RESETTER);
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1572390&r1=1572389&r2=1572390&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Thu Feb 27 01:49:50 2014
@@ -169,6 +169,7 @@ A workaround is to use a Java 7 update 4
<ul>
<li><bugzilla>55959</bugzilla> - improve error message when Test Script Recorder fails due to I/O problem</li>
<li><bugzilla>52013</bugzilla> - Test Script Recorder's Child View Results Tree does not take into account Test Script Recorder excluded/included URLs. Based on report and analysis of James Liang</li>
+<li><bugzilla>56119</bugzilla> - File uploads fail every other attempt using timers. Enable idle timeouts for servers that don't send Keep-Alive headers.</li>
</ul>
<h3>Other samplers</h3>