Apache Solr open-source search software
SOLR-1214
Noble Paulfdbc44dfc49a
diff --git a/CHANGES.txt b/CHANGES.txtindex f1ffcad5563..5ef994001e0 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -237,6 +237,9 @@ New Features60. SOLR-243: Add configurable IndexReaderFactory so that alternate IndexReader implementationscan be specified via solrconfig.xml. (Andrzej Bialecki, hossman, Mark Miller, John Wang)++61. SOLR-1214: differentiate between solr home and instanceDir .deprecates the method SolrResourceLoader#locateInstanceDir()+ and it is renamed to locateSolrHome (noble)Optimizations----------------------diff --git a/src/java/org/apache/solr/core/CoreContainer.java b/src/java/org/apache/solr/core/CoreContainer.javaindex 398ae5c7b05..4954a66aad0 100644--- a/src/java/org/apache/solr/core/CoreContainer.java+++ b/src/java/org/apache/solr/core/CoreContainer.java@@ -72,8 +72,14 @@ public class CoreContainerprotected Map<String ,IndexSchema> indexSchemaCache;protected String adminHandler;protected boolean shareSchema;+ protected final String solrHome;+ @Deprecatedpublic CoreContainer() {+ solrHome =".";+ }+ public CoreContainer(String home) {+ solrHome =home;}public Properties getContainerProperties() {@@ -104,13 +110,13 @@ public class CoreContainer// core container instantiationpublic CoreContainer initialize() throws IOException, ParserConfigurationException, SAXException {CoreContainer cores = null;- String instanceDir = SolrResourceLoader.locateInstanceDir();- File fconf = new File(instanceDir, solrConfigFilename == null? "solr.xml": solrConfigFilename);+ String solrHome = SolrResourceLoader.locateSolrHome();+ File fconf = new File(solrHome, solrConfigFilename == null? "solr.xml": solrConfigFilename);log.info("looking for solr.xml: " + fconf.getAbsolutePath());if (fconf.exists()) {- cores = new CoreContainer();- cores.load(instanceDir, fconf);+ cores = new CoreContainer(solrHome);+ cores.load(solrHome, fconf);abortOnConfigurationError = false;// if any core aborts on startup, then abortfor (SolrCore c : cores.getCores()) {@@ -122,7 +128,7 @@ public class CoreContainersolrConfigFilename = cores.getConfigFile().getName();} else {// perform compatibility init- cores = new CoreContainer(new SolrResourceLoader(instanceDir));+ cores = new CoreContainer(new SolrResourceLoader(solrHome));SolrConfig cfg = solrConfigFilename == null ? new SolrConfig() : new SolrConfig(solrConfigFilename);CoreDescriptor dcore = new CoreDescriptor(cores, "", ".");SolrCore singlecore = new SolrCore(null, null, cfg, null, dcore);@@ -147,6 +153,7 @@ public class CoreContainer*/public CoreContainer(String dir, File configFile ) throws ParserConfigurationException, IOException, SAXException{+ solrHome = dir;this.load(dir, configFile);}@@ -156,8 +163,9 @@ public class CoreContainer*/public CoreContainer(SolrResourceLoader loader) {this.loader = loader;+ solrHome = loader.getInstanceDir();}-+//-------------------------------------------------------------------// Initialization / Cleanup//-------------------------------------------------------------------@@ -349,7 +357,7 @@ public class CoreContainer// Make the instanceDir relative to the cores instanceDir if not absoluteFile idir = new File(dcore.getInstanceDir());if (!idir.isAbsolute()) {- idir = new File(loader.getInstanceDir(), dcore.getInstanceDir());+ idir = new File(solrHome, dcore.getInstanceDir());}String instanceDir = idir.getPath();@@ -761,5 +769,8 @@ public class CoreContainerthrow xforward;}}-++ public String getSolrHome() {+ return solrHome;+ }}diff --git a/src/java/org/apache/solr/core/CoreDescriptor.java b/src/java/org/apache/solr/core/CoreDescriptor.javaindex d70482d8720..9da0a4f41c3 100644--- a/src/java/org/apache/solr/core/CoreDescriptor.java+++ b/src/java/org/apache/solr/core/CoreDescriptor.java@@ -91,7 +91,7 @@ public class CoreDescriptor {if (new File(instanceDir).isAbsolute()) {return SolrResourceLoader.normalizeDir(SolrResourceLoader.normalizeDir(instanceDir) + dataDir);} else {- return SolrResourceLoader.normalizeDir(coreContainer.loader.getInstanceDir() ++ return SolrResourceLoader.normalizeDir(coreContainer.getSolrHome() +SolrResourceLoader.normalizeDir(instanceDir) + dataDir);}}diff --git a/src/java/org/apache/solr/core/SolrResourceLoader.java b/src/java/org/apache/solr/core/SolrResourceLoader.javaindex e5ad3a42992..84ab4d8b5f3 100644--- a/src/java/org/apache/solr/core/SolrResourceLoader.java+++ b/src/java/org/apache/solr/core/SolrResourceLoader.java@@ -84,7 +84,7 @@ public class SolrResourceLoader implements ResourceLoaderpublic SolrResourceLoader( String instanceDir, ClassLoader parent, Properties coreProperties ){if( instanceDir == null ) {- this.instanceDir = SolrResourceLoader.locateInstanceDir();+ this.instanceDir = SolrResourceLoader.locateSolrHome();} else{this.instanceDir = normalizeDir(instanceDir);}@@ -428,13 +428,13 @@ public class SolrResourceLoader implements ResourceLoaderwaitingForResources.clear();}/**- * Determines the instanceDir from the environment.+ * Determines the solrhome from the environment.* Tries JNDI (java:comp/env/solr/home) then system property (solr.solr.home);* if both fail, defaults to solr/* @return the instance directory name*//**- * Finds the instanceDir based on looking up the value in one of three places:+ * Finds the solrhome based on looking up the value in one of three places:* <ol>* <li>JNDI: via java:comp/env/solr/home</li>* <li>The system property solr.solr.home</li>@@ -442,11 +442,10 @@ public class SolrResourceLoader implements ResourceLoader* </ol>** The return value is normalized. Normalization essentially means it ends in a trailing slash.- * @return A normalized instanceDir- *- * @see #normalizeDir(String)+ * @return A normalized solrhome+ * @see #normalizeDir(String)*/- public static String locateInstanceDir() {+ public static String locateSolrHome() {String home = null;// Try JNDItry {@@ -477,6 +476,10 @@ public class SolrResourceLoader implements ResourceLoader}return normalizeDir( home );}+ @Deprecated+ public static String locateInstanceDir() {+ return locateSolrHome();+ }public String getInstanceDir() {return instanceDir;