add a retry

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1293346 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2012-02-24 17:16:34 +00:00
parent 6d2ef6a1e4
commit 51ae7ee512
1 changed files with 15 additions and 6 deletions

View File

@ -1088,14 +1088,23 @@ public final class ZkController {
if (waitForNotLive){
prepCmd.setCheckLive(false);
}
try {
server.request(prepCmd);
} catch (Exception e) {
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
"Could not talk to the leader", e);
// let's retry a couple times - perhaps the leader just went down,
// or perhaps he is just not quite ready for us yet
for (int i = 0; i < 3; i++) {
try {
server.request(prepCmd);
break;
} catch (Exception e) {
SolrException.log(log, "There was a problem making a request to the leader", e);
try {
Thread.sleep(2000);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
}
}
}
server.shutdown();
}
return leaderProps;