Class Xact
- java.lang.Object
-
- java.util.Observable
-
- org.apache.derby.iapi.store.raw.xact.RawTransaction
-
- org.apache.derby.impl.store.raw.xact.Xact
-
- All Implemented Interfaces:
- Limit, LockOwner, Transaction
- Direct Known Subclasses:
- InternalXact
public class Xact extends RawTransaction implements Limit, LockOwner
A transaction has five states- CLOSED - cannot be used
- IDLE - no reads have been performed by the transaction.
- ACTIVE - at least one read has been attempted by the transaction
- UPDATE - at least one update has been attempted by the transaction
- PREPARED - the transaction is ready to commit (FUTURE).
Transaction identifiers are re-used for transactions that do not enter the UPDATE state during their lifetime.- See Also:
Transaction
-
-
Field Summary
Fields Modifier and Type Field and Description static intEND_ABORTEDstatic intEND_COMMITTEDstatic intEND_PREPAREDstatic intINTERNAL_TRANSACTIONstatic intNESTED_TOP_TRANSACTIONstatic intRECOVERY_ROLLBACK_FIRST-
Fields inherited from class org.apache.derby.iapi.store.raw.xact.RawTransaction
ABORT, COMMIT, LOCK_ESCALATE, SAVEPOINT_ROLLBACK
-
Fields inherited from interface org.apache.derby.iapi.store.raw.Transaction
KEEP_LOCKS, RELEASE_LOCKS, XA_OK, XA_RDONLY
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidabort()Abort all changes made by this transaction since the last commit, abort or the point the transaction was started, whichever is the most recent.longaddAndLoadStreamContainer(long segmentId, java.util.Properties tableProperties, RowSource rowSource)Add a new stream container to the segment and load the stream container.longaddContainer(long segmentId, long containerid, int mode, java.util.Properties tableProperties, int temporaryFlag)Add a new container to the segment.voidaddPostCommitWork(Serviceable work)Add to the list of post commit work that may be processed after this transaction commits.voidaddPostTerminationWork(Serviceable work)Add to the list of post termination work that may be processed after this transaction commits or aborts.voidaddUpdateTransaction(int transactionStatus)Add this to the xactFactory list of update transaction.booleananyoneBlocked()Return true if any transaction is currently blocked, even if not by this transaction.booleanblockBackup(boolean wait)Make the transaction block the online backup.voidcheckpointInRollForwardRecovery(LogInstant cinstant, long redoLWM, long undoLWM)Perform a checkpoint during rollforward recovery.voidclose()Close this transaction, the transaction must be idle.LogInstantcommit()Commit this transaction.LogInstantcommitNoSync(int commitflag)"Commit" this transaction without sync'ing the log.voidcreateXATransactionFromLocalTransaction(int format_id, byte[] global_id, byte[] branch_id)Convert a local transaction to a global transaction.LockingPolicydefaultLockingPolicy()voiddestroy()If this transaction is not idle, abort it.voiddropContainer(ContainerKey containerId)Drop a container.voiddropStreamContainer(long segmentId, long containerId)Drop a stream container.java.lang.StringgetActiveStateTxIdString()Get string id of the transaction that would be when the Transaction is IN active state.CompatibilitySpacegetCompatibilitySpace()Get the compatibility space of the transaction.java.lang.StringgetContextId()Get my transaction context IdContextManagergetContextManager()Return the context manager this transaction is associated with.DataFactorygetDataFactory()Get the data factory to be used during this transaction.DataValueFactorygetDataValueFactory()Get DataValueFactory.LockingPolicygetDefaultLockingPolicy()Get the current default locking policy for all operations within this transaction.FileResourcegetFileHandler()Get an object to handle non-transactional files.LogInstantgetFirstLogInstant()Get the log instant for the first log record written by this transaction.GlobalTransactionIdgetGlobalId()get the Global (external to raw store) transaction id that is unique across all raw storesTransactionIdgetId()get the short (internal to raw store) transaction id that is unique only for this raw storeLogInstantgetLastLogInstant()Get the log instant for the last log record written by this transaction.LockFactorygetLockFactory()Get the lock factory to be used during this transaction.DynamicByteArrayOutputStreamgetLogBuffer()Get the log buffer to be used during this transaction.LogFactorygetLogFactory()JIRA-606.java.lang.StringgetTransName()booleanhandlesPostTerminationWork()Can this transaction handles post termination workbooleaninAbort()Is the transaction in the middle of an abort.booleaninRollForwardRecovery()Is the transaction in rollforward recoverybooleanisActive()see if this transaction has ever done anything.booleanisBlockingBackup()Check if the transaction is blocking the backup ?booleanisIdle()See if this transaction is in the idle state, called by other thread to test the state of this transaction.booleanisNestedOwner()Return true if this is a nested owner, e.g., a nested user transaction.booleanisPrepared()see if this transaction is in PREPARED state.booleanisPristine()see if this transaction is in a pristine state.voidlogAndDo(Loggable operation)Log the operation and do it.voidlogAndUndo(Compensation compensation, LogInstant undoInstant, LimitObjectInput in)Log and apply a compensation operation.booleannestsUnder(LockOwner other)Return true if this owner nests under another owner.LockingPolicynewLockingPolicy(int mode, int isolation, boolean stricterOk)Obtain a locking policy for use in openContainer().booleannoWait()Tells whether lock requests should time out immediately if they can't be granted without waiting.ContainerHandleopenContainer(ContainerKey containerId, int mode)Open a container, with the transaction's default locking policy.ContainerHandleopenContainer(ContainerKey containerId, LockingPolicy locking, int mode)Open a container, with the defined locking policy, otherwise as openContainer(int containerId, boolean forUpdate).RawContainerHandleopenDroppedContainer(ContainerKey containerId, LockingPolicy locking)Open a container that may already have been dropped.StreamContainerHandleopenStreamContainer(long segmentId, long containerId, boolean hold)Open a stream container.voidprepareTransaction()Remove this from the xactFactory list of update transaction.voidreached(CompatibilitySpace compatibilitySpace, java.lang.Object group, int limit, java.util.Enumeration lockList, int lockCount)Called by the lock factory when a limit has been reached.voidrecoveryTransaction()Make this transaction aware that it is being used by recoveryvoidreCreateContainerForRedoRecovery(long segmentId, long containerId, ByteArray containerInfo)Recreate a container during redo recovery.intreleaseSavePoint(java.lang.String name, java.lang.Object kindOfSavepoint)Release the save point of the given name.voidremoveUpdateTransaction()Remove this from the xactFactory list of update transaction.voidreprepare()During recovery re-prepare a transaction.introllbackToSavePoint(java.lang.String name, java.lang.Object kindOfSavepoint)Rollback all changes made since the named savepoint was set.voidsetDefaultLockingPolicy(LockingPolicy policy)Set the default locking policy for all operations within this transaction.voidsetFirstLogInstant(LogInstant instant)Set the log instant for the first log record written by this transaction.voidsetLastLogInstant(LogInstant instant)Set the log instant for the last log record written by this transaction.voidsetNoLockWait(boolean noWait)Tell this transaction whether it should time out immediately if a lock cannot be granted without waiting.intsetSavePoint(java.lang.String name, java.lang.Object kindOfSavepoint)Set a save point in the current transaction.voidsetTransactionId(Loggable beginXact, TransactionId localId)Set the transactionId (Global and internal) of this transaction using a log record that contains the Global idvoidsetTransName(java.lang.String name)voidsetup(PersistentSet set)The default value for LOCKS_ESCALATION_THRESHOLDRawTransactionstartNestedTopTransaction()Start a nested top transaction.java.lang.StringtoInternalDetailString()java.lang.StringtoString()Return the xid as a string.voidxa_commit(boolean onePhase)This method is called to commit the current XA global transaction.intxa_prepare()This method is called to ask the resource manager to prepare for a transaction commit of the transaction specified in xid.voidxa_rollback()rollback the current global transaction.-
Methods inherited from class org.apache.derby.iapi.store.raw.xact.RawTransaction
checkLogicalOperationOk, notifyObservers, recoveryRollbackFirst, setObserverException
-
-
-
-
Field Detail
-
END_ABORTED
public static final int END_ABORTED
- See Also:
- Constant Field Values
-
END_PREPARED
public static final int END_PREPARED
- See Also:
- Constant Field Values
-
END_COMMITTED
public static final int END_COMMITTED
- See Also:
- Constant Field Values
-
RECOVERY_ROLLBACK_FIRST
public static final int RECOVERY_ROLLBACK_FIRST
- See Also:
- Constant Field Values
-
INTERNAL_TRANSACTION
public static final int INTERNAL_TRANSACTION
- See Also:
- Constant Field Values
-
NESTED_TOP_TRANSACTION
public static final int NESTED_TOP_TRANSACTION
- See Also:
- Constant Field Values
-
-
Method Detail
-
getLockFactory
public final LockFactory getLockFactory()
Description copied from class:RawTransactionGet the lock factory to be used during this transaction.- Specified by:
getLockFactoryin classRawTransaction
-
getDataFactory
public final DataFactory getDataFactory()
Description copied from class:RawTransactionGet the data factory to be used during this transaction.- Specified by:
getDataFactoryin classRawTransaction
-
getLogFactory
public final LogFactory getLogFactory()
JIRA-606. As a part of this fix, it was required that LogFactory.checkVersion method to be exposed for any possible Version checks in the Transaction processing module.- Specified by:
getLogFactoryin classRawTransaction
-
anyoneBlocked
public boolean anyoneBlocked()
Return true if any transaction is currently blocked, even if not by this transaction.- Specified by:
anyoneBlockedin interfaceTransaction
-
getLogBuffer
public DynamicByteArrayOutputStream getLogBuffer()
Description copied from class:RawTransactionGet the log buffer to be used during this transaction.- Specified by:
getLogBufferin classRawTransaction
-
logAndUndo
public void logAndUndo(Compensation compensation, LogInstant undoInstant, LimitObjectInput in) throws StandardException
Log and apply a compensation operation. Only need to write out the compensation op itself, the optional data has already been written by the rollforward operation this is attempting to undo.- Specified by:
logAndUndoin classRawTransaction- Parameters:
compensation- the Compensation OperationundoInstant- the LogInstant of the Loggable Operation this compensation operation is going to roll backin- optional data for the rollback operation- Throws:
StandardException- Standard Derby exception policy- See Also:
Transaction.logAndDo(org.apache.derby.iapi.store.raw.Loggable)
-
addUpdateTransaction
public void addUpdateTransaction(int transactionStatus)
Add this to the xactFactory list of update transaction.- Specified by:
addUpdateTransactionin classRawTransaction
-
removeUpdateTransaction
public void removeUpdateTransaction()
Remove this from the xactFactory list of update transaction.- Specified by:
removeUpdateTransactionin classRawTransaction
-
prepareTransaction
public void prepareTransaction()
Remove this from the xactFactory list of update transaction.- Specified by:
prepareTransactionin classRawTransaction
-
setFirstLogInstant
public void setFirstLogInstant(LogInstant instant)
Set the log instant for the first log record written by this transaction.- Specified by:
setFirstLogInstantin classRawTransaction
-
getFirstLogInstant
public LogInstant getFirstLogInstant()
Get the log instant for the first log record written by this transaction.- Specified by:
getFirstLogInstantin classRawTransaction
-
setLastLogInstant
public void setLastLogInstant(LogInstant instant)
Set the log instant for the last log record written by this transaction.- Specified by:
setLastLogInstantin classRawTransaction
-
getLastLogInstant
public LogInstant getLastLogInstant()
Get the log instant for the last log record written by this transaction.- Specified by:
getLastLogInstantin classRawTransaction
-
setTransactionId
public void setTransactionId(Loggable beginXact, TransactionId localId)
Description copied from class:RawTransactionSet the transactionId (Global and internal) of this transaction using a log record that contains the Global id- Specified by:
setTransactionIdin classRawTransaction
-
setup
public void setup(PersistentSet set) throws StandardException
The default value for LOCKS_ESCALATION_THRESHOLD- Specified by:
setupin interfaceTransaction- Throws:
StandardException- Standard Derby exception policy
-
getGlobalId
public final GlobalTransactionId getGlobalId()
get the Global (external to raw store) transaction id that is unique across all raw stores- Specified by:
getGlobalIdin interfaceTransaction- Specified by:
getGlobalIdin classRawTransaction
-
getContextManager
public final ContextManager getContextManager()
Description copied from interface:TransactionReturn the context manager this transaction is associated with.- Specified by:
getContextManagerin interfaceTransaction
-
getCompatibilitySpace
public final CompatibilitySpace 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.
- Specified by:
getCompatibilitySpacein interfaceTransaction- Returns:
- The compatibility space of the transaction.
-
noWait
public boolean noWait()
Tells whether lock requests should time out immediately if they can't be granted without waiting. Only works if this object is the owner of the compatibility space used in the request.
-
setNoLockWait
public void setNoLockWait(boolean noWait)
Tell this transaction whether it should time out immediately if a lock cannot be granted without waiting. This could be used in a nested transaction to prevent long waits if there is a lock conflict between the nested transaction and its parent. If it is used this way, the calling code should catch timeout exceptions from the nested transaction and retry the operation (without disabling waiting) in the parent transaction.This only works if this transaction is the owner of the compatibility space used in the request. If this transaction has inherited the compatibility space from its parent, the call to this method has no effect (except in debug builds, where an error will be raised).
- Specified by:
setNoLockWaitin interfaceTransaction- Parameters:
noWait- iftruenever wait for a lock in this transaction, but time out immediately- See Also:
LockOwner.noWait()
-
getId
public final TransactionId getId()
get the short (internal to raw store) transaction id that is unique only for this raw store- Specified by:
getIdin classRawTransaction
-
getContextId
public final java.lang.String getContextId()
Get my transaction context Id
-
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 tonewLockingPolicy( LockingPolicy.MODE_RECORD, TransactionController.ISOLATION_SERIALIZABLE, true);This default can be changed by subsequent calls to setDefaultLockingPolicy(LockingPolicy policy).- Specified by:
getDefaultLockingPolicyin interfaceTransaction- Returns:
- The current default locking policy in this transaction.
- See Also:
Transaction.getDefaultLockingPolicy()
-
newLockingPolicy
public final LockingPolicy newLockingPolicy(int mode, int isolation, boolean stricterOk)
Description copied from interface:TransactionObtain 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.- Specified by:
newLockingPolicyin interfaceTransaction- Parameters:
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.- Returns:
- A object that can be used in an openContainer call, null if a matching policy cannot be found.
- See Also:
Transaction.newLockingPolicy(int, int, boolean)
-
setDefaultLockingPolicy
public final void setDefaultLockingPolicy(LockingPolicy policy)
Description copied from interface:TransactionSet the default locking policy for all operations within this transaction. The transaction is intially started with a default locking policy equivalent tonewLockingPolicy( LockingPolicy.MODE_RECORD, LockingPolicy.ISOLATION_SERIALIZABLE, true);- Specified by:
setDefaultLockingPolicyin interfaceTransaction- Parameters:
policy- The lock policy to use, if null then then a no locking policy will be installed as the default.- See Also:
Transaction.setDefaultLockingPolicy(org.apache.derby.iapi.store.raw.LockingPolicy)
-
commit
public LogInstant commit() throws StandardException
Description copied from interface:TransactionCommit this transaction. All savepoints within this transaction are released.- Specified by:
commitin interfaceTransaction- Returns:
- the commit instant of this transaction, or null if it didn't make any changes
- Throws:
StandardException- Standard Derby exception policy
-
commitNoSync
public LogInstant commitNoSync(int commitflag) throws StandardException
Description copied from interface:Transaction"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.- Specified by:
commitNoSyncin interfaceTransaction- Throws:
StandardException- Standard Derby exception policy
-
abort
public void abort() throws StandardExceptionDescription copied from interface:TransactionAbort 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.- Specified by:
abortin interfaceTransaction- Throws:
StandardException- Standard Derby exception policy- See Also:
Transaction.abort()
-
reprepare
public void reprepare() throws StandardExceptionDuring recovery re-prepare a transaction.After redo() and undo(), this routine is called on all outstanding in-doubt (prepared) transactions. This routine re-acquires all logical write locks for operations in the xact, and then modifies the transaction table entry to make the transaction look as if it had just been prepared following startup after recovery.
This routine is only called during Recovery.
- Specified by:
repreparein classRawTransaction- Throws:
StandardException- Standard exception policy.
-
destroy
public void destroy() throws StandardExceptionIf this transaction is not idle, abort it. After this call close().- Specified by:
destroyin interfaceTransaction- Throws:
StandardException- Standard Derby error policy Thrown if the transaction is not idle.- See Also:
RawStoreFactory.startTransaction(org.apache.derby.iapi.services.context.ContextManager, java.lang.String)
-
close
public void close() throws StandardExceptionDescription copied from interface:TransactionClose 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.- Specified by:
closein interfaceTransaction- Throws:
StandardException- Thrown if the transaction is not idle, the transaction remains open.- See Also:
Transaction.close()
-
logAndDo
public void logAndDo(Loggable operation) throws StandardException
Log the operation and do it. If this transaction has not generated any log records prior to this, then log a beginXact log record. If the passed in operation is null, then do nothing (after logging the beginXact if needed).- Specified by:
logAndDoin interfaceTransaction- Parameters:
operation- the operation that is to be applied- Throws:
StandardException- Standard Derby exception policy- See Also:
Transaction.logAndDo(org.apache.derby.iapi.store.raw.Loggable)
-
addPostCommitWork
public void addPostCommitWork(Serviceable work)
Description copied from interface:TransactionAdd 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.- Specified by:
addPostCommitWorkin interfaceTransaction- Parameters:
work- the post commit work that is added
-
addPostTerminationWork
public void addPostTerminationWork(Serviceable work)
Description copied from interface:TransactionAdd to the list of post termination work that may be processed after this transaction commits or aborts.- Specified by:
addPostTerminationWorkin interfaceTransaction- Parameters:
work- the post termination work that is added
-
openContainer
public ContainerHandle openContainer(ContainerKey containerId, int mode) throws StandardException
Description copied from interface:TransactionOpen 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.
- Specified by:
openContainerin interfaceTransaction- Returns:
- a valid ContainerHandle or null if the container does not exist.
- Throws:
StandardException- Standard Derby exception policy- See Also:
Transaction.openContainer(org.apache.derby.iapi.store.raw.ContainerKey, int)
-
openContainer
public ContainerHandle openContainer(ContainerKey containerId, LockingPolicy locking, int mode) throws StandardException
Description copied from interface:TransactionOpen 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.
- Specified by:
openContainerin interfaceTransactionlocking- The lock policy to use, if null then then a no locking policy will be used.- Returns:
- a valid ContainerHandle or null if the container does not exist.
- Throws:
StandardException- Standard Derby exception policy- See Also:
Transaction.openContainer(org.apache.derby.iapi.store.raw.ContainerKey, int)
-
openDroppedContainer
public RawContainerHandle openDroppedContainer(ContainerKey containerId, LockingPolicy locking) throws StandardException
Open a container that may already have been dropped.- Specified by:
openDroppedContainerin classRawTransaction- Throws:
StandardException- Standard Derby exception policy- See Also:
RawTransaction.openDroppedContainer(org.apache.derby.iapi.store.raw.ContainerKey, org.apache.derby.iapi.store.raw.LockingPolicy)
-
addContainer
public long addContainer(long segmentId, long containerid, int mode, java.util.Properties tableProperties, int temporaryFlag) throws StandardExceptionDescription copied from interface:TransactionAdd 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.
- Specified by:
addContainerin interfaceTransaction- Parameters:
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.- Returns:
- a container identifer that can be used in openContainer() This id is only valid within this RawStoreFactory. Returns a negative number if a container could not be allocated.
- Throws:
StandardException- Standard Derby exception policy- See Also:
Transaction.addContainer(long, long, int, java.util.Properties, int)
-
addAndLoadStreamContainer
public long addAndLoadStreamContainer(long segmentId, java.util.Properties tableProperties, RowSource rowSource) throws StandardExceptionDescription copied from interface:TransactionAdd 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.
- Specified by:
addAndLoadStreamContainerin interfaceTransaction- Throws:
StandardException- Standard Derby exception policy- See Also:
Transaction.addAndLoadStreamContainer(long, java.util.Properties, org.apache.derby.iapi.store.access.RowSource)
-
openStreamContainer
public StreamContainerHandle openStreamContainer(long segmentId, long containerId, boolean hold) throws StandardException
Description copied from interface:TransactionOpen a stream container.- Specified by:
openStreamContainerin interfaceTransaction- Returns:
- a valid StreamContainerHandle or null if the container does not exist.
- Throws:
StandardException- Standard Derby exception policy- See Also:
Transaction.openStreamContainer(long, long, boolean)
-
dropStreamContainer
public void dropStreamContainer(long segmentId, long containerId) throws StandardExceptionDescription copied from interface:TransactionDrop a stream container.Synchronisation
This call will remove the container.
- Specified by:
dropStreamContainerin interfaceTransaction- Throws:
StandardException- Standard Derby error policy- See Also:
Transaction.dropStreamContainer(long, long)
-
reCreateContainerForRedoRecovery
public void reCreateContainerForRedoRecovery(long segmentId, long containerId, ByteArray containerInfo) throws StandardExceptionRecreate a container during redo recovery. Used only during redo recovery while processing log records which are trying to create a container, and no valid container is found in the database.- Specified by:
reCreateContainerForRedoRecoveryin classRawTransaction- Throws:
StandardException- Standard Derby exception policy- See Also:
RawTransaction.reCreateContainerForRedoRecovery(long, long, org.apache.derby.iapi.util.ByteArray)
-
dropContainer
public void dropContainer(ContainerKey containerId) throws StandardException
Description copied from interface:TransactionDrop 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.
- Specified by:
dropContainerin interfaceTransaction- Throws:
StandardException- Standard Derby error policy- See Also:
Transaction.dropContainer(org.apache.derby.iapi.store.raw.ContainerKey)
-
setSavePoint
public int setSavePoint(java.lang.String name, java.lang.Object kindOfSavepoint) throws StandardExceptionDescription copied from interface:TransactionSet 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".- Specified by:
setSavePointin interfaceTransaction- Parameters:
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 savepoint- Returns:
- returns total number of savepoints in the stack.
- Throws:
StandardException- Standard Derby exception policy- See Also:
Transaction.setSavePoint(java.lang.String, java.lang.Object)
-
releaseSavePoint
public int releaseSavePoint(java.lang.String name, java.lang.Object kindOfSavepoint) throws StandardExceptionDescription copied from interface:TransactionRelease 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.- Specified by:
releaseSavePointin interfaceTransaction- Parameters:
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 savepoint- Returns:
- returns total number of savepoints in the stack.
- Throws:
StandardException- Standard Derby exception policy- See Also:
Transaction.releaseSavePoint(java.lang.String, java.lang.Object)
-
rollbackToSavePoint
public int rollbackToSavePoint(java.lang.String name, java.lang.Object kindOfSavepoint) throws StandardExceptionDescription copied from interface:TransactionRollback 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).- Specified by:
rollbackToSavePointin interfaceTransaction- Parameters:
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 savepoint- Returns:
- returns total number of savepoints in the stack.
- Throws:
StandardException- Standard Derby exception policy- See Also:
Transaction.rollbackToSavePoint(java.lang.String, java.lang.Object)
-
defaultLockingPolicy
public final LockingPolicy defaultLockingPolicy()
-
handlesPostTerminationWork
public boolean handlesPostTerminationWork()
Description copied from class:RawTransactionCan this transaction handles post termination work- Specified by:
handlesPostTerminationWorkin classRawTransaction
-
recoveryTransaction
public void recoveryTransaction()
Description copied from class:RawTransactionMake this transaction aware that it is being used by recovery- Specified by:
recoveryTransactionin classRawTransaction
-
startNestedTopTransaction
public RawTransaction startNestedTopTransaction() throws StandardException
Description copied from class:RawTransactionStart a nested top transaction. A nested top transaction behaves exactly like a user transaction. Nested top transaction allow system type work to proceed in a separate transaction to the current user transaction and be committed independently of the user transaction (usually before the user transaction). Only one nested top transaction can be active in a context at any one time. After a commit the transaction may be re-used. A nested top transaction conflicts on the logical locks of its "parent" transaction.- Specified by:
startNestedTopTransactionin classRawTransaction- Throws:
StandardException- Derby Standard error policy
-
isActive
public final boolean isActive()
see if this transaction has ever done anything. MT - single thread through synchronizing this. This method may be called by other thread to test the state of this transaction. That's why we need to synchronize with all methods which enters or exits the Idle state. Local method which read the state need not be synchronized because the other thread may look at the state but it may not change it.- Returns:
- true if this transaction is not in idle or closed state
-
isPrepared
public final boolean isPrepared()
see if this transaction is in PREPARED state. MT - single thread through synchronizing this. This method may be called by other thread to test the state of this transaction.- Returns:
- true if this transaction is in PREPARED state.
-
isIdle
public boolean isIdle()
See if this transaction is in the idle state, called by other thread to test the state of this transaction. That's why we need to synchronzied with all methods whcih enters or exits the idle state- Specified by:
isIdlein interfaceTransaction- Returns:
- true if it is idle, otherwise false
-
isPristine
public boolean isPristine()
see if this transaction is in a pristine state.
MT - called only by the same thread that owns the xact, no need to synchronize.- Specified by:
isPristinein interfaceTransaction- Returns:
- true if it hasn't done any updates, otherwise false
-
inAbort
public boolean inAbort()
Description copied from class:RawTransactionIs the transaction in the middle of an abort.- Specified by:
inAbortin classRawTransaction
-
getFileHandler
public FileResource getFileHandler()
Description copied from interface:TransactionGet an object to handle non-transactional files.- Specified by:
getFileHandlerin interfaceTransaction
-
blockBackup
public boolean blockBackup(boolean wait) throws StandardExceptionMake the transaction block the online backup.- Specified by:
blockBackupin classRawTransaction- Parameters:
wait- if true, waits until the transaction can block the backup.- Returns:
- true if the transaction blocked the backup. false otherwise.
- Throws:
StandardException- if interrupted while waiting for the backup in progress to complete.
-
isBlockingBackup
public boolean isBlockingBackup()
Check if the transaction is blocking the backup ?- Specified by:
isBlockingBackupin classRawTransaction- Returns:
- true if this transaction is blocking the backup, otherwise false
-
reached
public void reached(CompatibilitySpace compatibilitySpace, java.lang.Object group, int limit, java.util.Enumeration lockList, int lockCount) throws StandardException
Description copied from interface:LimitCalled by the lock factory when a limit has been reached.- Specified by:
reachedin interfaceLimit- Parameters:
compatibilitySpace- lock space the limit was set forgroup- lock group the limit was set forlimit- the limit's settinglockList- the list of Lockable's in the grouplockCount- the number of locks in the group- Throws:
StandardException- Standard Derby error policy.
-
createXATransactionFromLocalTransaction
public void createXATransactionFromLocalTransaction(int format_id, byte[] global_id, byte[] branch_id) throws StandardExceptionConvert a local transaction to a global 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, and no current global id.
Simply call setTransactionId() which takes care of error checking.
- Specified by:
createXATransactionFromLocalTransactionin interfaceTransaction- Parameters:
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()- Throws:
StandardException- Standard exception policy.
-
xa_commit
public void xa_commit(boolean onePhase) throws StandardExceptionThis method is called to commit the current XA global transaction.RESOLVE - how do we map to the "right" XAExceptions.
- Specified by:
xa_commitin interfaceTransaction- Parameters:
onePhase- If true, the resource manager should use a one-phase commit protocol to commit the work done on behalf of current xid.- Throws:
StandardException- Standard exception policy.
-
xa_prepare
public int xa_prepare() throws StandardExceptionThis method is called to ask the resource manager to prepare for a transaction commit of the transaction specified in xid.- Specified by:
xa_preparein interfaceTransaction- Returns:
- A value indicating the resource manager's vote on the the outcome of the transaction. The possible values are: XA_RDONLY or XA_OK. If the resource manager wants to roll back the transaction, it should do so by throwing an appropriate XAException in the prepare method.
- Throws:
StandardException- Standard exception policy.
-
xa_rollback
public void xa_rollback() throws StandardExceptionrollback 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.
- Specified by:
xa_rollbackin interfaceTransaction- Throws:
StandardException- Standard exception policy.
-
toString
public java.lang.String toString()
Return the xid as a string.The virtual lock table depends on this routine returning just the local transaction id as a string, even if it is a global transaction. Joins between the lock table and the transaction table will not work if this routine returns anything other than myId.toString().
- Overrides:
toStringin classjava.lang.Object- Returns:
- The xid as a string.
-
toInternalDetailString
public java.lang.String toInternalDetailString()
-
getActiveStateTxIdString
public java.lang.String getActiveStateTxIdString()
Get string id of the transaction that would be when the Transaction is IN active state. This transaction "name" will be the same id which is returned in the TransactionInfo information if Tx is already in Active State. If the Transaction is in IDLE state, Transaction ID is incremented when getActiveStateTxIdString() on raw transaction is called, instead of the Tx ID being incremented when Transaction gets into active state. The reason for incrementing the Tx ID earlier than when Tx is actually goes into active state is some debug statement cases like log statement text. SQL statements are written to log before they are actually executed; In such cases we would like to display the actual TX ID on which locks are acquired when the statement is executed.- Specified by:
getActiveStateTxIdStringin interfaceTransaction- Returns:
- The a string which identifies the transaction.
-
getDataValueFactory
public DataValueFactory getDataValueFactory() throws StandardException
Get DataValueFactory.Return a DataValueFactory that can be used to allocate objects. Used to make calls to: DataValueFactory.getInstanceUsingFormatIdAndCollationType()
- Specified by:
getDataValueFactoryin interfaceTransaction- Returns:
- a booted data value factory.
- Throws:
StandardException- Standard exception policy.
-
getTransName
public java.lang.String getTransName()
-
setTransName
public void setTransName(java.lang.String name)
-
inRollForwardRecovery
public boolean inRollForwardRecovery()
Is the transaction in rollforward recovery- Specified by:
inRollForwardRecoveryin classRawTransaction
-
checkpointInRollForwardRecovery
public void checkpointInRollForwardRecovery(LogInstant cinstant, long redoLWM, long undoLWM) throws StandardException
Perform a checkpoint during rollforward recovery.- Specified by:
checkpointInRollForwardRecoveryin classRawTransaction- Parameters:
cinstant- The LogInstant of the checkpointredoLWM- Redo Low Water Mark in the check point recordundoLWM- Undo Low Water Mark in the checkpoint- Throws:
StandardException
-
isNestedOwner
public boolean isNestedOwner()
Description copied from interface:LockOwnerReturn true if this is a nested owner, e.g., a nested user transaction.
- Specified by:
isNestedOwnerin interfaceLockOwner
-
nestsUnder
public boolean nestsUnder(LockOwner other)
Description copied from interface:LockOwnerReturn true if this owner nests under another owner.
- Specified by:
nestsUnderin interfaceLockOwner
-
-
DataMelt 3.0 © DataMelt by jWork.ORG