SOLR-5509: Do not retry to yourself.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1546286 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2013-11-28 05:15:16 +00:00
parent 301d7a080a
commit 8ed8d46efe
3 changed files with 14 additions and 7 deletions

View File

@ -360,12 +360,14 @@ public class SolrCmdDistributor {
private ZkStateReader zkStateReader;
private String collection;
private String shardId;
private String fromAddress;
public RetryNode(ZkCoreNodeProps nodeProps, ZkStateReader zkStateReader, String collection, String shardId) {
public RetryNode(ZkCoreNodeProps nodeProps, ZkStateReader zkStateReader, String collection, String shardId, String fromCoreUrl) {
super(nodeProps);
this.zkStateReader = zkStateReader;
this.collection = collection;
this.shardId = shardId;
this.fromAddress = fromCoreUrl;
}
@Override
@ -383,6 +385,10 @@ public class SolrCmdDistributor {
return true;
}
if (fromAddress.equals(leaderProps.getCoreUrl())) {
// we became the leader
return false;
}
this.nodeProps = leaderProps;
return true;

View File

@ -298,7 +298,8 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
} else {
// I need to forward onto the leader...
nodes = new ArrayList<Node>(1);
nodes.add(new RetryNode(new ZkCoreNodeProps(leaderReplica), zkController.getZkStateReader(), collection, shardId));
nodes.add(new RetryNode(new ZkCoreNodeProps(leaderReplica), zkController.getZkStateReader(), collection, shardId, ZkCoreNodeProps.getCoreUrl(
zkController.getBaseUrl(), req.getCore().getName())));
forwardToLeader = true;
}

View File

@ -331,7 +331,7 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
final AtomicInteger retries = new AtomicInteger();
ZkNodeProps nodeProps = new ZkNodeProps(ZkStateReader.BASE_URL_PROP, solrclient1.getBaseURL(), ZkStateReader.CORE_NAME_PROP, "");
RetryNode retryNode = new RetryNode(new ZkCoreNodeProps(nodeProps), null, "collection1", "shard1") {
RetryNode retryNode = new RetryNode(new ZkCoreNodeProps(nodeProps), null, "collection1", "shard1", "locahost") {
@Override
public boolean checkRetry() {
retries.incrementAndGet();
@ -367,7 +367,7 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
final AtomicInteger retries = new AtomicInteger();
nodeProps = new ZkNodeProps(ZkStateReader.BASE_URL_PROP, solrclient.getBaseURL(), ZkStateReader.CORE_NAME_PROP, "");
RetryNode retryNode = new RetryNode(new ZkCoreNodeProps(nodeProps), null, "collection1", "shard1") {
RetryNode retryNode = new RetryNode(new ZkCoreNodeProps(nodeProps), null, "collection1", "shard1", "locahost") {
@Override
public boolean checkRetry() {
ss.setExp(null);
@ -413,7 +413,7 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
final AtomicInteger retries = new AtomicInteger();
nodeProps = new ZkNodeProps(ZkStateReader.BASE_URL_PROP, solrclient.getBaseURL(), ZkStateReader.CORE_NAME_PROP, "");
RetryNode retryNode = new RetryNode(new ZkCoreNodeProps(nodeProps), null, "collection1", "shard1") {
RetryNode retryNode = new RetryNode(new ZkCoreNodeProps(nodeProps), null, "collection1", "shard1", "locahost") {
@Override
public boolean checkRetry() {
retries.incrementAndGet();
@ -457,7 +457,7 @@ public class SolrCmdDistributorTest extends BaseDistributedSearchTestCase {
ArrayList<Node> nodes = new ArrayList<Node>();
ZkNodeProps nodeProps = new ZkNodeProps(ZkStateReader.BASE_URL_PROP, "[ff01::114]:33332" + context, ZkStateReader.CORE_NAME_PROP, "");
RetryNode retryNode = new RetryNode(new ZkCoreNodeProps(nodeProps), null, "collection1", "shard1") {
RetryNode retryNode = new RetryNode(new ZkCoreNodeProps(nodeProps), null, "collection1", "shard1", "locahost") {
@Override
public boolean checkRetry() {
ZkNodeProps leaderProps = new ZkNodeProps(ZkStateReader.BASE_URL_PROP, solrclient.getBaseURL(),