be careful about retrying rather than NPE

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1292312 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2012-02-22 14:30:53 +00:00
parent baee5394c1
commit fd993e0c11
1 changed files with 16 additions and 14 deletions

View File

@ -36,6 +36,7 @@ import org.apache.solr.cloud.ZkController;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.CloudState; import org.apache.solr.common.cloud.CloudState;
import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkCoreNodeProps; import org.apache.solr.common.cloud.ZkCoreNodeProps;
import org.apache.solr.common.cloud.ZkNodeProps; import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader; import org.apache.solr.common.cloud.ZkStateReader;
@ -645,20 +646,21 @@ public class CoreAdminHandler extends RequestHandlerBase {
.getZkController() .getZkController()
.getCloudState(); .getCloudState();
String collection = cloudDescriptor.getCollectionName(); String collection = cloudDescriptor.getCollectionName();
ZkNodeProps nodeProps = Slice slice = cloudState.getSlice(collection,
cloudState.getSlice(collection, cloudDescriptor.getShardId());
cloudDescriptor.getShardId()).getShards().get(coreNodeName); if (slice != null) {
ZkNodeProps nodeProps = slice.getShards().get(coreNodeName);
if (nodeProps != null) { if (nodeProps != null) {
state = nodeProps.get(ZkStateReader.STATE_PROP); state = nodeProps.get(ZkStateReader.STATE_PROP);
live = cloudState.liveNodesContain(nodeName); live = cloudState.liveNodesContain(nodeName);
if (nodeProps != null && state.equals(waitForState)) { if (nodeProps != null && state.equals(waitForState)) {
if (checkLive == null) { if (checkLive == null) {
break; break;
} else if (checkLive && live) { } else if (checkLive && live) {
break; break;
} else if (!checkLive && !live) { } else if (!checkLive && !live) {
break; break;
}
} }
} }
} }