You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2015/02/26 23:19:14 UTC

svn commit: r1662589 - in /lucene/dev/branches/lucene_solr_4_10/solr: CHANGES.txt core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java

Author: anshum
Date: Thu Feb 26 22:19:14 2015
New Revision: 1662589

URL: http://svn.apache.org/r1662589
Log:
SOLR-7038: Validate config set presence before trying to create a collection (merge from branch_5x)

Modified:
    lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt
    lucene/dev/branches/lucene_solr_4_10/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java
    lucene/dev/branches/lucene_solr_4_10/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java

Modified: lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt?rev=1662589&r1=1662588&r2=1662589&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt Thu Feb 26 22:19:14 2015
@@ -78,6 +78,9 @@ Bug Fixes
   
 * SOLR-6928: solr.cmd stop works only in english (john.work, Jan Høydahl, Timothy Potter)
 
+* SOLR-7038: Validate the presence of configset before trying to create a collection.
+  (Anshum Gupta, Mark Miller)
+
 * SOLR-7016: Fix bin\solr.cmd to work in a directory with spaces in the name.
   (Timothy Potter, Uwe Schindler)
 

Modified: lucene/dev/branches/lucene_solr_4_10/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java?rev=1662589&r1=1662588&r2=1662589&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java (original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java Thu Feb 26 22:19:14 2015
@@ -2116,6 +2116,13 @@ public class OverseerCollectionProcessor
       throw new SolrException(ErrorCode.BAD_REQUEST, "collection already exists: " + collectionName);
     }
     
+    String configName = getConfigName(collectionName, message);
+    if (configName == null) {
+      throw new SolrException(ErrorCode.BAD_REQUEST, "No config set found to associate with the collection.");
+    } else if (!validateConfig(configName)) {
+      throw new SolrException(ErrorCode.BAD_REQUEST, "Can not find the specified config set: " + configName);
+    }
+
     try {
       // look at the replication factor and see if it matches reality
       // if it does not, find best nodes to create more cores
@@ -2196,8 +2203,8 @@ public class OverseerCollectionProcessor
       }
       boolean isLegacyCloud =  Overseer.isLegacy(zkStateReader.getClusterProps());
 
-      String configName = createConfNode(collectionName, message, isLegacyCloud);
-
+      createConfNode(configName, collectionName, isLegacyCloud);
+      
       Overseer.getInQueue(zkStateReader.getZkClient()).offer(ZkStateReader.toJSON(message));
 
       // wait for a while until we don't see the collection
@@ -2432,11 +2439,12 @@ public class OverseerCollectionProcessor
     } while (srsp != null);
   }
 
-  private String createConfNode(String coll, ZkNodeProps message, boolean isLegacyCloud) throws KeeperException, InterruptedException {
+  private String getConfigName(String coll, ZkNodeProps message) throws KeeperException, InterruptedException {
     String configName = message.getStr(OverseerCollectionProcessor.COLL_CONF);
-    if(configName == null){
+    
+    if(configName == null) {
       // if there is only one conf, use that
-      List<String> configNames=null;
+      List<String> configNames = null;
       try {
         configNames = zkStateReader.getZkClient().getChildren(ZkController.CONFIGS_ZKNODE, null, true);
         if (configNames != null && configNames.size() == 1) {
@@ -2447,9 +2455,15 @@ public class OverseerCollectionProcessor
       } catch (KeeperException.NoNodeException e) {
 
       }
-
     }
+    return configName;
+  }
 
+  private boolean validateConfig(String configName) throws KeeperException, InterruptedException {
+    return zkStateReader.getZkClient().exists(ZkController.CONFIGS_ZKNODE + "/" + configName, true);
+  }
+  
+  private void createConfNode(String configName, String coll, boolean isLegacyCloud) throws KeeperException, InterruptedException {
     if(configName!= null){
       log.info("creating collections conf node {} ",ZkStateReader.COLLECTIONS_ZKNODE + "/" + coll);
       zkStateReader.getZkClient().makePath(ZkStateReader.COLLECTIONS_ZKNODE + "/" + coll,
@@ -2462,7 +2476,6 @@ public class OverseerCollectionProcessor
         throw new SolrException(ErrorCode.BAD_REQUEST,"Unable to get config name");
       }
     }
-    return configName;
 
   }
 

Modified: lucene/dev/branches/lucene_solr_4_10/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java?rev=1662589&r1=1662588&r2=1662589&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java (original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java Thu Feb 26 22:19:14 2015
@@ -346,6 +346,8 @@ public class OverseerCollectionProcessor
         return zkMap.containsKey(key);
       }
     }).anyTimes();
+
+    zkMap.put("/configs/myconfig", null);
     
     return liveNodes;
   }