Ignore:
Timestamp:
2015-02-03T21:57:53+13:00 (9 years ago)
Author:
ak19
Message:

Moving from using the solr jetty server to solr using the GS3 tomcat server. Now localhost:8383/solr hosts the solr server RESTful pages. Changes: 1. Minor changes to GS3 build.xml. 2. GLI no longer does the temporary stopping of the GS3 server, launching jetty server for building a solr collection, stopping jetty, restarting GS3 tomcat server. GLI leaves the GS3 server running. 3. The main changes are to ext/solr. The ext/solr/gs3-setup.sh sets the new SOLR_PORT and SOLR_HOST variables read from the GS3 build.properties, as the jetty port and host variables are no longer used. ext/solr/build.xml now puts the solr war file into tomcat's webapps, as well as helper libraries necessary (xalan related); a solr.xml context file is created from a template file and placed into tomcat's conf/Catalina/localhost; additional solr jar files are copied into tomcat/lib, as well as the slf4j bridge being copied into GS3/web/WEB-INF/lib; the solr perl code has been changed to use the new RESTful URLs and particularly to work with solr running off the GS3 tomcat server, or stop and start it as required, rather than working with (or stopping and starting) the solr jetty server. A new run_solr_server.pl executable script runs the tomcat server rather than the jetty server; major changes to the Java Solr code to no longer work with the EmbeddedSolrServer (which caused a conflict when the index is accessed by solr jetty server upon rebuild of solr collections), our solr Java code now uses HttpSolrServer to contact the solr servlet running off tomcat. 5. Still a bug: when search results go over a page after rebuilding a solr collection in GLI against a running GS3 server, the 2nd page of search results aren't present and things break. But if the server is not running, solr collections rebuild fine, so the changes do everything that GS3.06 did and more.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/solr/trunk/src/build.xml

    r29707 r29711  
    99
    1010  <!-- greenstone3 paths -->
    11   <property name="web.home" value="${basedir}/../../web"/>
     11  <!-- http://stackoverflow.com/questions/3136849/how-do-i-convert-a-relative-path-in-ant-to-an-absolute-path
     12    http://stackoverflow.com/questions/8295860/pathconvert-with-relative-file-names -->
     13  <property name="web.home" location="${basedir}/../../web"/> <!-- location property creates an absolute path -->
    1214  <property name="localsite.collectdir" value="${web.home}/sites/localsite/collect"/>
    1315  <property name="web.classesdir" value="${web.home}/WEB-INF/classes"/>
    1416  <property name="web.libdir" value="${web.home}/WEB-INF/lib"/> 
    1517  <property name="web.extdir" value="${web.home}/ext/solr"/>
     18
     19  <property name="tomcat.dir" location="${basedir}/../../packages/tomcat"/> <!-- location property creates an absolute path -->
     20  <property name="tomcat.lib.dir" value="${tomcat.dir}/lib"/>
     21  <property name="tomcat.context.dir" value="${tomcat.dir}/conf/Catalina/localhost"/>
    1622
    1723  <path id="compile.classpath">
     
    2531      <include name="*.jar"/>
    2632    </fileset>
     33    <pathelement location="lib/servlet-api-3.0.jar"/>
    2734  </path>
     35
    2836
    2937  <!-- FILE LISTINGS.-->
     
    149157    <echo>Unzipping pre-built index</echo>
    150158    <unzip dest="${localsite.collectdir}/solr-jdbm-demo" src="${localsite.collectdir}/solr-jdbm-demo/index.zip" />
    151 
    152 
    153   </target>
    154  
     159  </target>
     160
     161  <!-- Setting up solr to work with tomcat server instead of jetty server -->
     162  <target name="solr-for-tomcat" description="Helper-target: setting up solr to work tomcat">
     163   
     164    <echo>Copying solr jars needed for running solr with tomcat: ${basedir}/lib/ext</echo> 
     165    <copy todir="${tomcat.lib.dir}">     
     166      <fileset dir="lib/ext">
     167    <include name="*.jar"/>
     168      </fileset>
     169    </copy>
     170   
     171    <!-- slf4j and commons logging bridge needed to avoid exception about incompatibility in tomcat log files-->
     172    <echo>Copying ${basedir}/lib/ext/jcl-over-slf4j-1.6.6.jar again to ${web.libdir}</echo>
     173    <copy todir="${web.libdir}">
     174      <filelist id="logging-bridge" dir="lib/ext" files="jcl-over-slf4j-1.6.6.jar"/>
     175    </copy>
     176
     177    <echo>Moving xalan related jar files from  ${web.libdir} to ${tomcat.lib.dir}, to share with solr</echo>
     178    <move todir="${tomcat.lib.dir}">
     179      <filelist dir="${web.libdir}">
     180    <file name="xalan.jar"/>
     181    <file name="xercesImpl.jar"/>
     182    <file name="xml-apis.jar"/>
     183    <file name="xsltc.jar"/>
     184    <file name="serializer.jar"/>
     185      </filelist>
     186    </move>
     187   
     188    <echo>Copying ${basedir}/webapps/solr.war to ${tomcat.dir}/webapps</echo>
     189    <copy todir="${tomcat.dir}/webapps" file="webapps/solr.war" />
     190    <echo>Generating solr context file in ${tomcat.context.dir}</echo>
     191   
     192    <!-- we want unix paths (forward slashes) in the tomcat context file -->
     193    <pathconvert targetos="unix" property="gsdl3.web.home">
     194      <path path="${web.home}"/><!-- creates an absolute path-->
     195    </pathconvert>
     196    <pathconvert targetos="unix" property="tomcat.home">
     197      <path path="${tomcat.dir}"/><!-- creates an absolute path-->
     198    </pathconvert>
     199    <filter token="gsdl3home" value="${gsdl3.web.home}"/>
     200    <filter token="tomcathome" value="${tomcat.home}"/>
     201    <copy file="solr-tomcat-context.xml.in" tofile="${tomcat.context.dir}/solr.xml" filtering="true" overwrite="true"/>
     202
     203  </target> 
    155204
    156205  <!-- copy the content of the web folder (avoiding the top-level .svn directory) -->
     
    165214  </target>
    166215
    167   <target name="add-service" depends="copy-solr-web,copy-files,compile" description="Run this target to setup the Solr extension for Greenstone3" />
    168 
    169  
    170   <target name="del-service"
    171     description="Run this target to unset the Solr extension for Greenstone3"> 
    172    
     216
     217  <target name="add-service" depends="copy-solr-web,copy-files,solr-for-tomcat,compile" description="Run this target to setup the Solr extension for Greenstone3" />
     218 
     219  <target name="del-service" depends="del-files,del-solr-for-tomcat"
     220    description="Run this target to unset the Solr extension for Greenstone3" />
     221
     222
     223  <target name="del-files" description="Helper-target to delete files for del-service target">
    173224    <!-- failonerror is set to false in case some files don't exist
    174225    and can't be deleted therefore -->
    175    
    176 
    177 
    178     <echo/>
    179     <echo>Removing from  gsdl3 properties area: properties/${property-files}</echo>
     226
     227    <echo/>
     228    <echo>Removing from gsdl3 properties area: properties/${property-files}</echo>
    180229    <delete failonerror="false">
    181230          <filelist dir="${web.classesdir}" files="${property-files}"/>
     
    194243    <echo/>
    195244    <echo>Removing solr-jdbm-demo collection from: ${localsite.collectdir}</echo>
    196     <delete failonerror="false" includeEmptyDirs="true" dir="${localsite.collectcdir}/solr-jdbm-demo"/>
    197    
     245    <delete failonerror="false" includeEmptyDirs="true" dir="${localsite.collectcdir}/solr-jdbm-demo"/>
     246
     247  </target>
     248 
     249  <target name="del-solr-for-tomcat" description="Helper-target to remove files for getting solr to work with tomcat">
     250
     251    <echo/>
     252    <echo>Removing solr modifications to tomcat: context file, solr.war and deployed version, jar files</echo>
     253
     254    <!-- Actually need to ensure tomcat is not running at this point
     255         But if solr.war is deleted first, it can't be re-deployed when deleting the solr folder subsequently
     256      -->
     257    <delete failonerror="false" file="${tomcat.dir}/webapps/solr.war"/>
     258    <delete failonerror="false" includeEmptyDirs="true" dir="${tomcat.dir}/webapps/solr"/>
     259
     260    <delete failonerror="false" file="${tomcat.context.dir}/solr.xml"/>
     261
     262    <!-- delete all the jar files in tomcat/lib that were copied from ext/solr/lib/ext
     263         which are all the jar files that are present in both tomcat/lib and ext/solr/lib/ext
     264         https://ant.apache.org/manual/Types/selectors.html#presentselect -->
     265    <delete failonerror="false">     
     266      <fileset dir="${tomcat.lib.dir}" includes="**/*.jar">     
     267        <present present="both" targetdir="lib/ext"/>
     268      </fileset>
     269    </delete>
     270
     271    <!-- remove logging bridge jar file that was added into greenstone 3 web lib area -->
     272    <delete failonerror="false" file="${web.libdir}/jcl-over-slf4j-1.6.6.jar"/>
     273
     274    <!-- moving shared xalan related jar files back from tomcat lib to GS3 web lib -->
     275    <move todir="${web.libdir}">
     276      <filelist dir="${tomcat.lib.dir}">
     277        <file name="xalan.jar"/>
     278        <file name="xercesImpl.jar"/>
     279        <file name="xml-apis.jar"/>
     280        <file name="xsltc.jar"/>
     281        <file name="serializer.jar"/>
     282      </filelist>
     283    </move>
     284
     285    <!--http://stackoverflow.com/questions/2140637/how-do-i-build-a-list-of-file-names-->
    198286  </target>
    199287 
Note: See TracChangeset for help on using the changeset viewer.