You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by yo...@apache.org on 2006/03/31 17:45:36 UTC

svn commit: r390446 - in /incubator/solr/trunk: example/solr/ example/solr/conf/ example/solrconf/ src/apps/SolrTest/solr/ src/apps/SolrTest/solr/conf/ src/apps/SolrTest/solrconf/ src/java/org/apache/solr/core/

Author: yonik
Date: Fri Mar 31 07:45:36 2006
New Revision: 390446

URL: http://svn.apache.org/viewcvs?rev=390446&view=rev
Log:
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.

Added:
    incubator/solr/trunk/example/solr/
    incubator/solr/trunk/example/solr/conf/
      - copied from r390435, incubator/solr/trunk/example/solrconf/
    incubator/solr/trunk/src/apps/SolrTest/solr/
    incubator/solr/trunk/src/apps/SolrTest/solr/conf/
      - copied from r389608, incubator/solr/trunk/src/apps/SolrTest/solrconf/
Removed:
    incubator/solr/trunk/example/solrconf/
    incubator/solr/trunk/src/apps/SolrTest/solrconf/
Modified:
    incubator/solr/trunk/example/solr/conf/solrconfig.xml
    incubator/solr/trunk/src/java/org/apache/solr/core/Config.java
    incubator/solr/trunk/src/java/org/apache/solr/core/SolrConfig.java
    incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java

Modified: incubator/solr/trunk/example/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewcvs/incubator/solr/trunk/example/solr/conf/solrconfig.xml?rev=390446&r1=390435&r2=390446&view=diff
==============================================================================
--- incubator/solr/trunk/example/solr/conf/solrconfig.xml (original)
+++ incubator/solr/trunk/example/solr/conf/solrconfig.xml Fri Mar 31 07:45:36 2006
@@ -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>

Modified: incubator/solr/trunk/src/java/org/apache/solr/core/Config.java
URL: http://svn.apache.org/viewcvs/incubator/solr/trunk/src/java/org/apache/solr/core/Config.java?rev=390446&r1=390445&r2=390446&view=diff
==============================================================================
--- incubator/solr/trunk/src/java/org/apache/solr/core/Config.java (original)
+++ incubator/solr/trunk/src/java/org/apache/solr/core/Config.java Fri Mar 31 07:45:36 2006
@@ -188,13 +188,9 @@
       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 @@
     }
   }
 
-  // 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 @@
       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 @@
       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;
   }

Modified: incubator/solr/trunk/src/java/org/apache/solr/core/SolrConfig.java
URL: http://svn.apache.org/viewcvs/incubator/solr/trunk/src/java/org/apache/solr/core/SolrConfig.java?rev=390446&r1=390445&r2=390446&view=diff
==============================================================================
--- incubator/solr/trunk/src/java/org/apache/solr/core/SolrConfig.java (original)
+++ incubator/solr/trunk/src/java/org/apache/solr/core/SolrConfig.java Fri Mar 31 07:45:36 2006
@@ -28,18 +28,7 @@
   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 @@
     } 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");
   }
 }

Modified: incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
URL: http://svn.apache.org/viewcvs/incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java?rev=390446&r1=390445&r2=390446&view=diff
==============================================================================
--- incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java (original)
+++ incubator/solr/trunk/src/java/org/apache/solr/core/SolrCore.java Fri Mar 31 07:45:36 2006
@@ -180,10 +180,10 @@
       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");