SOLR-6603: LBHttpSolrServer - lazily allocate skipped-zombie-servers list. (This closes #97)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1630285 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2014-10-09 05:32:06 +00:00
parent d51eef911f
commit d5191d5674
2 changed files with 23 additions and 7 deletions

View File

@ -214,6 +214,12 @@ Bug Fixes
* SOLR-6545: Query field list with wild card on dynamic field fails.
(Burke Webster, Xu Zhang, shalin)
Optimizations
----------------------
* SOLR-6603: LBHttpSolrServer - lazily allocate skipped-zombie-servers list.
(Christine Poerschke via shalin)
Other Changes
----------------------

View File

@ -286,7 +286,7 @@ public class LBHttpSolrServer extends SolrServer {
Rsp rsp = new Rsp();
Exception ex = null;
boolean isUpdate = req.request instanceof IsUpdateRequest;
List<ServerWrapper> skipped = new ArrayList<>(req.getNumDeadServersToTry());
List<ServerWrapper> skipped = null;
for (String serverStr : req.getServers()) {
serverStr = normalize(serverStr);
@ -294,8 +294,16 @@ public class LBHttpSolrServer extends SolrServer {
ServerWrapper wrapper = zombieServers.get(serverStr);
if (wrapper != null) {
// System.out.println("ZOMBIE SERVER QUERIED: " + serverStr);
if (skipped.size() < req.getNumDeadServersToTry())
skipped.add(wrapper);
final int numDeadServersToTry = req.getNumDeadServersToTry();
if (numDeadServersToTry > 0) {
if (skipped == null) {
skipped = new ArrayList<>(numDeadServersToTry);
skipped.add(wrapper);
}
else if (skipped.size() < numDeadServersToTry) {
skipped.add(wrapper);
}
}
continue;
}
rsp.server = serverStr;
@ -308,10 +316,12 @@ public class LBHttpSolrServer extends SolrServer {
}
// try the servers we previously skipped
for (ServerWrapper wrapper : skipped) {
ex = doRequest(wrapper.solrServer, req, rsp, isUpdate, true, wrapper.getKey());
if (ex == null) {
return rsp; // SUCCESS
if (skipped != null) {
for (ServerWrapper wrapper : skipped) {
ex = doRequest(wrapper.solrServer, req, rsp, isUpdate, true, wrapper.getKey());
if (ex == null) {
return rsp; // SUCCESS
}
}
}