From 34dc1329028d66a0f37ad5b68be18a7482887cc6 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Fri, 31 Mar 2006 15:45:36 +0000 Subject: [PATCH] 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 --- example/{solrconf => solr/conf}/protwords.txt | 0 example/{solrconf => solr/conf}/schema.xml | 0 .../{solrconf => solr/conf}/solrconfig.xml | 4 +-- example/{solrconf => solr/conf}/stopwords.txt | 0 example/{solrconf => solr/conf}/synonyms.txt | 0 .../{solrconf => solr/conf}/protwords.txt | 0 .../{solrconf => solr/conf}/schema.xml | 0 .../{solrconf => solr/conf}/solrconfig.xml | 0 .../{solrconf => solr/conf}/stopwords.txt | 0 .../{solrconf => solr/conf}/synonyms.txt | 0 src/java/org/apache/solr/core/Config.java | 36 +++++++++++-------- src/java/org/apache/solr/core/SolrConfig.java | 15 ++------ src/java/org/apache/solr/core/SolrCore.java | 4 +-- 13 files changed, 28 insertions(+), 31 deletions(-) rename example/{solrconf => solr/conf}/protwords.txt (100%) rename example/{solrconf => solr/conf}/schema.xml (100%) rename example/{solrconf => solr/conf}/solrconfig.xml (99%) rename example/{solrconf => solr/conf}/stopwords.txt (100%) rename example/{solrconf => solr/conf}/synonyms.txt (100%) rename src/apps/SolrTest/{solrconf => solr/conf}/protwords.txt (100%) rename src/apps/SolrTest/{solrconf => solr/conf}/schema.xml (100%) rename src/apps/SolrTest/{solrconf => solr/conf}/solrconfig.xml (100%) rename src/apps/SolrTest/{solrconf => solr/conf}/stopwords.txt (100%) rename src/apps/SolrTest/{solrconf => solr/conf}/synonyms.txt (100%) diff --git a/example/solrconf/protwords.txt b/example/solr/conf/protwords.txt similarity index 100% rename from example/solrconf/protwords.txt rename to example/solr/conf/protwords.txt diff --git a/example/solrconf/schema.xml b/example/solr/conf/schema.xml similarity index 100% rename from example/solrconf/schema.xml rename to example/solr/conf/schema.xml diff --git a/example/solrconf/solrconfig.xml b/example/solr/conf/solrconfig.xml similarity index 99% rename from example/solrconf/solrconfig.xml rename to example/solr/conf/solrconfig.xml index df333ce7a26..e3fbac522a7 100755 --- a/example/solrconf/solrconfig.xml +++ b/example/solr/conf/solrconfig.xml @@ -3,10 +3,10 @@ diff --git a/example/solrconf/stopwords.txt b/example/solr/conf/stopwords.txt similarity index 100% rename from example/solrconf/stopwords.txt rename to example/solr/conf/stopwords.txt diff --git a/example/solrconf/synonyms.txt b/example/solr/conf/synonyms.txt similarity index 100% rename from example/solrconf/synonyms.txt rename to example/solr/conf/synonyms.txt diff --git a/src/apps/SolrTest/solrconf/protwords.txt b/src/apps/SolrTest/solr/conf/protwords.txt similarity index 100% rename from src/apps/SolrTest/solrconf/protwords.txt rename to src/apps/SolrTest/solr/conf/protwords.txt diff --git a/src/apps/SolrTest/solrconf/schema.xml b/src/apps/SolrTest/solr/conf/schema.xml similarity index 100% rename from src/apps/SolrTest/solrconf/schema.xml rename to src/apps/SolrTest/solr/conf/schema.xml diff --git a/src/apps/SolrTest/solrconf/solrconfig.xml b/src/apps/SolrTest/solr/conf/solrconfig.xml similarity index 100% rename from src/apps/SolrTest/solrconf/solrconfig.xml rename to src/apps/SolrTest/solr/conf/solrconfig.xml diff --git a/src/apps/SolrTest/solrconf/stopwords.txt b/src/apps/SolrTest/solr/conf/stopwords.txt similarity index 100% rename from src/apps/SolrTest/solrconf/stopwords.txt rename to src/apps/SolrTest/solr/conf/stopwords.txt diff --git a/src/apps/SolrTest/solrconf/synonyms.txt b/src/apps/SolrTest/solr/conf/synonyms.txt similarity index 100% rename from src/apps/SolrTest/solrconf/synonyms.txt rename to src/apps/SolrTest/solr/conf/synonyms.txt diff --git a/src/java/org/apache/solr/core/Config.java b/src/java/org/apache/solr/core/Config.java index 818444b650c..ce6e7e9e9a3 100644 --- a/src/java/org/apache/solr/core/Config.java +++ b/src/java/org/apache/solr/core/Config.java @@ -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; } diff --git a/src/java/org/apache/solr/core/SolrConfig.java b/src/java/org/apache/solr/core/SolrConfig.java index 3c0b1dcfad9..42f4ffa121c 100644 --- a/src/java/org/apache/solr/core/SolrConfig.java +++ b/src/java/org/apache/solr/core/SolrConfig.java @@ -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"); } } diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.java index 752c0ca3d40..9c98df17e02 100644 --- a/src/java/org/apache/solr/core/SolrCore.java +++ b/src/java/org/apache/solr/core/SolrCore.java @@ -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");