mirror of https://github.com/apache/lucene.git
SOLR-1730: Hook in handling of bad cores, failure of QEC to load, add in test
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1211827 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c1d30a25ac
commit
97b40049d0
|
@ -215,7 +215,6 @@ public class CoreContainer
|
|||
}
|
||||
|
||||
/**
|
||||
* @exception generates an error if you attempt to set this value to false
|
||||
* @deprecated all cores now abort on configuration error regardless of configuration
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -246,6 +245,9 @@ public class CoreContainer
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -617,11 +617,14 @@ public final class SolrCore implements SolrInfoMBean {
|
|||
// Finally tell anyone who wants to know
|
||||
resourceLoader.inform( resourceLoader );
|
||||
resourceLoader.inform( this ); // last call before the latch is released.
|
||||
} catch (IOException e) {
|
||||
log.error("", e);
|
||||
} 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();
|
||||
}
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
|
|||
elevationCache.put(null, loadElevationMap( cfg ));
|
||||
}
|
||||
}
|
||||
|
||||
//in other words, we think this is in the data dir, not the conf dir
|
||||
if (!exists){
|
||||
// preload the first data
|
||||
RefCounted<SolrIndexSearcher> searchHolder = null;
|
||||
|
@ -215,10 +215,10 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
|
|||
}
|
||||
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 ) {
|
||||
|
@ -242,7 +242,7 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
|
|||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
//load up the elevation map
|
||||
private Map<String, ElevationObj> loadElevationMap( Config cfg ) throws IOException
|
||||
{
|
||||
XPath xpath = XPathFactory.newInstance().newXPath();
|
||||
|
|
|
@ -96,7 +96,7 @@ public class SolrDispatchFilter implements Filter
|
|||
}
|
||||
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 );
|
||||
}
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package org.apache.solr.handler.component;
|
||||
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* SOLR-1730, tests what happens when a component fails to initialize properly
|
||||
*
|
||||
**/
|
||||
public class BadComponentTest extends SolrTestCaseJ4{
|
||||
@Test
|
||||
public void testBadElevate() throws Exception {
|
||||
try {
|
||||
System.setProperty("elevate.file", "foo.xml");
|
||||
initCore("solrconfig-elevate.xml", "schema12.xml");
|
||||
assertTrue(false);
|
||||
} catch (Throwable e) {
|
||||
log.error("Exception", e);
|
||||
assertTrue(true);
|
||||
} finally {
|
||||
System.clearProperty("elevate.file");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -30,6 +30,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;
|
||||
|
@ -45,6 +46,12 @@ public class QueryElevationComponentTest extends SolrTestCaseJ4 {
|
|||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
//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");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue