Skip to content

Apache Lucene open-source search software

SOLR-2324: SolrCloud solr.xml parameters are not persisted by CoreContainer.

Mark Robert Miller177380802540
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 9e3fdb1ae4c..82ac5588b47 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -105,8 +105,10 @@ New Features
levenshtein automata. (rmuir)
* SOLR-1873: SolrCloud - added shared/central config and core/shard managment via zookeeper,
- built-in load balancing, and infrastructure for future SolrCloud work.
- (yonik, Mark Miller)
+ built-in load balancing, and infrastructure for future SolrCloud work. (yonik, Mark Miller)
+ Additional Work:
+ SOLR-2324: SolrCloud solr.xml parameters are not persisted by CoreContainer.
+ (Massimo Schiavon, Mark Miller)
* SOLR-1729: Evaluation of NOW for date math is done only once per request for
consistency, and is also propagated to shards in distributed search.
diff --git a/solr/src/java/org/apache/solr/core/CoreContainer.java b/solr/src/java/org/apache/solr/core/CoreContainer.java
index 2b0150a0403..ef8dc62a4e8 100644
--- a/solr/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/src/java/org/apache/solr/core/CoreContainer.java
@@ -79,6 +79,7 @@ public class CoreContainer
protected Map<String ,IndexSchema> indexSchemaCache;
protected String adminHandler;
protected boolean shareSchema;
+ protected Integer zkClientTimeout;
protected String solrHome;
protected String defaultCoreName = "";
private ZkController zkController;
@@ -313,7 +314,7 @@ public class CoreContainer
zkHost = cfg.get("solr/@zkHost" , null);
adminPath = cfg.get("solr/cores/@adminPath", null);
shareSchema = cfg.getBool("solr/cores/@shareSchema", false);
- int zkClientTimeout = cfg.getInt("solr/cores/@zkClientTimeout", 10000);
+ zkClientTimeout = cfg.getInt("solr/cores/@zkClientTimeout", 10000);
hostPort = System.getProperty("hostPort");
if (hostPort == null) {
@@ -889,6 +890,7 @@ public class CoreContainer
if (this.libDir != null) {
writeAttribute(w,"sharedLib",libDir);
}
+ if(zkHost != null) writeAttribute(w, "zkHost", zkHost);
writeAttribute(w,"persistent",isPersistent());
w.write(">\n");
@@ -897,9 +899,13 @@ public class CoreContainer
}
w.write(" <cores");
writeAttribute(w, "adminPath",adminPath);
- if(adminHandler != null) writeAttribute(w, "adminHandler",adminHandler);
- if(shareSchema) writeAttribute(w, "shareSchema","true");
- if(!defaultCoreName.equals("")) writeAttribute(w, "defaultCoreName",defaultCoreName);
+ if(adminHandler != null) writeAttribute(w, "adminHandler", adminHandler);
+ if(shareSchema) writeAttribute(w, "shareSchema", "true");
+ if(!defaultCoreName.equals("")) writeAttribute(w, "defaultCoreName", defaultCoreName);
+ if(host != null) writeAttribute(w, "host", host);
+ if(hostPort != null) writeAttribute(w, "hostPort", hostPort);
+ if(zkClientTimeout != null) writeAttribute(w, "zkClientTimeout", zkClientTimeout);
+ if(hostContext != null) writeAttribute(w, "hostContext", hostContext);
w.write(">\n");
synchronized(cores) {
diff --git a/solr/src/test-files/solr/shared/solr.xml b/solr/src/test-files/solr/shared/solr.xml
index 970ec198b35..d8a5b0583f8 100644
--- a/solr/src/test-files/solr/shared/solr.xml
+++ b/solr/src/test-files/solr/shared/solr.xml
@@ -30,7 +30,7 @@
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via REST
-->
- <cores adminPath="/admin/cores" defaultCoreName="core0">
+ <cores adminPath="/admin/cores" defaultCoreName="core0" host="127.0.0.1" hostPort="${hostPort:8983}" hostContext="solr" zkClientTimeout="8000">
<core name="core0" instanceDir="./">
<property name="version" value="3.5"/>
<property name="l10n" value="EN"/>
diff --git a/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java b/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
index fc2f578b6b6..cf3eff2f19a 100644
--- a/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
+++ b/solr/src/test/org/apache/solr/client/solrj/embedded/TestSolrProperties.java
@@ -70,11 +70,13 @@ public class TestSolrProperties extends LuceneTestCase {
@Before
public void setUp() throws Exception {
super.setUp();
+ System.setProperty("solr.solr.home", getSolrHome());
+
File home = SolrTestCaseJ4.getFile(getSolrHome());
System.setProperty("solr.solr.home", home.getAbsolutePath());
log.info("pwd: " + (new File(".")).getAbsolutePath());
- solrXml = new File(home, "solr.xml");
+ solrXml = new File(home, getSolrXml());
cores = new CoreContainer(home.getAbsolutePath(), solrXml);
}
@@ -191,12 +193,17 @@ public class TestSolrProperties extends LuceneTestCase {
mcr = CoreAdminRequest.persist("solr-persist.xml", coreadmin);
- // System.out.println(IOUtils.toString(new FileInputStream(new File(solrXml.getParent(), "solr-persist.xml"))));
+ //System.out.println(IOUtils.toString(new FileInputStream(new File(solrXml.getParent(), "solr-persist.xml"))));
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
FileInputStream fis = new FileInputStream(new File(solrXml.getParent(), "solr-persist.xml"));
try {
Document document = builder.parse(fis);
assertTrue(exists("/solr/cores[@defaultCoreName='core0']", document));
+ assertTrue(exists("/solr/cores[@host='127.0.0.1']", document));
+ assertTrue(exists("/solr/cores[@hostPort='8983']", document));
+ assertTrue(exists("/solr/cores[@zkClientTimeout='8000']", document));
+ assertTrue(exists("/solr/cores[@hostContext='solr']", document));
+
} finally {
fis.close();
}