mirror of https://github.com/apache/lucene.git
SOLR-5704: new cores should be created under coreRootDirectory
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1566598 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f5a1519069
commit
ce571f0242
|
@ -299,6 +299,9 @@ Bug Fixes
|
|||
* SOLR-5644: SplitShard does not handle not finding a shard leader well.
|
||||
(Mark Miller, Anshum Gupta via shalin)
|
||||
|
||||
* SOLR-5704: coreRootDirectory was not respected when creating new cores
|
||||
via CoreAdminHandler (Jesse Sipprell, Alan Woodward)
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -74,8 +74,8 @@ public abstract class ConfigSolr {
|
|||
}
|
||||
}
|
||||
|
||||
public static ConfigSolr fromString(String xml) {
|
||||
return fromInputStream(null, new ByteArrayInputStream(xml.getBytes(Charsets.UTF_8)));
|
||||
public static ConfigSolr fromString(SolrResourceLoader loader, String xml) {
|
||||
return fromInputStream(loader, new ByteArrayInputStream(xml.getBytes(Charsets.UTF_8)));
|
||||
}
|
||||
|
||||
public static ConfigSolr fromInputStream(SolrResourceLoader loader, InputStream is) {
|
||||
|
@ -104,6 +104,17 @@ public abstract class ConfigSolr {
|
|||
|
||||
public abstract CoresLocator getCoresLocator();
|
||||
|
||||
|
||||
/**
|
||||
* The directory against which relative core instance dirs are resolved. If none is
|
||||
* specified in the config, uses solr home.
|
||||
*
|
||||
* @return core root directory
|
||||
*/
|
||||
public String getCoreRootDirectory() {
|
||||
return get(CfgProp.SOLR_COREROOTDIRECTORY, config.getResourceLoader().getInstanceDir());
|
||||
}
|
||||
|
||||
public PluginInfo getShardHandlerFactoryPluginInfo() {
|
||||
Node node = config.getNode(getShardHandlerFactoryConfigPath(), false);
|
||||
return (node == null) ? null : new PluginInfo(node, "shardHandlerFactory", false, true);
|
||||
|
|
|
@ -40,9 +40,7 @@ public class ConfigSolrXml extends ConfigSolr {
|
|||
checkForIllegalConfig();
|
||||
fillPropMap();
|
||||
config.substituteProperties();
|
||||
log.info("Config-defined core root directory: {}", get(CfgProp.SOLR_COREROOTDIRECTORY, ""));
|
||||
String coreRoot = get(CfgProp.SOLR_COREROOTDIRECTORY, config.getResourceLoader().getInstanceDir());
|
||||
coresLocator = new CorePropertiesLocator(coreRoot);
|
||||
coresLocator = new CorePropertiesLocator(getCoreRootDirectory());
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
|
||||
|
|
|
@ -793,6 +793,10 @@ public class CoreContainer {
|
|||
return null;
|
||||
}
|
||||
|
||||
public String getCoreRootDirectory() {
|
||||
return cfg.getCoreRootDirectory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a core by name and increase its refcount.
|
||||
*
|
||||
|
|
|
@ -162,7 +162,7 @@ public class CoreDescriptor {
|
|||
coreProperties.putAll(defaultProperties);
|
||||
coreProperties.put(CORE_NAME, name);
|
||||
coreProperties.put(CORE_INSTDIR, instanceDir);
|
||||
coreProperties.put(CORE_ABS_INSTDIR, convertToAbsolute(instanceDir, container.getSolrHome()));
|
||||
coreProperties.put(CORE_ABS_INSTDIR, convertToAbsolute(instanceDir, container.getCoreRootDirectory()));
|
||||
|
||||
for (String propname : coreProps.stringPropertyNames()) {
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ public class CorePropertiesLocator implements CoresLocator {
|
|||
|
||||
public CorePropertiesLocator(String coreDiscoveryRoot) {
|
||||
this.rootDirectory = new File(coreDiscoveryRoot);
|
||||
logger.info("Config-defined core root directory: {}", this.rootDirectory.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -322,8 +322,8 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
|||
@Test
|
||||
public void testCustomHandlers() throws Exception {
|
||||
|
||||
ConfigSolr config = ConfigSolr.fromString(CUSTOM_HANDLERS_SOLR_XML);
|
||||
SolrResourceLoader loader = new SolrResourceLoader("solr/collection1");
|
||||
ConfigSolr config = ConfigSolr.fromString(loader, CUSTOM_HANDLERS_SOLR_XML);
|
||||
|
||||
CoreContainer cc = new CoreContainer(loader, config);
|
||||
try {
|
||||
|
|
|
@ -132,7 +132,7 @@ public class TestHarness extends BaseTestHarness {
|
|||
this.coreName = coreName;
|
||||
|
||||
SolrResourceLoader loader = new SolrResourceLoader(SolrResourceLoader.locateSolrHome());
|
||||
ConfigSolr config = getTestHarnessConfig(coreName, dataDir, solrConfig, indexSchema);
|
||||
ConfigSolr config = getTestHarnessConfig(loader, coreName, dataDir, solrConfig, indexSchema);
|
||||
container = new CoreContainer(loader, config);
|
||||
container.load();
|
||||
|
||||
|
@ -150,11 +150,19 @@ public class TestHarness extends BaseTestHarness {
|
|||
/**
|
||||
* Create a TestHarness using a specific solr home directory and solr xml
|
||||
* @param solrHome the solr home directory
|
||||
* @param solrXml a File pointing to a solr.xml configuration
|
||||
* @param solrXml the text of a solrxml
|
||||
*/
|
||||
public TestHarness(String solrHome, String solrXml) {
|
||||
this(new SolrResourceLoader(solrHome),
|
||||
ConfigSolr.fromString(solrXml));
|
||||
this(new SolrResourceLoader(solrHome), solrXml);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a TestHarness using a specific solr resource loader and solr xml
|
||||
* @param loader the SolrResourceLoader to use
|
||||
* @param solrXml the text of a solrxml
|
||||
*/
|
||||
public TestHarness(SolrResourceLoader loader, String solrXml) {
|
||||
this(loader, ConfigSolr.fromString(loader, solrXml));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,7 +177,7 @@ public class TestHarness extends BaseTestHarness {
|
|||
updater.init(null);
|
||||
}
|
||||
|
||||
private static ConfigSolr getTestHarnessConfig(String coreName, String dataDir,
|
||||
private static ConfigSolr getTestHarnessConfig(SolrResourceLoader loader, String coreName, String dataDir,
|
||||
String solrConfig, String schema) {
|
||||
String solrxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
|
||||
+ "<solr persistent=\"false\">\n"
|
||||
|
@ -185,7 +193,7 @@ public class TestHarness extends BaseTestHarness {
|
|||
+ "\" transient=\"false\" loadOnStartup=\"true\""
|
||||
+ " shard=\"${shard:shard1}\" collection=\"${collection:collection1}\" instanceDir=\"" + coreName + "/\" />\n"
|
||||
+ " </cores>\n" + "</solr>";
|
||||
return ConfigSolr.fromString(solrxml);
|
||||
return ConfigSolr.fromString(loader, solrxml);
|
||||
}
|
||||
|
||||
public CoreContainer getCoreContainer() {
|
||||
|
|
Loading…
Reference in New Issue