fr.dyade.aaa.util.MySqlDBRepository Class Reference

Inherits fr.dyade.aaa.util.Repository.

Inheritance diagram for fr.dyade.aaa.util.MySqlDBRepository:

Inheritance graph
[legend]
Collaboration diagram for fr.dyade.aaa.util.MySqlDBRepository:

Collaboration graph
[legend]
List of all members.

Public Member Functions

int getNbSavedObjects ()
int getNbDeletedObjects ()
int getNbBadDeletedObjects ()
int getNbLoadedObjects ()
void init (File dir) throws IOException
String[] list (String prefix) throws IOException
void save (String dirName, String name, byte[] content) throws IOException
Object loadobj (String dirName, String name) throws IOException, ClassNotFoundException
byte[] load (String dirName, String name) throws IOException
void delete (String dirName, String name) throws IOException
void commit () throws IOException
void close () throws IOException

Static Public Attributes

static Logger logger

Package Functions

 MySqlDBRepository ()

Package Attributes

String driver = System.getProperty("DBDriver", "org.gjt.mm.mysql.Driver")
String connurl = System.getProperty("ConnURL", "jdbc:mysql://localhost:3306/mysql")
String user = System.getProperty("DBUser", "root")
String pass = System.getProperty("DBPass", "")
BasicDataSource ds = null
boolean reconnectLoop = false
File dir = null
Connection conn = null
PreparedStatement insertStmt = null
PreparedStatement updateStmt = null
PreparedStatement deleteStmt = null

Detailed Description

This class allows to use a MySQL database as repository with the NTransaction module.

The basic setup at the code to get Database code to run is the same.

The additional thing when using MySQL database is:

  1. For the a3servers.xml that will be copy to run directory, we have to add these:
       <property name="Transaction" value="fr.dyade.aaa.util.NTransaction"/>
       <property name="NTRepositoryImpl" value="fr.dyade.aaa.util.MySqlDBRepository"/>
       <property name="DBDriver" value="org.gjt.mm.mysql.Driver"/>
       <property name="ConnURL" value="jdbc:mysql://hostname:3306/instance"/>
       <property name="DBUser" value="dbUserName"/>
       <property name="DBPass" value="dbPassword"/>
     
  2. In the start script in the bin directory:
    1. We have to add the following library
       CLASSPATH=$CLASSPATH:$VIATOR_LIB/mysql-connector-java-5.0.5-bin.jar
       CLASSPATH=$CLASSPATH:$VIATOR_LIB/commons-dbcp-1.2.1.jar
       CLASSPATH=$CLASSPATH:$VIATOR_LIB/commons-pool-1.3.jar
       
    2. change the java command to add in a few -D parameter
       JAVA_ARGS=$JAVA_ARGS"
       -DNTRepositoryImpl=fr.dyade.aaa.util.MySqlDBRepository
       -DDBDriver=org.gjt.mm.mysql.Driver
       -DConnURL=jdbc:mysql://hostname:3306/instance
       -DDBUser=dbUserName
       -DDBPass=dbPassword"
       
    3. may need to up size the max memory for better performace This is what we use: JAVA_ARGS=" -Xms100M -Xmx1024M "
  3. At the MySQL database side:
    1. we have to set the max-allowed-packet to a bigger size, I think the default is 1M, if the number of messages become large, it will fail. "max_allowed_packet=16M"
    2. create the JoramDB table first (we decided that we will create it outside here instead of in the code.
       CREATE TABLE JoramDB (name VARCHAR(256), content longblob, primary key(name));
       

    See also:
    NTransaction

    Repository

Definition at line 100 of file MySqlDBRepository.java.


Member Function Documentation

int fr.dyade.aaa.util.MySqlDBRepository.getNbSavedObjects (  ) 

Returns the number of save operation to repository.

Returns:
The number of save operation to repository.

Implements fr.dyade.aaa.util.Repository.

Definition at line 127 of file MySqlDBRepository.java.

int fr.dyade.aaa.util.MySqlDBRepository.getNbDeletedObjects (  ) 

Returns the number of delete operation on repository.

Returns:
The number of delete operation on repository.

Implements fr.dyade.aaa.util.Repository.

Definition at line 138 of file MySqlDBRepository.java.

int fr.dyade.aaa.util.MySqlDBRepository.getNbBadDeletedObjects (  ) 

Returns the number of useless delete operation on repository.

Returns:
The number of useless delete operation on repository.

Implements fr.dyade.aaa.util.Repository.

Definition at line 149 of file MySqlDBRepository.java.

int fr.dyade.aaa.util.MySqlDBRepository.getNbLoadedObjects (  ) 

Returns the number of load operation from repository.

Returns:
The number of load operation from repository.

Implements fr.dyade.aaa.util.Repository.

Definition at line 160 of file MySqlDBRepository.java.

void fr.dyade.aaa.util.MySqlDBRepository.init ( File  dir  )  throws IOException

Initializes the repository. Opens the connection, evntually creates the database and tables.

Implements fr.dyade.aaa.util.Repository.

Definition at line 176 of file MySqlDBRepository.java.

References fr.dyade.aaa.util.MySqlDBRepository.conn, fr.dyade.aaa.util.MySqlDBRepository.deleteStmt, fr.dyade.aaa.util.MySqlDBRepository.dir, fr.dyade.aaa.util.MySqlDBRepository.driver, fr.dyade.aaa.util.MySqlDBRepository.insertStmt, fr.dyade.aaa.util.MySqlDBRepository.pass, fr.dyade.aaa.util.MySqlDBRepository.updateStmt, and fr.dyade.aaa.util.MySqlDBRepository.user.

String [] fr.dyade.aaa.util.MySqlDBRepository.list ( String  prefix  )  throws IOException

Gets a list of persistent objects that name corresponds to prefix.

Returns:
The list of corresponding names.

Implements fr.dyade.aaa.util.Repository.

Definition at line 245 of file MySqlDBRepository.java.

References fr.dyade.aaa.util.MySqlDBRepository.conn, fr.dyade.aaa.util.MySqlDBRepository.logger, and fr.dyade.aaa.util.MySqlDBRepository.reconnectLoop.

void fr.dyade.aaa.util.MySqlDBRepository.save ( String  dirName,
String  name,
byte[]  content 
) throws IOException

Save the corresponding bytes array.

Implements fr.dyade.aaa.util.Repository.

Definition at line 289 of file MySqlDBRepository.java.

References fr.dyade.aaa.util.MySqlDBRepository.insertStmt, fr.dyade.aaa.util.MySqlDBRepository.logger, fr.dyade.aaa.util.MySqlDBRepository.reconnectLoop, and fr.dyade.aaa.util.MySqlDBRepository.updateStmt.

Object fr.dyade.aaa.util.MySqlDBRepository.loadobj ( String  dirName,
String  name 
) throws IOException, ClassNotFoundException

Loads the object.

Returns:
The loaded object or null if it does not exist.

Definition at line 362 of file MySqlDBRepository.java.

References fr.dyade.aaa.util.MySqlDBRepository.load(), and fr.dyade.aaa.util.MySqlDBRepository.logger.

Here is the call graph for this function:

byte [] fr.dyade.aaa.util.MySqlDBRepository.load ( String  dirName,
String  name 
) throws IOException

Loads the byte array.

Returns:
The loaded bytes array.

Implements fr.dyade.aaa.util.Repository.

Definition at line 394 of file MySqlDBRepository.java.

References fr.dyade.aaa.util.MySqlDBRepository.conn, fr.dyade.aaa.util.MySqlDBRepository.logger, and fr.dyade.aaa.util.MySqlDBRepository.reconnectLoop.

Referenced by fr.dyade.aaa.util.MySqlDBRepository.loadobj().

void fr.dyade.aaa.util.MySqlDBRepository.delete ( String  dirName,
String  name 
) throws IOException

Deletes the corresponding objects in repository.

Implements fr.dyade.aaa.util.Repository.

Definition at line 456 of file MySqlDBRepository.java.

References fr.dyade.aaa.util.MySqlDBRepository.conn, fr.dyade.aaa.util.MySqlDBRepository.logger, and fr.dyade.aaa.util.MySqlDBRepository.reconnectLoop.

void fr.dyade.aaa.util.MySqlDBRepository.commit (  )  throws IOException

Commits all changes to the repository.

Implements fr.dyade.aaa.util.Repository.

Definition at line 499 of file MySqlDBRepository.java.

References fr.dyade.aaa.util.MySqlDBRepository.conn.

void fr.dyade.aaa.util.MySqlDBRepository.close (  )  throws IOException

Closes the repository.

Implements fr.dyade.aaa.util.Repository.

Definition at line 514 of file MySqlDBRepository.java.

References fr.dyade.aaa.util.MySqlDBRepository.conn, and fr.dyade.aaa.util.MySqlDBRepository.ds.


The documentation for this class was generated from the following file:
Generated on Tue Sep 16 16:17:20 2008 for joram by  doxygen 1.5.0