lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hoss...@apache.org
Subject svn commit: r1375690 - in /lucene/dev/branches/branch_4x: ./ dev-tools/ lucene/ lucene/analysis/ lucene/analysis/icu/src/java/org/apache/lucene/collation/ lucene/backwards/ lucene/benchmark/ lucene/core/ lucene/demo/ lucene/facet/ lucene/grouping/ luce...
Date Tue, 21 Aug 2012 17:46:57 GMT
Author: hossman
Date: Tue Aug 21 17:46:55 2012
New Revision: 1375690

URL: http://svn.apache.org/viewvc?rev=1375690&view=rev
Log:
SOLR-3746: Proper error reporting if updateLog is configured w/o necessary _version_ field
in schema.xml (merge r1375674)

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/dev-tools/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/BUILD.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/JRE_VERSION_MIGRATION.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/LICENSE.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/MIGRATE.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/README.txt   (props changed)
    lucene/dev/branches/branch_4x/lucene/analysis/   (props changed)
    lucene/dev/branches/branch_4x/lucene/analysis/icu/src/java/org/apache/lucene/collation/ICUCollationKeyFilterFactory.java
  (props changed)
    lucene/dev/branches/branch_4x/lucene/backwards/   (props changed)
    lucene/dev/branches/branch_4x/lucene/benchmark/   (props changed)
    lucene/dev/branches/branch_4x/lucene/build.xml   (props changed)
    lucene/dev/branches/branch_4x/lucene/common-build.xml   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/demo/   (props changed)
    lucene/dev/branches/branch_4x/lucene/facet/   (props changed)
    lucene/dev/branches/branch_4x/lucene/grouping/   (props changed)
    lucene/dev/branches/branch_4x/lucene/highlighter/   (props changed)
    lucene/dev/branches/branch_4x/lucene/ivy-settings.xml   (props changed)
    lucene/dev/branches/branch_4x/lucene/join/   (props changed)
    lucene/dev/branches/branch_4x/lucene/licenses/   (props changed)
    lucene/dev/branches/branch_4x/lucene/memory/   (props changed)
    lucene/dev/branches/branch_4x/lucene/misc/   (props changed)
    lucene/dev/branches/branch_4x/lucene/module-build.xml   (props changed)
    lucene/dev/branches/branch_4x/lucene/queries/   (props changed)
    lucene/dev/branches/branch_4x/lucene/queryparser/   (props changed)
    lucene/dev/branches/branch_4x/lucene/sandbox/   (props changed)
    lucene/dev/branches/branch_4x/lucene/site/   (props changed)
    lucene/dev/branches/branch_4x/lucene/spatial/   (props changed)
    lucene/dev/branches/branch_4x/lucene/suggest/   (props changed)
    lucene/dev/branches/branch_4x/lucene/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/lucene/tools/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/solr/LICENSE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/README.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/build.xml   (props changed)
    lucene/dev/branches/branch_4x/solr/cloud-dev/   (props changed)
    lucene/dev/branches/branch_4x/solr/common-build.xml   (props changed)
    lucene/dev/branches/branch_4x/solr/contrib/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrCore.java
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/VersionInfo.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestBadConfig.java
    lucene/dev/branches/branch_4x/solr/dev-tools/   (props changed)
    lucene/dev/branches/branch_4x/solr/example/   (props changed)
    lucene/dev/branches/branch_4x/solr/lib/   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/httpclient-LICENSE-ASL.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/httpclient-NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/httpcore-LICENSE-ASL.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/httpcore-NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/httpmime-LICENSE-ASL.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/licenses/httpmime-NOTICE.txt   (props changed)
    lucene/dev/branches/branch_4x/solr/scripts/   (props changed)
    lucene/dev/branches/branch_4x/solr/solrj/   (props changed)
    lucene/dev/branches/branch_4x/solr/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/solr/testlogging.properties   (props changed)
    lucene/dev/branches/branch_4x/solr/webapp/   (props changed)

Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1375690&r1=1375689&r2=1375690&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Tue Aug 21 17:46:55 2012
@@ -70,6 +70,9 @@ Bug Fixes
   conjunction with stored copyField targets by making real-time get never
   return copyField targets. (yonik)
 
+* SOLR-3746: Proper error reporting if updateLog is configured w/o necessary 
+  "_version_" field in schema.xml (hossman)
+
 
 Other Changes
 ----------------------

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrCore.java?rev=1375690&r1=1375689&r2=1375690&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/core/SolrCore.java Tue
Aug 21 17:46:55 2012
@@ -479,6 +479,13 @@ public final class SolrCore implements S
     } catch (SolrException e) {
       throw e;
     } catch (Exception e) {
+      // The JVM likes to wrap our helpful SolrExceptions in things like
+      // "InvocationTargetException" that have no useful getMessage
+      if (null != e.getCause() && e.getCause() instanceof SolrException) {
+        SolrException inner = (SolrException) e.getCause();
+        throw inner;
+      }
+
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Error Instantiating "+msg+",
"+className+ " failed to instantiate " +cast.getName(), e);
     }
   }
@@ -502,6 +509,13 @@ public final class SolrCore implements S
     } catch (SolrException e) {
       throw e;
     } catch (Exception e) {
+      // The JVM likes to wrap our helpful SolrExceptions in things like
+      // "InvocationTargetException" that have no useful getMessage
+      if (null != e.getCause() && e.getCause() instanceof SolrException) {
+        SolrException inner = (SolrException) e.getCause();
+        throw inner;
+      }
+
       throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Error Instantiating "+msg+",
"+className+ " failed to instantiate " + UpdateHandler.class.getName(), e);
     }
   }

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/VersionInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/VersionInfo.java?rev=1375690&r1=1375689&r2=1375690&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/VersionInfo.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/update/VersionInfo.java
Tue Aug 21 17:46:55 2012
@@ -28,6 +28,7 @@ import org.apache.lucene.util.BitUtil;
 import org.apache.lucene.util.BytesRef;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.SchemaField;
 import org.apache.solr.search.SolrIndexSearcher;
 import org.apache.solr.util.RefCounted;
@@ -41,10 +42,45 @@ public class VersionInfo {
   private SchemaField idField;
   final ReadWriteLock lock = new ReentrantReadWriteLock(true);
 
+  /**
+   * Gets and returns the {@link #VERSION_FIELD} from the specified 
+   * schema, after verifying that it is indexed, stored, and single-valued.  
+   * If any of these pre-conditions are not met, it throws a SolrException 
+   * with a user suitable message indicating the problem.
+   */
+  public static SchemaField getAndCheckVersionField(IndexSchema schema) 
+    throws SolrException {
+    final String errPrefix = VERSION_FIELD + "field must exist in schema, using indexed=\"true\"
stored=\"true\" and multiValued=\"false\"";
+    SchemaField sf = schema.getFieldOrNull(VERSION_FIELD);
+
+    if (null == sf) {
+      throw new SolrException
+        (SolrException.ErrorCode.SERVER_ERROR, 
+         errPrefix + " (" + VERSION_FIELD + " does not exist)");
+    }
+    if ( !sf.indexed() ) {
+      throw new SolrException
+        (SolrException.ErrorCode.SERVER_ERROR, 
+         errPrefix + " (" + VERSION_FIELD + " is not indexed");
+    }
+    if ( !sf.stored() ) {
+      throw new SolrException
+        (SolrException.ErrorCode.SERVER_ERROR, 
+         errPrefix + " (" + VERSION_FIELD + " is not stored");
+    }
+    if ( sf.multiValued() ) {
+      throw new SolrException
+        (SolrException.ErrorCode.SERVER_ERROR, 
+         errPrefix + " (" + VERSION_FIELD + " is not multiValued");
+    }
+    
+    return sf;
+  }
+
   public VersionInfo(UpdateLog ulog, int nBuckets) {
     this.ulog = ulog;
     SolrCore core = ulog.uhandler.core;
-    versionField = core.getSchema().getFieldOrNull(VERSION_FIELD);
+    versionField = getAndCheckVersionField(core.getSchema());
     idField = core.getSchema().getUniqueKeyField();
     buckets = new VersionBucket[ BitUtil.nextHighestPowerOfTwo(nBuckets) ];
     for (int i=0; i<buckets.length; i++) {

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestBadConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestBadConfig.java?rev=1375690&r1=1375689&r2=1375690&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestBadConfig.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/core/TestBadConfig.java
Tue Aug 21 17:46:55 2012
@@ -27,6 +27,21 @@ public class TestBadConfig extends Abstr
     assertConfigs("bad_solrconfig.xml","schema.xml","unset.sys.property");
   }
 
+  public void testUpdateLogButNoVersionField() throws Exception {
+    
+    // :TODO: neccessary until SOLR-3699 is fixed
+    System.setProperty("solr.directoryFactory", 
+                       "org.apache.solr.core.SimpleFSDirectoryFactory");
+
+
+    System.setProperty("enable.update.log", "true");
+    try {
+      assertConfigs("solrconfig.xml", "schema12.xml", "_version_");
+    } finally {
+      System.clearProperty("enable.update.log");
+    }
+  }
+
   public void testBogusScriptEngine() throws Exception {
     // sanity check
     Assume.assumeTrue(null == (new ScriptEngineManager()).getEngineByName("giberish"));



Mime
View raw message