mirror of https://github.com/apache/lucene.git
SOLR-4932 some extra parameters persisted to solr.xml
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1493982 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8233c923a1
commit
0b6fa118f5
|
@ -160,6 +160,10 @@ Bug Fixes
|
|||
* SOLR-4923: Commits to non leaders as part of a request that also contain updates
|
||||
can execute out of order. (hossman, Ricardo Merizalde, Mark Miller)
|
||||
|
||||
* SOLR-4932: persisting solr.xml saves some parameters it shouldn't when they weren't
|
||||
defined in the original. Benign since the default values are saved, but still incorrect.
|
||||
(Erick Erickson, thanks Shawn Heisey for helping test!)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -1117,14 +1117,15 @@ public class CoreContainer
|
|||
Map<String,String> rootSolrAttribs = new HashMap<String,String>();
|
||||
|
||||
addAttrib(rootSolrAttribs, ConfigSolr.CfgProp.SOLR_SHAREDLIB, "sharedLib", this.libDir);
|
||||
addAttrib(rootSolrAttribs, ConfigSolr.CfgProp.SOLR_PERSISTENT, "persistent", Boolean.toString(isPersistent()));
|
||||
addAttrib(rootSolrAttribs, ConfigSolr.CfgProp.SOLR_PERSISTENT, "persistent",
|
||||
Boolean.toString(isPersistent()), "false");
|
||||
addAttrib(rootSolrAttribs, ConfigSolr.CfgProp.SOLR_CORELOADTHREADS, "coreLoadThreads",
|
||||
Integer.toString(this.coreLoadThreads), Integer.toString(CORE_LOAD_THREADS));
|
||||
addAttrib(rootSolrAttribs, ConfigSolr.CfgProp.SOLR_ZKHOST, "zkHost", this.zkHost);
|
||||
|
||||
// <solr attrib="value"> <cores attrib="value">
|
||||
Map<String,String> coresAttribs = new HashMap<String,String>();
|
||||
addAttrib(coresAttribs, ConfigSolr.CfgProp.SOLR_ADMINPATH, "adminPath", this.adminPath);
|
||||
addAttrib(coresAttribs, ConfigSolr.CfgProp.SOLR_ADMINPATH, "adminPath", this.adminPath, this.getAdminPath());
|
||||
addAttrib(coresAttribs, ConfigSolr.CfgProp.SOLR_ADMINHANDLER, "adminHandler", this.adminHandler);
|
||||
addAttrib(coresAttribs, ConfigSolr.CfgProp.SOLR_SHARESCHEMA, "shareSchema",
|
||||
Boolean.toString(this.shareSchema),
|
||||
|
@ -1149,9 +1150,9 @@ public class CoreContainer
|
|||
Integer.toString(this.transientCacheSize), Integer.toString(Integer.MAX_VALUE));
|
||||
}
|
||||
addAttrib(coresAttribs, ConfigSolr.CfgProp.SOLR_DISTRIBUPDATECONNTIMEOUT, "distribUpdateConnTimeout",
|
||||
Integer.toString(this.distribUpdateConnTimeout));
|
||||
Integer.toString(this.distribUpdateConnTimeout), Integer.toString(this.distribUpdateConnTimeout));
|
||||
addAttrib(coresAttribs, ConfigSolr.CfgProp.SOLR_DISTRIBUPDATESOTIMEOUT, "distribUpdateSoTimeout",
|
||||
Integer.toString(this.distribUpdateSoTimeout));
|
||||
Integer.toString(this.distribUpdateSoTimeout), Integer.toString(this.distribUpdateSoTimeout));
|
||||
addAttrib(coresAttribs, ConfigSolr.CfgProp.SOLR_MANAGEMENTPATH, "managementPath",
|
||||
this.managementPath);
|
||||
|
||||
|
|
|
@ -285,8 +285,8 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
|||
CoreAdminParams.CoreAdminAction.CREATE.toString(),
|
||||
CoreAdminParams.DATA_DIR, dataDir,
|
||||
CoreAdminParams.NAME, name,
|
||||
"schema", "schema-tiny.xml",
|
||||
"config", "solrconfig-minimal.xml");
|
||||
"schema", "schema.xml",
|
||||
"config", "solrconfig.xml");
|
||||
|
||||
admin.handleRequestBody(request, resp);
|
||||
fail("Should have thrown an error");
|
||||
|
@ -347,29 +347,29 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
|||
CoreDescriptor d1 = new CoreDescriptor(cc, "core1", "./core1");
|
||||
d1.setTransient(true);
|
||||
d1.setLoadOnStartup(true);
|
||||
d1.setSchemaName("schema-tiny.xml");
|
||||
d1.setConfigName("solrconfig-minimal.xml");
|
||||
d1.setSchemaName("schema.xml");
|
||||
d1.setConfigName("solrconfig.xml");
|
||||
SolrCore core1 = cc.create(d1);
|
||||
|
||||
CoreDescriptor d2 = new CoreDescriptor(cc, "core2", "./core2");
|
||||
d2.setTransient(true);
|
||||
d2.setLoadOnStartup(false);
|
||||
d2.setSchemaName("schema-tiny.xml");
|
||||
d2.setConfigName("solrconfig-minimal.xml");
|
||||
d2.setSchemaName("schema.xml");
|
||||
d2.setConfigName("solrconfig.xml");
|
||||
SolrCore core2 = cc.create(d2);
|
||||
|
||||
CoreDescriptor d3 = new CoreDescriptor(cc, "core3", "./core3");
|
||||
d3.setTransient(false);
|
||||
d3.setLoadOnStartup(true);
|
||||
d3.setSchemaName("schema-tiny.xml");
|
||||
d3.setConfigName("solrconfig-minimal.xml");
|
||||
d3.setSchemaName("schema.xml");
|
||||
d3.setConfigName("solrconfig.xml");
|
||||
SolrCore core3 = cc.create(d3);
|
||||
|
||||
CoreDescriptor d4 = new CoreDescriptor(cc, "core4", "./core4");
|
||||
d4.setTransient(false);
|
||||
d4.setLoadOnStartup(false);
|
||||
d4.setSchemaName("schema-tiny.xml");
|
||||
d4.setConfigName("solrconfig-minimal.xml");
|
||||
d4.setSchemaName("schema.xml");
|
||||
d4.setConfigName("solrconfig.xml");
|
||||
SolrCore core4 = cc.create(d4);
|
||||
|
||||
final File oneXml = new File(solrHomeDirectory, "lazy1.solr.xml");
|
||||
|
@ -455,31 +455,23 @@ public class TestLazyCores extends SolrTestCaseJ4 {
|
|||
|
||||
private final static String LOTS_SOLR_XML = " <solr persistent=\"false\"> " +
|
||||
"<cores adminPath=\"/admin/cores\" defaultCoreName=\"collectionLazy2\" transientCacheSize=\"4\"> " +
|
||||
"<core name=\"collection1\" instanceDir=\"collection1\" config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
|
||||
"<core name=\"collection1\" instanceDir=\"collection1\" /> " +
|
||||
|
||||
"<core name=\"collectionLazy2\" instanceDir=\"collection2\" transient=\"true\" loadOnStartup=\"true\" " +
|
||||
" config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
|
||||
"<core name=\"collectionLazy2\" instanceDir=\"collection2\" transient=\"true\" loadOnStartup=\"true\" /> " +
|
||||
|
||||
"<core name=\"collectionLazy3\" instanceDir=\"collection3\" transient=\"on\" loadOnStartup=\"false\" " +
|
||||
"config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
|
||||
"<core name=\"collectionLazy3\" instanceDir=\"collection3\" transient=\"on\" loadOnStartup=\"false\" /> " +
|
||||
|
||||
"<core name=\"collectionLazy4\" instanceDir=\"collection4\" transient=\"false\" loadOnStartup=\"false\" " +
|
||||
"config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
|
||||
"<core name=\"collectionLazy4\" instanceDir=\"collection4\" transient=\"false\" loadOnStartup=\"false\" /> " +
|
||||
|
||||
"<core name=\"collectionLazy5\" instanceDir=\"collection5\" transient=\"false\" loadOnStartup=\"true\" " +
|
||||
"config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
|
||||
"<core name=\"collectionLazy5\" instanceDir=\"collection5\" transient=\"false\" loadOnStartup=\"true\" /> " +
|
||||
|
||||
"<core name=\"collectionLazy6\" instanceDir=\"collection6\" transient=\"true\" loadOnStartup=\"false\" " +
|
||||
"config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
|
||||
"<core name=\"collectionLazy6\" instanceDir=\"collection6\" transient=\"true\" loadOnStartup=\"false\" /> " +
|
||||
|
||||
"<core name=\"collectionLazy7\" instanceDir=\"collection7\" transient=\"true\" loadOnStartup=\"false\" " +
|
||||
"config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
|
||||
"<core name=\"collectionLazy7\" instanceDir=\"collection7\" transient=\"true\" loadOnStartup=\"false\" /> " +
|
||||
|
||||
"<core name=\"collectionLazy8\" instanceDir=\"collection8\" transient=\"true\" loadOnStartup=\"false\" " +
|
||||
"config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
|
||||
"<core name=\"collectionLazy8\" instanceDir=\"collection8\" transient=\"true\" loadOnStartup=\"false\" /> " +
|
||||
|
||||
"<core name=\"collectionLazy9\" instanceDir=\"collection9\" transient=\"true\" loadOnStartup=\"false\" " +
|
||||
"config=\"solrconfig-minimal.xml\" schema=\"schema-tiny.xml\" /> " +
|
||||
"<core name=\"collectionLazy9\" instanceDir=\"collection9\" transient=\"true\" loadOnStartup=\"false\" /> " +
|
||||
|
||||
"</cores> " +
|
||||
"</solr>";
|
||||
|
|
|
@ -84,8 +84,8 @@ public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
|
|||
public void testSystemVars() throws Exception {
|
||||
//Set these system props in order to insure that we don't write out the values rather than the ${} syntax.
|
||||
System.setProperty("solr.zkclienttimeout", "93");
|
||||
System.setProperty("solrconfig", "solrconfig-minimal.xml");
|
||||
System.setProperty("schema", "schema-tiny.xml");
|
||||
System.setProperty("solrconfig", "solrconfig.xml");
|
||||
System.setProperty("schema", "schema.xml");
|
||||
System.setProperty("zkHostSet", "localhost:9983");
|
||||
|
||||
CoreContainer cc = init(SOLR_XML_LOTS_SYSVARS, "SystemVars1", "SystemVars2");
|
||||
|
@ -179,6 +179,7 @@ public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
|
|||
// Now the other way, If I replace the original name in the original XML file with "RenamedCore", does it match
|
||||
// what was persisted?
|
||||
persistList = getAllNodes(origXml);
|
||||
expressions = new String[persistList.length];
|
||||
for (int idx = 0; idx < persistList.length; ++idx) {
|
||||
// /solr/cores/core[@name='SystemVars1' and @collection='${collection:collection1}']
|
||||
expressions[idx] = persistList[idx].replace("@name='" + which + "'", "@name='RenamedCore'");
|
||||
|
@ -240,6 +241,21 @@ public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimalXml() throws Exception {
|
||||
CoreContainer cc = init(SOLR_XML_MINIMAL, "SystemVars1");
|
||||
try {
|
||||
origMatchesPersist(cc, new File(solrHomeDirectory, "minimal.solr.xml"));
|
||||
} finally {
|
||||
cc.shutdown();
|
||||
if (solrHomeDirectory.exists()) {
|
||||
FileUtils.deleteDirectory(solrHomeDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testUnloadCreate() throws Exception {
|
||||
doTestUnloadCreate("SystemVars1");
|
||||
|
@ -266,8 +282,6 @@ public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
|
|||
(req(CoreAdminParams.ACTION,
|
||||
CoreAdminParams.CoreAdminAction.CREATE.toString(),
|
||||
CoreAdminParams.INSTANCE_DIR, instPath,
|
||||
CoreAdminParams.CONFIG, "solrconfig-minimal.xml",
|
||||
CoreAdminParams.SCHEMA, "schema-tiny.xml",
|
||||
CoreAdminParams.NAME, which),
|
||||
resp);
|
||||
assertNull("Exception on create", resp.getException());
|
||||
|
@ -284,10 +298,10 @@ public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
|
|||
String name = "@name='" + which + "'";
|
||||
|
||||
if (persistList[idx].contains(name)) {
|
||||
if (persistList[idx].contains("@schema='schema-tiny.xml'")) {
|
||||
expressions[idx] = persistList[idx].replace("schema-tiny.xml", "${schema:schema-tiny.xml}");
|
||||
} else if (persistList[idx].contains("@config='solrconfig-minimal.xml'")) {
|
||||
expressions[idx] = persistList[idx].replace("solrconfig-minimal.xml", "${solrconfig:solrconfig-minimal.xml}");
|
||||
if (persistList[idx].contains("@schema='schema.xml'")) {
|
||||
expressions[idx] = persistList[idx].replace("schema.xml", "${schema:schema.xml}");
|
||||
} else if (persistList[idx].contains("@config='solrconfig.xml'")) {
|
||||
expressions[idx] = persistList[idx].replace("solrconfig.xml", "${solrconfig:solrconfig.xml}");
|
||||
} else if (persistList[idx].contains("@instanceDir=")) {
|
||||
expressions[idx] = persistList[idx].replaceFirst("instanceDir\\='.*?'", "instanceDir='" + which + "'");
|
||||
} else {
|
||||
|
@ -333,9 +347,7 @@ public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
|
|||
CoreAdminParams.TRANSIENT, "true",
|
||||
CoreAdminParams.LOAD_ON_STARTUP, "true",
|
||||
CoreAdminParams.PROPERTY_PREFIX + "prefix1", "valuep1",
|
||||
CoreAdminParams.PROPERTY_PREFIX + "prefix2", "valueP2",
|
||||
CoreAdminParams.CONFIG, "solrconfig-minimal.xml",
|
||||
CoreAdminParams.SCHEMA, "schema-tiny.xml"),
|
||||
CoreAdminParams.PROPERTY_PREFIX + "prefix2", "valueP2"),
|
||||
resp);
|
||||
assertNull("Exception on create", resp.getException());
|
||||
|
||||
|
@ -347,17 +359,16 @@ public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
|
|||
CoreAdminParams.NAME, "props2",
|
||||
CoreAdminParams.PROPERTY_PREFIX + "prefix2_1", "valuep2_1",
|
||||
CoreAdminParams.PROPERTY_PREFIX + "prefix2_2", "valueP2_2",
|
||||
CoreAdminParams.CONFIG, "solrconfig-minimal.xml",
|
||||
CoreAdminParams.CONFIG, "solrconfig.xml",
|
||||
CoreAdminParams.DATA_DIR, "./dataDirTest",
|
||||
CoreAdminParams.SCHEMA, "schema-tiny.xml"),
|
||||
CoreAdminParams.SCHEMA, "schema.xml"),
|
||||
resp);
|
||||
assertNull("Exception on create", resp.getException());
|
||||
|
||||
// Everything that was in the original XML file should be in the persisted one.
|
||||
final File persistXml = new File(solrHomeDirectory, "persist_create_core.solr.xml");
|
||||
cc.persistFile(persistXml);
|
||||
String[] expressions = getAllNodes(new File(solrHomeDirectory, "solr.xml"));
|
||||
assertXmlFile(persistXml, expressions);
|
||||
assertXmlFile(persistXml, getAllNodes(new File(solrHomeDirectory, "solr.xml")));
|
||||
|
||||
|
||||
// And the params for the new core should be in the persisted file.
|
||||
|
@ -365,14 +376,12 @@ public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
|
|||
(persistXml
|
||||
, "/solr/cores/core[@name='props1']/property[@name='prefix1' and @value='valuep1']"
|
||||
, "/solr/cores/core[@name='props1']/property[@name='prefix2' and @value='valueP2']"
|
||||
, "/solr/cores/core[@name='props1' and @config='solrconfig-minimal.xml']"
|
||||
, "/solr/cores/core[@name='props1' and @schema='schema-tiny.xml']"
|
||||
, "/solr/cores/core[@name='props1' and @transient='true']"
|
||||
, "/solr/cores/core[@name='props1' and @loadOnStartup='true']"
|
||||
, "/solr/cores/core[@name='props2']/property[@name='prefix2_1' and @value='valuep2_1']"
|
||||
, "/solr/cores/core[@name='props2']/property[@name='prefix2_2' and @value='valueP2_2']"
|
||||
, "/solr/cores/core[@name='props2' and @config='solrconfig-minimal.xml']"
|
||||
, "/solr/cores/core[@name='props2' and @schema='schema-tiny.xml']"
|
||||
, "/solr/cores/core[@name='props2' and @config='solrconfig.xml']"
|
||||
, "/solr/cores/core[@name='props2' and @schema='schema.xml']"
|
||||
, "/solr/cores/core[@name='props2' and not(@loadOnStartup)]"
|
||||
, "/solr/cores/core[@name='props2' and not(@transient)]"
|
||||
, "/solr/cores/core[@name='props2' and @dataDir='./dataDirTest']"
|
||||
|
@ -490,21 +499,28 @@ public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
|
|||
" distribUpdateSoTimeout=\"${distribUpdateSoTimeout:120000}\" \n" +
|
||||
" leaderVoteWait=\"${leadVoteWait:32}\" managementPath=\"${manpath:/var/lib/path}\" transientCacheSize=\"${tranSize:128}\"> \n" +
|
||||
" <core name=\"SystemVars1\" instanceDir=\"SystemVars1\" shard=\"${shard:32}\" \n" +
|
||||
" collection=\"${collection:collection1}\" config=\"${solrconfig:solrconfig-minimal.xml}\" \n" +
|
||||
" schema=\"${schema:schema-tiny.xml}\" ulogDir=\"${ulog:./}\" roles=\"${myrole:boss}\" \n" +
|
||||
" collection=\"${collection:collection1}\" config=\"${solrconfig:solrconfig.xml}\" \n" +
|
||||
" schema=\"${schema:schema.xml}\" ulogDir=\"${ulog:./}\" roles=\"${myrole:boss}\" \n" +
|
||||
" dataDir=\"${data:./}\" loadOnStartup=\"${onStart:true}\" transient=\"${tran:true}\" \n" +
|
||||
" coreNodeName=\"${coreNode:utterlyridiculous}\" \n" +
|
||||
" >\n" +
|
||||
" </core>\n" +
|
||||
" <core name=\"SystemVars2\" instanceDir=\"SystemVars2\" shard=\"${shard:32}\" \n" +
|
||||
" collection=\"${collection:collection2}\" config=\"${solrconfig:solrconfig-minimal.xml}\" \n" +
|
||||
" coreNodeName=\"${coreNodeName:}\" schema=\"${schema:schema-tiny.xml}\">\n" +
|
||||
" collection=\"${collection:collection2}\" config=\"${solrconfig:solrconfig.xml}\" \n" +
|
||||
" coreNodeName=\"${coreNodeName:}\" schema=\"${schema:schema.xml}\">\n" +
|
||||
" <property name=\"collection\" value=\"{collection:collection2}\"/>\n" +
|
||||
" <property name=\"schema\" value=\"${schema:schema-tiny.xml}\"/>\n" +
|
||||
" <property name=\"schema\" value=\"${schema:schema.xml}\"/>\n" +
|
||||
" <property name=\"coreNodeName\" value=\"EricksCore\"/>\n" +
|
||||
" </core>\n" +
|
||||
" </cores>\n" +
|
||||
"</solr>";
|
||||
|
||||
|
||||
private static String SOLR_XML_MINIMAL =
|
||||
"<solr >\n" +
|
||||
" <cores> \n" +
|
||||
" <core name=\"SystemVars1\" instanceDir=\"SystemVars1\" />\n" +
|
||||
" </cores>\n" +
|
||||
"</solr>";
|
||||
|
||||
}
|
||||
|
|
|
@ -1467,8 +1467,8 @@ public abstract class SolrTestCaseJ4 extends LuceneTestCase {
|
|||
File subHome = new File(dstRoot, "conf");
|
||||
assertTrue("Failed to make subdirectory ", dstRoot.mkdirs());
|
||||
String top = SolrTestCaseJ4.TEST_HOME() + "/collection1/conf";
|
||||
FileUtils.copyFile(new File(top, "schema-tiny.xml"), new File(subHome, "schema-tiny.xml"));
|
||||
FileUtils.copyFile(new File(top, "solrconfig-minimal.xml"), new File(subHome, "solrconfig-minimal.xml"));
|
||||
FileUtils.copyFile(new File(top, "schema-tiny.xml"), new File(subHome, "schema.xml"));
|
||||
FileUtils.copyFile(new File(top, "solrconfig-minimal.xml"), new File(subHome, "solrconfig.xml"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue