lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r898437 - in /lucene/solr/branches/cloud/src: java/org/apache/solr/handler/component/ solrj/org/apache/solr/client/solrj/impl/ test/org/apache/solr/ test/org/apache/solr/client/solrj/
Date Tue, 12 Jan 2010 17:40:39 GMT
Author: yonik
Date: Tue Jan 12 17:40:39 2010
New Revision: 898437

URL: http://svn.apache.org/viewvc?rev=898437&view=rev
Log:
SOLR-1698: when load balancing or distributed search, default to no retries.

Modified:
    lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/SearchHandler.java
    lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java
    lucene/solr/branches/cloud/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/SearchHandler.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/SearchHandler.java?rev=898437&r1=898436&r2=898437&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/SearchHandler.java
(original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/handler/component/SearchHandler.java
Tue Jan 12 17:40:39 2010
@@ -40,6 +40,8 @@
 import org.apache.lucene.queryParser.ParseException;
 import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
 import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
+import org.apache.commons.httpclient.params.HttpMethodParams;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -366,7 +368,13 @@
     mgr.getParams().setConnectionTimeout(SearchHandler.connectionTimeout);
     mgr.getParams().setSoTimeout(SearchHandler.soTimeout);
     // mgr.getParams().setStaleCheckingEnabled(false);
+
     client = new HttpClient(mgr);
+
+    // prevent retries  (note: this didn't work when set on mgr.. needed to be set on client)
+    DefaultHttpMethodRetryHandler retryhandler = new DefaultHttpMethodRetryHandler(0, false);
+    client.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryhandler);
+
     try {
       loadbalancer = new LBHttpSolrServer(client);
     } catch (MalformedURLException e) {

Modified: lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java?rev=898437&r1=898436&r2=898437&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
(original)
+++ lucene/solr/branches/cloud/src/solrj/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
Tue Jan 12 17:40:39 2010
@@ -18,6 +18,9 @@
 
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.DefaultMethodRetryHandler;
+import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
+import org.apache.commons.httpclient.params.HttpMethodParams;
 import org.apache.solr.client.solrj.*;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.util.NamedList;
@@ -172,6 +175,9 @@
 
   public LBHttpSolrServer(String... solrServerUrls) throws MalformedURLException {
     this(new HttpClient(new MultiThreadedHttpConnectionManager()), solrServerUrls);
+
+    DefaultHttpMethodRetryHandler retryhandler = new DefaultHttpMethodRetryHandler(0, false);
+    httpClient.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryhandler);
   }
 
   /** The provided httpClient should use a multi-threaded connection manager */ 
@@ -185,7 +191,7 @@
           throws MalformedURLException {
     this.httpClient = httpClient;
     for (String s : solrServerUrl) {
-      ServerWrapper wrapper = new ServerWrapper(new CommonsHttpSolrServer(s, httpClient,
parser));
+      ServerWrapper wrapper = new ServerWrapper(makeServer(s));
       aliveServers.put(wrapper.getKey(), wrapper);
     }
     updateAliveList();
@@ -319,7 +325,7 @@
   }
 
   public void addSolrServer(String server) throws MalformedURLException {
-    CommonsHttpSolrServer solrServer = new CommonsHttpSolrServer(server, httpClient);
+    CommonsHttpSolrServer solrServer = makeServer(server);
     addToAlive(new ServerWrapper(solrServer));
   }
 

Modified: lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java?rev=898437&r1=898436&r2=898437&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java
(original)
+++ lucene/solr/branches/cloud/src/test/org/apache/solr/BaseDistributedSearchTestCase.java
Tue Jan 12 17:40:39 2010
@@ -43,7 +43,7 @@
   protected String context = "/solr";
   protected String shards;
   protected String[] shardsArr;
-  protected String[] deadServers = {"localhost:33331/solr","localhost:33332/solr"};
+  protected String[] deadServers = {"does_not_exist_54321:33331/solr","localhost:33332/solr"};
   protected File testDir;
   protected SolrServer controlClient;
   protected int portSeed;

Modified: lucene/solr/branches/cloud/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java?rev=898437&r1=898436&r2=898437&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
(original)
+++ lucene/solr/branches/cloud/src/test/org/apache/solr/client/solrj/TestLBHttpSolrServer.java
Tue Jan 12 17:40:39 2010
@@ -44,7 +44,7 @@
  */
 public class TestLBHttpSolrServer extends TestCase {
   SolrInstance[] solr = new SolrInstance[3];
-  HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
+  // HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());
 
   public void setUp() throws Exception {
     for (int i = 0; i < solr.length; i++) {
@@ -63,7 +63,7 @@
       doc.addField("name", solrInstance.name);
       docs.add(doc);
     }
-    CommonsHttpSolrServer solrServer = new CommonsHttpSolrServer(solrInstance.getUrl(), httpClient);
+    CommonsHttpSolrServer solrServer = new CommonsHttpSolrServer(solrInstance.getUrl());
     UpdateResponse resp = solrServer.add(docs);
     assertEquals(0, resp.getStatus());
     resp = solrServer.commit();
@@ -84,9 +84,9 @@
     }
     String[] servers = serverList.toArray(new String[serverList.size()]);
 
-    LBHttpSolrServer lb = new LBHttpSolrServer(httpClient, servers);
+    LBHttpSolrServer lb = new LBHttpSolrServer(servers);
     lb.setAliveCheckInterval(500);
-    LBHttpSolrServer lb2 = new LBHttpSolrServer(httpClient);
+    LBHttpSolrServer lb2 = new LBHttpSolrServer();
     lb2.setAliveCheckInterval(500);
 
 
@@ -176,11 +176,11 @@
 
     
     // slow LB for Simple API
-    LBHttpSolrServer slowLB = new LBHttpSolrServer(httpClient, servers);
+    LBHttpSolrServer slowLB = new LBHttpSolrServer(servers);
     slowLB.setAliveCheckInterval(1000000000);
 
     // slow LB for advanced API
-    LBHttpSolrServer slowLB2 = new LBHttpSolrServer(httpClient);
+    LBHttpSolrServer slowLB2 = new LBHttpSolrServer();
     slowLB2.setAliveCheckInterval(1000000000);
 
     // stop all solr servers
@@ -240,7 +240,7 @@
 
   // this test is a subset of testSimple and is no longer needed
   public void XtestTwoServers() throws Exception {
-    LBHttpSolrServer lbHttpSolrServer = new LBHttpSolrServer(httpClient, solr[0].getUrl(),
solr[1].getUrl());
+    LBHttpSolrServer lbHttpSolrServer = new LBHttpSolrServer(solr[0].getUrl(), solr[1].getUrl());
     lbHttpSolrServer.setAliveCheckInterval(500);
     SolrQuery solrQuery = new SolrQuery("*:*");
     Set<String> names = new HashSet<String>();



Mime
View raw message