Top Description Fields Constructors Methods
org.apache.derby.impl.drda

pack-priv Class DRDAXAProtocol

extends Object
Class Inheritance
Imports
javax.transaction.xa.XAException, .XAResource, .Xid, org.apache.derby.iapi.jdbc.ResourceAdapter, org.apache.derby.iapi.services.monitor.Monitor, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.iapi.store.access.xa.XAXactId, org.apache.derby.shared.common.reference.MessageId

This class translates DRDA XA protocol from an application requester to XA calls for Derby and then translates the results from Derby to DRDA for return to the application requester. This class requires the use of javax.transaction.xa classes from j2ee, so is separated from DRDAConnThread, because of the additional library requirements

Field Summary

Modifier and TypeField and Description
private DRDAConnThread
private DDMReader
private DDMWriter
private Xid
xid

Holds the Xid of the global transaction associated with the corresponding DRDAConnThread (and connection itself).

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private void
commitLocalTransaction()

Commit local transaction.

private void
commitTransaction(Xid
- XID (formatId = -1 for local transaction)
xid
,
int
- xaflags
xaflags
)

Commit the xa transaction.

private void
commitXATransaction(Xid
- XID
xid
,
int
- xaflags
xaflags
)

Commit the xa transaction.

private void
endXA(Xid
- XID
xid
,
int
- xaflags
xaflags
)

End the xa transaction.

private void
forgetXATransaction(Xid
- XID
xid
)

Forget the xa transaction.

pack-priv ResourceAdapter

Returns:

The ResourceAdapter instance for the underlying database.
getResourceAdapter
()

private XAResource

Returns:

XAResource
getXAResource
()

get XAResource for the connection

protected void
parseSYNCCTL()

Parse SYNCCTL - Parse SYNCCTL command for XAMGR lvl 7

protected int
parseSYNCTYPE()

parse SYNCTYPE for XAMGR lvl 7 return synctype value CodePoint.SYNCTYPE_NEW_UOW -> XAResource.start() CodePoint.SYNCTYPE_END_UOW -> XAResource.end() CodePoint.SYNCTYPE_PREPARE -> XAResource.prepare() CodePoint.SYNCTYPE_MIGRATE -> not supported //SYNCPT MGR LEVEL 5 CodePoint.SYNCTYPE_REQ_COMMIT -> not supported //SYNCPT MGR LEVEL 5 CodePoint.SYNCTYPE_COMMITTED -> XAResource.commit() or local commit for null XID CodePoint.SYNCTYPE_REQ_LOG -> not supported CodePoint.SYNCTYPE_REQ_FORGET -> XAResource.forget() CodePoint.SYNCTYPE_ROLLBACK -> XAResource.rollback() CodePoint.SYNCTYPE_MIGRATED -> not supported CodePoint.SYNCTYPE_INDOUBT -> XAResource.recover();

private int

Returns:

XAFlags value
parseXAFlags
()

parse XAFlags

private long

Returns:

A timeout value.
parseXATimeout
()

Parses a XA transaction timout value.

private Xid
parseXID()

Parse XID formatId -1 translates into a null XID and a local transaction

private void
prepareXATransaction(Xid
- XID
xid
)

Prepare the xa transaction.

private int
processXAException(XAException
- XA Exception
xe
)

return xa exception errorCode.

private void
private void
recoverXA(int xaflags)

Call recover.

pack-priv void
rollbackCurrentTransaction()

This function rollbacks the current global transaction associated with the XAResource or a local transaction.

private void
rollbackLocalTransaction(boolean
Indicates whether the function should send a SYNCCRD response
sendSYNCCRD
)

Rollback a local transaction.

private void
rollbackTransaction(Xid
Xid for rollback for global transaction. If xid formatid is -1 it represents a local transaction
xid
,
boolean
Indicates whether the function should send a SYNCCRD response
sendSYNCCRD
)

Rollback transaction.

private void
rollbackXATransaction(Xid
- XID
xid
,
boolean
Indicates whether the function should send a SYNCCRD response
sendSYNCCRD
)

Rollback the xa transaction.

private void
startXATransaction(Xid
- XID (formatId = -1 for local transaction)
xid
,
int
- xaflags
xaflags
,
long
- The timeout for the global transaction in millis (or -1 if not specified)
xaTimeout
)

Start the xa transaction.

private String

Returns:

- sync type meaning
syncTypeToString
(int syncType)

printable syncType for debug output

private void
writePRPHRCLST(Xid[]
- list of indoubt xa transactions obtained from recover
xids
)

write PRPHRCLST (indoubt list)

private void
writeSYNCCRD(int
- XA Command to send response for see parseSYNCTYPE
synctype
,
int
- return value from XA command
xaRetVal
,
Xid[]
- list of xids to return for recover. null for other commands
xids
)

Write SYNCCRD (SYNCCTL response)

private void
writeXID(Xid
- XID to write
xid
)

write XID

private String

Returns:

printable xaflags for debug output
xaflagsToString
(int xaflags)

printable xaflags

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

connThreadback to summary
private DRDAConnThread connThread
readerback to summary
private DDMReader reader
writerback to summary
private DDMWriter writer
xidback to summary
private Xid xid

Holds the Xid of the global transaction associated with the corresponding DRDAConnThread (and connection itself).

Constructor Detail

DRDAXAProtocolback to summary
pack-priv DRDAXAProtocol(DRDAConnThread connThread)

Method Detail

commitLocalTransactionback to summary
private void commitLocalTransaction() throws DRDAProtocolException

Commit local transaction. Send SYNCCRD response.

commitTransactionback to summary
private void commitTransaction(Xid xid, int xaflags) throws DRDAProtocolException

Commit the xa transaction. Send SYNCCRD response

Parameters
xid:Xid

- XID (formatId = -1 for local transaction)

xaflags:int

- xaflags

commitXATransactionback to summary
private void commitXATransaction(Xid xid, int xaflags) throws DRDAProtocolException

Commit the xa transaction. Send SYNCCRD response.

Parameters
xid:Xid

- XID

xaflags:int

- xaflags

endXAback to summary
private void endXA(Xid xid, int xaflags) throws DRDAProtocolException

End the xa transaction. Send SYNCRRD response

Parameters
xid:Xid

- XID

xaflags:int

- xaflags

forgetXATransactionback to summary
private void forgetXATransaction(Xid xid) throws DRDAProtocolException

Forget the xa transaction. Send SYNCCRD response.

Parameters
xid:Xid

- XID

getResourceAdapterback to summary
pack-priv ResourceAdapter getResourceAdapter()
Returns:ResourceAdapter

The ResourceAdapter instance for the underlying database.

getXAResourceback to summary
private XAResource getXAResource()

get XAResource for the connection

Returns:XAResource

XAResource

parseSYNCCTLback to summary
protected void parseSYNCCTL() throws DRDAProtocolException

Parse SYNCCTL - Parse SYNCCTL command for XAMGR lvl 7

parseSYNCTYPEback to summary
protected int parseSYNCTYPE() throws DRDAProtocolException

parse SYNCTYPE for XAMGR lvl 7 return synctype value CodePoint.SYNCTYPE_NEW_UOW -> XAResource.start() CodePoint.SYNCTYPE_END_UOW -> XAResource.end() CodePoint.SYNCTYPE_PREPARE -> XAResource.prepare() CodePoint.SYNCTYPE_MIGRATE -> not supported //SYNCPT MGR LEVEL 5 CodePoint.SYNCTYPE_REQ_COMMIT -> not supported //SYNCPT MGR LEVEL 5 CodePoint.SYNCTYPE_COMMITTED -> XAResource.commit() or local commit for null XID CodePoint.SYNCTYPE_REQ_LOG -> not supported CodePoint.SYNCTYPE_REQ_FORGET -> XAResource.forget() CodePoint.SYNCTYPE_ROLLBACK -> XAResource.rollback() CodePoint.SYNCTYPE_MIGRATED -> not supported CodePoint.SYNCTYPE_INDOUBT -> XAResource.recover();

parseXAFlagsback to summary
private int parseXAFlags() throws DRDAProtocolException

parse XAFlags

Returns:int

XAFlags value

parseXATimeoutback to summary
private long parseXATimeout() throws DRDAProtocolException

Parses a XA transaction timout value.

Returns:long

A timeout value.

parseXIDback to summary
private Xid parseXID() throws DRDAProtocolException

Parse XID formatId -1 translates into a null XID and a local transaction

prepareXATransactionback to summary
private void prepareXATransaction(Xid xid) throws DRDAProtocolException

Prepare the xa transaction. Send SYNCCRD response.

Parameters
xid:Xid

- XID

processXAExceptionback to summary
private int processXAException(XAException xe)

return xa exception errorCode. print to console for debug output.

Parameters
xe:XAException

- XA Exception

recoverXAback to summary
private void recoverXA() throws DRDAProtocolException
recoverXAback to summary
private void recoverXA(int xaflags) throws DRDAProtocolException

Call recover. Send SYNCCRD response with indoubt list

rollbackCurrentTransactionback to summary
pack-priv void rollbackCurrentTransaction()

This function rollbacks the current global transaction associated with the XAResource or a local transaction. The function should be called only in exceptional cases - like client socket is closed.

rollbackLocalTransactionback to summary
private void rollbackLocalTransaction(boolean sendSYNCCRD) throws DRDAProtocolException

Rollback a local transaction. Optionally send SYNCCRD response.

Parameters
sendSYNCCRD:boolean

Indicates whether the function should send a SYNCCRD response

rollbackTransactionback to summary
private void rollbackTransaction(Xid xid, boolean sendSYNCCRD) throws DRDAProtocolException

Rollback transaction. Optionally send SYNCCRD response.

Parameters
xid:Xid

Xid for rollback for global transaction. If xid formatid is -1 it represents a local transaction

sendSYNCCRD:boolean

Indicates whether the function should send a SYNCCRD response

rollbackXATransactionback to summary
private void rollbackXATransaction(Xid xid, boolean sendSYNCCRD) throws DRDAProtocolException

Rollback the xa transaction. Optionally send SYNCCRD response.

Parameters
xid:Xid

- XID

sendSYNCCRD:boolean

Indicates whether the function should send a SYNCCRD response

startXATransactionback to summary
private void startXATransaction(Xid xid, int xaflags, long xaTimeout) throws DRDAProtocolException

Start the xa transaction. Send SYNCRRD response

Parameters
xid:Xid

- XID (formatId = -1 for local transaction)

xaflags:int

- xaflags

xaTimeout:long

- The timeout for the global transaction in millis (or -1 if not specified)

syncTypeToStringback to summary
private String syncTypeToString(int syncType)

printable syncType for debug output

Returns:String

- sync type meaning

writePRPHRCLSTback to summary
private void writePRPHRCLST(Xid[] xids) throws DRDAProtocolException

write PRPHRCLST (indoubt list)

Parameters
xids:Xid[]

- list of indoubt xa transactions obtained from recover

writeSYNCCRDback to summary
private void writeSYNCCRD(int synctype, int xaRetVal, Xid[] xids) throws DRDAProtocolException

Write SYNCCRD (SYNCCTL response)

Parameters
synctype:int

- XA Command to send response for see parseSYNCTYPE

xaRetVal:int

- return value from XA command

xids:Xid[]

- list of xids to return for recover. null for other commands

writeXIDback to summary
private void writeXID(Xid xid) throws DRDAProtocolException

write XID

Parameters
xid:Xid

- XID to write

xaflagsToStringback to summary
private String xaflagsToString(int xaflags)

printable xaflags

Returns:String

printable xaflags for debug output