org.objectweb.cjdbc.controller.recoverylog
Class AbstractRecoveryLog

java.lang.Object
  extended byjavax.management.StandardMBean
      extended byorg.objectweb.cjdbc.controller.jmx.AbstractStandardMBean
          extended byorg.objectweb.cjdbc.controller.recoverylog.AbstractRecoveryLog
All Implemented Interfaces:
AbstractRecoveryLogMBean, javax.management.DynamicMBean, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, XmlComponent
Direct Known Subclasses:
JDBCRecoveryLog

public abstract class AbstractRecoveryLog
extends AbstractStandardMBean
implements XmlComponent, AbstractRecoveryLogMBean

Log Recovery is responsible for logging performed queries, managing checkpoints and retrieving write requests executed from a given checkpoint.

Version:
1.0
Author:
Emmanuel Cecchet , Julie Marguerite

Nested Class Summary
 
Nested classes inherited from class javax.management.StandardMBean
 
Field Summary
(package private) static Trace logger
           
private  long recoveringNb
           
 
Fields inherited from class org.objectweb.cjdbc.controller.jmx.AbstractStandardMBean
 
Fields inherited from class javax.management.StandardMBean
 
Fields inherited from interface org.objectweb.cjdbc.common.xml.XmlComponent
DOCTYPE_DB, XML_VERSION
 
Constructor Summary
protected AbstractRecoveryLog(java.lang.Class mBeanInterface)
          Generic constructor.
 
Method Summary
abstract  void abort(TransactionMarkerMetaData tm)
          Log a transaction abort.
abstract  void begin(TransactionMarkerMetaData tm)
          Log the beginning of a new transaction.
 void beginRecovery()
          Notify the recovery log that a recovery process has started.
abstract  void cleanRecoveryLog()
          Possibly clean the recovery log after all recovery process are done.
abstract  void commit(TransactionMarkerMetaData tm)
          Log a transaction commit.
 void endRecovery()
          Notify the recovery log that a recovery process has finished.
abstract  BackendRecoveryInfo getBackendInfo(java.lang.String databaseName, java.lang.String backendName)
          Retrieve recovery information on a backend.
abstract  java.util.ArrayList getCheckpointNames()
          Returns an array of names of all the checkpoint available in the recovery log
abstract  long getCheckpointRequestId(java.lang.String checkpointName)
          Get the request id corresponding to a given checkpoint.
abstract  java.lang.String[][] getData()
          Allow to get the content of the recovery log for viewing
abstract  long getLastTransactionId()
          Get the id of the last transaction logged in the recovery log.
 long getRecoveringNb()
          Returns the recoveringNb value.
 java.lang.String getXml()
          Get xml information of the current recovery load in the system.
abstract  java.lang.String getXmlImpl()
           
 boolean isRecovering()
          Returns true if at least one backend has started a recover process.
abstract  void logRequest(AbstractWriteRequest request)
          Log a write request.
abstract  void logRequest(StoredProcedure proc, boolean isRead)
          Log a call to a stored procedure.
abstract  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.
abstract  void removeCheckpoint(java.lang.String checkpointName)
          Remove a checkpoint from the recovery.
abstract  void rollback(TransactionMarkerMetaData tm)
          Log a transaction rollback.
abstract  void storeBackendInfo(java.lang.String databaseName, java.lang.String backendName, java.lang.String checkpoint, int backendState)
          Store the state of the backend in the recovery log
abstract  void storeCheckpoint(java.lang.String checkpointName)
          Store a Checkpoint using the current log state.
abstract  void storeCheckpoint(java.lang.String checkpointName, long requestId)
          Store a Checkpoint using the given request id.
 
Methods inherited from class org.objectweb.cjdbc.controller.jmx.AbstractStandardMBean
addNotificationListener, getAssociatedString, getDescription, getDescription, getDescription, getDescription, getDescription, getDescription, getNotificationInfo, getParameterName, getParameterName, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class javax.management.StandardMBean
cacheMBeanInfo, getAttribute, getAttributes, getCachedMBeanInfo, getClassName, getConstructors, getDescription, getImpact, getImplementation, getImplementationClass, getMBeanInfo, getMBeanInterface, invoke, setAttribute, setAttributes, setImplementation
 
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
Constructor Detail

AbstractRecoveryLog

protected AbstractRecoveryLog(java.lang.Class mBeanInterface)
                       throws javax.management.NotCompliantMBeanException
Generic constructor.

Parameters:
mBeanInterface - the MBean interface
Throws:
javax.management.NotCompliantMBeanException - if the MBean is not JMX compliant
Method Detail

getRecoveringNb

public long getRecoveringNb()
Returns the recoveringNb value.

Specified by:
getRecoveringNb in interface AbstractRecoveryLogMBean
Returns:
Returns the recoveringNb.

logRequest

public abstract void logRequest(AbstractWriteRequest request)
                         throws java.sql.SQLException
Log a write request.

Parameters:
request - The write request to log
Throws:
java.sql.SQLException - if an error occurs

logRequest

public abstract void logRequest(StoredProcedure proc,
                                boolean isRead)
                         throws java.sql.SQLException
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
Throws:
java.sql.SQLException - if an error occurs

getLastTransactionId

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

Specified by:
getLastTransactionId in interface AbstractRecoveryLogMBean
Returns:
the last transaction id.
Throws:
java.sql.SQLException - if an error occured while retrieving the id.

begin

public abstract void begin(TransactionMarkerMetaData tm)
                    throws java.sql.SQLException
Log the beginning of a new transaction.

Parameters:
tm - The transaction marker metadata
Throws:
java.sql.SQLException - if an error occurs

abort

public abstract void abort(TransactionMarkerMetaData tm)
                    throws java.sql.SQLException
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
Throws:
java.sql.SQLException - if an error occurs

commit

public abstract void commit(TransactionMarkerMetaData tm)
                     throws java.sql.SQLException
Log a transaction commit.

Parameters:
tm - The transaction marker metadata
Throws:
java.sql.SQLException - if an error occurs

rollback

public abstract void rollback(TransactionMarkerMetaData tm)
                       throws java.sql.SQLException
Log a transaction rollback.

Parameters:
tm - The transaction marker metadata
Throws:
java.sql.SQLException - if an error occurs

storeCheckpoint

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

Specified by:
storeCheckpoint in interface AbstractRecoveryLogMBean
Parameters:
checkpointName - Name of the checkpoint
Throws:
java.sql.SQLException - if an error occurs

storeCheckpoint

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

Specified by:
storeCheckpoint in interface AbstractRecoveryLogMBean
Parameters:
checkpointName - Name of the checkpoint
requestId - request identifier
Throws:
java.sql.SQLException - if an error occurs

removeCheckpoint

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

Specified by:
removeCheckpoint in interface AbstractRecoveryLogMBean
Parameters:
checkpointName - to remove
Throws:
java.sql.SQLException - if an error occurs

getCheckpointRequestId

public abstract 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.

Specified by:
getCheckpointRequestId in interface AbstractRecoveryLogMBean
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)

recoverNextRequest

public abstract 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
Throws:
java.sql.SQLException - if an error occurs
See Also:
getCheckpointRequestId(String)

beginRecovery

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


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()

isRecovering

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

Specified by:
isRecovering in interface AbstractRecoveryLogMBean
Returns:
boolean

cleanRecoveryLog

public abstract void cleanRecoveryLog()
                               throws java.sql.SQLException
Possibly clean the recovery log after all recovery process are done.

Specified by:
cleanRecoveryLog in interface AbstractRecoveryLogMBean
Throws:
java.sql.SQLException - if an error occurs

getXml

public java.lang.String getXml()
Get xml information of the current recovery load in the system.

Specified by:
getXml in interface XmlComponent
Returns:
xml formatted string

getXmlImpl

public abstract java.lang.String getXmlImpl()
See Also:
XmlComponent.getXml()

getCheckpointNames

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

Specified by:
getCheckpointNames in interface AbstractRecoveryLogMBean
Returns:
ArrayList of String checkpoint names
Throws:
java.sql.SQLException - if fails

storeBackendInfo

public abstract void storeBackendInfo(java.lang.String databaseName,
                                      java.lang.String backendName,
                                      java.lang.String checkpoint,
                                      int backendState)
                               throws java.sql.SQLException
Store the state of the backend in the recovery log

Specified by:
storeBackendInfo in interface AbstractRecoveryLogMBean
Parameters:
databaseName - name of the virtual database
backendName - name of the backend
checkpoint - lastknown check point for this backend
backendState - the state of the backend
Throws:
java.sql.SQLException - if cannot proceed

getBackendInfo

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

Specified by:
getBackendInfo in interface AbstractRecoveryLogMBean
Parameters:
databaseName - the virtual database name
backendName - the backend name
Returns:
BackendRecoveryInfo instance or null if the backend does not exist
Throws:
java.sql.SQLException - if cannot proceed

getData

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

Returns:
String[][]
See Also:
RecoveryLogViewer


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