You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by gs...@apache.org on 2011/12/08 13:09:09 UTC

svn commit: r1211850 - in /lucene/dev/branches/branch_3x: ./ lucene/ solr/ solr/core/src/java/org/apache/solr/core/ solr/core/src/java/org/apache/solr/handler/component/ solr/core/src/java/org/apache/solr/servlet/ solr/core/src/test-files/solr/conf/ so...

Author: gsingers
Date: Thu Dec  8 12:09:09 2011
New Revision: 1211850

URL: http://svn.apache.org/viewvc?rev=1211850&view=rev
Log:
SOLR-1730: backport to 3x

Added:
    lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/handler/component/BadComponentTest.java
      - copied unchanged from r1211827, lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/BadComponentTest.java
Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/solr/   (props changed)
    lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/CoreContainer.java
    lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrCore.java
    lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
    lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
    lucene/dev/branches/branch_3x/solr/core/src/test-files/solr/conf/solrconfig-elevate.xml
    lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java

Modified: lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/CoreContainer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/CoreContainer.java?rev=1211850&r1=1211849&r2=1211850&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/CoreContainer.java (original)
+++ lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/CoreContainer.java Thu Dec  8 12:09:09 2011
@@ -136,6 +136,9 @@ public class CoreContainer 
       setAbortOnConfigurationError(0 < cores.numCoresAbortOnConfigError);
       
       solrConfigFilename = cores.getConfigFile().getName();
+      if (cores.cores.isEmpty()){
+        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "No cores were created, please check the logs for errors");
+      }
       
       return cores;
     }

Modified: lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrCore.java?rev=1211850&r1=1211849&r2=1211850&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrCore.java (original)
+++ lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/core/SolrCore.java Thu Dec  8 12:09:09 2011
@@ -594,11 +594,15 @@ public final class SolrCore implements S
       // Finally tell anyone who wants to know
       resourceLoader.inform( resourceLoader );
       resourceLoader.inform( this );  // last call before the latch is released.
-      instance = this;   // set singleton for backwards compatibility
-    } catch (IOException e) {
-      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
+      instance = this;
+    } catch (Throwable e) {
+      log.error("Error in constructing the core", e);
+      latch.countDown();//release the latch, otherwise we block trying to do the close.  This should be fine, since counting down on a latch of 0 is still fine
+      //close down the searcher and any other resources, if it exists, as this is not recoverable
+      close();
+      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, null, e, false);
     } finally {
-      // allow firstSearcher events to fire
+      // allow firstSearcher events to fire and make sure it is released
       latch.countDown();
     }
 

Modified: lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java?rev=1211850&r1=1211849&r2=1211850&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java (original)
+++ lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java Thu Dec  8 12:09:09 2011
@@ -197,10 +197,10 @@ public class QueryElevationComponent ext
     }
     catch( Exception ex ) {
       throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
-          "Error initializing QueryElevationComponent.", ex );
+          "Error initializing QueryElevationComponent.", ex, false );
     }
   }
-
+  //get the elevation map from the data dir
   Map<String, ElevationObj> getElevationMap( IndexReader reader, SolrCore core ) throws Exception
   {
     synchronized( elevationCache ) {
@@ -224,7 +224,7 @@ public class QueryElevationComponent ext
       return map;
     }
   }
-  
+  //load up the elevation map
   private Map<String, ElevationObj> loadElevationMap( Config cfg ) throws IOException
   {
     XPath xpath = XPathFactory.newInstance().newXPath();

Modified: lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java?rev=1211850&r1=1211849&r2=1211850&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java (original)
+++ lucene/dev/branches/branch_3x/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java Thu Dec  8 12:09:09 2011
@@ -97,7 +97,7 @@ public class SolrDispatchFilter implemen
     }
     catch( Throwable t ) {
       // catch this so our filter still works
-      log.error( "Could not start Solr. Check solr/home property", t);
+      log.error( "Could not start Solr. Check solr/home property and the logs", t);
       SolrConfig.severeErrors.add( t );
       SolrCore.log( t );
     }

Modified: lucene/dev/branches/branch_3x/solr/core/src/test-files/solr/conf/solrconfig-elevate.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/test-files/solr/conf/solrconfig-elevate.xml?rev=1211850&r1=1211849&r2=1211850&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/test-files/solr/conf/solrconfig-elevate.xml (original)
+++ lucene/dev/branches/branch_3x/solr/core/src/test-files/solr/conf/solrconfig-elevate.xml Thu Dec  8 12:09:09 2011
@@ -185,7 +185,17 @@
   <!-- test elevation -->
   <searchComponent name="elevate" class="org.apache.solr.handler.component.QueryElevationComponent" >
     <str name="queryFieldType">string</str>
-    <str name="config-file">elevate.xml</str>
+    <str name="config-file">${elevate.file:elevate.xml}</str>
+  </searchComponent>
+
+  <!-- SOLR-1730 -->
+  <!--<searchComponent name="badElevate" class="org.apache.solr.handler.component.QueryElevationComponent" >
+    <str name="queryFieldType">string</str>
+    <str name="config-file">foo.xml</str>
+  </searchComponent>-->
+  <searchComponent name="dataElevate" class="org.apache.solr.handler.component.QueryElevationComponent" >
+    <str name="queryFieldType">string</str>
+    <str name="config-file">${elevate.data.file:elevate-data.xml}</str>
   </searchComponent>
 
   <requestHandler name="/elevate" class="org.apache.solr.handler.component.SearchHandler">
@@ -197,6 +207,24 @@
     </arr>
   </requestHandler>
 
+  <requestHandler name="/dataElevate" class="org.apache.solr.handler.component.SearchHandler">
+    <lst name="defaults">
+      <str name="echoParams">explicit</str>
+    </lst>
+    <arr name="last-components">
+      <str>dataElevate</str>
+    </arr>
+  </requestHandler>
+
+  <!--<requestHandler name="/badElevate" class="org.apache.solr.handler.component.SearchHandler">
+    <lst name="defaults">
+      <str name="echoParams">explicit</str>
+    </lst>
+    <arr name="last-components">
+      <str>badElevate</str>
+    </arr>
+  </requestHandler>-->
+
   <!-- enable streaming for testing... -->
   <requestDispatcher handleSelect="true" >
     <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" />

Modified: lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java?rev=1211850&r1=1211849&r2=1211850&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java (original)
+++ lucene/dev/branches/branch_3x/solr/core/src/test/org/apache/solr/handler/component/QueryElevationComponentTest.java Thu Dec  8 12:09:09 2011
@@ -29,6 +29,7 @@ import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.MapSolrParams;
 import org.apache.solr.common.params.QueryElevationParams;
+import org.apache.solr.common.util.FileUtils;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
 import org.apache.solr.handler.component.QueryElevationComponent.ElevationObj;
@@ -44,7 +45,13 @@ public class QueryElevationComponentTest
 
   @BeforeClass
   public static void beforeClass() throws Exception {
-    initCore("solrconfig-elevate.xml","schema12.xml");
+    //write out elevate-data.xml to the Data dir first by copying it from conf, which we know exists, this way we can test both conf and data configurations
+    createTempDir();
+    File parent = new File(TEST_HOME(), "conf");
+    File elevateFile = new File(parent, "elevate.xml");
+    File elevateDataFile = new File(dataDir, "elevate-data.xml");
+    FileUtils.copyFile(elevateFile, elevateDataFile);
+    initCore("solrconfig-elevate.xml", "schema12.xml");
   }
 
   @Before