You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2013/12/23 12:44:21 UTC

svn commit: r1553095 - in /lucene/dev/trunk/solr: core/src/java/org/apache/solr/cloud/ core/src/test/org/apache/solr/cloud/ solrj/src/java/org/apache/solr/common/cloud/

Author: noble
Date: Mon Dec 23 11:44:21 2013
New Revision: 1553095

URL: http://svn.apache.org/r1553095
Log:
SOLR-5525 use hasCollection()

Modified:
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/Overseer.java
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
    lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/Overseer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/Overseer.java?rev=1553095&r1=1553094&r2=1553095&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/Overseer.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/Overseer.java Mon Dec 23 11:44:21 2013
@@ -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;
       }

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java?rev=1553095&r1=1553094&r2=1553095&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java Mon Dec 23 11:44:21 2013
@@ -366,8 +366,7 @@ public class OverseerCollectionProcessor
       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
     }
 
     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
     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
   }
   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);
     }
     

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java?rev=1553095&r1=1553094&r2=1553095&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java Mon Dec 23 11:44:21 2013
@@ -387,8 +387,7 @@ public class CollectionsAPIDistributedZk
     createNewSolrServer("", baseUrl).request(request);
     
     cloudClient.getZkStateReader().updateClusterState(true);
-    assertFalse(cloudClient.getZkStateReader().getClusterState()
-        .getCollections().contains("halfdeletedcollection2"));
+    assertFalse(cloudClient.getZkStateReader().getClusterState().hasCollection("halfdeletedcollection2"));
     
   }
 

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java?rev=1553095&r1=1553094&r2=1553095&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/UnloadDistributedZkTest.java Mon Dec 23 11:44:21 2013
@@ -138,7 +138,7 @@ public class UnloadDistributedZkTest ext
     //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");

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java?rev=1553095&r1=1553094&r2=1553095&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java (original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/common/cloud/ZkNodeProps.java Mon Dec 23 11:44:21 2013
@@ -146,4 +146,9 @@ public class ZkNodeProps implements JSON
     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());
+  }
 }