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.
|
* SOLR-5644: SplitShard does not handle not finding a shard leader well.
|
||||||
(Mark Miller, Anshum Gupta via shalin)
|
(Mark Miller, Anshum Gupta via shalin)
|
||||||
|
|
||||||
|
* SOLR-5704: coreRootDirectory was not respected when creating new cores
|
||||||
|
via CoreAdminHandler (Jesse Sipprell, Alan Woodward)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,8 @@ public abstract class ConfigSolr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigSolr fromString(String xml) {
|
public static ConfigSolr fromString(SolrResourceLoader loader, String xml) {
|
||||||
return fromInputStream(null, new ByteArrayInputStream(xml.getBytes(Charsets.UTF_8)));
|
return fromInputStream(loader, new ByteArrayInputStream(xml.getBytes(Charsets.UTF_8)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigSolr fromInputStream(SolrResourceLoader loader, InputStream is) {
|
public static ConfigSolr fromInputStream(SolrResourceLoader loader, InputStream is) {
|
||||||
|
@ -104,6 +104,17 @@ public abstract class ConfigSolr {
|
||||||
|
|
||||||
public abstract CoresLocator getCoresLocator();
|
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() {
|
public PluginInfo getShardHandlerFactoryPluginInfo() {
|
||||||
Node node = config.getNode(getShardHandlerFactoryConfigPath(), false);
|
Node node = config.getNode(getShardHandlerFactoryConfigPath(), false);
|
||||||
return (node == null) ? null : new PluginInfo(node, "shardHandlerFactory", false, true);
|
return (node == null) ? null : new PluginInfo(node, "shardHandlerFactory", false, true);
|
||||||
|
|
|
@ -40,9 +40,7 @@ public class ConfigSolrXml extends ConfigSolr {
|
||||||
checkForIllegalConfig();
|
checkForIllegalConfig();
|
||||||
fillPropMap();
|
fillPropMap();
|
||||||
config.substituteProperties();
|
config.substituteProperties();
|
||||||
log.info("Config-defined core root directory: {}", get(CfgProp.SOLR_COREROOTDIRECTORY, ""));
|
coresLocator = new CorePropertiesLocator(getCoreRootDirectory());
|
||||||
String coreRoot = get(CfgProp.SOLR_COREROOTDIRECTORY, config.getResourceLoader().getInstanceDir());
|
|
||||||
coresLocator = new CorePropertiesLocator(coreRoot);
|
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
|
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, e);
|
||||||
|
|
|
@ -793,6 +793,10 @@ public class CoreContainer {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCoreRootDirectory() {
|
||||||
|
return cfg.getCoreRootDirectory();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a core by name and increase its refcount.
|
* Gets a core by name and increase its refcount.
|
||||||
*
|
*
|
||||||
|
|
|
@ -162,7 +162,7 @@ public class CoreDescriptor {
|
||||||
coreProperties.putAll(defaultProperties);
|
coreProperties.putAll(defaultProperties);
|
||||||
coreProperties.put(CORE_NAME, name);
|
coreProperties.put(CORE_NAME, name);
|
||||||
coreProperties.put(CORE_INSTDIR, instanceDir);
|
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()) {
|
for (String propname : coreProps.stringPropertyNames()) {
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class CorePropertiesLocator implements CoresLocator {
|
||||||
|
|
||||||
public CorePropertiesLocator(String coreDiscoveryRoot) {
|
public CorePropertiesLocator(String coreDiscoveryRoot) {
|
||||||
this.rootDirectory = new File(coreDiscoveryRoot);
|
this.rootDirectory = new File(coreDiscoveryRoot);
|
||||||
|
logger.info("Config-defined core root directory: {}", this.rootDirectory.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -322,8 +322,8 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
@Test
|
@Test
|
||||||
public void testCustomHandlers() throws Exception {
|
public void testCustomHandlers() throws Exception {
|
||||||
|
|
||||||
ConfigSolr config = ConfigSolr.fromString(CUSTOM_HANDLERS_SOLR_XML);
|
|
||||||
SolrResourceLoader loader = new SolrResourceLoader("solr/collection1");
|
SolrResourceLoader loader = new SolrResourceLoader("solr/collection1");
|
||||||
|
ConfigSolr config = ConfigSolr.fromString(loader, CUSTOM_HANDLERS_SOLR_XML);
|
||||||
|
|
||||||
CoreContainer cc = new CoreContainer(loader, config);
|
CoreContainer cc = new CoreContainer(loader, config);
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class TestHarness extends BaseTestHarness {
|
||||||
this.coreName = coreName;
|
this.coreName = coreName;
|
||||||
|
|
||||||
SolrResourceLoader loader = new SolrResourceLoader(SolrResourceLoader.locateSolrHome());
|
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 = new CoreContainer(loader, config);
|
||||||
container.load();
|
container.load();
|
||||||
|
|
||||||
|
@ -150,11 +150,19 @@ public class TestHarness extends BaseTestHarness {
|
||||||
/**
|
/**
|
||||||
* Create a TestHarness using a specific solr home directory and solr xml
|
* Create a TestHarness using a specific solr home directory and solr xml
|
||||||
* @param solrHome the solr home directory
|
* @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) {
|
public TestHarness(String solrHome, String solrXml) {
|
||||||
this(new SolrResourceLoader(solrHome),
|
this(new SolrResourceLoader(solrHome), solrXml);
|
||||||
ConfigSolr.fromString(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);
|
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 solrConfig, String schema) {
|
||||||
String solrxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
|
String solrxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
|
||||||
+ "<solr persistent=\"false\">\n"
|
+ "<solr persistent=\"false\">\n"
|
||||||
|
@ -185,7 +193,7 @@ public class TestHarness extends BaseTestHarness {
|
||||||
+ "\" transient=\"false\" loadOnStartup=\"true\""
|
+ "\" transient=\"false\" loadOnStartup=\"true\""
|
||||||
+ " shard=\"${shard:shard1}\" collection=\"${collection:collection1}\" instanceDir=\"" + coreName + "/\" />\n"
|
+ " shard=\"${shard:shard1}\" collection=\"${collection:collection1}\" instanceDir=\"" + coreName + "/\" />\n"
|
||||||
+ " </cores>\n" + "</solr>";
|
+ " </cores>\n" + "</solr>";
|
||||||
return ConfigSolr.fromString(solrxml);
|
return ConfigSolr.fromString(loader, solrxml);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CoreContainer getCoreContainer() {
|
public CoreContainer getCoreContainer() {
|
||||||
|
|
Loading…
Reference in New Issue