Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.derby.iapi.store.raw
Interface Transaction  view Transaction download Transaction.java


public interface Transaction


Field Summary
static int KEEP_LOCKS
           
static int RELEASE_LOCKS
           
static int XA_OK
           
static int XA_RDONLY
           
 
Method Summary
 void abort()
          Abort all changes made by this transaction since the last commit, abort or the point the transaction was started, whichever is the most recent.
 long addAndLoadStreamContainer(long segmentId, java.util.Properties tableProperties, org.apache.derby.iapi.store.access.RowSource rowSource)
          Add a new stream container to the segment and load the stream container.
 long addContainer(long segmentId, long containerId, int mode, java.util.Properties tableProperties, int temporaryFlag)
          Add a new container to the segment.
 void addPostCommitWork(org.apache.derby.iapi.services.daemon.Serviceable work)
          Add to the list of post commit work that may be processed after this transaction commits.
 void addPostTerminationWork(org.apache.derby.iapi.services.daemon.Serviceable work)
          Add to the list of post termination work that may be processed after this transaction commits or aborts.
 boolean anyoneBlocked()
          Return true if any transaction is blocked, even if not by this one.
 void close()
          Close this transaction, the transaction must be idle.
 org.apache.derby.iapi.store.raw.log.LogInstant commit()
          Commit this transaction.
 org.apache.derby.iapi.store.raw.log.LogInstant commitNoSync(int commitflag)
          "Commit" this transaction without sync'ing the log.
 void createXATransactionFromLocalTransaction(int format_id, byte[] global_id, byte[] branch_id)
          Convert a local transaction to a global transaction.
 void destroy()
          If this transaction is not idle, abort it.
 void dropContainer(ContainerKey containerId)
          Drop a container.
 void dropStreamContainer(long segmentId, long containerId)
          Drop a stream container.
 java.lang.String getActiveStateTxIdString()
          get string ID of the actual transaction ID that will be used when transaction is in active state.
 long[] getCacheStats(java.lang.String cacheName)
          Get cache statistics for the specified cache
 java.lang.Object getCompatibilitySpace()
          Get the compatibility space of the transaction.
 org.apache.derby.iapi.services.context.ContextManager getContextManager()
          Return the context manager this transaction is associated with.
 LockingPolicy getDefaultLockingPolicy()
          Get the current default locking policy for all operations within this transaction.
 org.apache.derby.iapi.store.access.FileResource getFileHandler()
          Get an object to handle non-transactional files.
 GlobalTransactionId getGlobalId()
          Return my transaction identifier.
 boolean isIdle()
          Reveals whether the transaction has ever read or written data.
 boolean isPristine()
          Reveal whether the transaction is in a pristine state, which means it hasn't done any updates since the last commit.
 void logAndDo(Loggable operation)
          Log an operation and then action it in the context of this transaction.
 LockingPolicy newLockingPolicy(int mode, int isolation, boolean stricterOk)
          Obtain a locking policy for use in openContainer().
 ContainerHandle openContainer(ContainerKey containerId, int mode)
          Open a container, with the transaction's default locking policy.
 ContainerHandle openContainer(ContainerKey containerId, LockingPolicy locking, int mode)
          Open a container, with the defined locking policy, otherwise as openContainer(int containerId, boolean forUpdate).
 StreamContainerHandle openStreamContainer(long segmentId, long containerId, boolean hold)
          Open a stream container.
 int releaseSavePoint(java.lang.String name, java.lang.Object kindOfSavepoint)
          Release the save point of the given name.
 void resetCacheStats(java.lang.String cacheName)
          Reset the cache statistics for the specified cache
 int rollbackToSavePoint(java.lang.String name, java.lang.Object kindOfSavepoint)
          Rollback all changes made since the named savepoint was set.
 void setDefaultLockingPolicy(LockingPolicy policy)
          Set the default locking policy for all operations within this transaction.
 int setSavePoint(java.lang.String name, java.lang.Object kindOfSavepoint)
          Set a save point in the current transaction.
 void setup(org.apache.derby.iapi.services.property.PersistentSet set)
          Called after the transaction has been attached to an Access Manger TransactionController.
 void xa_commit(boolean onePhase)
          This method is called to commit the current XA global transaction.
 int xa_prepare()
          This method is called to ask the resource manager to prepare for a transaction commit of the transaction specified in xid.
 void xa_rollback()
          rollback the current global transaction.
 

Field Detail

RELEASE_LOCKS

public static final int RELEASE_LOCKS
See Also:
Constant Field Values

KEEP_LOCKS

public static final int KEEP_LOCKS
See Also:
Constant Field Values

XA_RDONLY

public static final int XA_RDONLY
See Also:
Constant Field Values

XA_OK

public static final int XA_OK
See Also:
Constant Field Values
Method Detail

getContextManager

public org.apache.derby.iapi.services.context.ContextManager getContextManager()
Return the context manager this transaction is associated with.


getCompatibilitySpace

public java.lang.Object getCompatibilitySpace()
Get the compatibility space of the transaction.

Returns an object that can be used with the lock manager to provide the compatibility space of a transaction. 2 transactions with the same compatibility space will not conflict in locks. The usual case is that each transaction has it's own unique compatibility space.


setup

public void setup(org.apache.derby.iapi.services.property.PersistentSet set)
           throws org.apache.derby.iapi.error.StandardException
Called after the transaction has been attached to an Access Manger TransactionController. Thus may not be called for all transactions. Purpose is to allow a transaction access to database (service) properties. Will not be called for transactions early in the boot process, ie. before the property conglomerate is set up.


getGlobalId

public GlobalTransactionId getGlobalId()
Return my transaction identifier. Transaction identifiers may be re-used for transactions that do not modify the raw store. May return null if this transaction has no globalId.


getDefaultLockingPolicy

public LockingPolicy getDefaultLockingPolicy()
Get the current default locking policy for all operations within this transaction. The transaction is initially started with a default locking policy equivalent to
                         newLockingPolicy(
              LockingPolicy.MODE_RECORD, LockingPolicy.ISOLATION_SERIALIZABLE, true);
                
This default can be changed by subsequent calls to setDefaultLockingPolicy(LockingPolicy policy).


newLockingPolicy

public LockingPolicy newLockingPolicy(int mode,
                                      int isolation,
                                      boolean stricterOk)
Obtain a locking policy for use in openContainer(). The mode and isolation must be constants from LockingPolicy. If higherOK is true then the object returned may implement a stricter form of locking than the one requested.
A null LockingPolicy reference is identical to a LockingPolicy obtained by using MODE_NONE which is guaranteed to exist.


setDefaultLockingPolicy

public void setDefaultLockingPolicy(LockingPolicy policy)
Set the default locking policy for all operations within this transaction. The transaction is intially started with a default locking policy equivalent to
                         newLockingPolicy(
              LockingPolicy.MODE_RECORD, LockingPolicy.ISOLATION_SERIALIZABLE, true);
                


commit

public org.apache.derby.iapi.store.raw.log.LogInstant commit()
                                                      throws org.apache.derby.iapi.error.StandardException
Commit this transaction. All savepoints within this transaction are released.


commitNoSync

public org.apache.derby.iapi.store.raw.log.LogInstant commitNoSync(int commitflag)
                                                            throws org.apache.derby.iapi.error.StandardException
"Commit" this transaction without sync'ing the log. Everything else is identical to commit(), use this at your own risk.
bits in the commitflag can turn on to fine tuned the "commit": KEEP_LOCKS - no locks will be released by the commit and no post commit processing will be initiated. If, for some reasons, the locks cannot be kept even if this flag is set, then the commit will sync the log, i.e., it will revert to the normal commit.


abort

public void abort()
           throws org.apache.derby.iapi.error.StandardException
Abort all changes made by this transaction since the last commit, abort or the point the transaction was started, whichever is the most recent. All savepoints within this transaction are released.


close

public void close()
           throws org.apache.derby.iapi.error.StandardException
Close this transaction, the transaction must be idle. This close will pop the transaction context off the stack that was pushed when the transaction was started.


destroy

public void destroy()
             throws org.apache.derby.iapi.error.StandardException
If this transaction is not idle, abort it. After this call close().


setSavePoint

public int setSavePoint(java.lang.String name,
                        java.lang.Object kindOfSavepoint)
                 throws org.apache.derby.iapi.error.StandardException
Set a save point in the current transaction. A save point defines a point in time in the transaction that changes can be rolled back to. Savepoints can be nested and they behave like a stack. Setting save points "one" and "two" and the rolling back "one" will rollback all the changes made since "one" (including those made since "two") and release savepoint "two".


releaseSavePoint

public int releaseSavePoint(java.lang.String name,
                            java.lang.Object kindOfSavepoint)
                     throws org.apache.derby.iapi.error.StandardException
Release the save point of the given name. Relasing a savepoint removes all knowledge from this transaction of the named savepoint and any savepoints set since the named savepoint was set.


rollbackToSavePoint

public int rollbackToSavePoint(java.lang.String name,
                               java.lang.Object kindOfSavepoint)
                        throws org.apache.derby.iapi.error.StandardException
Rollback all changes made since the named savepoint was set. The named savepoint is not released, it remains valid within this transaction, and thus can be named it future rollbackToSavePoint() calls. Any savepoints set since this named savepoint are released (and their changes rolled back).


openContainer

public ContainerHandle openContainer(ContainerKey containerId,
                                     int mode)
                              throws org.apache.derby.iapi.error.StandardException
Open a container, with the transaction's default locking policy.

Note that if NOWAIT has been specified lock will be requested with no wait time, and if lock is not granted a SQLState.LOCK_TIMEOUT exception will be thrown.

The release() method of ContainerHandle will be called when this transaction is aborted or commited, it may be called explicitly to release the ContainerHandle before the end of the transaction.


openContainer

public ContainerHandle openContainer(ContainerKey containerId,
                                     LockingPolicy locking,
                                     int mode)
                              throws org.apache.derby.iapi.error.StandardException
Open a container, with the defined locking policy, otherwise as openContainer(int containerId, boolean forUpdate).

Calls locking.lockContainer(this, returnValue, forUpdate) to lock the container. Note that if NOWAIT has been specified lock will be requested with no wait time, and if lock is not granted a SQLState.LOCK_TIMEOUT exception will be thrown.


addContainer

public long addContainer(long segmentId,
                         long containerId,
                         int mode,
                         java.util.Properties tableProperties,
                         int temporaryFlag)
                  throws org.apache.derby.iapi.error.StandardException
Add a new container to the segment. The new container initially has one page, page Container.FIRST_PAGE_NUMBER.
If pageSize is equal to ContainerHandle.DEFAULT_PAGESIZE or invalid then a default page size will be picked.
SpareSpace indicates that percent (0% - 100%) of page space that will be attempted to be reserved for updates. E.g. with a value of 20 a page that would normally hold 40 rows will be limited to 32 rows, actual calculation for the threshold where no more inserts are all accepted is up to the implementation. Whatever the value of spaceSpace an empty page will always accept at least one insert. If spare space is equal to ContainerHandle.DEFAULT_PAGESIZE or invalid then a default value will be used.

Synchronisation

The new container is exclusivly locked by this transaction until it commits.


dropContainer

public void dropContainer(ContainerKey containerId)
                   throws org.apache.derby.iapi.error.StandardException
Drop a container.

Synchronisation

This call will mark the container as dropped and then obtain an CX lock on the container. Once a container has been marked as dropped it cannot be retrieved by any openContainer() call.

Once the exclusive lock has been obtained the container is removed and all its pages deallocated. The container will be fully removed at the commit time of the transaction.


addAndLoadStreamContainer

public long addAndLoadStreamContainer(long segmentId,
                                      java.util.Properties tableProperties,
                                      org.apache.derby.iapi.store.access.RowSource rowSource)
                               throws org.apache.derby.iapi.error.StandardException
Add a new stream container to the segment and load the stream container. This stream container doesn't not have locks, and do not log. It does not have the concept of a page. It is used by the external sort only.

Synchronisation

This call will mark the container as dropped and then obtain an CX lock on the container. Once a container has been marked as dropped it cannot be retrieved by any openContainer() call.

Once the exclusive lock has been obtained the container is removed and all its pages deallocated. The container will be fully removed at the commit time of the transaction.


openStreamContainer

public StreamContainerHandle openStreamContainer(long segmentId,
                                                 long containerId,
                                                 boolean hold)
                                          throws org.apache.derby.iapi.error.StandardException
Open a stream container.


dropStreamContainer

public void dropStreamContainer(long segmentId,
                                long containerId)
                         throws org.apache.derby.iapi.error.StandardException
Drop a stream container.

Synchronisation

This call will remove the container.


logAndDo

public void logAndDo(Loggable operation)
              throws org.apache.derby.iapi.error.StandardException
Log an operation and then action it in the context of this transaction. The Loggable Operation is logged in the transaction log file and then its doMe method is called to perform the required change. If this transaction aborts or a rollback is performed of the current savepoint (if any) then a compensation Operation needs to be generated that will compensate for the change of this Operation.


addPostCommitWork

public void addPostCommitWork(org.apache.derby.iapi.services.daemon.Serviceable work)
Add to the list of post commit work that may be processed after this transaction commits. If this transaction aborts, then the post commit work list will be thrown away. No post commit work will be taken out on a rollback to save point.


addPostTerminationWork

public void addPostTerminationWork(org.apache.derby.iapi.services.daemon.Serviceable work)
Add to the list of post termination work that may be processed after this transaction commits or aborts.


isIdle

public boolean isIdle()
Reveals whether the transaction has ever read or written data.


isPristine

public boolean isPristine()
Reveal whether the transaction is in a pristine state, which means it hasn't done any updates since the last commit.


getFileHandler

public org.apache.derby.iapi.store.access.FileResource getFileHandler()
Get an object to handle non-transactional files.


getCacheStats

public long[] getCacheStats(java.lang.String cacheName)
Get cache statistics for the specified cache


resetCacheStats

public void resetCacheStats(java.lang.String cacheName)
Reset the cache statistics for the specified cache


anyoneBlocked

public boolean anyoneBlocked()
Return true if any transaction is blocked, even if not by this one.


createXATransactionFromLocalTransaction

public void createXATransactionFromLocalTransaction(int format_id,
                                                    byte[] global_id,
                                                    byte[] branch_id)
                                             throws org.apache.derby.iapi.error.StandardException
Convert a local transaction to a global transaction.

Get a transaction controller with which to manipulate data within the access manager. Tbis controller allows one to manipulate a global XA conforming transaction.

Must only be called a previous local transaction was created and exists in the context. Can only be called if the current transaction is in the idle state.

The (format_id, global_id, branch_id) triplet is meant to come exactly from a javax.transaction.xa.Xid. We don't use Xid so that the system can be delivered on a non-1.2 vm system and not require the javax classes in the path.


xa_commit

public void xa_commit(boolean onePhase)
               throws org.apache.derby.iapi.error.StandardException
This method is called to commit the current XA global transaction.

RESOLVE - how do we map to the "right" XAExceptions.


xa_prepare

public int xa_prepare()
               throws org.apache.derby.iapi.error.StandardException
This method is called to ask the resource manager to prepare for a transaction commit of the transaction specified in xid.


xa_rollback

public void xa_rollback()
                 throws org.apache.derby.iapi.error.StandardException
rollback the current global transaction.

The given transaction is roll'ed back and it's history is not maintained in the transaction table or long term log.


getActiveStateTxIdString

public java.lang.String getActiveStateTxIdString()
get string ID of the actual transaction ID that will be used when transaction is in active state.