Middle-R Installation 
======================

Index:
  1) Requirements
  2) Installation Procedure
  3) Execution Procedure
  4) JDBC-R


1) Requirements


   * An ISO/ANSI C compiler. Recent versions of GCC are
     recommendable (3.2.2).

   * The ENSEMBLE Group Communication System is needed . To
     download ENSEMBLE go to "http://dsl.cs.technion.ac.il/projects/Ensemble".
     It is recommended to use version 1.10 (with OCAML 3.02).

   * A Database Management System (BDMS). The DBMS is PostgreSQL-R. 
     PostgresSQL-R is a version of PostgreSQL with new functionalities (management of writeSets).
     This software is included in this distribution. Unpack the "pgsql-r-v?.tgz" file 
     and follow the instructions in the INSTALL file.


2) Installation 

The source code of Middle-R is in the "middle-r-src.tgz" file. 

   2.1) Unpack the source code distribution:
	
	tar xvzf middle-r-src.tgz  

   2.2) Compile the source code:
	
	make

   2.3) Create internal tables and data for Middle-R .
        Use the context-middler.sql file included in the package and type:
	   createdb middleR

           psql middleR < context-middler.sql
           

3) Execution 

Command line options:

   * Number of replicas (mandatory): sets the number of initial replicas in the system.
   
   * Multicast Address and port (optional): it is the multicast address and port used for replica discovery.
     The default multicast address is "234.5.6.7" and port "3456".

 
In each replica, it is necessary to initialize PostgresSQL and execute the following command:

   transmng number_of_replicas -m [multicast_address] -p [port] 


4) JDBC-R

The JDBC API provides programmatic access to relational data from the Java programming language. 
Using the JDBC API, applications written in the Java can execute SQL statements, 
retrieve results, and propagate changes back to an underlying data source. 
The JDBC API can also be used to interact with multiple data sources in a distributed, heterogenous environment. 

JDBC-R is a JDBC driver (implements the JDBC API) to access to replicated databases. 
It allows to interact in a transparent way with a middleware which takes care of the coordination 
of the different replicas. Besides providing the funcionaly of a standard JDBC driver, it offers:

  * tolerates failures with the replica which has stablished the connection.
  * A mechanism for replica discovery .

Unpacking the "postgresql-7.3.2.tgz" file, you will find:

   a) The source code of JDBC-R (path: postgresql-7.3.2/src/interfaces/DriverPostgres). See README
      file to compile and create jars files included in the directory. 
 
   b) The JDBC-R jars files (path: postgresql-7.3.2/src/interfaces/DriverPostgres/jars). 

The JDBC-R driver recognises JDBC URL'S of the form:

   jdbc:postgresql://multicast_address:port/database

To use JDBC-R, add postgresql.jar, Zql.jar and stat-tools.jar to the environment variable CLASSPATH. 

NOTE: You can find the jars Zql.jar and stat-tools.jar files in "postgresql-7.3.2/src/interfaces/DriverPostgres/lib" or download "jdbc-r-src.tgz" file at http://adapt.ls.fi.upm.es/Downloads.htm.Zql.jar can be downloaded from its original web "http://www.experlog.com/gibello/zql".
