SOLR-1214

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@786434 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Noble Paul 2009-06-19 09:58:58 +00:00
parent dce2b6db15
commit fdbc44dfc4
4 changed files with 33 additions and 16 deletions

View File

@ -237,6 +237,9 @@ New Features
60. SOLR-243: Add configurable IndexReaderFactory so that alternate IndexReader implementations
can 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
----------------------

View File

@ -72,8 +72,14 @@ public class CoreContainer
protected Map<String ,IndexSchema> indexSchemaCache;
protected String adminHandler;
protected boolean shareSchema;
protected final String solrHome;
@Deprecated
public CoreContainer() {
solrHome =".";
}
public CoreContainer(String home) {
solrHome =home;
}
public Properties getContainerProperties() {
@ -104,13 +110,13 @@ public class CoreContainer
// core container instantiation
public 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 abort
for (SolrCore c : cores.getCores()) {
@ -122,7 +128,7 @@ public class CoreContainer
solrConfigFilename = 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 absolute
File 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 CoreContainer
throw xforward;
}
}
public String getSolrHome() {
return solrHome;
}
}

View File

@ -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);
}
}

View File

@ -84,7 +84,7 @@ public class SolrResourceLoader implements ResourceLoader
public 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 ResourceLoader
waitingForResources.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 JNDI
try {
@ -477,6 +476,10 @@ public class SolrResourceLoader implements ResourceLoader
}
return normalizeDir( home );
}
@Deprecated
public static String locateInstanceDir() {
return locateSolrHome();
}
public String getInstanceDir() {
return instanceDir;