diff --git a/solr/core/src/java/org/apache/solr/cloud/Overseer.java b/solr/core/src/java/org/apache/solr/cloud/Overseer.java index 9298216f301..1771bd415a3 100644 --- a/solr/core/src/java/org/apache/solr/cloud/Overseer.java +++ b/solr/core/src/java/org/apache/solr/cloud/Overseer.java @@ -262,7 +262,7 @@ public class Overseer { private ClusterState buildCollection(ClusterState clusterState, ZkNodeProps message) { String collection = message.getStr("name"); log.info("building a new collection: " + collection); - if(clusterState.getCollections().contains(collection) ){ + if(clusterState.hasCollection(collection) ){ log.warn("Collection {} already exists. exit" ,collection); return clusterState; } diff --git a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java index 9d427dca8a0..9078602614a 100644 --- a/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java +++ b/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java @@ -366,8 +366,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread { boolean removed = false; while (System.currentTimeMillis() < timeout) { Thread.sleep(100); - removed = !zkStateReader.getClusterState().getCollections() - .contains(message.getStr("name")); + removed = !zkStateReader.getClusterState().hasCollection(message.getStr(collection)); if (removed) { Thread.sleep(100); // just a bit of time so it's more likely other // readers see on return @@ -609,7 +608,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread { } if (parentSlice == null) { - if(clusterState.getCollections().contains(collectionName)) { + if(clusterState.hasCollection(collectionName)) { throw new SolrException(ErrorCode.BAD_REQUEST, "No shard with the specified name exists: " + slice); } else { throw new SolrException(ErrorCode.BAD_REQUEST, "No collection with the specified name exists: " + collectionName); @@ -1003,7 +1002,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread { Slice slice = clusterState.getSlice(collection, sliceId); if (slice == null) { - if(clusterState.getCollections().contains(collection)) { + if(clusterState.hasCollection(collection)) { throw new SolrException(ErrorCode.BAD_REQUEST, "No shard with the specified name exists: " + slice); } else { @@ -1316,7 +1315,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread { } private void createCollection(ClusterState clusterState, ZkNodeProps message, NamedList results) throws KeeperException, InterruptedException { String collectionName = message.getStr("name"); - if (clusterState.getCollections().contains(collectionName)) { + if (clusterState.hasCollection(collectionName)) { throw new SolrException(ErrorCode.BAD_REQUEST, "collection already exists: " + collectionName); } diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java index d2379fff899..3579f4bfd7a 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java @@ -387,8 +387,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa createNewSolrServer("", baseUrl).request(request); cloudClient.getZkStateReader().updateClusterState(true); - assertFalse(cloudClient.getZkStateReader().getClusterState() - .getCollections().contains("halfdeletedcollection2")); + assertFalse(cloudClient.getZkStateReader().getClusterState().hasCollection("halfdeletedcollection2")); } diff --git a/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java index dbc69718db1..d7979d82043 100644 --- a/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java @@ -138,7 +138,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest { //printLayout(); // the collection should be gone timeoutAt = System.currentTimeMillis() + 30000; - while (getCommonCloudSolrServer().getZkStateReader().getClusterState().getCollections().contains(collection)) { + while (getCommonCloudSolrServer().getZkStateReader().getClusterState().hasCollection(collection)) { if (System.currentTimeMillis() > timeoutAt) { printLayout(); fail("Still found collection"); diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java index 71fa6497636..45f735cd5a4 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java @@ -146,4 +146,9 @@ public class ZkNodeProps implements JSONWriter.Writable { return propMap.containsKey(key); } + public boolean getBool(String key, boolean b) { + Object o = propMap.get(key); + if(o==null) return b; + return Boolean.parseBoolean(o.toString()); + } }