One quick work-around for multiple Solr webapps in Resin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

One quick work-around for multiple Solr webapps in Resin

kkrugler
Hi all,

Just a quick note about how I did this.

One caveat - I'm using a slightly older version of Solr, without
solr.solr.home support.

Also, this is fragile in the sense that it relies on (a) the current
working directory being the Resin home directory, and (b) the path to
the webapp must be ./webapps/<webapp name>.

Anyway, for what it's worth...

1. In SolrSevlet.java's init() method, change the beginning to be:

     // See if the web.xml for this instance of the Resin servlet is specifying
     // an explicit location for our configuration data.
     String configdir = getInitParameter("solr.configdir");
     if (configdir != null) {
      log.info("Setting solr.configdir to " + configdir);
      System.setProperty("solr.configdir", configdir);
     }

Note that relative to the original source (at least my version), it's
just getInitParameter(), not getServletContext().getInitParameter(),
and the name of the parameter is solr.configdir (all lower-case), not
solr.configDir.

2. Build and deploy the Solr webapp to Resin. Mine is called
solr-notes for this example.

3. In the webapp's web.xml (<resin_root>/webapps/solr-notes/WEB-INF/web.xml):

a. Uncomment out the first three system-property lines (as noted in
the comment, to work around a bug in Resin)

b. Add an init-param to the servlet section:

   <servlet>
     <servlet-name>SolrServer</servlet-name>
     <display-name>Solr</display-name>
     <description>Solr Server</description>
     <servlet-class>org.apache.solr.servlet.SolrServlet</servlet-class>
     <load-on-startup>0</load-on-startup>
     <init-param solr.configdir="./webapps/solr-notes/conf/"/>
   </servlet>

4. Copy the contents of the Solr config directory to
<resin_root>/webapps/solr-notes/conf. As part of this, you can edit
solrconfig.xml to specify the location of the data directory as:

   <dataDir>./webapps/solr-notes/data/</dataDir>

5. Repeat steps 2 - 4 for the second webapp, with a different name.

-- Ken
--
Ken Krugler
Krugle, Inc.
+1 530-210-6378
"Find Code, Find Answers"
Reply | Threaded
Open this post in threaded view
|

Re: One quick work-around for multiple Solr webapps in Resin

Yonik Seeley
Hi Ken,

Very early on, some parameters were read from web.xml, and configured like so:

  <context-param>
    <param-name>solar.schema</param-name>
    <param-value>schema.xml</param-value>
  </context-param>

  <context-param>
    <param-name>solar.indexdir</param-name>
    <param-value>index</param-value>
  </context-param>

I'm not sure which is better, contex or init params (both are
available at init() time), but this is an alternative to the jindi
approach recently discussed.

The advantage to the jindi approach is that it doesn't require editing
of the Solr war, and hence easier upgrading - just copy it into place.
 If there is a need, we could support both... it would just be a
matter of deciding which config had precedence in the case that
multiple mechanisms are used.

-Yonik

On 4/19/06, Ken Krugler <[hidden email]> wrote:

> Hi all,
>
> Just a quick note about how I did this.
>
> One caveat - I'm using a slightly older version of Solr, without
> solr.solr.home support.
>
> Also, this is fragile in the sense that it relies on (a) the current
> working directory being the Resin home directory, and (b) the path to
> the webapp must be ./webapps/<webapp name>.
>
> Anyway, for what it's worth...
>
> 1. In SolrSevlet.java's init() method, change the beginning to be:
>
>      // See if the web.xml for this instance of the Resin servlet is specifying
>      // an explicit location for our configuration data.
>      String configdir = getInitParameter("solr.configdir");
>      if (configdir != null) {
>         log.info("Setting solr.configdir to " + configdir);
>         System.setProperty("solr.configdir", configdir);
>      }
>
> Note that relative to the original source (at least my version), it's
> just getInitParameter(), not getServletContext().getInitParameter(),
> and the name of the parameter is solr.configdir (all lower-case), not
> solr.configDir.
>
> 2. Build and deploy the Solr webapp to Resin. Mine is called
> solr-notes for this example.
>
> 3. In the webapp's web.xml (<resin_root>/webapps/solr-notes/WEB-INF/web.xml):
>
> a. Uncomment out the first three system-property lines (as noted in
> the comment, to work around a bug in Resin)
>
> b. Add an init-param to the servlet section:
>
>    <servlet>
>      <servlet-name>SolrServer</servlet-name>
>      <display-name>Solr</display-name>
>      <description>Solr Server</description>
>      <servlet-class>org.apache.solr.servlet.SolrServlet</servlet-class>
>      <load-on-startup>0</load-on-startup>
>      <init-param solr.configdir="./webapps/solr-notes/conf/"/>
>    </servlet>
>
> 4. Copy the contents of the Solr config directory to
> <resin_root>/webapps/solr-notes/conf. As part of this, you can edit
> solrconfig.xml to specify the location of the data directory as:
>
>    <dataDir>./webapps/solr-notes/data/</dataDir>
>
> 5. Repeat steps 2 - 4 for the second webapp, with a different name.
>
> -- Ken
Reply | Threaded
Open this post in threaded view
|

Re: One quick work-around for multiple Solr webapps in Resin

kkrugler
Hi Yonik,

>Very early on, some parameters were read from web.xml, and configured like so:
>
>   <context-param>
>     <param-name>solar.schema</param-name>
>     <param-value>schema.xml</param-value>
>   </context-param>
>
>   <context-param>
>     <param-name>solar.indexdir</param-name>
>     <param-value>index</param-value>
>   </context-param>

Ah, that explains it.

>I'm not sure which is better, contex or init params (both are
>available at init() time), but this is an alternative to the jindi
>approach recently discussed.

 From what little I've seen of Resin servlets, if a parameter is only
being used inside the init() method, then typically it's specified
using the <init-param> tag. Don't know if that's Resin-specific or
not.

>The advantage to the jindi approach is that it doesn't require editing
>of the Solr war, and hence easier upgrading - just copy it into place.

Yes, that would be easier - having to update the web.xml after Resin
runs once (to unpack the .war) is kind of a pain.

>  If there is a need, we could support both... it would just be a
>matter of deciding which config had precedence in the case that
>multiple mechanisms are used.

I only did it this way because I knew how to get it working, versus
the jindi approach :) So I've got no special reason to ask for
ongoing support of the init-param technique.

-- Ken


>On 4/19/06, Ken Krugler <[hidden email]> wrote:
>>  Hi all,
>>
>>  Just a quick note about how I did this.
>>
>>  One caveat - I'm using a slightly older version of Solr, without
>>  solr.solr.home support.
>>
>>  Also, this is fragile in the sense that it relies on (a) the current
>>  working directory being the Resin home directory, and (b) the path to
>>  the webapp must be ./webapps/<webapp name>.
>>
>>  Anyway, for what it's worth...
>>
>>  1. In SolrSevlet.java's init() method, change the beginning to be:
>>
>>       // See if the web.xml for this instance of the Resin servlet
>>is specifying
>>       // an explicit location for our configuration data.
>>       String configdir = getInitParameter("solr.configdir");
>>       if (configdir != null) {
>>          log.info("Setting solr.configdir to " + configdir);
>>          System.setProperty("solr.configdir", configdir);
>>       }
>>
>>  Note that relative to the original source (at least my version), it's
>>  just getInitParameter(), not getServletContext().getInitParameter(),
>>  and the name of the parameter is solr.configdir (all lower-case), not
>>  solr.configDir.
>>
>>  2. Build and deploy the Solr webapp to Resin. Mine is called
>>  solr-notes for this example.
>>
>>  3. In the webapp's web.xml
>>(<resin_root>/webapps/solr-notes/WEB-INF/web.xml):
>>
>>  a. Uncomment out the first three system-property lines (as noted in
>>  the comment, to work around a bug in Resin)
>>
>>  b. Add an init-param to the servlet section:
>>
>>     <servlet>
>>       <servlet-name>SolrServer</servlet-name>
>>       <display-name>Solr</display-name>
>>       <description>Solr Server</description>
>>       <servlet-class>org.apache.solr.servlet.SolrServlet</servlet-class>
>>       <load-on-startup>0</load-on-startup>
>>       <init-param solr.configdir="./webapps/solr-notes/conf/"/>
>>     </servlet>
>>
>>  4. Copy the contents of the Solr config directory to
>>  <resin_root>/webapps/solr-notes/conf. As part of this, you can edit
>>  solrconfig.xml to specify the location of the data directory as:
>>
>>     <dataDir>./webapps/solr-notes/data/</dataDir>
>>
>>  5. Repeat steps 2 - 4 for the second webapp, with a different name.
>>
>>  -- Ken


--
Ken Krugler
Krugle, Inc.
+1 530-210-6378
"Find Code, Find Answers"