lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1583369 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/core/ solr/core/src/test/org/apache/solr/cloud/ solr/solrj/ solr/solrj/src/java/org/apache/solr/client/solrj/impl/ solr/test-framework/ solr/test-framework/src/java/org/apache/solr...
Date Mon, 31 Mar 2014 16:23:34 GMT
Author: markrmiller
Date: Mon Mar 31 16:23:34 2014
New Revision: 1583369

URL: http://svn.apache.org/r1583369
Log:
SOLR-5934: Commit again to 4x - different JIRA caused the failes - LBHttpSolrServer exception
handling improvement and small test improvements.

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
    lucene/dev/branches/branch_4x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
    lucene/dev/branches/branch_4x/solr/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java

Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1583369&r1=1583368&r2=1583369&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Mon Mar 31 16:23:34 2014
@@ -199,6 +199,9 @@ Other Changes
 
 * SOLR-5936: Deprecate non-Trie-based numeric & date field types. (Steve Rowe)
 
+* SOLR-5934: LBHttpSolrServer exception handling improvement and small test
+  improvements. (Gregory Chanan via Mark Miller)
+
 ==================  4.7.1  ==================
 
 Versions of Major Components

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java?rev=1583369&r1=1583368&r2=1583369&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
Mon Mar 31 16:23:34 2014
@@ -75,14 +75,14 @@ public class ChaosMonkeyNothingIsSafeTes
     SolrCmdDistributor.testing_errorHook = null;
   }
   
-  public static String[] fieldNames = new String[]{"f_i", "f_f", "f_d", "f_l", "f_dt"};
-  public static RandVal[] randVals = new RandVal[]{rint, rfloat, rdouble, rlong, rdate};
+  protected static final String[] fieldNames = new String[]{"f_i", "f_f", "f_d", "f_l", "f_dt"};
+  protected static final RandVal[] randVals = new RandVal[]{rint, rfloat, rdouble, rlong,
rdate};
   
-  protected String[] getFieldNames() {
+  public String[] getFieldNames() {
     return fieldNames;
   }
 
-  protected RandVal[] getRandValues() {
+  public RandVal[] getRandValues() {
     return randVals;
   }
   

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java?rev=1583369&r1=1583368&r2=1583369&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
Mon Mar 31 16:23:34 2014
@@ -58,14 +58,14 @@ public class ChaosMonkeySafeLeaderTest e
     SolrCmdDistributor.testing_errorHook = null;
   }
   
-  public static String[] fieldNames = new String[]{"f_i", "f_f", "f_d", "f_l", "f_dt"};
-  public static RandVal[] randVals = new RandVal[]{rint, rfloat, rdouble, rlong, rdate};
+  protected static final String[] fieldNames = new String[]{"f_i", "f_f", "f_d", "f_l", "f_dt"};
+  protected static final RandVal[] randVals = new RandVal[]{rint, rfloat, rdouble, rlong,
rdate};
   
-  protected String[] getFieldNames() {
+  public String[] getFieldNames() {
     return fieldNames;
   }
 
-  protected RandVal[] getRandValues() {
+  public RandVal[] getRandValues() {
     return randVals;
   }
   

Modified: lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java?rev=1583369&r1=1583368&r2=1583369&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
(original)
+++ lucene/dev/branches/branch_4x/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
Mon Mar 31 16:23:34 2014
@@ -298,85 +298,17 @@ public class LBHttpSolrServer extends So
       rsp.server = serverStr;
       HttpSolrServer server = makeServer(serverStr);
 
-      try {
-        rsp.rsp = server.request(req.getRequest());
+      ex = doRequest(server, req, rsp, isUpdate, false, null);
+      if (ex == null) {
         return rsp; // SUCCESS
-      } catch (SolrException e) {
-        // we retry on 404 or 403 or 503 or 500
-        // unless it's an update - then we only retry on connect exceptions
-        if (!isUpdate && RETRY_CODES.contains(e.code())) {
-          ex = addZombie(server, e);
-        } else {
-          // Server is alive but the request was likely malformed or invalid
-          throw e;
-        }
-      } catch (SocketException e) {
-        if (!isUpdate || e instanceof ConnectException) {
-          ex = addZombie(server, e);
-        } else {
-          throw e;
-        }
-      } catch (SocketTimeoutException e) {
-        if (!isUpdate) {
-          ex = addZombie(server, e);
-        } else {
-          throw e;
-        }
-      } catch (SolrServerException e) {
-        Throwable rootCause = e.getRootCause();
-        if (!isUpdate && rootCause instanceof IOException) {
-          ex = addZombie(server, e);
-        } else if (isUpdate && rootCause instanceof ConnectException) {
-          ex = addZombie(server, e);
-        } else {
-          throw e;
-        }
-      } catch (Exception e) {
-        throw new SolrServerException(e);
       }
     }
 
     // try the servers we previously skipped
     for (ServerWrapper wrapper : skipped) {
-      try {
-        rsp.rsp = wrapper.solrServer.request(req.getRequest());
-        zombieServers.remove(wrapper.getKey());
-        return rsp; // SUCCESS
-      } catch (SolrException e) {
-        // we retry on 404 or 403 or 503 or 500
-        // unless it's an update - then we only retry on connect exceptions
-        if (!isUpdate && RETRY_CODES.contains(e.code())) {
-          ex = e;
-          // already a zombie, no need to re-add
-        } else {
-          // Server is alive but the request was malformed or invalid
-          zombieServers.remove(wrapper.getKey());
-          throw e;
-        }
-
-      } catch (SocketException e) {
-        if (!isUpdate || e instanceof ConnectException) {
-          ex = e;
-        } else {
-          throw e;
-        }
-      } catch (SocketTimeoutException e) {
-        if (!isUpdate) {
-          ex = e;
-        } else {
-          throw e;
-        }
-      } catch (SolrServerException e) {
-        Throwable rootCause = e.getRootCause();
-        if (!isUpdate && rootCause instanceof IOException) {
-          ex = e;
-        } else if (isUpdate && rootCause instanceof ConnectException) {
-          ex = e;
-        } else {
-          throw e;
-        }
-      } catch (Exception e) {
-        throw new SolrServerException(e);
+      ex = doRequest(wrapper.solrServer, req, rsp, isUpdate, true, wrapper.getKey());
+      if (ex == null) {
+         return rsp; // SUCCESS
       }
     }
 
@@ -401,7 +333,53 @@ public class LBHttpSolrServer extends So
     return e;
   }  
 
+  protected Exception doRequest(HttpSolrServer server, Req req, Rsp rsp, boolean isUpdate,
+      boolean isZombie, String zombieKey) throws SolrServerException, IOException {
+    Exception ex = null;
+    try {
+      rsp.rsp = server.request(req.getRequest());
+      if (isZombie) {
+        zombieServers.remove(zombieKey);
+      }
+    } catch (SolrException e) {
+      // we retry on 404 or 403 or 503 or 500
+      // unless it's an update - then we only retry on connect exception
+      if (!isUpdate && RETRY_CODES.contains(e.code())) {
+        ex = (!isZombie) ? addZombie(server, e) : e;
+      } else {
+        // Server is alive but the request was likely malformed or invalid
+        if (isZombie) {
+          zombieServers.remove(zombieKey);
+        }
+        throw e;
+      }
+    } catch (SocketException e) {
+      if (!isUpdate || e instanceof ConnectException) {
+        ex = (!isZombie) ? addZombie(server, e) : e;
+      } else {
+        throw e;
+      }
+    } catch (SocketTimeoutException e) {
+      if (!isUpdate) {
+        ex = (!isZombie) ? addZombie(server, e) : e;
+      } else {
+        throw e;
+      }
+    } catch (SolrServerException e) {
+      Throwable rootCause = e.getRootCause();
+      if (!isUpdate && rootCause instanceof IOException) {
+        ex = (!isZombie) ? addZombie(server, e) : e;
+      } else if (isUpdate && rootCause instanceof ConnectException) {
+        ex = (!isZombie) ? addZombie(server, e) : e;
+      } else {
+        throw e;
+      }
+    } catch (Exception e) {
+      throw new SolrServerException(e);
+    }
 
+    return ex;
+  }
 
   private void updateAliveList() {
     synchronized (aliveServers) {

Modified: lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1583369&r1=1583368&r2=1583369&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
(original)
+++ lucene/dev/branches/branch_4x/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
Mon Mar 31 16:23:34 2014
@@ -1138,27 +1138,23 @@ public abstract class AbstractFullDistri
     Set<SolrDocument> onlyInB = new HashSet<>(setB);
     onlyInB.removeAll(setA);
 
-    if (onlyInA.size() > 0) {
-      for (SolrDocument doc : onlyInA) {
-        if (!addFails.contains(doc.getFirstValue("id"))) {
-          legal = false;
-        } else {
-          System.err.println("###### Only in " + aName + ": " + onlyInA
-              + ", but this is expected because we found an add fail for "
-              + doc.getFirstValue("id"));
-        }
+    for (SolrDocument doc : onlyInA) {
+      if (!addFails.contains(doc.getFirstValue("id"))) {
+        legal = false;
+      } else {
+        System.err.println("###### Only in " + aName + ": " + onlyInA
+            + ", but this is expected because we found an add fail for "
+            + doc.getFirstValue("id"));
       }
-      
     }
-    if (onlyInB.size() > 0) {
-      for (SolrDocument doc : onlyInB) {
-        if (!deleteFails.contains(doc.getFirstValue("id"))) {
-          legal = false;
-        } else {
-          System.err.println("###### Only in " + bName + ": " + onlyInB
-              + ", but this is expected because we found a delete fail for "
-              + doc.getFirstValue("id"));
-        }
+      
+    for (SolrDocument doc : onlyInB) {
+      if (!deleteFails.contains(doc.getFirstValue("id"))) {
+        legal = false;
+      } else {
+        System.err.println("###### Only in " + bName + ": " + onlyInB
+            + ", but this is expected because we found a delete fail for "
+            + doc.getFirstValue("id"));
       }
     }
     
@@ -1656,8 +1652,12 @@ public abstract class AbstractFullDistri
     if (client == null) {
       final String baseUrl = getBaseUrl((HttpSolrServer) clients.get(clientIndex));
       SolrServer server = createNewSolrServer("", baseUrl);
-      res.setResponse(server.request(request));
-      server.shutdown();
+      try {
+        res.setResponse(server.request(request));
+        server.shutdown();
+      } finally {
+        if (server != null) server.shutdown();
+      }
     } else {
       res.setResponse(client.request(request));
     }



Mime
View raw message