org.objectweb.cjdbc.controller.recoverylog
Class RecoveryLog

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.recoverylog.RecoveryLog
All Implemented Interfaces:
XmlComponent

public class RecoveryLog
extends java.lang.Object
implements XmlComponent

Recovery Log using a database accessed through JDBC.

Version:
1.0
Author:
Emmanuel Cecchet , Julie Marguerite , Nicolas Modrzyk *, Jean-Bernard van Zuylen

Field Summary
private  java.lang.String backendTableBackendName
           
private  java.lang.String backendTableBackendState
           
private  java.lang.String backendTableCheckpointName
           
private  java.lang.String backendTableCreateStatement
          Backend table options
private  java.lang.String backendTableCreateTable
           
private  java.lang.String backendTableDatabaseName
           
private  java.lang.String backendTableExtraStatement
           
private  java.lang.String backendTableName
           
private  java.lang.String checkpointTableCreateStatement
           
private  java.lang.String checkpointTableCreateTable
          Checkpoint table options.
private  java.lang.String checkpointTableExtraStatement
           
private  java.lang.String checkpointTableName
           
private  java.lang.String checkpointTableNameType
           
private  java.lang.String checkpointTableRequestIdType
           
private  java.lang.String driverClassName
          Driver class name.
private  java.lang.String driverName
          Driver name.
private  java.lang.String dumpTableBackendNameColumnType
           
private  java.lang.String dumpTableCheckpointNameColumnType
           
private  java.lang.String dumpTableCreateStatement
          Dump table options
private  java.lang.String dumpTableCreateTable
           
private  java.lang.String dumpTableDumpDateColumnType
           
private  java.lang.String dumpTableDumpFormatColumnType
           
private  java.lang.String dumpTableDumpNameColumnType
           
private  java.lang.String dumpTableDumpPathColumnType
           
private  java.lang.String dumpTableExtraStatementDefinition
           
private  java.lang.String dumpTableName
           
private  java.lang.String dumpTableTablesColumnName
           
private  java.lang.String dumpTableTablesColumnType
           
private  java.sql.Connection internalConnectionManagedByGetDatabaseConnection
          Database connection
(package private) static Trace logger
           
private  LoggerThread loggerThread
           
private  java.lang.String login
          User's login.
private  java.lang.String logTableCreateStatement
           
private  java.lang.String logTableCreateTable
          Recovery log table options.
private  java.lang.String logTableExtraStatement
           
private  long logTableId
          Current maximum value of the primary key in logTableName.
private  java.lang.String logTableIdType
           
private  java.lang.String logTableName
           
private  java.lang.String logTableSqlColumnName
           
private  java.lang.String logTableSqlType
           
private  java.lang.String logTableTransactionIdType
           
private  java.lang.String logTableVloginType
           
private  java.lang.String password
          User's password.
private  long recoveringNb
          Number of backends currently recovering
protected  int recoveryBatchSize
          Size of the pendingRecoveryTasks queue used by the recover thread
private  int timeout
          Timeout for SQL requests.
private  java.lang.String url
          Driver URL.
 
Fields inherited from interface org.objectweb.cjdbc.common.xml.XmlComponent
DOCTYPE_CONTROLLER, DOCTYPE_DB, XML_VERSION
 
Constructor Summary
RecoveryLog(java.lang.String driverName, java.lang.String driverClassName, java.lang.String url, java.lang.String login, java.lang.String password, int requestTimeout, int recoveryBatchSize)
          Creates a new RecoveryLog instance.
 
Method Summary
 void beginRecovery()
          Notify the recovery log that a recovery process has started.
 void checkRecoveryLogTables()
          Checks if the recovery log and checkpoint tables exist, and create them if they do not exist.
 void cleanRecoveryLog()
          Possibly clean the recovery log after all recovery process are done.
 void deleteLogEntriesBeforeCheckpoint(java.lang.String checkpointName)
          Deletes recovery log entries that are older than specified checkpoint.
 void endRecovery()
          Notify the recovery log that a recovery process has finished.
 java.lang.String getAssociatedString()
           
 BackendRecoveryInfo getBackendRecoveryInfo(java.lang.String databaseName, java.lang.String backendName)
          Retrieve recovery information on a backend.
 java.lang.String getBackendTableName()
          Returns the backendTableName value.
 java.util.ArrayList getCheckpointNames()
          Returns an array of names of all the checkpoint available in the recovery log
 long getCheckpointRequestId(java.lang.String checkpointName)
          Get the request id corresponding to a given checkpoint.
 java.lang.String getCheckpointTableName()
          Returns the checkpointTableName value.
 java.lang.String[][] getData()
          Allow to get the content of the recovery log for viewing
protected  java.sql.Connection getDatabaseConnection()
          Gets a connection to the database.
 DumpInfo getDumpInfo(java.lang.String dumpName)
          Get the DumpInfo element corresponding to the given dump name.
 java.util.ArrayList getDumpList()
          Retrieve the list of available dumps.
 long getLastTransactionId()
          Get the id of the last transaction logged in the recovery log.
 java.lang.String getLogTableName()
          Returns the logTableName value.
 java.lang.String getLogTableSqlColumnName()
          Returns the logTableSqlColumnName value.
 LogEntry getNextLogEntry(long previousLogEntryId)
          Get the next log entry from the recovery log given the id of the previous log entry.
 long getRecoveringNb()
          Returns the recoveringNb value.
 int getRecoveryBatchSize()
          Number of queries that can be accumulated into a batch when recovering
 java.lang.String getXml()
          Get xml formatted representation of this cjdbc component
private  long incrementLogTableId()
          Increments the value of logTableId.
private  void intializeDatabase()
          Checks if the tables (log and checkpoint) already exist, and create them if needed.
protected  void invalidateInternalConnection()
          Invalidate the connection when an error occurs so that the next call to getDatabaseConnection() re-allocates a new connection.
 boolean isRecovering()
          Returns true if at least one backend has started a recover process.
 long logAbort(TransactionMarkerMetaData tm)
          Log a transaction abort.
 long logBegin(TransactionMarkerMetaData tm)
          Log the beginning of a new transaction.
 long logCommit(TransactionMarkerMetaData tm)
          Log a transaction commit.
 void logLogEntry(LogEntry logEntry)
          Log a log entry in the recovery log.
 long logReleaseSavepoint(TransactionMarkerMetaData tm, java.lang.String name)
          Log a transaction savepoint removal.
 long logRequest(AbstractWriteRequest request)
          Log a write request.
 long logRequest(StoredProcedure proc, boolean isRead)
          Log a call to a stored procedure.
 long logRollback(TransactionMarkerMetaData tm)
          Log a transaction rollback.
 long logRollback(TransactionMarkerMetaData tm, java.lang.String savepointName)
          Log a transaction rollback to a savepoint
 long logSetSavepoint(TransactionMarkerMetaData tm, java.lang.String name)
          Log a transaction savepoint.
 RecoveryTask recoverNextRequest(long previousRequestId)
          Get the next request (begin/commit/rollback or WriteRequest) from the recovery log given the id of the previously recovered request.
private  java.lang.String recreateSkeleton(java.lang.String sql)
          Recreate the skeleton of the query from the query itself with the param tag
 void removeCheckpoint(java.lang.String checkpointName)
          Remove a checkpoint from the recovery.
 void removeDump(DumpInfo dumpInfo)
          Remove a dump information from the dump table base.
 void resetLogTableIdAndDeleteRecoveryLog(java.lang.String checkpointName, long newCheckpointId)
          Reset the current log table id and delete the recovery log information older than the given checkpoint.
 void setBackendTableCreateStatement(java.lang.String createTable, java.lang.String tableName, java.lang.String checkpointNameType, java.lang.String backendNameType, java.lang.String backendStateType, java.lang.String databaseNameType, java.lang.String extraStatement)
          Sets the backend table create statement
 void setCheckpointTableCreateStatement(java.lang.String createTable, java.lang.String tableName, java.lang.String nameType, java.lang.String requestIdType, java.lang.String extraStatement)
          Sets the checkpoint table name and create statement.
private  void setDriverProcessedAndSkeleton(AbstractRequest request)
          Set the driverProcessed flag of the given request according to its SQL content and rebuild the SQL skeleton if necessary.
 void setDumpInfo(DumpInfo dumpInfo)
          Set DumpInfo, thereby making a new dump available for restore.
 void setDumpTableCreateStatement(java.lang.String createTable, java.lang.String tableName, java.lang.String dumpNameColumnType, java.lang.String dumpDateColumnType, java.lang.String dumpPathColumnType, java.lang.String dumpFormatColumnType, java.lang.String checkpointNameColumnType, java.lang.String backendNameColumnType, java.lang.String tablesColumnName, java.lang.String tablesColumnType, java.lang.String extraStatement)
          Sets the dump table name and create statement.
 void setLogTableCreateStatement(java.lang.String createTable, java.lang.String tableName, java.lang.String idType, java.lang.String vloginType, java.lang.String sqlName, java.lang.String sqlType, java.lang.String transactionIdType, java.lang.String extraStatement)
          Sets the log table name and create statement.
 void shutdown()
          Shutdown the recovery log and all its threads.
 void storeBackendRecoveryInfo(java.lang.String databaseName, BackendRecoveryInfo backendRecoveryInfo)
          Store the state of the backend in the recovery log
 void storeCheckpoint(java.lang.String checkpointName)
          Store a Checkpoint using the current log state.
 void storeCheckpoint(java.lang.String checkpointName, long requestId)
          Store a Checkpoint using the given request id.
 void storeDump(DumpInfo dump)
          Store the given dump information in the dump table
 void storeDumpCheckpointName(java.lang.String dumpCheckpointName, long checkpointId)
           
 void unlogCommit(TransactionMarkerMetaData tm)
          Remove a transaction commit from the recovery log.
 void unlogRequest(AbstractRequest request)
          Remove a request from the recovery log.
 void unlogRequest(StoredProcedure proc)
          Remove a stored procedure from the recovery log.
 void unlogRollback(TransactionMarkerMetaData tm)
          Remove a transaction rollback from the recovery log.
 boolean updateDumpPath(java.lang.String dumpName, java.lang.String newPath)
          Update the path name for a given checkpoint.
private  boolean validCheckpointName(java.lang.String checkpointName)
          Checks if a checkpoint with the name checkpointName is already stored in the database.
private  void waitForLogQueueToEmpty()
          Synchronizes with the loggerThread, waiting for log requests to be flushed to the recovery log.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static Trace logger

recoveringNb

private long recoveringNb
Number of backends currently recovering


recoveryBatchSize

protected int recoveryBatchSize
Size of the pendingRecoveryTasks queue used by the recover thread


driverClassName

private java.lang.String driverClassName
Driver class name.


driverName

private java.lang.String driverName
Driver name.


url

private java.lang.String url
Driver URL.


login

private java.lang.String login
User's login.


password

private java.lang.String password
User's password.


internalConnectionManagedByGetDatabaseConnection

private java.sql.Connection internalConnectionManagedByGetDatabaseConnection
Database connection


logTableCreateTable

private java.lang.String logTableCreateTable
Recovery log table options.

See Also:
setLogTableCreateStatement(String, String, String, String, String, String, String, String)

logTableName

private java.lang.String logTableName

logTableCreateStatement

private java.lang.String logTableCreateStatement

logTableIdType

private java.lang.String logTableIdType

logTableVloginType

private java.lang.String logTableVloginType

logTableSqlColumnName

private java.lang.String logTableSqlColumnName

logTableSqlType

private java.lang.String logTableSqlType

logTableTransactionIdType

private java.lang.String logTableTransactionIdType

logTableExtraStatement

private java.lang.String logTableExtraStatement

checkpointTableCreateTable

private java.lang.String checkpointTableCreateTable
Checkpoint table options.

See Also:
setCheckpointTableCreateStatement(String, String, String, String, String)

checkpointTableName

private java.lang.String checkpointTableName

checkpointTableCreateStatement

private java.lang.String checkpointTableCreateStatement

checkpointTableNameType

private java.lang.String checkpointTableNameType

checkpointTableRequestIdType

private java.lang.String checkpointTableRequestIdType

checkpointTableExtraStatement

private java.lang.String checkpointTableExtraStatement

backendTableCreateStatement

private java.lang.String backendTableCreateStatement
Backend table options

See Also:
setBackendTableCreateStatement(String, String, String, String, String, String, String)

backendTableName

private java.lang.String backendTableName

backendTableCreateTable

private java.lang.String backendTableCreateTable

backendTableDatabaseName

private java.lang.String backendTableDatabaseName

backendTableExtraStatement

private java.lang.String backendTableExtraStatement

backendTableCheckpointName

private java.lang.String backendTableCheckpointName

backendTableBackendState

private java.lang.String backendTableBackendState

backendTableBackendName

private java.lang.String backendTableBackendName

dumpTableCreateStatement

private java.lang.String dumpTableCreateStatement
Dump table options

See Also:
#setDumpTableCreateStatement(String, String, String, String, String, String, String, String, String, String)

dumpTableCreateTable

private java.lang.String dumpTableCreateTable

dumpTableName

private java.lang.String dumpTableName

dumpTableDumpNameColumnType

private java.lang.String dumpTableDumpNameColumnType

dumpTableDumpDateColumnType

private java.lang.String dumpTableDumpDateColumnType

dumpTableDumpPathColumnType

private java.lang.String dumpTableDumpPathColumnType

dumpTableDumpFormatColumnType

private java.lang.String dumpTableDumpFormatColumnType

dumpTableCheckpointNameColumnType

private java.lang.String dumpTableCheckpointNameColumnType

dumpTableBackendNameColumnType

private java.lang.String dumpTableBackendNameColumnType

dumpTableTablesColumnName

private java.lang.String dumpTableTablesColumnName

dumpTableTablesColumnType

private java.lang.String dumpTableTablesColumnType

dumpTableExtraStatementDefinition

private java.lang.String dumpTableExtraStatementDefinition

logTableId

private long logTableId
Current maximum value of the primary key in logTableName.


timeout

private int timeout
Timeout for SQL requests.


loggerThread

private LoggerThread loggerThread
Constructor Detail

RecoveryLog

public RecoveryLog(java.lang.String driverName,
                   java.lang.String driverClassName,
                   java.lang.String url,
                   java.lang.String login,
                   java.lang.String password,
                   int requestTimeout,
                   int recoveryBatchSize)
Creates a new RecoveryLog instance.

Parameters:
driverName - the driverClassName name.
driverClassName - the driverClassName class name.
url - the JDBC URL.
login - the login to use to connect to the database.
password - the password to connect to the database.
requestTimeout - timeout in seconds for update queries.
recoveryBatchSize - number of queries that can be accumulated into a batch when recovering
Method Detail

getDatabaseConnection

protected java.sql.Connection getDatabaseConnection()
                                             throws java.sql.SQLException
Gets a connection to the database.

Returns:
a connection to the database
Throws:
java.sql.SQLException - if an error occurs.
See Also:
invalidateInternalConnection()

incrementLogTableId

private long incrementLogTableId()
Increments the value of logTableId.


intializeDatabase

private void intializeDatabase()
                        throws java.sql.SQLException
Checks if the tables (log and checkpoint) already exist, and create them if needed.

Throws:
java.sql.SQLException

invalidateInternalConnection

protected void invalidateInternalConnection()
Invalidate the connection when an error occurs so that the next call to getDatabaseConnection() re-allocates a new connection.

See Also:
getDatabaseConnection()

logAbort

public long logAbort(TransactionMarkerMetaData tm)
Log a transaction abort. This is used only for transaction that were started but where no request was executed, which is in fact an empty transaction. The underlying implementation might safely discard the corresponding begin from the log as an optimization.

Parameters:
tm - The transaction marker metadata
Returns:
the identifier of the entry in the recovery log

logBegin

public long logBegin(TransactionMarkerMetaData tm)
Log the beginning of a new transaction.

Parameters:
tm - The transaction marker metadata
Returns:
the identifier of the entry in the recovery log

logCommit

public long logCommit(TransactionMarkerMetaData tm)
Log a transaction commit.

Parameters:
tm - The transaction marker metadata
Returns:
the identifier of the entry in the recovery log

logLogEntry

public void logLogEntry(LogEntry logEntry)
Log a log entry in the recovery log.

Parameters:
logEntry - the log entry to to be written in the recovery log.

logReleaseSavepoint

public long logReleaseSavepoint(TransactionMarkerMetaData tm,
                                java.lang.String name)
Log a transaction savepoint removal.

Parameters:
tm - The transaction marker metadata
name - The name of the savepoint to log
Returns:
the identifier of the entry in the recovery log

logRequest

public long logRequest(AbstractWriteRequest request)
Log a write request.

Parameters:
request - The write request to log
Returns:
the identifier of the entry in the recovery log

logRequest

public long logRequest(StoredProcedure proc,
                       boolean isRead)
Log a call to a stored procedure.

Parameters:
proc - The stored procedure call to log
isRead - True if the stored procedure call returns a ResultSet
Returns:
the identifier of the entry in the recovery log

logRollback

public long logRollback(TransactionMarkerMetaData tm)
Log a transaction rollback.

Parameters:
tm - The transaction marker metadata
Returns:
the identifier of the entry in the recovery log

logRollback

public long logRollback(TransactionMarkerMetaData tm,
                        java.lang.String savepointName)
Log a transaction rollback to a savepoint

Parameters:
tm - The transaxtion marker metadata
savepointName - The name of the savepoint
Returns:
the identifier of the entry in the recovery log

logSetSavepoint

public long logSetSavepoint(TransactionMarkerMetaData tm,
                            java.lang.String name)
Log a transaction savepoint.

Parameters:
tm - The transaction marker metadata
name - The name of the savepoint to log
Returns:
the identifier of the entry in the recovery log

resetLogTableIdAndDeleteRecoveryLog

public void resetLogTableIdAndDeleteRecoveryLog(java.lang.String checkpointName,
                                                long newCheckpointId)
                                         throws java.sql.SQLException
Reset the current log table id and delete the recovery log information older than the given checkpoint. This method also deletes all entries in the checkpoint table. This method is asynchronous: the delete is performed via a post to the loggger thread.

Parameters:
checkpointName - the checkpoint name to delete from.
newCheckpointId - the new checkpoint identifier
Throws:
java.sql.SQLException - if an error occurs

unlogCommit

public void unlogCommit(TransactionMarkerMetaData tm)
Remove a transaction commit from the recovery log. This commit was logged because no backend was available locally to execute it but that finally ended up in failing at all other controllers.

Parameters:
tm - the commited transaction
See Also:
DistributedRequestManager.removeFailedCommitFromRecoveryLog(TransactionMarkerMetaData)

unlogRequest

public void unlogRequest(AbstractRequest request)
Remove a request from the recovery log. This request was logged because no backend was available locally to execute it but that finally ended up in failing at all other controllers.

Parameters:
request - request that was logged but failed at all controllers and must be removed from recovery log
See Also:
DistributedRequestManager.removeFailedRequestFromRecoveryLog(AbstractWriteRequest, long)

unlogRequest

public void unlogRequest(StoredProcedure proc)
Remove a stored procedure from the recovery log. This stored procedure was logged because no backend was available locally to execute it but that finally ended up in failing at all other controllers.

Parameters:
proc - stored procedure that was logged but failed at all controllers and must be removed from recovery log
See Also:
DistributedRequestManager.removeFailedStoredProcedureFromRecoveryLog(StoredProcedure)

unlogRollback

public void unlogRollback(TransactionMarkerMetaData tm)
Remove a transaction rollback from the recovery log. This rollback was logged because no backend was available locally to execute it but that finally ended up in failing at all other controllers.

Parameters:
tm - the commited transaction
See Also:
DistributedRequestManager.removeFailedRollbackFromRecoveryLog(TransactionMarkerMetaData)

shutdown

public void shutdown()
Shutdown the recovery log and all its threads.


beginRecovery

public void beginRecovery()
Notify the recovery log that a recovery process has started.


cleanRecoveryLog

public void cleanRecoveryLog()
                      throws java.sql.SQLException
Possibly clean the recovery log after all recovery process are done. This removes all rollbacked transaction from the recovery log.

Throws:
java.sql.SQLException - if an error occurs.

endRecovery

public void endRecovery()
Notify the recovery log that a recovery process has finished. If this is the last recovery process to finish, the cleanRecoveryLog method is called

See Also:
cleanRecoveryLog()

getBackendRecoveryInfo

public BackendRecoveryInfo getBackendRecoveryInfo(java.lang.String databaseName,
                                                  java.lang.String backendName)
Retrieve recovery information on a backend. This includes, the last known state of the backend, and the last known checkpoint

Parameters:
databaseName - the virtual database name
backendName - the backend name
Returns:
BackendRecoveryInfo instance or null if the backend does not exist

getLastTransactionId

public long getLastTransactionId()
                          throws java.sql.SQLException
Get the id of the last transaction logged in the recovery log.

Returns:
the last transaction id.
Throws:
java.sql.SQLException - if an error occured while retrieving the id.

getRecoveringNb

public long getRecoveringNb()
Returns the recoveringNb value.

Returns:
Returns the recoveringNb.

getRecoveryBatchSize

public int getRecoveryBatchSize()
Number of queries that can be accumulated into a batch when recovering

Returns:
the recovery batch size

isRecovering

public boolean isRecovering()
Returns true if at least one backend has started a recover process.

Returns:
boolean

getNextLogEntry

public LogEntry getNextLogEntry(long previousLogEntryId)
                         throws java.sql.SQLException
Get the next log entry from the recovery log given the id of the previous log entry.

Parameters:
previousLogEntryId - previous log entry identifier
Returns:
the next log entry from the recovery log or null if no further entry can be found
Throws:
java.sql.SQLException - if an error occurs while accesing the recovery log

recoverNextRequest

public RecoveryTask recoverNextRequest(long previousRequestId)
                                throws java.sql.SQLException
Get the next request (begin/commit/rollback or WriteRequest) from the recovery log given the id of the previously recovered request.

The id of the request before the first one to recover is given by getCheckpointRequestId.

Parameters:
previousRequestId - id of the previously recovered request
Returns:
AbstractTask task corresponding to the next request to recover or null if no such request exists
Throws:
java.sql.SQLException - if an error occurs
See Also:
getCheckpointRequestId(String)

deleteLogEntriesBeforeCheckpoint

public void deleteLogEntriesBeforeCheckpoint(java.lang.String checkpointName)
                                      throws java.sql.SQLException
Deletes recovery log entries that are older than specified checkpoint. Entries are deleted directly into the recovery log database, as opposed to via a post to the logger thread (as resetLogTableIdAndDeleteRecoveryLog).

Parameters:
checkpointName - the name of the checkpoint uptil which log entries should be removed
Throws:
java.sql.SQLException - in case of error.

getCheckpointNames

public java.util.ArrayList getCheckpointNames()
                                       throws java.sql.SQLException
Returns an array of names of all the checkpoint available in the recovery log

Returns:
ArrayList of String checkpoint names
Throws:
java.sql.SQLException - if fails

getCheckpointRequestId

public long getCheckpointRequestId(java.lang.String checkpointName)
                            throws java.sql.SQLException
Get the request id corresponding to a given checkpoint. This is the first step in a recovery process. Following steps consist in calling recoverNextRequest.

Parameters:
checkpointName - Name of the checkpoint
Returns:
int the request identifier corresponding to this checkpoint.
Throws:
java.sql.SQLException - if an error occurs
See Also:
recoverNextRequest(long)

removeCheckpoint

public void removeCheckpoint(java.lang.String checkpointName)
                      throws java.sql.SQLException
Remove a checkpoint from the recovery. This is useful for recovery maintenant

Parameters:
checkpointName - to remove
Throws:
java.sql.SQLException - if an error occurs

storeBackendRecoveryInfo

public void storeBackendRecoveryInfo(java.lang.String databaseName,
                                     BackendRecoveryInfo backendRecoveryInfo)
                              throws java.sql.SQLException
Store the state of the backend in the recovery log

Parameters:
databaseName - the virtual database name
backendRecoveryInfo - the backend recovery information to store
Throws:
java.sql.SQLException - if cannot proceed

storeCheckpoint

public void storeCheckpoint(java.lang.String checkpointName)
                     throws java.sql.SQLException
Store a Checkpoint using the current log state.

Parameters:
checkpointName - Name of the checkpoint
Throws:
java.sql.SQLException - if an error occurs

storeCheckpoint

public void storeCheckpoint(java.lang.String checkpointName,
                            long requestId)
                     throws java.sql.SQLException
Store a Checkpoint using the given request id.

Parameters:
checkpointName - Name of the checkpoint
requestId - request identifier
Throws:
java.sql.SQLException - if an error occurs

getDumpInfo

public DumpInfo getDumpInfo(java.lang.String dumpName)
                     throws java.sql.SQLException
Get the DumpInfo element corresponding to the given dump name. Returns null if no information is found for this dump name.

Parameters:
dumpName - the name of the dump to look for
Returns:
a DumpInfo object or null if not found in the table
Throws:
java.sql.SQLException - if a recovery log database access error occurs

getDumpList

public java.util.ArrayList getDumpList()
                                throws java.sql.SQLException
Retrieve the list of available dumps.

Returns:
an ArrayList of DumpInfo objects
Throws:
java.sql.SQLException - if a recovery log database access error occurs

removeDump

public void removeDump(DumpInfo dumpInfo)
                throws java.sql.SQLException
Remove a dump information from the dump table base.

Parameters:
dumpInfo - the DumpInfo to remove
Throws:
java.sql.SQLException - if the dump has has not been removed from the dump table

setDumpInfo

public void setDumpInfo(DumpInfo dumpInfo)
                 throws VirtualDatabaseException
Set DumpInfo, thereby making a new dump available for restore.

Parameters:
dumpInfo - the dump info to create.
Throws:
VirtualDatabaseException - if an error occurs

storeDump

public void storeDump(DumpInfo dump)
               throws java.sql.SQLException
Store the given dump information in the dump table

Parameters:
dump - the DumpInfo to store
Throws:
java.sql.SQLException - if a recovery log database access error occurs

updateDumpPath

public boolean updateDumpPath(java.lang.String dumpName,
                              java.lang.String newPath)
                       throws java.sql.SQLException
Update the path name for a given checkpoint.

Parameters:
dumpName - the dump name
newPath - the new path to set
Returns:
if the dump path was successfully updated, false if it failed (usually because the dump does not exist)
Throws:
java.sql.SQLException - if a recovery log database access error occurs

checkRecoveryLogTables

public void checkRecoveryLogTables()
Checks if the recovery log and checkpoint tables exist, and create them if they do not exist. This method also starts the logger thread.


getBackendTableName

public java.lang.String getBackendTableName()
Returns the backendTableName value.

Returns:
Returns the backendTableName.

getCheckpointTableName

public java.lang.String getCheckpointTableName()
Returns the checkpointTableName value.

Returns:
Returns the checkpointTableName.

getLogTableName

public java.lang.String getLogTableName()
Returns the logTableName value.

Returns:
Returns the logTableName.

getLogTableSqlColumnName

public java.lang.String getLogTableSqlColumnName()
Returns the logTableSqlColumnName value.

Returns:
Returns the logTableSqlColumnName.

setBackendTableCreateStatement

public void setBackendTableCreateStatement(java.lang.String createTable,
                                           java.lang.String tableName,
                                           java.lang.String checkpointNameType,
                                           java.lang.String backendNameType,
                                           java.lang.String backendStateType,
                                           java.lang.String databaseNameType,
                                           java.lang.String extraStatement)
Sets the backend table create statement

Parameters:
createTable - statement to create the table
tableName - the backend table name
checkpointNameType - type for the checkpointName column
backendNameType - type for the backendName column
backendStateType - type for the backendState column
databaseNameType - type for the databaseName column
extraStatement - like primary keys

setCheckpointTableCreateStatement

public void setCheckpointTableCreateStatement(java.lang.String createTable,
                                              java.lang.String tableName,
                                              java.lang.String nameType,
                                              java.lang.String requestIdType,
                                              java.lang.String extraStatement)
Sets the checkpoint table name and create statement.

Parameters:
createTable - statement to create the table
tableName - name of the checkpoint table.
nameType - type for the name column
requestIdType - type for the requestId column
extraStatement - like primary keys

setDumpTableCreateStatement

public void setDumpTableCreateStatement(java.lang.String createTable,
                                        java.lang.String tableName,
                                        java.lang.String dumpNameColumnType,
                                        java.lang.String dumpDateColumnType,
                                        java.lang.String dumpPathColumnType,
                                        java.lang.String dumpFormatColumnType,
                                        java.lang.String checkpointNameColumnType,
                                        java.lang.String backendNameColumnType,
                                        java.lang.String tablesColumnName,
                                        java.lang.String tablesColumnType,
                                        java.lang.String extraStatement)
Sets the dump table name and create statement.

Parameters:
createTable - statement to create the table
tableName - name of the checkpoint table.
dumpNameColumnType - the dump name column type
dumpDateColumnType - the dump data column type
dumpPathColumnType - the dump path column type
dumpFormatColumnType - the dump tpe column type
checkpointNameColumnType - the checkpoint name column type
backendNameColumnType - the backend name column type
tablesColumnName - the database tables column name
tablesColumnType - the database tables column type
extraStatement - like primary keys

setLogTableCreateStatement

public void setLogTableCreateStatement(java.lang.String createTable,
                                       java.lang.String tableName,
                                       java.lang.String idType,
                                       java.lang.String vloginType,
                                       java.lang.String sqlName,
                                       java.lang.String sqlType,
                                       java.lang.String transactionIdType,
                                       java.lang.String extraStatement)
Sets the log table name and create statement.

Parameters:
createTable - statement to create the table
tableName - name of the log table
idType - type of the id column
vloginType - type of the login column
sqlName - name of the sql statement column
sqlType - type of the sql column
transactionIdType - type of the transaction column
extraStatement - extra statement like primary keys ...

recreateSkeleton

private java.lang.String recreateSkeleton(java.lang.String sql)
Recreate the skeleton of the query from the query itself with the param tag

Parameters:
sql - the sql query as it is recorded in the recovery log
Returns:
the sql skelton with '?' instead of the tags
See Also:
PreparedStatement.setWithTag(int, String, String)

setDriverProcessedAndSkeleton

private void setDriverProcessedAndSkeleton(AbstractRequest request)
Set the driverProcessed flag of the given request according to its SQL content and rebuild the SQL skeleton if necessary.

Parameters:
request - Request to process

validCheckpointName

private boolean validCheckpointName(java.lang.String checkpointName)
                             throws java.sql.SQLException
Checks if a checkpoint with the name checkpointName is already stored in the database.

Parameters:
checkpointName - name of the checkpoint.
Returns:
ResultSet empty if no checkpoint was found.
Throws:
java.sql.SQLException

waitForLogQueueToEmpty

private void waitForLogQueueToEmpty()
Synchronizes with the loggerThread, waiting for log requests to be flushed to the recovery log.


getAssociatedString

public java.lang.String getAssociatedString()
See Also:
AbstractStandardMBean.getAssociatedString()

getData

public java.lang.String[][] getData()
Allow to get the content of the recovery log for viewing

Returns:
String[][]
See Also:
RecoveryLogViewer

getXml

public java.lang.String getXml()
Description copied from interface: XmlComponent
Get xml formatted representation of this cjdbc component

Specified by:
getXml in interface XmlComponent
Returns:
xml formatted fragment
See Also:
org.objectweb.cjdbc.controller.recoverylog.AbstractRecoveryLog#getXmlImpl()

storeDumpCheckpointName

public void storeDumpCheckpointName(java.lang.String dumpCheckpointName,
                                    long checkpointId)
Parameters:
dumpCheckpointName - name of the checkpoint to store
checkpointId - id of the checkpoint
See Also:
StoreDumpCheckpointEvent


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.