Top Description Fields Constructors Methods
org.apache.derby.impl.store.raw.xact

public Class XactXAResourceManager

extends Object
implements XAResourceManager
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.store.access.xa.XAResourceManager
Imports
org.apache.derby.shared.common.reference.SQLState, org.apache.derby.iapi.services.context.ContextManager, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.error.StandardException, org.apache.derby.iapi.store.access.xa.XAResourceManager, .XAXactId, org.apache.derby.iapi.store.access.AccessFactoryGlobals, org.apache.derby.iapi.store.raw.RawStoreFactory, .Transaction, java.util.ArrayList, javax.transaction.xa.Xid, .XAResource

The XactXAResourceManager implements the Access XAResource interface, which provides offline control over two phase commit transactions. It is expected to be used by TM's (transaction manager's), to recover if systems fail while transactions are still in-doubt (prepared).

This interface allows access to commit,prepare,abort global transactions as part of a two phase commit protocol. These interfaces have been chosen to be exact implementations required to implement the XAResource interfaces as part of the JTA standard extension.

It is expected that the following interfaces are only used during the recovery portion of 2 phase commit, when the transaction manager is cleaning up after a runtime crash - it is expected that no current context managers exist for the Xid's being operated on. The "online" two phase commit protocol will be implemented by calls directly on a TransactionController.

The XAResource interface is a Java mapping of the industry standard XA resource manager interface. Please refer to: X/Open CAE Specification - Distributed Transaction Processing: The XA Specification, X/Open Document No. XO/CAE/91/300 or ISBN 1 872630 24 3.

See Also
org.apache.derby.iapi.store.access.xa.XAResourceManager

Field Summary

Modifier and TypeField and Description
private RawStoreFactory
private TransactionTable
transaction_table

Fields of the class

Constructor Summary

AccessConstructor and Description
public
XactXAResourceManager(RawStoreFactory rsf, TransactionTable tt)

Constructors for This class:

Method Summary

Modifier and TypeMethod and Description
public void
commit(ContextManager
The ContextManager returned from the find() call.
cm
,
Xid
A global transaction identifier.
xid
,
boolean
If true, the resource manager should use a one-phase commit protocol to commit the work done on behalf of xid.
onePhase
)

Implements org.apache.derby.iapi.store.access.xa.XAResourceManager.commit.

This method is called to commit the global transaction specified by xid.

public ContextManager
find(Xid
A global transaction identifier.
xid
)

Implements org.apache.derby.iapi.store.access.xa.XAResourceManager.find.

Find the given Xid in the transaction table.

public void
forget(ContextManager
The ContextManager returned from the find() call.
cm
,
Xid
A global transaction identifier.
xid
)

Implements org.apache.derby.iapi.store.access.xa.XAResourceManager.forget.

This method is called to remove the given transaction from the transaction table/log.

public Xid[]

Returns:

Return a array with 0 or more Xid's which are currently in prepared or heuristically completed state. If an error occurs during the operation, an appropriate error is thrown.
recover
(int
combination of the following flags XAResource.{TMSTARTRSCAN,TMENDRSCAN,TMNOFLAGS}. TMNOFLAGS must be used when no other flags are used.
flags
)

Implements org.apache.derby.iapi.store.access.xa.XAResourceManager.recover.

This method is called to obtain a list of prepared transactions.

public void
rollback(ContextManager
The ContextManager returned from the find() call.
cm
,
Xid
A global transaction identifier.
xid
)

Implements org.apache.derby.iapi.store.access.xa.XAResourceManager.rollback.

rollback the transaction identified by Xid.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

rsfback to summary
private RawStoreFactory rsf
transaction_tableback to summary
private TransactionTable transaction_table

Fields of the class

Constructor Detail

XactXAResourceManagerback to summary
public XactXAResourceManager(RawStoreFactory rsf, TransactionTable tt)

Constructors for This class:

Method Detail

commitback to summary
public void commit(ContextManager cm, Xid xid, boolean onePhase) throws StandardException

Implements org.apache.derby.iapi.store.access.xa.XAResourceManager.commit.

This method is called to commit the global transaction specified by xid.

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

Parameters
cm:ContextManager

The ContextManager returned from the find() call.

xid:Xid

A global transaction identifier.

onePhase:boolean

If true, the resource manager should use a one-phase commit protocol to commit the work done on behalf of xid.

Exceptions
StandardException:
Standard exception policy.
findback to summary
public ContextManager find(Xid xid)

Implements org.apache.derby.iapi.store.access.xa.XAResourceManager.find.

Find the given Xid in the transaction table.

This routine is used to find a in-doubt transaction from the list of Xid's returned from the recover() routine.

In the current implementation it is up to the calling routine to make the returned ContextManager the "current" ContextManager before calls to commit,abort, or forget. The caller is responsible for error handling, ie. calling cleanupOnError() on the correct ContextManager.

If the Xid is not in the system, "null" is returned. RESOLVE - find out from sku if she wants a exception instead?

Parameters
xid:Xid

A global transaction identifier.

forgetback to summary
public void forget(ContextManager cm, Xid xid) throws StandardException

Implements org.apache.derby.iapi.store.access.xa.XAResourceManager.forget.

This method is called to remove the given transaction from the transaction table/log.

Used to let the store remove all record from log and transaction table of the given transaction. This should only be used to clean up heuristically completed transactions, otherwise commit or abort should be used to act on other transactions.

Parameters
cm:ContextManager

The ContextManager returned from the find() call.

xid:Xid

A global transaction identifier.

Exceptions
StandardException:
Standard exception policy.
recoverback to summary
public Xid[] recover(int flags) throws StandardException

Implements org.apache.derby.iapi.store.access.xa.XAResourceManager.recover.

This method is called to obtain a list of prepared transactions.

This call returns a complete list of global transactions which are either prepared or heuristically complete.

The XAResource interface expects a scan type interface, but our implementation only returns a complete list of transactions. So to simulate the scan the following state is maintained. If TMSTARTSCAN is specified the complete list is returned. If recover is called with TMNOFLAGS is ever called a 0 length array is returned.

Parameters
flags:int

combination of the following flags XAResource.{TMSTARTRSCAN,TMENDRSCAN,TMNOFLAGS}. TMNOFLAGS must be used when no other flags are used.

Returns:Xid[]

Return a array with 0 or more Xid's which are currently in prepared or heuristically completed state. If an error occurs during the operation, an appropriate error is thrown.

Exceptions
StandardException:
Standard exception policy.
rollbackback to summary
public void rollback(ContextManager cm, Xid xid) throws StandardException

Implements org.apache.derby.iapi.store.access.xa.XAResourceManager.rollback.

rollback the transaction identified by Xid.

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

Parameters
cm:ContextManager

The ContextManager returned from the find() call.

xid:Xid

A global transaction identifier.

Exceptions
StandardException:
Standard exception policy.