mirror of https://github.com/apache/lucene.git
removed legacy solar name support, change default config directory to ./solr/conf, make data directory ./solr/data, make base dir (./solr) configurable from solr.solr.home property, preliminary support for multiple solr wars, enhance exception message when resource isn't found.
git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@390446 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f513261391
commit
34dc132902
|
@ -3,10 +3,10 @@
|
|||
<config>
|
||||
|
||||
<!-- Used to specify an alternate directory to hold all index data
|
||||
other than the default ./data
|
||||
other than the default ./solr/data
|
||||
If replication is in use, this should match the replication configuration. -->
|
||||
<!--
|
||||
<dataDir>data</dataDir>
|
||||
<dataDir>./solr/data</dataDir>
|
||||
-->
|
||||
|
||||
<indexDefaults>
|
|
@ -188,13 +188,9 @@ public class Config {
|
|||
return Class.forName(cname, true, loader);
|
||||
} catch (ClassNotFoundException e) {
|
||||
String newName=cname;
|
||||
if (newName.startsWith("solar.")) {
|
||||
// handle legacy package names
|
||||
newName = cname.substring("solar.".length());
|
||||
} else if (cname.startsWith(project+".")) {
|
||||
if (newName.startsWith(project)) {
|
||||
newName = cname.substring(project.length()+1);
|
||||
}
|
||||
|
||||
for (String subpackage : subpackages) {
|
||||
try {
|
||||
String name = base + '.' + subpackage + newName;
|
||||
|
@ -218,17 +214,29 @@ public class Config {
|
|||
}
|
||||
}
|
||||
|
||||
// The directory where solr will look for config files by default.
|
||||
// defaults to "./solrconf/"
|
||||
private static final String configDir;
|
||||
static {
|
||||
String str = System.getProperty("solr.configdir");
|
||||
|
||||
private static String instance = project;
|
||||
public static void setInstanceName(String name) {
|
||||
instance = name;
|
||||
}
|
||||
public static String getInstanceName() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static String getInstanceDir() {
|
||||
String str = System.getProperty(instance + ".solr.home");
|
||||
if (str==null) {
|
||||
str="solrconf/";
|
||||
str=instance + '/';
|
||||
} else if ( !(str.endsWith("/") || str.endsWith("\\")) ) {
|
||||
str+='/';
|
||||
}
|
||||
configDir = str;
|
||||
return str;
|
||||
}
|
||||
|
||||
// The directory where solr will look for config files by default.
|
||||
// defaults to "./solr/conf/"
|
||||
static String getConfigDir() {
|
||||
return getInstanceDir() + "conf/";
|
||||
}
|
||||
|
||||
public static InputStream openResource(String resource) {
|
||||
|
@ -238,7 +246,7 @@ public class Config {
|
|||
File f = new File(resource);
|
||||
if (!f.isAbsolute()) {
|
||||
// try $CWD/solrconf/
|
||||
f = new File(configDir + resource);
|
||||
f = new File(getConfigDir() + resource);
|
||||
}
|
||||
if (f.isFile() && f.canRead()) {
|
||||
return new FileInputStream(f);
|
||||
|
@ -256,7 +264,7 @@ public class Config {
|
|||
throw new RuntimeException("Error opening " + resource, e);
|
||||
}
|
||||
if (is==null) {
|
||||
throw new RuntimeException("Can't find resource " + resource);
|
||||
throw new RuntimeException("Can't find resource '" + resource + "' in classpath or '" + getConfigDir() + "', cwd="+System.getProperty("user.dir"));
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
|
|
@ -28,18 +28,7 @@ public class SolrConfig {
|
|||
static {
|
||||
RuntimeException e=null;
|
||||
String file="solrconfig.xml";
|
||||
InputStream is=null;
|
||||
try {
|
||||
is = Config.openResource(file);
|
||||
} catch (RuntimeException ee) {
|
||||
e=ee;
|
||||
file = "solarconfig.xml"; // backward compat
|
||||
try {
|
||||
is = Config.openResource(file);
|
||||
} catch (Exception eee) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
InputStream is = Config.openResource(file);
|
||||
|
||||
try {
|
||||
config=new Config(file, is, "/config/");
|
||||
|
@ -47,7 +36,7 @@ public class SolrConfig {
|
|||
} catch (Exception ee) {
|
||||
throw new RuntimeException("Error in solrconfig.xml", ee);
|
||||
}
|
||||
Config.log.info("Loaded Config solrconfig.xml");
|
||||
|
||||
Config.log.info("Loaded Config solrconfig.xml");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -180,10 +180,10 @@ public final class SolrCore {
|
|||
core = this; // set singleton
|
||||
|
||||
if (dataDir ==null) {
|
||||
dataDir =SolrConfig.config.get("dataDir","data");
|
||||
dataDir =SolrConfig.config.get("dataDir",Config.getInstanceDir()+"data");
|
||||
}
|
||||
|
||||
log.info("Opening new SolrCore with data directory at " + dataDir);
|
||||
log.info("Opening new SolrCore at " + Config.getInstanceDir() + ", dataDir="+dataDir);
|
||||
|
||||
if (schema==null) {
|
||||
schema = new IndexSchema("schema.xml");
|
||||
|
|
Loading…
Reference in New Issue