You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2014/03/31 00:04:59 UTC
svn commit: r1583213 - in /lucene/dev/trunk/solr: ./
core/src/test/org/apache/solr/cloud/
solrj/src/java/org/apache/solr/client/solrj/impl/
test-framework/src/java/org/apache/solr/cloud/
Author: markrmiller
Date: Sun Mar 30 22:04:58 2014
New Revision: 1583213
URL: http://svn.apache.org/r1583213
Log:
SOLR-5934: LBHttpSolrServer exception handling improvement and small test improvements.
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1583213&r1=1583212&r2=1583213&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Sun Mar 30 22:04:58 2014
@@ -250,6 +250,9 @@ Other Changes
* SOLR-5914: Cleanup and fix Solr's test cleanup code.
(Mark Miller, Uwe Schindler)
+* 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/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java?rev=1583213&r1=1583212&r2=1583213&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeyNothingIsSafeTest.java Sun Mar 30 22:04:58 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/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java?rev=1583213&r1=1583212&r2=1583213&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ChaosMonkeySafeLeaderTest.java Sun Mar 30 22:04:58 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/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java?rev=1583213&r1=1583212&r2=1583213&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrServer.java Sun Mar 30 22:04:58 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/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1583213&r1=1583212&r2=1583213&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Sun Mar 30 22:04:58 2014
@@ -1137,27 +1137,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"));
}
}
@@ -1655,8 +1651,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));
}