Pranav,

Sorry, I should have checked my response a little better as I
misspelled your name and, mentioned that I tried what Marcus suggested
then described something totally different.
I didn't try using the property mechanism as Marcus suggested as I am
not using a solr.xml file.

What you mentioned in your post on Wed, Jul 18, 2012 at 3:46 PM will
work as I have done it successfully.
That is I created a JVM variable to contain the connect URLs for each
of my environments and one of those to set the URL parameter of the
dataSource entity
in my data config files.

Best,
Jerry


On Mon, Jul 23, 2012 at 3:34 PM, jerry.min...@gmail.com
<jerry.min...@gmail.com> wrote:
> Pranay,
>
> I tried two similar approaches to resolve this in my system which is
> Solr 4.0 running in Tomcat 7.x on Ubuntu 9.10.
>
> My preference was to use an alias for each of my database environments
> as a JVM parameter because it makes more sense to me that the database
> connection be stored in the data config file rather than in a Tomcat
> configuration or startup file.
> Because of preference, I first attempted the following:
> 1. Set a JVM environment variable 'solr.dbEnv' to the represent the
> database environment that should be accessed. For example, in my dev
> environment, the JVM environment variable was set as -Dsolr.dbEnv=dev.
> 2. In the data config file I had 3 data sources. Each data source had
> a name that matched one of the database environment aliases.
> 3. In the entity of my data config file "dataSource" parameter was set
> as follows dataSource=${solr.dbEnv}.
>
> Unfortunately, this fails to work. Setting "dataSource" parameter in
> the data config file does not override the default. The default
> appears to be the first data source defined in the data config file.
>
> Second, I tried what Marcus suggested.
>
> That is, I created a JVM variable to contain the connect URLs for each
> of my environments.
> I use that variable to set the URL parameter of the dataSource entity
> in the data config file.
>
> This works well.
>
>
> Best,
> Jerry Mindek
>
> Unfortunately, the first option did not work. It seemed as though
> On Wed, Jul 18, 2012 at 3:46 PM, Pranav Prakash <pra...@gmail.com> wrote:
>> That approach would work for core dependent parameters. In my case, the
>> params are environment dependent. I think a simpler approach would be to
>> pass the url param as JVM options, and these XMLs get it from there.
>>
>> I haven't tried it yet.
>>
>> *Pranav Prakash*
>>
>> "temet nosce"
>>
>>
>>
>> On Tue, Jul 17, 2012 at 5:09 PM, Markus Klose <m...@shi-gmbh.com> wrote:
>>
>>> Hi
>>>
>>> There is one more approach using the property mechanism.
>>>
>>> You could specify the datasource like this:
>>> <dataSource name="database" driver="${sqlDriver}" url="${sqlURL}"/>
>>>
>>>  And you can specifiy the properties in the solr.xml in your core
>>> configuration like this:
>>>
>>> <core instanceDir="core1" name="core1">
>>>         <property name="sqlURL" value="jdbc:hsqldb:/temp/example/ex"/>
>>>         ....
>>> </core>
>>>
>>>
>>> Viele Grüße aus Augsburg
>>>
>>> Markus Klose
>>> SHI Elektronische Medien GmbH
>>>
>>>
>>> Adresse: Curt-Frenzel-Str. 12, 86167 Augsburg
>>>
>>> Tel.:   0821 7482633 26
>>> Tel.:   0821 7482633 0 (Zentrale)
>>> Mobil:0176 56516869
>>> Fax:   0821 7482633 29
>>>
>>> E-Mail: markus.kl...@shi-gmbh.com
>>> Internet: http://www.shi-gmbh.com
>>>
>>> Registergericht Augsburg HRB 17382
>>> Geschäftsführer: Peter Spiske
>>> USt.-ID: DE 182167335
>>>
>>>
>>>
>>>
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Rahul Warawdekar [mailto:rahul.warawde...@gmail.com]
>>> Gesendet: Mittwoch, 11. Juli 2012 11:21
>>> An: solr-user@lucene.apache.org
>>> Betreff: Re: DIH XML configs for multi environment
>>>
>>> http://wiki.eclipse.org/Jetty/Howto/Configure_JNDI_Datasource
>>> http://docs.codehaus.org/display/JETTY/DataSource+Examples
>>>
>>>
>>> On Wed, Jul 11, 2012 at 2:30 PM, Pranav Prakash <pra...@gmail.com> wrote:
>>>
>>> > That's cool. Is there something similar for Jetty as well? We use Jetty!
>>> >
>>> > *Pranav Prakash*
>>> >
>>> > "temet nosce"
>>> >
>>> >
>>> >
>>> > On Wed, Jul 11, 2012 at 1:49 PM, Rahul Warawdekar <
>>> > rahul.warawde...@gmail.com> wrote:
>>> >
>>> > > Hi Pranav,
>>> > >
>>> > > If you are using Tomcat to host Solr, you can define your data
>>> > > source in context.xml file under tomcat configuration.
>>> > > You have to refer to this datasource with the same name in all the 3
>>> > > environments from DIH data-config.xml.
>>> > > This context.xml file will vary across 3 environments having
>>> > > different credentials for dev, stag and prod.
>>> > >
>>> > > eg
>>> > > DIH data-config.xml will refer to the datasource as listed below
>>> > > <dataSource jndiName="java:comp/env/<*YOUR_DATASOURCE_NAME*>"
>>> > > type="JdbcDataSource" readOnly="true" />
>>> > >
>>> > > context.xml file which is located under "/<TOMCAT_HOME>/conf" folder
>>> > > will have the resource entry as follows
>>> > >   <Resource name="<*YOUR_DATASOURCE_NAME*>" auth="Container"
>>> > >             type="" username="XXXXX" password="XXXXX"
>>> > >             driverClassName=""
>>> > >             url=""
>>> > >             maxActive="8"
>>> > >             />
>>> > >
>>> > > On Wed, Jul 11, 2012 at 1:31 PM, Pranav Prakash <pra...@gmail.com>
>>> > wrote:
>>> > >
>>> > > > The DIH XML config file has to be specified dataSource. In my
>>> > > > case, and possibly with many others, the logon credentials as well
>>> > > > as mysql
>>> > server
>>> > > > paths would differ based on environments (dev, stag, prod). I
>>> > > > don't
>>> > want
>>> > > to
>>> > > > end up coming with three different DIH config files, three
>>> > > > different handlers and so on.
>>> > > >
>>> > > > What is a good way to deal with this?
>>> > > >
>>> > > >
>>> > > > *Pranav Prakash*
>>> > > >
>>> > > > "temet nosce"
>>> > > >
>>> > >
>>> > >
>>> > >
>>> > > --
>>> > > Thanks and Regards
>>> > > Rahul A. Warawdekar
>>> > >
>>> >
>>>
>>>
>>>
>>> --
>>> Thanks and Regards
>>> Rahul A. Warawdekar
>>>

Reply via email to