SOLR-3827: Fix shareSchema=true in solr.xml

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1383735 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2012-09-12 02:03:45 +00:00
parent 64d204c04e
commit e8c6d5b242
4 changed files with 44 additions and 3 deletions

View File

@ -152,6 +152,9 @@ Bug Fixes
* SOLR-3823: Fix 'bq' parsing in edismax. Please note that this required
reverting the negative boost support added by SOLR-3278 (hossman)
* SOLR-3827: Fix shareSchema=true in solr.xml
(Tomás Fernández Löbbe via hossman)
Other Changes
----------------------

View File

@ -837,7 +837,7 @@ public class CoreContainer
IndexSchema schema = null;
if (indexSchemaCache != null) {
if (zkController != null) {
if (zkController == null) {
File schemaFile = new File(dcore.getSchemaName());
if (!schemaFile.isAbsolute()) {
schemaFile = new File(solrLoader.getInstanceDir() + "conf"
@ -1435,6 +1435,10 @@ public class CoreContainer
public ZkController getZkController() {
return zkController;
}
public boolean isShareSchema() {
return shareSchema;
}
/** The default ShardHandlerFactory used to communicate with other solr instances */
public ShardHandlerFactory getShardHandlerFactory() {

View File

@ -28,7 +28,7 @@
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via request handler
-->
<cores adminPath="/admin/cores" defaultCoreName="collection1" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="solr" zkClientTimeout="8000" numShards="${numShards:3}">
<cores adminPath="/admin/cores" defaultCoreName="collection1" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="solr" zkClientTimeout="8000" numShards="${numShards:3}" shareSchema="${shareSchema:false}">
<core name="collection1" instanceDir="collection1" shard="${shard:}" collection="${collection:collection1}" config="${solrconfig:solrconfig.xml}" schema="${schema:schema.xml}"/>
</cores>
</solr>

View File

@ -40,7 +40,41 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
public static void beforeClass() throws Exception {
initCore("solrconfig.xml", "schema.xml");
}
public void testShareSchema() throws IOException, ParserConfigurationException, SAXException {
final File workDir = new File(TEMP_DIR, this.getClass().getName());
if (workDir.exists()) {
FileUtils.deleteDirectory(workDir);
}
assertTrue("Failed to mkdirs workDir", workDir.mkdirs());
String solrHome = SolrResourceLoader.locateSolrHome();
File fconf = new File(solrHome, "solr.xml");
final CoreContainer cores = new CoreContainer(solrHome);
System.setProperty("shareSchema", "true");
cores.load(solrHome, fconf);
try {
cores.setPersistent(false);
assertTrue(cores.isShareSchema());
CoreDescriptor descriptor1 = new CoreDescriptor(cores, "core1", "./collection1");
SolrCore core1 = cores.create(descriptor1);
CoreDescriptor descriptor2 = new CoreDescriptor(cores, "core2", "./collection1");
SolrCore core2 = cores.create(descriptor2);
assertSame(core1.getSchema(), core2.getSchema());
core1.close();
core2.close();
} finally {
cores.shutdown();
}
}
@Test
public void testPersist() throws Exception {
final File workDir = new File(TEMP_DIR, this.getClass().getName()