From 1773808025409d60e133aba78cb6944f38a2b5ea Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Wed, 20 Apr 2011 16:38:51 +0000 Subject: [PATCH] SOLR-2324: SolrCloud solr.xml parameters are not persisted by CoreContainer. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1095455 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 6 ++++-- .../java/org/apache/solr/core/CoreContainer.java | 14 ++++++++++---- solr/src/test-files/solr/shared/solr.xml | 2 +- .../client/solrj/embedded/TestSolrProperties.java | 11 +++++++++-- 4 files changed, 24 insertions(+), 9 deletions(-) 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 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(" \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 --> - + 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(); }