mirror of https://github.com/apache/lucene.git
SOLR-5009: Don't create multiple SolrResourceLoaders for same Solr home, wasting resources and slowing down startup. This fixes the problem where the loader was not correctly closed, making tests fail on Windows.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1500156 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a278bb6628
commit
568f6a398a
|
@ -253,6 +253,10 @@ Bug Fixes
|
|||
* SOLR-5000: ManagedIndexSchema doesn't persist uniqueKey tag after calling addFields
|
||||
method. (Jun Ohtani, Steve Rowe)
|
||||
|
||||
* SOLR-5002: Don't create multiple SolrResourceLoaders for same Solr home, wasting
|
||||
resources and slowing down startup. This fixes the problem where the loader was
|
||||
not correctly closed, making tests fail on Windows. (Steve Rowe, Uwe Schindler)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ public class ZkCLI {
|
|||
SolrResourceLoader loader = new SolrResourceLoader(solrHome);
|
||||
solrHome = loader.getInstanceDir();
|
||||
|
||||
ConfigSolr cfg = ConfigSolr.fromSolrHome(solrHome);
|
||||
ConfigSolr cfg = ConfigSolr.fromSolrHome(loader, solrHome);
|
||||
|
||||
if(!ZkController.checkChrootPath(zkServerAddress, true)) {
|
||||
System.out.println("A chroot was specified in zkHost but the znode doesn't exist. ");
|
||||
|
|
|
@ -46,11 +46,9 @@ public abstract class ConfigSolr {
|
|||
|
||||
public final static String SOLR_XML_FILE = "solr.xml";
|
||||
|
||||
public static ConfigSolr fromFile(File configFile) {
|
||||
public static ConfigSolr fromFile(SolrResourceLoader loader, File configFile) {
|
||||
log.info("Loading container configuration from {}", configFile.getAbsolutePath());
|
||||
|
||||
String solrHome = configFile.getParent();
|
||||
SolrResourceLoader loader = new SolrResourceLoader(solrHome);
|
||||
InputStream inputStream = null;
|
||||
|
||||
try {
|
||||
|
@ -87,8 +85,8 @@ public abstract class ConfigSolr {
|
|||
}
|
||||
}
|
||||
|
||||
public static ConfigSolr fromSolrHome(String solrHome) {
|
||||
return fromFile(new File(solrHome, SOLR_XML_FILE));
|
||||
public static ConfigSolr fromSolrHome(SolrResourceLoader loader, String solrHome) {
|
||||
return fromFile(loader, new File(solrHome, SOLR_XML_FILE));
|
||||
}
|
||||
|
||||
public static ConfigSolr fromConfig(Config config) {
|
||||
|
|
|
@ -129,7 +129,7 @@ public class CoreContainer
|
|||
* @see #load()
|
||||
*/
|
||||
public CoreContainer() {
|
||||
this(SolrResourceLoader.locateSolrHome());
|
||||
this(new SolrResourceLoader(SolrResourceLoader.locateSolrHome()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -139,7 +139,7 @@ public class CoreContainer
|
|||
* @see #load()
|
||||
*/
|
||||
public CoreContainer(SolrResourceLoader loader) {
|
||||
this(loader, ConfigSolr.fromSolrHome(loader.getInstanceDir()));
|
||||
this(loader, ConfigSolr.fromSolrHome(loader, loader.getInstanceDir()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -149,7 +149,7 @@ public class CoreContainer
|
|||
* @see #load()
|
||||
*/
|
||||
public CoreContainer(String solrHome) {
|
||||
this(new SolrResourceLoader(solrHome), ConfigSolr.fromSolrHome(solrHome));
|
||||
this(new SolrResourceLoader(solrHome));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,7 +172,8 @@ public class CoreContainer
|
|||
* @return a loaded CoreContainer
|
||||
*/
|
||||
public static CoreContainer createAndLoad(String solrHome, File configFile) {
|
||||
CoreContainer cc = new CoreContainer(new SolrResourceLoader(solrHome), ConfigSolr.fromFile(configFile));
|
||||
SolrResourceLoader loader = new SolrResourceLoader(solrHome);
|
||||
CoreContainer cc = new CoreContainer(loader, ConfigSolr.fromFile(loader, configFile));
|
||||
cc.load();
|
||||
return cc;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue