Changeset 29903

Show
Ignore:
Timestamp:
20.05.2015 17:19:33 (4 years ago)
Author:
ak19
Message:

Changing over from embedded derby db to networked derby server. Not yet tested on windows.

Location:
main/trunk/greenstone3
Files:
2 added
6 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/build.properties.in

    r29845 r29903  
    1515# uncomment the following if you have moved the greenstone3 web directory to tomcats webapps dir  
    1616#web.home=${tomcat.installed.path}/webapps/greenstone3 
     17 
     18# Default derby networked server portnumber is 1527, can change this here in case of conflict 
     19derby.server.port=1527 
    1720 
    1821## Collection building options 
  • main/trunk/greenstone3/build.xml

    r29845 r29903  
    606606    <pathelement location="${web.writablelib}"/> 
    607607    <fileset dir="${web.writablelib}"> 
    608       <include name="derby.jar"/> 
     608      <include name="derbyclient.jar"/> <!--<include name="derby.jar"/>--> 
    609609    </fileset> 
    610610  </path> 
    611611   
     612  <path id="derby.server.classpath"> 
     613    <pathelement location="${web.lib}/derbynet.jar"/> 
     614    <pathelement location="${web.lib}/derby.jar"/> 
     615  </path> 
     616 
     617 
    612618  <path id="local.tomcat.path"> 
    613619    <pathelement location="${basedir}/bin/script"/> 
     
    780786 
    781787  <target name="get-default-servlet-url"> 
    782     <echo>http://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}</echo> 
     788    <echo>http://${tomcat.server}:${tomcat.port}${app.path}${server.default.servlet}</echo> 
    783789  </target>  
    784790   
    785   <target name="start" depends="init,configure-tomcat,configure-web,configure-solr-ext,start-tomcat" 
     791  <target name="start-derby-java"> 
     792    <echo>Launching derby on ${derby.server.port}...</echo> 
     793    <java classname="org.apache.derby.drda.NetworkServerControl" fork="true" spawn="true" clonevm="true">       
     794      <arg value="start"/> 
     795      <classpath refid="derby.server.classpath"/> 
     796    </java> 
     797  </target> 
     798   
     799  <!-- Using derby 10.1.2.1 
     800       See db-derby-10.1.2.1-bin/docs/html/adminguide/index.html --> 
     801  <target name="start-derby"> 
     802    <echo>About to launch derby on ${derby.server.port}</echo> 
     803    <property name="derby.server.classpath.prop" refid="derby.server.classpath" /> 
     804 
     805    <exec executable="java" spawn="true"><!-- failonerror="true"--> 
     806      <env key="CLASSPATH" path="${derby.server.classpath.prop}"/> 
     807      <arg value="org.apache.derby.drda.NetworkServerControl"/> 
     808      <arg value="start"/> 
     809      <arg value="-p"/> 
     810      <arg value="${derby.server.port}"/> 
     811    </exec>    
     812  </target> 
     813 
     814  <target name="stop-derby"> 
     815    <java classname="org.apache.derby.drda.NetworkServerControl"> 
     816      <arg value="shutdown"/> 
     817      <classpath refid="derby.server.classpath"/> 
     818    </java> 
     819  </target> 
     820 
     821  <target name="start" depends="init,configure-tomcat,configure-web,configure-solr-ext,start-derby,start-tomcat" 
    786822    description="Startup the Tomcat server." > 
    787823    <echo>${app.name} (${app.version}) server running using Apache Tomcat and Java</echo>  
     
    813849  </target> 
    814850 
    815   <target name="stop" depends="init,stop-tomcat"  
     851  <target name="stop" depends="init,stop-tomcat,stop-derby"  
    816852    description="Shutdown the Tomcat server."/> 
    817853   
     
    12011237    <filter token="tomcat.server" value="${tomcat.server}"/> 
    12021238    <filter token="tomcat.port" value="${tomcat.port}"/> 
     1239    <filter token="derbyserver.port" value="${derby.server.port}"/> 
    12031240    <filter token="perlpath" value="${escaped.perl.path}"/> 
    12041241    <filter token="disable.collection.building" value="${disable.collection.building}"/> 
     
    13521389    <filter token="privilegedattribute" value="${privileged.attribute}"/> 
    13531390    <filter token="allowedIPs" value="${allowed.IPs}"/> 
     1391    <filter token="derbyserverport" value="${derby.server.port}"/> 
    13541392      </filterset> 
    13551393    </copy> 
     
    17351773  <target name="update-userdb" description="Add or modify users" depends="check-tomcat-running"> 
    17361774 
    1737     <!-- stop tomcat if running, since derby db is embedded and only allows connections from one jvm instance at a time 
     1775    <!--  
     1776       We're now using derby networked server, so stopping and starting tomcat is not necessary. 
     1777       For embedded derby: stop tomcat if running, since derby db is embedded  
     1778       and only allows connections from one jvm instance at a time 
    17381779     See http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html 
    17391780     The ${tomcat.isrunning} property is set by the depends-target "check-tomcat-running" --> 
     1781    <!-- 
    17401782    <if> 
    17411783      <bool> 
     
    17441786      <antcall target="stop-tomcat"/> 
    17451787    </if> 
     1788    --> 
    17461789 
    17471790    <!--<echo>${admin.password}</echo>--> <!-- for testing --> 
     
    17581801     
    17591802    <!-- run tomcat again if it used to be running --> 
     1803    <!-- 
    17601804    <if> 
    17611805      <bool> 
     
    17641808      <antcall target="start-tomcat"/> 
    17651809    </if> 
     1810    --> 
    17661811  </target> 
    17671812 
  • main/trunk/greenstone3/resources/tomcat/greenstone3.xml.in

    r29845 r29903  
    1010    allowLinking="false" 
    1111    xmlBlockExternal="false"> 
    12    
     12 
     13<!-- 
     14   For embedded derby db: 
     15   driverName="org.apache.derby.jdbc.EmbeddedDriver" 
     16   connectionURL="jdbc:derby:@gsdl3webhome@/etc/usersDB" 
     17-->   
    1318    <Realm className="org.apache.catalina.realm.JDBCRealm"  
    14         driverName="org.apache.derby.jdbc.EmbeddedDriver" 
    15         connectionURL="jdbc:derby:@gsdl3webhome@/etc/usersDB" 
     19        driverName="org.apache.derby.jdbc.ClientDriver" 
     20        connectionURL="jdbc:derby://localhost:@derbyserverport@/@gsdl3webhome@/etc/usersDB" 
    1621        userTable="users" userNameCol="username" userCredCol="password" 
    1722        userRoleTable="roles" roleNameCol="role" 
  • main/trunk/greenstone3/resources/web/global.properties.in

    r29250 r29903  
    1919tomcat.port=@tomcat.port@ 
    2020tomcat.context=greenstone3 
     21derby.server.port=@derbyserver.port@ 
    2122 
    2223## Proxy setup - set these if you are behind a firewall and you want services that access the internet 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/sql/derby/DerbySQLServer.java

    r20009 r29903  
    88import java.sql.SQLException; 
    99 
     10import org.greenstone.util.GlobalProperties; 
     11 
    1012public class DerbySQLServer implements SQLServer{ 
    11     static final String PROTOCOL = "jdbc:derby:"; 
    12     static final String DRIVER = "org.apache.derby.jdbc.EmbeddedDriver"; 
     13    
     14    static final String PORT = GlobalProperties.getProperty("derby.server.port");//, "1527"); 
     15    static final String PROTOCOL = "jdbc:derby://localhost:"+PORT+"/"; //"jdbc:derby:"; 
     16    static final String DRIVER = "org.apache.derby.jdbc.ClientDriver"; //"org.apache.derby.jdbc.EmbeddedDriver"; 
    1317    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.sql.derby.DerbySQLServer.class.getName());      
    1418 
     
    5155    public boolean disconnect(String databasePath){ 
    5256    try{ 
    53         String protocol_str = PROTOCOL + databasePath + ";shutdown=true";  
    54         DriverManager.getConnection(protocol_str); 
     57        // Only shutdown if using embedded derby,  
     58        // not if it's a networked derby server, which is what we now use 
     59 
     60        if(DRIVER.equals("org.apache.derby.jdbc.EmbeddedDriver")) { 
     61        String protocol_str = PROTOCOL + databasePath + ";shutdown=true";        
     62        DriverManager.getConnection(protocol_str); 
     63        } 
    5564    }catch (SQLException se){ 
    5665        String theError = (se).getSQLState(); 
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/DerbyWrapper.java

    r28234 r29903  
    3535public class DerbyWrapper 
    3636{ 
    37     static final String PROTOCOL = "jdbc:derby:"; 
    38     static final String DRIVER = "org.apache.derby.jdbc.EmbeddedDriver"; 
     37    static final String PORT = GlobalProperties.getProperty("derby.server.port");//, "1527"); 
     38    static final String PROTOCOL = "jdbc:derby://localhost:"+PORT+"/"; // "jdbc:derby:"; 
     39    static final String DRIVER = "org.apache.derby.jdbc.ClientDriver"; //"org.apache.derby.jdbc.EmbeddedDriver"; 
    3940    static final String USERSDB = "usersDB"; 
    4041    static final String USERS = "users"; 
     
    134135        { 
    135136            //  shutdown the whole server 
     137            // but not if we're a derby client using the derby network server  
     138            // only if we're using an embedded derby 
     139            if(DRIVER.equals("org.apache.derby.jdbc.EmbeddedDriver")) { 
    136140            DriverManager.getConnection(PROTOCOL + ";shutdown=true"); 
     141            } 
    137142        } 
    138143        catch (SQLException se)