Class RawTransaction
java.lang.Object
org.apache.derby.iapi.services.monitor.DerbyObservable
org.apache.derby.iapi.store.raw.xact.RawTransaction
- All Implemented Interfaces:
Transaction
- Direct Known Subclasses:
Xact
RawTransaction is the form of Transaction used within the raw store. This
allows the break down of RawStore functionality into (at least) three modules
(Transactions, Data, Log) without exposing internal information on the
external interface.
The transaction will notify any Observer's just before the transaction is committed, aborted or a rollback to savepoint occurs. The argument passed to the update() method of the Observer's will be one of
- RawTransaction.COMMIT - transaction is committing
- RawTransaction.ABORT - transaction is aborting
- RawTransaction.SAVEPOINTROLLBACK - transaction is being rolled back to a savepoint
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Integerstatic final Integerstatic final Integerprotected StandardExceptionstatic final IntegerFields inherited from interface Transaction
KEEP_LOCKS, RELEASE_LOCKS, XA_OK, XA_RDONLY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddUpdateTransaction(int transactionStatus) Add this raw transaction on to the list of update transactionabstract booleanblockBackup(boolean wait) Make the transaction block the online backup.voidCheck to see if a logical operation is allowed by this transaction, throws a TransactionExceotion if it isn't.abstract voidcheckpointInRollForwardRecovery(LogInstant cinstant, long redoLWM, long undoLWM) Redo a checkpoint during rollforward recovery.abstract DataFactoryGet the data factory to be used during this transaction.abstract LogInstantGet the log instant for the first log record written by this transaction.abstract GlobalTransactionIdGet the shortId of this transaction.abstract TransactionIdgetId()Get the shortId of this transaction.abstract LogInstantGet the log instant for the last log record written by this transaction.abstract LockFactoryGet the lock factory to be used during this transaction.abstract DynamicByteArrayOutputStreamGet the log buffer to be used during this transaction.abstract LogFactoryGet the log factory to be used during this transaction.abstract booleanCan this transaction handles post termination workabstract booleaninAbort()Is the transaction in the middle of an abort.abstract booleanRetunrs true if the transaction is part of rollforward recoveryabstract booleanCheck if the transaction is blocking the backup ?abstract voidlogAndUndo(Compensation compensation, LogInstant undoInstant, LimitObjectInput in) Log a compensation operation and then action it in the context of this transaction.voidnotifyObservers(Object arg) Allow my users to notigy my observers.abstract RawContainerHandleopenDroppedContainer(ContainerKey containerId, LockingPolicy locking) Open a container that may be dropped - use only by logging and recovery.abstract voidChange the state of transaction in table to prepare.booleanReturn true if this transaction should be rolled back first in recovery.abstract voidMake this transaction aware that it is being used by recoveryabstract voidreCreateContainerForRedoRecovery(long segmentId, long containerId, ByteArray containerInfo) Recreate a container during redo recovery.abstract voidRemove this raw transaction from the list of update transactionabstract voidDuring recovery re-prepare a transaction.abstract voidsetFirstLogInstant(LogInstant instant) Set the log instant for the first log record written by this transaction.abstract voidsetLastLogInstant(LogInstant instant) Set the log instant for the last log record written by this transaction.voidAllow an Observer to indicate an exception to the transaction that is raised in its update() method.abstract voidsetTransactionId(Loggable beginXact, TransactionId shortId) Set the transactionId (Global and internal) of this transaction using a log record that contains the Global idabstract RawTransactionStart a nested top transaction.protected abstract intStatus that needs to go into the begin transaction log record, if there is one, to help with recoveryprotected abstract intStatus that needs to go into the end transaction log record, if there is one, to help with recoveryMethods inherited from class DerbyObservable
addObserver, countObservers, deleteObserver, notifyObservers, setChangedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Transaction
abort, addAndLoadStreamContainer, addContainer, addPostAbortWork, addPostCommitWork, addPostTerminationWork, anyoneBlocked, close, commit, commitNoSync, createXATransactionFromLocalTransaction, destroy, dropContainer, dropStreamContainer, getActiveStateTxIdString, getCompatibilitySpace, getContextManager, getDataValueFactory, getDefaultLockingPolicy, getFileHandler, isIdle, isPristine, logAndDo, newLockingPolicy, openContainer, openContainer, openStreamContainer, releaseSavePoint, rollbackToSavePoint, setDefaultLockingPolicy, setNoLockWait, setSavePoint, setup, xa_commit, xa_prepare, xa_rollback
-
Field Details
-
COMMIT
-
ABORT
-
SAVEPOINT_ROLLBACK
-
LOCK_ESCALATE
-
observerException
-
-
Constructor Details
-
RawTransaction
public RawTransaction()
-
-
Method Details
-
getLockFactory
Get the lock factory to be used during this transaction. -
getDataFactory
Get the data factory to be used during this transaction. -
getLogFactory
Get the log factory to be used during this transaction. -
getLogBuffer
Get the log buffer to be used during this transaction. -
logAndUndo
public abstract void logAndUndo(Compensation compensation, LogInstant undoInstant, LimitObjectInput in) throws StandardException Log a compensation operation and then action it in the context of this transaction. The CompensationOperation is logged in the transaction log file and then its doMe method is called to perform the required change. This compensation operation will rollback the change that was done by the Loggable Operation at undoInstant.- 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:
-
setTransactionId
Set the transactionId (Global and internal) of this transaction using a log record that contains the Global id -
getId
Get the shortId of this transaction. May return null if transactio has no ID. -
getGlobalId
Get the shortId of this transaction. May return null if transactio has no ID.- Specified by:
getGlobalIdin interfaceTransaction
-
addUpdateTransaction
public abstract void addUpdateTransaction(int transactionStatus) Add this raw transaction on to the list of update transaction -
removeUpdateTransaction
public abstract void removeUpdateTransaction()Remove this raw transaction from the list of update transaction -
prepareTransaction
public abstract void prepareTransaction()Change the state of transaction in table to prepare. -
setFirstLogInstant
Set the log instant for the first log record written by this transaction. -
getFirstLogInstant
Get the log instant for the first log record written by this transaction. -
setLastLogInstant
Set the log instant for the last log record written by this transaction. -
getLastLogInstant
Get the log instant for the last log record written by this transaction. If the transaction is unclear what its last log instant is, than it may return null. -
checkLogicalOperationOk
Check to see if a logical operation is allowed by this transaction, throws a TransactionExceotion if it isn't. This implementation allows logical operations. Transactions that need to disallow logical operations should hide this method.- Throws:
StandardException- Standard Derby error policy,
-
recoveryRollbackFirst
public boolean recoveryRollbackFirst()Return true if this transaction should be rolled back first in recovery. This implementation returns false. Transactions that need to rollback first during recovery should hide this method. -
reprepare
During 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.
- Throws:
StandardException- Standard exception policy.
-
setObserverException
Allow an Observer to indicate an exception to the transaction that is raised in its update() method. -
startNestedTopTransaction
Start 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.- Throws:
StandardException- Standard Derby error policy
-
openDroppedContainer
public abstract RawContainerHandle openDroppedContainer(ContainerKey containerId, LockingPolicy locking) throws StandardException Open a container that may be dropped - use only by logging and recovery. During recovery redo, a log record may refer to a container that has long been dropped. This interface is provided so a dropped container may be opened. If the container has been dropped and is known to be committed, then even if we open the dropped container with forUpdate true, the container will be silently opened as read only. Logging and recovery code always check for committed drop status. Anybody else wanting to use this interface must keep this in mind.- Throws:
StandardException- Standard Derby exception policy
-
reCreateContainerForRedoRecovery
public abstract void reCreateContainerForRedoRecovery(long segmentId, long containerId, ByteArray containerInfo) throws StandardException Recreate a container during redo recovery. Used during redo recovery when processing log records trying to create a container, but no container is found in the db.- Throws:
StandardException- Standard Derby exception policy
-
statusForBeginXactLog
protected abstract int statusForBeginXactLog()Status that needs to go into the begin transaction log record, if there is one, to help with recovery -
statusForEndXactLog
protected abstract int statusForEndXactLog()Status that needs to go into the end transaction log record, if there is one, to help with recovery -
inAbort
public abstract boolean inAbort()Is the transaction in the middle of an abort. -
handlesPostTerminationWork
public abstract boolean handlesPostTerminationWork()Can this transaction handles post termination work -
recoveryTransaction
public abstract void recoveryTransaction()Make this transaction aware that it is being used by recovery -
notifyObservers
Allow my users to notigy my observers.- Overrides:
notifyObserversin classDerbyObservable- Parameters:
arg- Extra information to be passed to the observer's callback method.
-
inRollForwardRecovery
public abstract boolean inRollForwardRecovery()Retunrs true if the transaction is part of rollforward recovery -
checkpointInRollForwardRecovery
public abstract void checkpointInRollForwardRecovery(LogInstant cinstant, long redoLWM, long undoLWM) throws StandardException Redo a checkpoint during rollforward recovery.- 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- Exception encountered during checkpoint
-
blockBackup
Make the transaction block the online backup.- 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 abstract boolean isBlockingBackup()Check if the transaction is blocking the backup ?- Returns:
- true if this transaction is blocking the backup, otherwise false
-