public interface Transaction
Modifier and Type | Field and Description |
---|---|
static int |
KEEP_LOCKS |
static int |
RELEASE_LOCKS |
static int |
XA_OK |
static int |
XA_RDONLY |
Modifier and Type | Method and Description |
---|---|
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,
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 |
addPostAbortWork(Serviceable work)
Add to the list of post abort work that may be processed after this
transaction aborts.
|
void |
addPostCommitWork(Serviceable work)
Add to the list of post commit work that may be processed after this
transaction commits.
|
void |
addPostTerminationWork(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.
|
LogInstant |
commit()
Commit this transaction.
|
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.
|
CompatibilitySpace |
getCompatibilitySpace()
Get the compatibility space of the transaction.
|
ContextManager |
getContextManager()
Return the context manager this transaction is associated with.
|
DataValueFactory |
getDataValueFactory()
Get DataValueFactory.
|
LockingPolicy |
getDefaultLockingPolicy()
Get the current default locking policy for all operations within this
transaction.
|
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.
|
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.
|
void |
setNoLockWait(boolean noWait)
Tell this transaction whether it should time out immediately if a lock
cannot be granted without waiting.
|
int |
setSavePoint(java.lang.String name,
java.lang.Object kindOfSavepoint)
Set a save point in the current transaction.
|
void |
setup(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.
|
static final int RELEASE_LOCKS
static final int KEEP_LOCKS
static final int XA_RDONLY
static final int XA_OK
ContextManager getContextManager()
CompatibilitySpace getCompatibilitySpace()
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.
void setNoLockWait(boolean noWait)
noWait
- if true
never wait for a lock in this transaction,
but time out immediatelyLockOwner.noWait()
void setup(PersistentSet set) throws StandardException
StandardException
- Standard Derby exception policyGlobalTransactionId getGlobalId()
LockingPolicy getDefaultLockingPolicy()
newLockingPolicy( LockingPolicy.MODE_RECORD, LockingPolicy.ISOLATION_SERIALIZABLE, true);This default can be changed by subsequent calls to setDefaultLockingPolicy(LockingPolicy policy).
LockingPolicy newLockingPolicy(int mode, int isolation, boolean stricterOk)
mode
- A constant of the form LockingPolicy.MODE_*isolation
- A constant of the form LockingPolicy.ISOLATION_*stricterOk
- True if a stricter level of locking is acceptable,
false if an exact match is required.void setDefaultLockingPolicy(LockingPolicy policy)
newLockingPolicy( LockingPolicy.MODE_RECORD, LockingPolicy.ISOLATION_SERIALIZABLE, true);
policy
- The lock policy to use, if null then then a no locking
policy will be installed as the default.LogInstant commit() throws StandardException
StandardException
- A transaction level exception is thrown
if the transaction was aborted due to some error. Any exceptions that
occur of lower severity than Transaction severity are caught, the
transaction is then aborted and then an exception of Transaction
severity is thrown nesting the original exception.
Any exception more severe than a
Transaction exception is not caught and the transaction is not aborted.
The transaction will be aborted by the standard context mechanism.LogInstant commitNoSync(int commitflag) throws StandardException
StandardException
- A transaction level exception is thrown
if the transaction was aborted due to some error. Any exceptions that
occur of lower severity than Transaction severity are caught, the
transaction is then aborted and then an exception of Transaction
severity is thrown nesting the original exception.
Any exception more severe than a
Transaction exception is not caught and the transaction is not aborted.
The transaction will be aborted by the standard context mechanism.void abort() throws StandardException
StandardException
- Only exceptions with severities greater
than ExceptionSeverity.TRANSACTION_SEVERITY will be thrown.void close() throws StandardException
StandardException
- A transaction level exception is
thrown if the transaction is not idle.RawStoreFactory.startTransaction(org.apache.derby.iapi.services.context.ContextManager, java.lang.String)
void destroy() throws StandardException
StandardException
- A transaction level exception is
thrown if the transaction is not idle.RawStoreFactory.startTransaction(org.apache.derby.iapi.services.context.ContextManager, java.lang.String)
int setSavePoint(java.lang.String name, java.lang.Object kindOfSavepoint) throws StandardException
name
- The user provided name of the savepointkindOfSavepoint
- A NULL value means it is an internal savepoint (ie not a user defined savepoint)
Non NULL value means it is a user defined savepoint which can be a SQL savepoint or a JDBC savepoint
A String value for kindOfSavepoint would mean it is SQL savepoint
A JDBC Savepoint object value for kindOfSavepoint would mean it is JDBC savepointStandardException
- A statement level exception is thrown if a savepoint already
exists in the current transaction with the same name.int releaseSavePoint(java.lang.String name, java.lang.Object kindOfSavepoint) throws StandardException
name
- The user provided name of the savepoint, set by the user
in the setSavePoint() call.kindOfSavepoint
- A NULL value means it is an internal savepoint (ie not a user defined savepoint)
Non NULL value means it is a user defined savepoint which can be a SQL savepoint or a JDBC savepoint
A String value for kindOfSavepoint would mean it is SQL savepoint
A JDBC Savepoint object value for kindOfSavepoint would mean it is JDBC savepointStandardException
- A statement level exception is thrown if a savepoint already
exists in the current transaction with the same name.int rollbackToSavePoint(java.lang.String name, java.lang.Object kindOfSavepoint) throws StandardException
name
- The user provided name of the savepoint, set by the user
in the setSavePoint() call.kindOfSavepoint
- A NULL value means it is an internal savepoint (ie not a user defined savepoint)
Non NULL value means it is a user defined savepoint which can be a SQL savepoint or a JDBC savepoint
A String value for kindOfSavepoint would mean it is SQL savepoint
A JDBC Savepoint object value for kindOfSavepoint would mean it is JDBC savepointStandardException
- A statement level exception is thrown if no savepoint exists with
the given name.ContainerHandle openContainer(ContainerKey containerId, int mode) throws StandardException
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.
StandardException
- Standard Derby exception policyContainerHandle openContainer(ContainerKey containerId, LockingPolicy locking, int mode) throws StandardException
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.
locking
- The lock policy to use, if null then then a no locking
policy will be used.StandardException
- Standard Derby exception policylong addContainer(long segmentId, long containerId, int mode, java.util.Properties tableProperties, int temporaryFlag) throws StandardException
Synchronisation
The new container is exclusivly locked by this transaction until it commits.
segmentId
- segment to create the container in.containerId
- If not equal to 0 then this container id will be
used to create the container, else if set to 0 then
the raw store will assign a number.mode
- mode description in @see ContainerHandle. This mode is
only effective for the duration of the addContainer call and not stored
persistently for the lifetime of the container.tableProperties
- Implementation-specific properties of the
conglomerate.StandardException
- Standard Derby error policyvoid dropContainer(ContainerKey containerId) throws StandardException
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.
StandardException
- Standard Derby error policylong addAndLoadStreamContainer(long segmentId, java.util.Properties tableProperties, RowSource rowSource) throws StandardException
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.
StandardException
- Standard Derby error policyStreamContainerHandle openStreamContainer(long segmentId, long containerId, boolean hold) throws StandardException
StandardException
- Standard Derby exception policyvoid dropStreamContainer(long segmentId, long containerId) throws StandardException
Synchronisation
This call will remove the container.
StandardException
- Standard Derby error policyvoid logAndDo(Loggable operation) throws StandardException
operation
- the operation that is to be appliedStandardException
- Standard Derby exception policyLoggable
void addPostCommitWork(Serviceable work)
work
- the post commit work that is addedvoid addPostAbortWork(Serviceable work)
work
- the post commit work that is addedvoid addPostTerminationWork(Serviceable work)
work
- the post termination work that is addedboolean isIdle()
boolean isPristine()
FileResource getFileHandler()
boolean anyoneBlocked()
void createXATransactionFromLocalTransaction(int format_id, byte[] global_id, byte[] branch_id) throws StandardException
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.
format_id
- the format id part of the Xid - ie. Xid.getFormatId().global_id
- the global transaction identifier part of XID - ie.
Xid.getGlobalTransactionId().branch_id
- The branch qualifier of the Xid - ie.
Xid.getBranchQaulifier()StandardException
- Standard exception policy.void xa_commit(boolean onePhase) throws StandardException
RESOLVE - how do we map to the "right" XAExceptions.
onePhase
- If true, the resource manager should use a one-phase
commit protocol to commit the work done on behalf of
current xid.StandardException
- Standard exception policy.int xa_prepare() throws StandardException
StandardException
- Standard exception policy.void xa_rollback() throws StandardException
The given transaction is roll'ed back and it's history is not maintained in the transaction table or long term log.
StandardException
- Standard exception policy.java.lang.String getActiveStateTxIdString()
DataValueFactory getDataValueFactory() throws StandardException
Return a DataValueFactory that can be used to allocate objects. Used to make calls to: DataValueFactory.getInstanceUsingFormatIdAndCollationType()
StandardException
- Standard exception policy.Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.