Package org.apache.derby.jdbc
Class XATransactionState
java.lang.Object
org.apache.derby.iapi.services.context.ContextImpl
org.apache.derby.jdbc.XATransactionState
- All Implemented Interfaces:
Context
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
The implementation of TimerTask to cancel a global transaction.private static class
A class used to monitor if the transaction is in the middle of cancelling or cleaning up on an error. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate EmbedXAResource
(package private) int
Association state of the transaction.(package private) XATransactionState.CleanupOrCancelMonitor
(package private) final EmbedConnection
(package private) final EmbedXAResource
(package private) boolean
has this transaction been prepared.(package private) boolean
Indicates whether this transaction is supposed to be rolled back by timeout.(package private) int
(package private) HashMap
<EmbedXAResource, XATransactionState> When an XAResource suspends a transaction (end(TMSUSPEND)) it must be resumed using the same XAConnection.(package private) static final int
(package private) static final int
(package private) static final int
(package private) XATransactionState.CancelXATransactionTask
A timer task scheduled for the time when the transaction will timeout.(package private) static final int
Rollback-only due to deadlock(package private) static final int
Rollback-only due to end(TMFAIL)(package private) static final int
Rollback-only due to timeout(package private) final XAXactId
-
Constructor Summary
ConstructorsConstructorDescriptionXATransactionState
(ContextManager cm, EmbedConnection conn, EmbedXAResource resource, XAXactId xid) -
Method Summary
Modifier and TypeMethodDescription(package private) void
This function is called from the timer task when the transaction times out.void
Contexts will be passed errors that are caught by the outer system when they are serious enough to require corrective action.(package private) boolean
end
(EmbedXAResource resource, int flags, boolean endingCurrentXid) private static ModuleFactory
Privileged Monitor lookup.private static TimerFactory
(package private) void
scheduleTimeoutTask
(long timeoutMillis) Schedule a timeout task which will rollback the global transaction after the specified time will elapse.(package private) void
start
(EmbedXAResource resource, int flags) (package private) void
xa_commit
(boolean onePhase) Commit the global transaction and cancel the timeout task.private void
This method cancels timeoutTask and assigns 'performTimeoutRollback = false'.(package private) int
Prepare the global transaction for commit.(package private) void
Rollback the global transaction and cancel the timeout task.Methods inherited from class org.apache.derby.iapi.services.context.ContextImpl
appendErrorInfo, getContextManager, getIdName, isLastHandler, popMe, pushMe
-
Field Details
-
TRO_TIMEOUT
static final int TRO_TIMEOUTRollback-only due to timeout- See Also:
-
TRO_DEADLOCK
static final int TRO_DEADLOCKRollback-only due to deadlock- See Also:
-
TRO_FAIL
static final int TRO_FAILRollback-only due to end(TMFAIL)- See Also:
-
T0_NOT_ASSOCIATED
static final int T0_NOT_ASSOCIATED- See Also:
-
T1_ASSOCIATED
static final int T1_ASSOCIATED- See Also:
-
TC_COMPLETED
static final int TC_COMPLETED- See Also:
-
conn
-
creatingResource
-
associatedResource
-
xid
-
cleanupOrCancelMonitor
XATransactionState.CleanupOrCancelMonitor cleanupOrCancelMonitor -
suspendedList
HashMap<EmbedXAResource,XATransactionState> suspendedListWhen an XAResource suspends a transaction (end(TMSUSPEND)) it must be resumed using the same XAConnection. This has been the traditional Cloudscape/Derby behaviour, though there does not seem to be a specific reference to this behaviour in the JTA spec. Note that while the transaction is suspended by this XAResource, another XAResource may join the transaction and suspend it after the join. -
associationState
int associationStateAssociation state of the transaction. -
rollbackOnlyCode
int rollbackOnlyCode -
isPrepared
boolean isPreparedhas this transaction been prepared. -
performTimeoutRollback
boolean performTimeoutRollbackIndicates whether this transaction is supposed to be rolled back by timeout. -
timeoutTask
XATransactionState.CancelXATransactionTask timeoutTaskA timer task scheduled for the time when the transaction will timeout.
-
-
Constructor Details
-
XATransactionState
XATransactionState(ContextManager cm, EmbedConnection conn, EmbedXAResource resource, XAXactId xid)
-
-
Method Details
-
getTimerFactory
-
cleanupOnError
Description copied from interface:Context
Contexts will be passed errors that are caught by the outer system when they are serious enough to require corrective action. They will be told what the error is, so that they can react appropriately. Most of the time, the contexts will react by either doing nothing or by removing themselves from the context manager. If there are no other references to the context, removing itself from the manager equates to freeing it.
On an exception that is session severity or greater the Context must push itself off the stack. This is to ensure that after a session has been closed there are no Contexts on the stack that potentially hold references to objects, thus delaying their garbage collection.Contexts must release all their resources before removing themselves from their context manager.
The context manager will "unwind" the contexts during cleanup in the reverse order they were placed on its global stack.
If error is an instance of StandardException then an implementation of this method may throw a new exception if and only if the new exception is an instance of StandardException that is more severe than the original error or the new exception is a not an instance of StandardException (e.g java.lang.NullPointerException).
-
start
- Throws:
XAException
-
end
- Throws:
XAException
-
scheduleTimeoutTask
void scheduleTimeoutTask(long timeoutMillis) Schedule a timeout task which will rollback the global transaction after the specified time will elapse.- Parameters:
timeoutMillis
- The number of milliseconds to be elapsed before the transaction will be rolled back.
-
xa_rollback
Rollback the global transaction and cancel the timeout task.- Throws:
SQLException
-
xa_commit
Commit the global transaction and cancel the timeout task.- Parameters:
onePhase
- Indicates whether to use one phase commit protocol. Otherwise two phase commit protocol will be used.- Throws:
SQLException
-
xa_prepare
Prepare the global transaction for commit.- Throws:
SQLException
-
xa_finalize
private void xa_finalize()This method cancels timeoutTask and assigns 'performTimeoutRollback = false'. -
cancel
This function is called from the timer task when the transaction times out.- Throws:
XAException
- See Also:
-
getMonitor
Privileged Monitor lookup. Must be private so that user code can't call this entry point.
-