org.objectweb.cjdbc.controller.scheduler.singledb
Class SingleDBPessimisticTransactionLevelScheduler

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.scheduler.AbstractScheduler
      extended byorg.objectweb.cjdbc.controller.scheduler.singledb.SingleDBPessimisticTransactionLevelScheduler
All Implemented Interfaces:
XmlComponent

public class SingleDBPessimisticTransactionLevelScheduler
extends AbstractScheduler

This scheduler provides transaction level scheduling for a SingleDB. Each write takes a lock on the whole database. All following writes are blocked until the transaction of the first write completes.

Version:
1.0
Author:
Emmanuel Cecchet

Field Summary
(package private)  TransactionExclusiveLock lock
           
private  long requestId
           
 
Fields inherited from class org.objectweb.cjdbc.controller.scheduler.AbstractScheduler
logger, parsingGranularity, raidbLevel
 
Fields inherited from interface org.objectweb.cjdbc.common.xml.XmlComponent
DOCTYPE_CONTROLLER, DOCTYPE_DB, XML_VERSION
 
Constructor Summary
SingleDBPessimisticTransactionLevelScheduler()
          Creates a new Pessimistic Transaction Level Scheduler
 
Method Summary
protected  void commitTransaction(long transactionId)
          Commit a transaction given its id.
 java.lang.String getXmlImpl()
           
 void notifyStoredProcedureCompleted(StoredProcedure proc)
          Notify the completion of a stored procedure.
 void notifyWriteCompleted(AbstractWriteRequest request)
          Notify the completion of a write statement.
 void readCompletedNotify(SelectRequest request)
          Notify the completion of a read statement.
private  void releaseLock(long transactionId)
          Release the locks we may own on the schema.
protected  void releaseSavepointTransaction(long transactionId, java.lang.String name)
          Release a savepoint given its name from a transaction given its id.
protected  void rollbackTransaction(long transactionId)
          Rollback a transaction given its id.
protected  void rollbackTransaction(long transactionId, java.lang.String savepointName)
          Rollback a transaction given its id to a savepoint given its name.
 void scheduleNonSuspendedStoredProcedure(StoredProcedure proc)
          Schedule a write request (implementation specific).
 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.
protected  void setSavepointTransaction(long transactionId, java.lang.String name)
          Set a savepoint given its name to a transaction given its id.
 
Methods inherited from class org.objectweb.cjdbc.controller.scheduler.AbstractScheduler
begin, beginCompleted, commit, commitCompleted, getNumberRead, getNumberWrite, getParsingGranularity, getPendingTransactions, getPendingWrites, getRAIDbLevel, getSchedulerData, getXml, incrementSavepointId, initializeTransactionId, isSuspendedTransactions, isSuspendedWrites, mergeDatabaseSchema, readCompleted, releaseSavepoint, resumeNewTransactions, resumeWrites, rollback, rollback, rollbackCompleted, savepointCompleted, scheduleStoredProcedure, scheduleWriteRequest, setDatabaseSchema, setParsingGranularity, setRAIDbLevel, setSavepoint, setSavepoint, storedProcedureCompleted, 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 long requestId

lock

TransactionExclusiveLock lock
Constructor Detail

SingleDBPessimisticTransactionLevelScheduler

public SingleDBPessimisticTransactionLevelScheduler()
Creates a new Pessimistic Transaction Level Scheduler

Method Detail

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)

readCompletedNotify

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

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

scheduleNonSuspendedWriteRequest

public void scheduleNonSuspendedWriteRequest(AbstractWriteRequest 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:
scheduleNonSuspendedWriteRequest in class AbstractScheduler
Parameters:
request - Write request to schedule (SQL macros are already handled if needed)
Throws:
java.sql.SQLException - if a timeout occurs
See Also:
AbstractScheduler.scheduleWriteRequest(AbstractWriteRequest)

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)

scheduleNonSuspendedStoredProcedure

public final void scheduleNonSuspendedStoredProcedure(StoredProcedure proc)
                                               throws java.sql.SQLException,
                                                      RollbackException
Description copied from class: AbstractScheduler
Schedule a write request (implementation specific). This method blocks until the request can be executed.

Specified by:
scheduleNonSuspendedStoredProcedure in class AbstractScheduler
Parameters:
proc - Stored procedure to schedule
Throws:
java.sql.SQLException - if a timeout occurs
RollbackException - if the transaction must be rollbacked
See Also:
AbstractScheduler.scheduleNonSuspendedStoredProcedure(org.objectweb.cjdbc.common.sql.StoredProcedure)

notifyStoredProcedureCompleted

public final void notifyStoredProcedureCompleted(StoredProcedure proc)
Description copied from class: AbstractScheduler
Notify the completion of a stored procedure. This method does not need to be synchronized, it is enforced by the caller.

Specified by:
notifyStoredProcedureCompleted in class AbstractScheduler
Parameters:
proc - the completed stored procedure
See Also:
AbstractScheduler.notifyStoredProcedureCompleted(org.objectweb.cjdbc.common.sql.StoredProcedure)

commitTransaction

protected final void commitTransaction(long 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(long)

rollbackTransaction

protected final void rollbackTransaction(long 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(long)

rollbackTransaction

protected final void rollbackTransaction(long transactionId,
                                         java.lang.String savepointName)
Description copied from class: AbstractScheduler
Rollback a transaction given its id to a savepoint given its name.

Specified by:
rollbackTransaction in class AbstractScheduler
Parameters:
transactionId - the transaction id
savepointName - the name of the savepoint
See Also:
AbstractScheduler.rollbackTransaction(long, String)

setSavepointTransaction

protected final void setSavepointTransaction(long transactionId,
                                             java.lang.String name)
Description copied from class: AbstractScheduler
Set a savepoint given its name to a transaction given its id.

Specified by:
setSavepointTransaction in class AbstractScheduler
Parameters:
transactionId - the transaction id
name - the name of the savepoint
See Also:
AbstractScheduler.setSavepointTransaction(long, String)

releaseSavepointTransaction

protected final void releaseSavepointTransaction(long transactionId,
                                                 java.lang.String name)
Description copied from class: AbstractScheduler
Release a savepoint given its name from a transaction given its id.

Specified by:
releaseSavepointTransaction in class AbstractScheduler
Parameters:
transactionId - the transaction id
name - the name of the savepoint
See Also:
AbstractScheduler.releaseSavepointTransaction(long, String)

releaseLock

private void releaseLock(long transactionId)
Release the locks we may own on the schema.

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

getXmlImpl

public java.lang.String getXmlImpl()
Specified by:
getXmlImpl in class AbstractScheduler
See Also:
AbstractScheduler.getXmlImpl()


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