mirror of https://github.com/apache/lucene.git
SOLR-4652: Fix broken behavior with shared libraries in resource loader for solr.xml plugins.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1463794 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
061f31e910
commit
e529be4006
|
@ -147,6 +147,9 @@ Bug Fixes
|
||||||
* SOLR-3758: Fixed SpellCheckComponent to work consistently with distributed grouping
|
* SOLR-3758: Fixed SpellCheckComponent to work consistently with distributed grouping
|
||||||
(James Dyer)
|
(James Dyer)
|
||||||
|
|
||||||
|
* SOLR-4652: Fix broken behavior with shared libraries in resource loader for
|
||||||
|
solr.xml plugins. (Ryan Ernst, Robert Muir, Uwe Schindler)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,6 @@ public class CoreContainer
|
||||||
protected CollectionsHandler collectionsHandler = null;
|
protected CollectionsHandler collectionsHandler = null;
|
||||||
protected File configFile = null;
|
protected File configFile = null;
|
||||||
protected String libDir = null;
|
protected String libDir = null;
|
||||||
protected ClassLoader libLoader = null;
|
|
||||||
protected SolrResourceLoader loader = null;
|
protected SolrResourceLoader loader = null;
|
||||||
protected Properties containerProperties;
|
protected Properties containerProperties;
|
||||||
protected Map<String ,IndexSchema> indexSchemaCache;
|
protected Map<String ,IndexSchema> indexSchemaCache;
|
||||||
|
@ -394,6 +393,15 @@ public class CoreContainer
|
||||||
// now.
|
// now.
|
||||||
cfg.substituteProperties();
|
cfg.substituteProperties();
|
||||||
|
|
||||||
|
// add the sharedLib to the shared resource loader before initializing cfg based plugins
|
||||||
|
libDir = cfg.get(ConfigSolr.ConfLevel.SOLR, "sharedLib", null);
|
||||||
|
if (libDir != null) {
|
||||||
|
File f = FileUtils.resolvePath(new File(dir), libDir);
|
||||||
|
log.info("loading shared library: " + f.getAbsolutePath());
|
||||||
|
loader.addToClassLoader(libDir);
|
||||||
|
loader.reloadLuceneSPI();
|
||||||
|
}
|
||||||
|
|
||||||
shardHandlerFactory = cfg.initShardHandler();
|
shardHandlerFactory = cfg.initShardHandler();
|
||||||
|
|
||||||
coreMaps.allocateLazyCores(cfg, loader);
|
coreMaps.allocateLazyCores(cfg, loader);
|
||||||
|
@ -448,7 +456,6 @@ public class CoreContainer
|
||||||
defaultCoreName = dcoreName;
|
defaultCoreName = dcoreName;
|
||||||
}
|
}
|
||||||
persistent = cfg.getBool(ConfigSolr.ConfLevel.SOLR, "persistent", false);
|
persistent = cfg.getBool(ConfigSolr.ConfLevel.SOLR, "persistent", false);
|
||||||
libDir = cfg.get(ConfigSolr.ConfLevel.SOLR, "sharedLib", null);
|
|
||||||
zkHost = cfg.get(ConfigSolr.ConfLevel.SOLR, "zkHost", null);
|
zkHost = cfg.get(ConfigSolr.ConfLevel.SOLR, "zkHost", null);
|
||||||
coreLoadThreads = cfg.getInt(ConfigSolr.ConfLevel.SOLR, "coreLoadThreads", CORE_LOAD_THREADS);
|
coreLoadThreads = cfg.getInt(ConfigSolr.ConfLevel.SOLR, "coreLoadThreads", CORE_LOAD_THREADS);
|
||||||
|
|
||||||
|
@ -485,12 +492,6 @@ public class CoreContainer
|
||||||
"SolrCloud requires a value of at least 2 in solr.xml for coreLoadThreads");
|
"SolrCloud requires a value of at least 2 in solr.xml for coreLoadThreads");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (libDir != null) {
|
|
||||||
File f = FileUtils.resolvePath(new File(dir), libDir);
|
|
||||||
log.info("loading shared library: " + f.getAbsolutePath());
|
|
||||||
libLoader = SolrResourceLoader.createClassLoader(f, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (adminPath != null) {
|
if (adminPath != null) {
|
||||||
if (adminHandler == null) {
|
if (adminHandler == null) {
|
||||||
coreAdminHandler = new CoreAdminHandler(this);
|
coreAdminHandler = new CoreAdminHandler(this);
|
||||||
|
@ -876,7 +877,7 @@ public class CoreContainer
|
||||||
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
|
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
|
||||||
"Could not find config name for collection:" + collection);
|
"Could not find config name for collection:" + collection);
|
||||||
}
|
}
|
||||||
solrLoader = new ZkSolrResourceLoader(instanceDir, zkConfigName, libLoader,
|
solrLoader = new ZkSolrResourceLoader(instanceDir, zkConfigName, loader.getClassLoader(),
|
||||||
ConfigSolrXml.getCoreProperties(instanceDir, dcore), zkController);
|
ConfigSolrXml.getCoreProperties(instanceDir, dcore), zkController);
|
||||||
config = getSolrConfigFromZk(zkConfigName, dcore.getConfigName(), solrLoader);
|
config = getSolrConfigFromZk(zkConfigName, dcore.getConfigName(), solrLoader);
|
||||||
schema = IndexSchemaFactory.buildIndexSchema(dcore.getSchemaName(), config);
|
schema = IndexSchemaFactory.buildIndexSchema(dcore.getSchemaName(), config);
|
||||||
|
@ -900,7 +901,7 @@ public class CoreContainer
|
||||||
SolrResourceLoader solrLoader = null;
|
SolrResourceLoader solrLoader = null;
|
||||||
|
|
||||||
SolrConfig config = null;
|
SolrConfig config = null;
|
||||||
solrLoader = new SolrResourceLoader(instanceDir, libLoader, ConfigSolrXml.getCoreProperties(instanceDir, dcore));
|
solrLoader = new SolrResourceLoader(instanceDir, loader.getClassLoader(), ConfigSolrXml.getCoreProperties(instanceDir, dcore));
|
||||||
try {
|
try {
|
||||||
config = new SolrConfig(solrLoader, dcore.getConfigName(), null);
|
config = new SolrConfig(solrLoader, dcore.getConfigName(), null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1057,7 +1058,7 @@ public class CoreContainer
|
||||||
cd.getName(), instanceDir.getAbsolutePath());
|
cd.getName(), instanceDir.getAbsolutePath());
|
||||||
SolrResourceLoader solrLoader;
|
SolrResourceLoader solrLoader;
|
||||||
if(zkController == null) {
|
if(zkController == null) {
|
||||||
solrLoader = new SolrResourceLoader(instanceDir.getAbsolutePath(), libLoader, ConfigSolrXml.getCoreProperties(instanceDir.getAbsolutePath(), cd));
|
solrLoader = new SolrResourceLoader(instanceDir.getAbsolutePath(), loader.getClassLoader(), ConfigSolrXml.getCoreProperties(instanceDir.getAbsolutePath(), cd));
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
String collection = cd.getCloudDescriptor().getCollectionName();
|
String collection = cd.getCloudDescriptor().getCollectionName();
|
||||||
|
@ -1069,7 +1070,7 @@ public class CoreContainer
|
||||||
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
|
throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
|
||||||
"Could not find config name for collection:" + collection);
|
"Could not find config name for collection:" + collection);
|
||||||
}
|
}
|
||||||
solrLoader = new ZkSolrResourceLoader(instanceDir.getAbsolutePath(), zkConfigName, libLoader,
|
solrLoader = new ZkSolrResourceLoader(instanceDir.getAbsolutePath(), zkConfigName, loader.getClassLoader(),
|
||||||
ConfigSolrXml.getCoreProperties(instanceDir.getAbsolutePath(), cd), zkController);
|
ConfigSolrXml.getCoreProperties(instanceDir.getAbsolutePath(), cd), zkController);
|
||||||
} catch (KeeperException e) {
|
} catch (KeeperException e) {
|
||||||
log.error("", e);
|
log.error("", e);
|
||||||
|
@ -1187,8 +1188,6 @@ public class CoreContainer
|
||||||
* @return a CoreAdminHandler
|
* @return a CoreAdminHandler
|
||||||
*/
|
*/
|
||||||
protected CoreAdminHandler createMultiCoreHandler(final String adminHandlerClass) {
|
protected CoreAdminHandler createMultiCoreHandler(final String adminHandlerClass) {
|
||||||
// :TODO: why create a new SolrResourceLoader? why not use this.loader ???
|
|
||||||
SolrResourceLoader loader = new SolrResourceLoader(solrHome, libLoader, null);
|
|
||||||
return loader.newAdminHandlerInstance(CoreContainer.this, adminHandlerClass);
|
return loader.newAdminHandlerInstance(CoreContainer.this, adminHandlerClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -309,6 +309,26 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testClassLoaderHierarchy() throws Exception {
|
||||||
|
final CoreContainer cc = init("_classLoaderHierarchy");
|
||||||
|
try {
|
||||||
|
cc.setPersistent(false);
|
||||||
|
ClassLoader sharedLoader = cc.loader.getClassLoader();
|
||||||
|
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
|
||||||
|
assertSame(contextLoader, sharedLoader.getParent());
|
||||||
|
|
||||||
|
CoreDescriptor descriptor1 = new CoreDescriptor(cc, "core1", "./collection1");
|
||||||
|
SolrCore core1 = cc.create(descriptor1);
|
||||||
|
ClassLoader coreLoader = core1.getResourceLoader().getClassLoader();
|
||||||
|
assertSame(sharedLoader, coreLoader.getParent());
|
||||||
|
|
||||||
|
core1.close();
|
||||||
|
} finally {
|
||||||
|
cc.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static final String EMPTY_SOLR_XML ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
|
private static final String EMPTY_SOLR_XML ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
|
||||||
"<solr persistent=\"false\">\n" +
|
"<solr persistent=\"false\">\n" +
|
||||||
|
|
Loading…
Reference in New Issue