tests: add test hook for SolrCmdDistributor error

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1428156 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2013-01-03 03:48:02 +00:00
parent d28c846d34
commit 5c06a17708
2 changed files with 19 additions and 1 deletions

View File

@ -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());
}
}

View File

@ -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;