Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

tests: add test hook for SolrCmdDistributor error

Yonik Seeley5c06a17708e6
diff --git a/solr/core/src/java/org/apache/solr/core/Diagnostics.java b/solr/core/src/java/org/apache/solr/core/Diagnostics.java
index c1cc5787ad2..84c76e04550 100644
--- a/solr/core/src/java/org/apache/solr/core/Diagnostics.java
+++ b/solr/core/src/java/org/apache/solr/core/Diagnostics.java
@@ -26,6 +26,18 @@ import java.lang.management.ThreadInfo;
public class Diagnostics {
protected static Logger log = LoggerFactory.getLogger(Diagnostics.class);
+ public interface Callable {
+ public void call(Object... data); // data depends on the context
+ }
+
+ public static void call(Callable callable, Object... data) {
+ try {
+ callable.call(data);
+ } catch (Throwable th) {
+ log.error("TEST HOOK EXCEPTION", th);
+ }
+ }
+
public static void logThreadDumps(String message) {
StringBuilder sb = new StringBuilder(32768);
if (message == null) message = "============ THREAD DUMP REQUESTED ============";
@@ -39,4 +51,5 @@ public class Diagnostics {
log.error(sb.toString());
}
+
}
diff --git a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
index 8c7e4615583..6bec6d43c77 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
@@ -40,6 +40,7 @@ import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.ZkCoreNodeProps;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.core.Diagnostics;
import org.apache.solr.core.SolrCore;
import org.apache.solr.util.AdjustableSemaphore;
import org.slf4j.Logger;
@@ -359,6 +360,8 @@ public class SolrCmdDistributor {
}
+ public static Diagnostics.Callable testing_errorHook; // called on error when forwarding request. Currently data=[this, Request]
+
void checkResponses(boolean block) {
while (pending != null && pending.size() > 0) {
@@ -372,7 +375,9 @@ public class SolrCmdDistributor {
Request sreq = future.get();
if (sreq.rspCode != 0) {
// error during request
-
+
+ if (testing_errorHook != null) Diagnostics.call(testing_errorHook, this, sreq);
+
// if there is a retry url, we want to retry...
boolean isRetry = sreq.node.checkRetry();
boolean doRetry = false;