|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.objectweb.cjdbc.controller.recoverylog.RecoveryLog
Recovery Log using a database accessed through JDBC.
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 |
static Trace logger
private long recoveringNb
protected int recoveryBatchSize
private java.lang.String driverClassName
private java.lang.String driverName
private java.lang.String url
private java.lang.String login
private java.lang.String password
private java.sql.Connection internalConnectionManagedByGetDatabaseConnection
private java.lang.String logTableCreateTable
setLogTableCreateStatement(String, String, String, String, String,
String, String, String)
private java.lang.String logTableName
private java.lang.String logTableCreateStatement
private java.lang.String logTableIdType
private java.lang.String logTableVloginType
private java.lang.String logTableSqlColumnName
private java.lang.String logTableSqlType
private java.lang.String logTableTransactionIdType
private java.lang.String logTableExtraStatement
private java.lang.String checkpointTableCreateTable
setCheckpointTableCreateStatement(String, String, String, String,
String)
private java.lang.String checkpointTableName
private java.lang.String checkpointTableCreateStatement
private java.lang.String checkpointTableNameType
private java.lang.String checkpointTableRequestIdType
private java.lang.String checkpointTableExtraStatement
private java.lang.String backendTableCreateStatement
setBackendTableCreateStatement(String, String, String, String,
String, String, String)
private java.lang.String backendTableName
private java.lang.String backendTableCreateTable
private java.lang.String backendTableDatabaseName
private java.lang.String backendTableExtraStatement
private java.lang.String backendTableCheckpointName
private java.lang.String backendTableBackendState
private java.lang.String backendTableBackendName
private java.lang.String dumpTableCreateStatement
#setDumpTableCreateStatement(String, String, String, String, String,
String, String, String, String, String)
private java.lang.String dumpTableCreateTable
private java.lang.String dumpTableName
private java.lang.String dumpTableDumpNameColumnType
private java.lang.String dumpTableDumpDateColumnType
private java.lang.String dumpTableDumpPathColumnType
private java.lang.String dumpTableDumpFormatColumnType
private java.lang.String dumpTableCheckpointNameColumnType
private java.lang.String dumpTableBackendNameColumnType
private java.lang.String dumpTableTablesColumnName
private java.lang.String dumpTableTablesColumnType
private java.lang.String dumpTableExtraStatementDefinition
private long logTableId
private int timeout
private LoggerThread loggerThread
Constructor Detail |
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)
RecoveryLog
instance.
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 recoveringMethod Detail |
protected java.sql.Connection getDatabaseConnection() throws java.sql.SQLException
java.sql.SQLException
- if an error occurs.invalidateInternalConnection()
private long incrementLogTableId()
private void intializeDatabase() throws java.sql.SQLException
java.sql.SQLException
protected void invalidateInternalConnection()
getDatabaseConnection()
public long logAbort(TransactionMarkerMetaData tm)
tm
- The transaction marker metadata
public long logBegin(TransactionMarkerMetaData tm)
tm
- The transaction marker metadata
public long logCommit(TransactionMarkerMetaData tm)
tm
- The transaction marker metadata
public void logLogEntry(LogEntry logEntry)
logEntry
- the log entry to to be written in the recovery log.public long logReleaseSavepoint(TransactionMarkerMetaData tm, java.lang.String name)
tm
- The transaction marker metadataname
- The name of the savepoint to log
public long logRequest(AbstractWriteRequest request)
request
- The write request to log
public long logRequest(StoredProcedure proc, boolean isRead)
proc
- The stored procedure call to logisRead
- True if the stored procedure call returns a ResultSet
public long logRollback(TransactionMarkerMetaData tm)
tm
- The transaction marker metadata
public long logRollback(TransactionMarkerMetaData tm, java.lang.String savepointName)
tm
- The transaxtion marker metadatasavepointName
- The name of the savepoint
public long logSetSavepoint(TransactionMarkerMetaData tm, java.lang.String name)
tm
- The transaction marker metadataname
- The name of the savepoint to log
public void resetLogTableIdAndDeleteRecoveryLog(java.lang.String checkpointName, long newCheckpointId) throws java.sql.SQLException
checkpointName
- the checkpoint name to delete from.newCheckpointId
- the new checkpoint identifier
java.sql.SQLException
- if an error occurspublic void unlogCommit(TransactionMarkerMetaData tm)
tm
- the commited transactionDistributedRequestManager.removeFailedCommitFromRecoveryLog(TransactionMarkerMetaData)
public void unlogRequest(AbstractRequest request)
request
- request that was logged but failed at all controllers and
must be removed from recovery logDistributedRequestManager.removeFailedRequestFromRecoveryLog(AbstractWriteRequest,
long)
public void unlogRequest(StoredProcedure proc)
proc
- stored procedure that was logged but failed at all controllers
and must be removed from recovery logDistributedRequestManager.removeFailedStoredProcedureFromRecoveryLog(StoredProcedure)
public void unlogRollback(TransactionMarkerMetaData tm)
tm
- the commited transactionDistributedRequestManager.removeFailedRollbackFromRecoveryLog(TransactionMarkerMetaData)
public void shutdown()
public void beginRecovery()
public void cleanRecoveryLog() throws java.sql.SQLException
java.sql.SQLException
- if an error occurs.public void endRecovery()
cleanRecoveryLog()
public BackendRecoveryInfo getBackendRecoveryInfo(java.lang.String databaseName, java.lang.String backendName)
databaseName
- the virtual database namebackendName
- the backend name
BackendRecoveryInfo instance or null
if the backend does not exist
public long getLastTransactionId() throws java.sql.SQLException
java.sql.SQLException
- if an error occured while retrieving the id.public long getRecoveringNb()
public int getRecoveryBatchSize()
public boolean isRecovering()
true
if at least one backend has started a recover
process.
boolean
public LogEntry getNextLogEntry(long previousLogEntryId) throws java.sql.SQLException
previousLogEntryId
- previous log entry identifier
java.sql.SQLException
- if an error occurs while accesing the recovery logpublic RecoveryTask recoverNextRequest(long previousRequestId) throws java.sql.SQLException
The id of the request before the first one to recover is given by getCheckpointRequestId.
previousRequestId
- id of the previously recovered request
java.sql.SQLException
- if an error occursgetCheckpointRequestId(String)
public void deleteLogEntriesBeforeCheckpoint(java.lang.String checkpointName) throws java.sql.SQLException
checkpointName
- the name of the checkpoint uptil which log entries
should be removed
java.sql.SQLException
- in case of error.public java.util.ArrayList getCheckpointNames() throws java.sql.SQLException
ArrayList
of String
checkpoint names
java.sql.SQLException
- if failspublic long getCheckpointRequestId(java.lang.String checkpointName) throws java.sql.SQLException
checkpointName
- Name of the checkpoint
java.sql.SQLException
- if an error occursrecoverNextRequest(long)
public void removeCheckpoint(java.lang.String checkpointName) throws java.sql.SQLException
checkpointName
- to remove
java.sql.SQLException
- if an error occurspublic void storeBackendRecoveryInfo(java.lang.String databaseName, BackendRecoveryInfo backendRecoveryInfo) throws java.sql.SQLException
databaseName
- the virtual database namebackendRecoveryInfo
- the backend recovery information to store
java.sql.SQLException
- if cannot proceedpublic void storeCheckpoint(java.lang.String checkpointName) throws java.sql.SQLException
checkpointName
- Name of the checkpoint
java.sql.SQLException
- if an error occurspublic void storeCheckpoint(java.lang.String checkpointName, long requestId) throws java.sql.SQLException
checkpointName
- Name of the checkpointrequestId
- request identifier
java.sql.SQLException
- if an error occurspublic DumpInfo getDumpInfo(java.lang.String dumpName) throws java.sql.SQLException
dumpName
- the name of the dump to look for
DumpInfo
object or null if not found in the table
java.sql.SQLException
- if a recovery log database access error occurspublic java.util.ArrayList getDumpList() throws java.sql.SQLException
ArrayList
of DumpInfo
objects
java.sql.SQLException
- if a recovery log database access error occurspublic void removeDump(DumpInfo dumpInfo) throws java.sql.SQLException
dumpInfo
- the DumpInfo
to remove
java.sql.SQLException
- if the dump has has not been removed from the dump
tablepublic void setDumpInfo(DumpInfo dumpInfo) throws VirtualDatabaseException
dumpInfo
- the dump info to create.
VirtualDatabaseException
- if an error occurspublic void storeDump(DumpInfo dump) throws java.sql.SQLException
dump
- the DumpInfo
to store
java.sql.SQLException
- if a recovery log database access error occurspublic boolean updateDumpPath(java.lang.String dumpName, java.lang.String newPath) throws java.sql.SQLException
dumpName
- the dump namenewPath
- the new path to set
java.sql.SQLException
- if a recovery log database access error occurspublic void checkRecoveryLogTables()
public java.lang.String getBackendTableName()
public java.lang.String getCheckpointTableName()
public java.lang.String getLogTableName()
public java.lang.String getLogTableSqlColumnName()
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)
createTable
- statement to create the tabletableName
- the backend table namecheckpointNameType
- type for the checkpointName columnbackendNameType
- type for the backendName columnbackendStateType
- type for the backendState columndatabaseNameType
- type for the databaseName columnextraStatement
- like primary keyspublic void setCheckpointTableCreateStatement(java.lang.String createTable, java.lang.String tableName, java.lang.String nameType, java.lang.String requestIdType, java.lang.String extraStatement)
createTable
- statement to create the tabletableName
- name of the checkpoint table.nameType
- type for the name columnrequestIdType
- type for the requestId columnextraStatement
- like primary keyspublic 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)
createTable
- statement to create the tabletableName
- name of the checkpoint table.dumpNameColumnType
- the dump name column typedumpDateColumnType
- the dump data column typedumpPathColumnType
- the dump path column typedumpFormatColumnType
- the dump tpe column typecheckpointNameColumnType
- the checkpoint name column typebackendNameColumnType
- the backend name column typetablesColumnName
- the database tables column nametablesColumnType
- the database tables column typeextraStatement
- like primary keyspublic 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)
createTable
- statement to create the tabletableName
- name of the log tableidType
- type of the id columnvloginType
- type of the login columnsqlName
- name of the sql statement columnsqlType
- type of the sql columntransactionIdType
- type of the transaction columnextraStatement
- extra statement like primary keys ...private java.lang.String recreateSkeleton(java.lang.String sql)
sql
- the sql query as it is recorded in the recovery log
PreparedStatement.setWithTag(int, String,
String)
private void setDriverProcessedAndSkeleton(AbstractRequest request)
request
- Request to processprivate boolean validCheckpointName(java.lang.String checkpointName) throws java.sql.SQLException
checkpointName
- name of the checkpoint.
java.sql.SQLException
private void waitForLogQueueToEmpty()
public java.lang.String getAssociatedString()
AbstractStandardMBean.getAssociatedString()
public java.lang.String[][] getData()
String[][]
RecoveryLogViewer
public java.lang.String getXml()
XmlComponent
getXml
in interface XmlComponent
org.objectweb.cjdbc.controller.recoverylog.AbstractRecoveryLog#getXmlImpl()
public void storeDumpCheckpointName(java.lang.String dumpCheckpointName, long checkpointId)
dumpCheckpointName
- name of the checkpoint to storecheckpointId
- id of the checkpointStoreDumpCheckpointEvent
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |