You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2011/04/16 02:27:17 UTC

svn commit: r1092849 - in /lucene/dev/branches/branch_3x: ./ lucene/ solr/ solr/CHANGES.txt solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java

Author: yonik
Date: Sat Apr 16 00:27:16 2011
New Revision: 1092849

URL: http://svn.apache.org/viewvc?rev=1092849&view=rev
Log:
SOLR-2466: set HttpClient retryCount to 0

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/CHANGES.txt
    lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java

Modified: lucene/dev/branches/branch_3x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/CHANGES.txt?rev=1092849&r1=1092848&r2=1092849&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_3x/solr/CHANGES.txt Sat Apr 16 00:27:16 2011
@@ -59,6 +59,11 @@ Bug Fixes
 * SOLR-2469: When using java replication with replicateAfter=startup, the first
   commit point on server startup is never removed. (yonik)
 
+* SOLR-2466: SolrJ's CommonsHttpSolrServer would retry requests on failure, regardless
+  of the configured maxRetries, due to HttpClient having it's own retry mechanism
+  by default.  The retryCount of HttpClient is now set to 0, and SolrJ does
+  the retry.  (yonik)
+  
 
 
 Other Changes

Modified: lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java?rev=1092849&r1=1092848&r2=1092849&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java (original)
+++ lucene/dev/branches/branch_3x/solr/src/solrj/org/apache/solr/client/solrj/impl/CommonsHttpSolrServer.java Sat Apr 16 00:27:16 2011
@@ -26,15 +26,7 @@ import java.util.*;
 import java.util.zip.GZIPInputStream;
 import java.util.zip.InflaterInputStream;
 
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpMethodBase;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.NoHttpResponseException;
+import org.apache.commons.httpclient.*;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
 import org.apache.commons.httpclient.methods.PostMethod;
@@ -43,6 +35,7 @@ import org.apache.commons.httpclient.met
 import org.apache.commons.httpclient.methods.multipart.Part;
 import org.apache.commons.httpclient.methods.multipart.PartBase;
 import org.apache.commons.httpclient.methods.multipart.StringPart;
+import org.apache.commons.httpclient.params.HttpMethodParams;
 import org.apache.commons.io.IOUtils;
 import org.apache.solr.client.solrj.ResponseParser;
 import org.apache.solr.client.solrj.SolrRequest;
@@ -205,15 +198,21 @@ public class CommonsHttpSolrServer exten
     if( _baseURL.indexOf( '?' ) >=0 ) {
       throw new RuntimeException( "Invalid base url for solrj.  The base URL must not contain parameters: "+_baseURL );
     }
- 
-    _httpClient = (client == null) ? new HttpClient(new MultiThreadedHttpConnectionManager()) : client;
 
     if (client == null) {
+      _httpClient = new HttpClient(new MultiThreadedHttpConnectionManager()) ;
+
+      // prevent retries  (note: this didn't work when set on mgr.. needed to be set on client)
+      DefaultHttpMethodRetryHandler retryhandler = new DefaultHttpMethodRetryHandler(0, false);
+      _httpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryhandler);
+
       // set some better defaults if we created a new connection manager and client
-      
+
       // increase the default connections
       this.setDefaultMaxConnectionsPerHost( 32 );  // 2
       this.setMaxTotalConnections( 128 ); // 20
+    } else {
+      _httpClient = client;
     }
 
     _parser = parser;