lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject svn commit: r1593130 - in /lucene/dev/branches/solr5473/solr: core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
Date Wed, 07 May 2014 20:22:23 GMT
Author: shalin
Date: Wed May  7 20:22:23 2014
New Revision: 1593130

URL: http://svn.apache.org/r1593130
Log:
SOLR-5473: Fix OCP.createConfNode and ZkStateReader.readConfigName to fail loudly if no configs
were found

Modified:
    lucene/dev/branches/solr5473/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java
    lucene/dev/branches/solr5473/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java

Modified: lucene/dev/branches/solr5473/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5473/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java?rev=1593130&r1=1593129&r2=1593130&view=diff
==============================================================================
--- lucene/dev/branches/solr5473/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java
(original)
+++ lucene/dev/branches/solr5473/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java
Wed May  7 20:22:23 2014
@@ -1976,7 +1976,7 @@ public class OverseerCollectionProcessor
       }
       boolean isLegacyCloud =  Overseer.isLegacy(zkStateReader.getClusterProps());
 
-      String configName = createConfNode(collectionName, message, isLegacyCloud);
+      String configName = createConfNode(collectionName, message);
 
       Overseer.getInQueue(zkStateReader.getZkClient()).offer(ZkStateReader.toJSON(message));
 
@@ -2207,37 +2207,32 @@ public class OverseerCollectionProcessor
   }
 
 
-  private String createConfNode(String coll, ZkNodeProps message, boolean isLegacyCloud)
throws KeeperException, InterruptedException {
+  private String createConfNode(String coll, ZkNodeProps message) throws KeeperException,
InterruptedException {
     String configName = message.getStr(OverseerCollectionProcessor.COLL_CONF);
-    if(configName == null){
-      // if there is only one conf, use that
-      List<String> configNames=null;
+
+    if (configName == null) {
+      List<String> configNames = null;
       try {
         configNames = zkStateReader.getZkClient().getChildren(ZkController.CONFIGS_ZKNODE,
null, true);
-        if (configNames != null && configNames.size() == 1) {
-          configName = configNames.get(0);
-          // no config set named, but there is only 1 - use it
-          log.info("Only one config set found in zk - using it:" + configName);
-        }
       } catch (KeeperException.NoNodeException e) {
-
+        throw new SolrException(ErrorCode.INVALID_STATE,
+            "The configs zk node doesn't exist: " + ZkController.CONFIGS_ZKNODE, e);
+      }
+      // if there is only one conf, use that
+      if (configNames != null && configNames.size() == 1) {
+        configName = configNames.get(0);
+        // no config set named, but there is only 1 - use it
+        log.info("Only one config set found in zk - using it: " + configName);
+      } else  {
+        throw new SolrException(ErrorCode.BAD_REQUEST, "Unable to determine config name for
collection: " + coll);
       }
-
     }
 
-    if(configName!= null){
-      log.info("creating collections conf node {} ",ZkStateReader.COLLECTIONS_ZKNODE + "/"
+ coll);
+    if (configName != null) {
+      log.info("creating collections conf node {} ", ZkStateReader.COLLECTIONS_ZKNODE + "/"
+ coll);
       zkStateReader.getZkClient().makePath(ZkStateReader.COLLECTIONS_ZKNODE + "/" + coll,
-          ZkStateReader.toJSON(ZkNodeProps.makeMap(ZkController.CONFIGNAME_PROP,configName)),true
);
-
-    } else {
-      if(isLegacyCloud){
-        log.warn("Could not obtain config name");
-      } else {
-        throw new SolrException(ErrorCode.BAD_REQUEST,"Unable to get config name");
-      }
+          ZkStateReader.toJSON(ZkNodeProps.makeMap(ZkController.CONFIGNAME_PROP, configName)),
true);
     }
-    return configName;
 
   }
 
@@ -2254,6 +2249,7 @@ public class OverseerCollectionProcessor
 
     processResponses(results);
 
+    return configName;
   }
 
   private void sliceCmd(ClusterState clusterState, ModifiableSolrParams params, String stateMatcher,
Slice slice) {

Modified: lucene/dev/branches/solr5473/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solr5473/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java?rev=1593130&r1=1593129&r2=1593130&view=diff
==============================================================================
--- lucene/dev/branches/solr5473/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
(original)
+++ lucene/dev/branches/solr5473/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
Wed May  7 20:22:23 2014
@@ -169,7 +169,8 @@ public class ZkStateReader {
           log.info("path={} {}={} specified config exists in ZooKeeper",
               new Object[] {path, CONFIGNAME_PROP, configName});
         }
-
+      } else  {
+        throw new ZooKeeperException(ErrorCode.INVALID_STATE, "No config data found at path:
" + path);
       }
     }
     catch (KeeperException e) {



Mime
View raw message