org.objectweb.cjdbc.controller.scheduler.raidb1
Class RAIDb1OptimisticTransactionLevelScheduler

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.scheduler.AbstractScheduler
      extended byorg.objectweb.cjdbc.controller.scheduler.raidb1.RAIDb1OptimisticTransactionLevelScheduler

public class RAIDb1OptimisticTransactionLevelScheduler
extends AbstractScheduler

This scheduler provides transaction level scheduling for RAIDb-1 controllers. Each write takes a lock on the table it affects. All following writes are blocked until the transaction of the first write completes. This scheduler automatically detects simple deadlocks and rollbacks the transaction inducing the deadlock. Note that transitive deadlocks (involving more than 2 tables are not detected).

Version:
1.0
Author:
Emmanuel Cecchet

Field Summary
private  int requestId
           
private  SchedulerDatabaseSchema schedulerDatabaseSchema
           
 
Fields inherited from class org.objectweb.cjdbc.controller.scheduler.AbstractScheduler
logger, needSQLMacroHandling, parsingGranularity, raidbLevel
 
Constructor Summary
RAIDb1OptimisticTransactionLevelScheduler()
          Creates a new Optimistic Transaction Level Scheduler
 
Method Summary
private  void acquireLockAndSetRequestId(AbstractWriteRequest request, TransactionExclusiveLock tableLock)
           
protected  void commitTransaction(int transactionId)
          Commit a transaction given its id.
 java.lang.String getInformation()
          Get information about the Request Scheduler
 java.lang.String getXmlInformation()
          Get information about the Request Scheduler in xml format
 void mergeDatabaseSchema(DatabaseSchema dbs)
          Merge the given DatabaseSchema with the current one.
 void notifyWriteCompleted(AbstractWriteRequest request)
          Notify the completion of a write statement.
 void readCompleted(SelectRequest request)
          Notify the completion of a read statement.
private  void releaseLocks(int transactionId)
          Release all locks we may own on tables.
protected  void rollbackTransaction(int transactionId)
          Rollback a transaction given its id.
 void scheduleNonSuspendedWriteRequest(AbstractWriteRequest request)
          Additionally to scheduling the request, this method replaces the SQL Date macros such as now() with the current date.
 void scheduleReadRequest(SelectRequest request)
          Additionally to scheduling the request, this method replaces the SQL Date macros such as now() with the current date.
 void setDatabaseSchema(DatabaseSchema dbs)
          Sets the DatabaseSchema of the current virtual database.
 
Methods inherited from class org.objectweb.cjdbc.controller.scheduler.AbstractScheduler
begin, beginCompleted, commit, commitCompleted, getParsingGranularity, getPendingWrites, getRAIDbLevel, handleSQLMacros, hasSQLMacros, resumeNewTransactions, resumeWrites, rollback, rollbackCompleted, scheduleReadRequest, scheduleWriteRequest, setParsingGranularity, setRAIDbLevel, suspendNewTransactionsForCheckpoint, suspendWrites, writeCompleted
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestId

private int requestId

schedulerDatabaseSchema

private SchedulerDatabaseSchema schedulerDatabaseSchema
Constructor Detail

RAIDb1OptimisticTransactionLevelScheduler

public RAIDb1OptimisticTransactionLevelScheduler()
Creates a new Optimistic Transaction Level Scheduler

Method Detail

setDatabaseSchema

public void setDatabaseSchema(DatabaseSchema dbs)
Sets the DatabaseSchema of the current virtual database. This is only needed by some schedulers that will have to define their own scheduler schema

Overrides:
setDatabaseSchema in class AbstractScheduler
Parameters:
dbs - a DatabaseSchema value
See Also:
SchedulerDatabaseSchema

mergeDatabaseSchema

public void mergeDatabaseSchema(DatabaseSchema dbs)
Merge the given DatabaseSchema with the current one.

Overrides:
mergeDatabaseSchema in class AbstractScheduler
Parameters:
dbs - a DatabaseSchema value
See Also:
SchedulerDatabaseSchema

scheduleReadRequest

public final void scheduleReadRequest(SelectRequest request)
                               throws java.sql.SQLException
Additionally to scheduling the request, this method replaces the SQL Date macros such as now() with the current date.

Specified by:
scheduleReadRequest in class AbstractScheduler
Parameters:
request - Select request to schedule (SQL macros are already handled if needed)
Throws:
java.sql.SQLException - if a timeout occurs
See Also:
AbstractScheduler.scheduleReadRequest(SelectRequest)

readCompleted

public final void readCompleted(SelectRequest request)
Description copied from class: AbstractScheduler
Notify the completion of a read statement.

Specified by:
readCompleted in class AbstractScheduler
Parameters:
request - the completed request
See Also:
AbstractScheduler.readCompleted(SelectRequest)

scheduleNonSuspendedWriteRequest

public void scheduleNonSuspendedWriteRequest(AbstractWriteRequest request)
                                      throws java.sql.SQLException,
                                             RollbackException
Additionally to scheduling the request, this method replaces the SQL Date macros such as now() with the current date.

Specified by:
scheduleNonSuspendedWriteRequest in class AbstractScheduler
Parameters:
request - Write request to schedule (SQL macros are already handled if needed)
Throws:
RollbackException - if the transaction must be rollbacked
java.sql.SQLException - if a timeout occurs
See Also:
AbstractScheduler.scheduleWriteRequest(AbstractWriteRequest)

acquireLockAndSetRequestId

private void acquireLockAndSetRequestId(AbstractWriteRequest request,
                                        TransactionExclusiveLock tableLock)
                                 throws java.sql.SQLException
Throws:
java.sql.SQLException

notifyWriteCompleted

public final void notifyWriteCompleted(AbstractWriteRequest request)
Description copied from class: AbstractScheduler
Notify the completion of a write statement. This method does not need to be synchronized, it is enforced by the caller.

Specified by:
notifyWriteCompleted in class AbstractScheduler
Parameters:
request - the completed request
See Also:
AbstractScheduler.notifyWriteCompleted(AbstractWriteRequest)

commitTransaction

protected final void commitTransaction(int transactionId)
Description copied from class: AbstractScheduler
Commit a transaction given its id.

Specified by:
commitTransaction in class AbstractScheduler
Parameters:
transactionId - the transaction id
See Also:
AbstractScheduler.commitTransaction(int)

rollbackTransaction

protected final void rollbackTransaction(int transactionId)
Description copied from class: AbstractScheduler
Rollback a transaction given its id.

Specified by:
rollbackTransaction in class AbstractScheduler
Parameters:
transactionId - the transaction id
See Also:
AbstractScheduler.rollbackTransaction(int)

releaseLocks

private final void releaseLocks(int transactionId)
Release all locks we may own on tables.

Parameters:
transactionId - id of the transaction that releases the locks

getInformation

public java.lang.String getInformation()
Description copied from class: AbstractScheduler
Get information about the Request Scheduler

Specified by:
getInformation in class AbstractScheduler
Returns:
String containing information
See Also:
AbstractScheduler.getInformation()

getXmlInformation

public java.lang.String getXmlInformation()
Description copied from class: AbstractScheduler
Get information about the Request Scheduler in xml format

Specified by:
getXmlInformation in class AbstractScheduler
Returns:
String containing information in xml
See Also:
AbstractScheduler.getXmlInformation()


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