You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ja...@apache.org on 2014/10/24 00:18:32 UTC

svn commit: r1633970 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/CHANGES.txt solr/core/ solr/core/src/java/org/apache/solr/cloud/CloudUtil.java solr/core/src/java/org/apache/solr/schema/IndexSchema.java

Author: janhoy
Date: Thu Oct 23 22:18:31 2014
New Revision: 1633970

URL: http://svn.apache.org/r1633970
Log:
SOLR-6647: Bad error message when missing resource from ZK when parsing Schema (backport)

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/solr/core/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1633970&r1=1633969&r2=1633970&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Thu Oct 23 22:18:31 2014
@@ -235,6 +235,8 @@ Bug Fixes
 * SOLR-6646: bin/solr start script fails to detect solr on non-default port and then after
   30s tails wrong log file (janhoy)
 
+* SOLR-6647: Bad error message when missing resource from ZK when parsing Schema (janhoy)
+
 Optimizations
 ----------------------
 

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java?rev=1633970&r1=1633969&r2=1633970&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/cloud/CloudUtil.java Thu Oct 23 22:18:31 2014
@@ -29,6 +29,7 @@ import org.apache.solr.common.cloud.Slic
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.CoreDescriptor;
+import org.apache.solr.core.SolrResourceLoader;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -84,4 +85,18 @@ public class CloudUtil {
       }
     }
   }
+
+  /**
+   * Returns a displayable unified path to the given resource. For non-solrCloud that will be the
+   * same as getConfigDir, but for Cloud it will be getCollectionZkPath ending in a /
+   * <p/>
+   * <b>Note:</b> Do not use this to generate a valid file path, but for debug printing etc
+   * @param loader Resource loader instance
+   * @return a String of path to resource
+   */
+  public static String unifiedResourcePath(SolrResourceLoader loader) {
+    return (loader instanceof ZkSolrResourceLoader) ?
+            ((ZkSolrResourceLoader) loader).getCollectionZkPath() + "/" :
+            loader.getConfigDir();
+  }
 }

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java?rev=1633970&r1=1633969&r2=1633970&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java (original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/schema/IndexSchema.java Thu Oct 23 22:18:31 2014
@@ -26,6 +26,7 @@ import org.apache.lucene.index.MultiFiel
 import org.apache.lucene.search.similarities.Similarity;
 import org.apache.lucene.uninverting.UninvertingReader;
 import org.apache.lucene.util.Version;
+import org.apache.solr.cloud.CloudUtil;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.params.SolrParams;
@@ -443,7 +444,8 @@ public class IndexSchema {
   }
 
   protected void readSchema(InputSource is) {
-    log.info("Reading Solr Schema from " + resourceName);
+    String resourcePath = CloudUtil.unifiedResourcePath(loader) + resourceName;
+    log.info("Reading Solr Schema from " + resourcePath);
 
     try {
       // pass the config resource loader to avoid building an empty one for no reason:
@@ -592,11 +594,11 @@ public class IndexSchema {
       }
     } catch (SolrException e) {
       throw new SolrException(ErrorCode.getErrorCode(e.code()), e.getMessage() + ". Schema file is " +
-          loader.getConfigDir() + resourceName, e);
+          resourcePath, e);
     } catch(Exception e) {
       // unexpected exception...
       throw new SolrException(ErrorCode.SERVER_ERROR,
-          "Schema Parsing Failed: " + e.getMessage() + ". Schema file is " + loader.getConfigDir() + resourceName,
+          "Schema Parsing Failed: " + e.getMessage() + ". Schema file is " + resourcePath,
           e);
     }