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 eh...@apache.org on 2007/06/05 05:13:32 UTC

svn commit: r544356 - /lucene/solr/trunk/example/solr/conf/solrconfig.xml

Author: ehatcher
Date: Mon Jun  4 20:13:31 2007
New Revision: 544356

URL: http://svn.apache.org/viewvc?view=rev&rev=544356
Log:
Add system property setting to allow data directory to be overridden

Modified:
    lucene/solr/trunk/example/solr/conf/solrconfig.xml

Modified: lucene/solr/trunk/example/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/example/solr/conf/solrconfig.xml?view=diff&rev=544356&r1=544355&r2=544356
==============================================================================
--- lucene/solr/trunk/example/solr/conf/solrconfig.xml (original)
+++ lucene/solr/trunk/example/solr/conf/solrconfig.xml Mon Jun  4 20:13:31 2007
@@ -29,9 +29,8 @@
   <!-- Used to specify an alternate directory to hold all index data
        other than the default ./data under the Solr home.
        If replication is in use, this should match the replication configuration. -->
-  <!--
-  <dataDir>./solr/data</dataDir>
-  -->
+  <dataDir>${solr.data.dir:./solr/data}</dataDir>
+
 
   <indexDefaults>
    <!-- Values here affect all index writers and act as a default unless overridden. -->



Re: svn commit: r544356 - /lucene/solr/trunk/example/solr/conf/solrconfig.xml

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jun 12, 2007, at 12:37 PM, Ryan McKinley wrote:

> Erik Hatcher wrote:
>> On Jun 12, 2007, at 1:34 AM, Ryan McKinley wrote:
>>>> -  <!--
>>>> -  <dataDir>./solr/data</dataDir>
>>>> -  -->
>>>> +  <dataDir>${solr.data.dir:./solr/data}</dataDir>
>>>> +
>>>>
>>>
>>> I just ran into something weird with this...
>>>
>>> If you set the solr home with JNDI or solr.solr.home, the dataDir  
>>> still defaults to "./solr/data" -- not the data directory  
>>> relative to solr home.  This requires you to *also* set:  
>>> "solr.data.dir" if you want to use a different data directory.
>>>
>>> I think we should comment it out so that the by default, setting  
>>> solr home moves everything.
>> Instead, maybe a relative path should be made relative to Solr's  
>> home directory instead of to the current working directory?
>
> that sounds good.
>
> It is nice to be able to set the data directory with a property...

Does this patch work for you, Ryan?


Index: src/java/org/apache/solr/core/SolrCore.java
===================================================================
--- src/java/org/apache/solr/core/SolrCore.java (revision 546568)
+++ src/java/org/apache/solr/core/SolrCore.java (working copy)
@@ -17,6 +17,8 @@
package org.apache.solr.core;
+import static org.apache.solr.core.Config.getInstanceDir;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -73,8 +75,8 @@
    public static Logger log = Logger.getLogger(SolrCore.class.getName 
());
    private final IndexSchema schema;
-  private final String dataDir;
-  private final String index_path;
+  private final File dataDir;
+  private final File index_path;
    private final UpdateHandler updateHandler;
    private static final long startTime = System.currentTimeMillis();
    private final RequestHandlers reqHandlers = new RequestHandlers();
@@ -114,8 +116,8 @@
    }
    public IndexSchema getSchema() { return schema; }
-  public String getDataDir() { return dataDir; }
-  public String getIndexDir() { return index_path; }
+  public String getDataDir() { return dataDir.getAbsolutePath(); }
+  public String getIndexDir() { return index_path.getAbsolutePath(); }
    // gets a non-caching searcher
    public SolrIndexSearcher newSearcher(String name) throws  
IOException {
@@ -187,18 +189,19 @@
        core = this;   // set singleton
        if (dataDir ==null) {
-        dataDir = SolrConfig.config.get 
("dataDir",Config.getInstanceDir()+"data");
+        dataDir = SolrConfig.config.get("dataDir", getInstanceDir() 
+"data");
        }
-      log.info("Opening new SolrCore at " + Config.getInstanceDir()  
+ ", dataDir="+dataDir);
+      log.info("Opening new SolrCore at " + getInstanceDir() + ",  
dataDir="+dataDir);
        if (schema==null) {
          schema = new IndexSchema("schema.xml");
        }
        this.schema = schema;
-      this.dataDir = dataDir;
-      this.index_path = dataDir + "/" + "index";
+      File dataDirTemp = new File(dataDir);
+      this.dataDir = dataDirTemp;
+      this.index_path = new File(this.dataDir,"index");
        this.maxWarmingSearchers = SolrConfig.config.getInt("query/ 
maxWarmingSearchers",Integer.MAX_VALUE);
@@ -421,7 +424,7 @@
      // if this fails, we need to decrement onDeckSearchers again.
      SolrIndexSearcher tmp;
      try {
-      tmp = new SolrIndexSearcher(schema, "main", index_path, true);
+      tmp = new SolrIndexSearcher(schema, "main", getIndexDir(), true);
      } catch (Throwable th) {
        synchronized(searcherLock) {
          onDeckSearchers--;

Re: svn commit: r544356 - /lucene/solr/trunk/example/solr/conf/solrconfig.xml

Posted by Ryan McKinley <ry...@gmail.com>.
Erik Hatcher wrote:
> 
> On Jun 12, 2007, at 1:34 AM, Ryan McKinley wrote:
>>> -  <!--
>>> -  <dataDir>./solr/data</dataDir>
>>> -  -->
>>> +  <dataDir>${solr.data.dir:./solr/data}</dataDir>
>>> +
>>>
>>
>> I just ran into something weird with this...
>>
>> If you set the solr home with JNDI or solr.solr.home, the dataDir 
>> still defaults to "./solr/data" -- not the data directory relative to 
>> solr home.  This requires you to *also* set: "solr.data.dir" if you 
>> want to use a different data directory.
>>
>> I think we should comment it out so that the by default, setting solr 
>> home moves everything.
> 
> Instead, maybe a relative path should be made relative to Solr's home 
> directory instead of to the current working directory?
> 

that sounds good.

It is nice to be able to set the data directory with a property...


Re: svn commit: r544356 - /lucene/solr/trunk/example/solr/conf/solrconfig.xml

Posted by Chris Hostetter <ho...@fucit.org>.
: In this case, relative to solr.home makes the most sense.  I like
: -Dsolr.data.dir=XXX out of the box, but enabling it explicitly isn't hard...

Yeah, I'm probably just being overly paranoid.  Making dataDir be relative
Solr Home is probably the way it should have worked all along ... so as
long as it's heavily documented in CHANGES.txt i think we'll be fine.

i suspect if anyone was specifying a solrhome *and* specifying a dataDir
we would have gotten a question about dataDir not being relative solrhome.
(allthough maybe we will now that 1.2 has the <dataDir> block un
commented)

We could just add an optional rel="cwd" (vs rel="solr") attribute to the
<dataDir> tag and make it really explicit.



-Hoss


Re: svn commit: r544356 - /lucene/solr/trunk/example/solr/conf/solrconfig.xml

Posted by Ryan McKinley <ry...@gmail.com>.
> 
> I'm ambivalent though - I'm happy to reverse the change to the example 
> solrconfig.xml too, though I like that one can fire up the example 
> configuration with a different data directory easily.
> 

I am happy either way - relative to solr home or just commented out.

In this case, relative to solr.home makes the most sense.  I like 
-Dsolr.data.dir=XXX out of the box, but enabling it explicitly isn't hard...






Re: svn commit: r544356 - /lucene/solr/trunk/example/solr/conf/solrconfig.xml

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jun 12, 2007, at 1:57 PM, Chris Hostetter wrote:

>
> : Instead, maybe a relative path should be made relative to Solr's  
> home
> : directory instead of to the current working directory?
>
> I'm not sure how i feel about that ... it would be one thing if  
> Solr could
> generate an error if the dataDir didn't exist, but since we create the
> directory on the fly as needed, changing this behavior <dataDir> is
> relative working directory vs solr.home) could really confuse people.
>
> Does the system property substitution stuff in the solrconfig deal  
> with
> substitutions that contain other substitutions?  if so then maybe we
> should set the solr.solr.home system property if we see that solr  
> home has
> been specified with JNDI, and make the example solrconfig something
> like...
>
>     <dataDir>${solr.data.dir:${solr.solr.home}/solr/data}</dataDir>

No, it does not support that type of substitution.

> ...but people can still choose to use something like...
>
>     <dataDir>data</dataDir>
>
> ...and have it mean "the data directory in my current working  
> directory"
>
>
> Of course, i may just be paranoid about breaking esoteric use cases.

It's a good point to consider.  Personally I'd never run with things  
specified out of the current directory that way, so its hard for me  
to identify with the troubles this change would make.  If folks were  
using the example application as-is this change wouldn't affect them.

I'm ambivalent though - I'm happy to reverse the change to the  
example solrconfig.xml too, though I like that one can fire up the  
example configuration with a different data directory easily.

	Erik


Re: svn commit: r544356 - /lucene/solr/trunk/example/solr/conf/solrconfig.xml

Posted by Chris Hostetter <ho...@fucit.org>.
: Instead, maybe a relative path should be made relative to Solr's home
: directory instead of to the current working directory?

I'm not sure how i feel about that ... it would be one thing if Solr could
generate an error if the dataDir didn't exist, but since we create the
directory on the fly as needed, changing this behavior <dataDir> is
relative working directory vs solr.home) could really confuse people.

Does the system property substitution stuff in the solrconfig deal with
substitutions that contain other substitutions?  if so then maybe we
should set the solr.solr.home system property if we see that solr home has
been specified with JNDI, and make the example solrconfig something
like...

    <dataDir>${solr.data.dir:${solr.solr.home}/solr/data}</dataDir>

...but people can still choose to use something like...

    <dataDir>data</dataDir>

...and have it mean "the data directory in my current working directory"


Of course, i may just be paranoid about breaking esoteric use cases.

-Hoss


Re: svn commit: r544356 - /lucene/solr/trunk/example/solr/conf/solrconfig.xml

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Jun 12, 2007, at 1:34 AM, Ryan McKinley wrote:
>> -  <!--
>> -  <dataDir>./solr/data</dataDir>
>> -  -->
>> +  <dataDir>${solr.data.dir:./solr/data}</dataDir>
>> +
>>
>
> I just ran into something weird with this...
>
> If you set the solr home with JNDI or solr.solr.home, the dataDir  
> still defaults to "./solr/data" -- not the data directory relative  
> to solr home.  This requires you to *also* set: "solr.data.dir" if  
> you want to use a different data directory.
>
> I think we should comment it out so that the by default, setting  
> solr home moves everything.

Instead, maybe a relative path should be made relative to Solr's home  
directory instead of to the current working directory?

	Erik


Re: svn commit: r544356 - /lucene/solr/trunk/example/solr/conf/solrconfig.xml

Posted by Ryan McKinley <ry...@gmail.com>.
> -  <!--
> -  <dataDir>./solr/data</dataDir>
> -  -->
> +  <dataDir>${solr.data.dir:./solr/data}</dataDir>
> +
>  

I just ran into something weird with this...

If you set the solr home with JNDI or solr.solr.home, the dataDir still 
defaults to "./solr/data" -- not the data directory relative to solr 
home.  This requires you to *also* set: "solr.data.dir" if you want to 
use a different data directory.

I think we should comment it out so that the by default, setting solr 
home moves everything.

ryan