Class DRDAXAProtocol
java.lang.Object
org.apache.derby.impl.drda.DRDAXAProtocol
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
FieldsModifier and TypeFieldDescriptionprivate DRDAConnThreadprivate DDMReaderprivate DDMWriterprivate XidHolds the Xid of the global transaction associated with the corresponding DRDAConnThread (and connection itself). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidCommit local transaction.private voidcommitTransaction(Xid xid, int xaflags) Commit the xa transaction.private voidcommitXATransaction(Xid xid, int xaflags) Commit the xa transaction.private voidEnd the xa transaction.private voidforgetXATransaction(Xid xid) Forget the xa transaction.(package private) ResourceAdapterprivate XAResourceget XAResource for the connectionprotected voidParse SYNCCTL - Parse SYNCCTL command for XAMGR lvl 7protected intparse 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 intparse XAFlagsprivate longParses a XA transaction timout value.private XidparseXID()Parse XID formatId -1 translates into a null XID and a local transactionprivate voidprepareXATransaction(Xid xid) Prepare the xa transaction.private intreturn xa exception errorCode. print to console for debug output.private voidprivate voidrecoverXA(int xaflags) Call recover.(package private) voidThis function rollbacks the current global transaction associated with the XAResource or a local transaction.private voidrollbackLocalTransaction(boolean sendSYNCCRD) Rollback a local transaction.private voidrollbackTransaction(Xid xid, boolean sendSYNCCRD) Rollback transaction.private voidrollbackXATransaction(Xid xid, boolean sendSYNCCRD) Rollback the xa transaction.private voidstartXATransaction(Xid xid, int xaflags, long xaTimeout) Start the xa transaction.private StringsyncTypeToString(int syncType) printable syncType for debug outputprivate voidwritePRPHRCLST(Xid[] xids) write PRPHRCLST (indoubt list)private voidwriteSYNCCRD(int synctype, int xaRetVal, Xid[] xids) Write SYNCCRD (SYNCCTL response)private voidwrite XIDprivate StringxaflagsToString(int xaflags) printable xaflags
-
Field Details
-
connThread
-
reader
-
writer
-
xid
Holds the Xid of the global transaction associated with the corresponding DRDAConnThread (and connection itself).
-
-
Constructor Details
-
DRDAXAProtocol
DRDAXAProtocol(DRDAConnThread connThread)
-
-
Method Details
-
parseSYNCCTL
Parse SYNCCTL - Parse SYNCCTL command for XAMGR lvl 7- Throws:
DRDAProtocolException
-
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();- Throws:
DRDAProtocolException
-
parseXID
Parse XID formatId -1 translates into a null XID and a local transaction- Throws:
DRDAProtocolException
-
parseXAFlags
parse XAFlags- Returns:
- XAFlags value
- Throws:
DRDAProtocolException
-
parseXATimeout
Parses a XA transaction timout value.- Returns:
- A timeout value.
- Throws:
DRDAProtocolException
-
startXATransaction
Start the xa transaction. Send SYNCRRD response- Parameters:
xid- - XID (formatId = -1 for local transaction)xaflags- - xaflagsxaTimeout- - The timeout for the global transaction in millis (or -1 if not specified)- Throws:
DRDAProtocolException
-
commitTransaction
Commit the xa transaction. Send SYNCCRD response- Parameters:
xid- - XID (formatId = -1 for local transaction)xaflags- - xaflags- Throws:
DRDAProtocolException
-
commitLocalTransaction
Commit local transaction. Send SYNCCRD response.- Throws:
DRDAProtocolException
-
commitXATransaction
Commit the xa transaction. Send SYNCCRD response.- Parameters:
xid- - XIDxaflags- - xaflags- Throws:
DRDAProtocolException
-
rollbackTransaction
Rollback transaction. Optionally send SYNCCRD response.- Parameters:
xid- Xid for rollback for global transaction. If xid formatid is -1 it represents a local transactionsendSYNCCRD- Indicates whether the function should send a SYNCCRD response- Throws:
DRDAProtocolException
-
rollbackLocalTransaction
Rollback a local transaction. Optionally send SYNCCRD response.- Parameters:
sendSYNCCRD- Indicates whether the function should send a SYNCCRD response- Throws:
DRDAProtocolException
-
rollbackXATransaction
Rollback the xa transaction. Optionally send SYNCCRD response.- Parameters:
xid- - XIDsendSYNCCRD- Indicates whether the function should send a SYNCCRD response- Throws:
DRDAProtocolException
-
endXA
End the xa transaction. Send SYNCRRD response- Parameters:
xid- - XIDxaflags- - xaflags- Throws:
DRDAProtocolException
-
prepareXATransaction
Prepare the xa transaction. Send SYNCCRD response.- Parameters:
xid- - XID- Throws:
DRDAProtocolException
-
forgetXATransaction
Forget the xa transaction. Send SYNCCRD response.- Parameters:
xid- - XID- Throws:
DRDAProtocolException
-
recoverXA
- Throws:
DRDAProtocolException
-
recoverXA
Call recover. Send SYNCCRD response with indoubt list- Throws:
DRDAProtocolException
-
writeSYNCCRD
Write SYNCCRD (SYNCCTL response)- Parameters:
synctype- - XA Command to send response for see parseSYNCTYPExaRetVal- - return value from XA commandxids- - list of xids to return for recover. null for other commands- Throws:
DRDAProtocolException
-
writePRPHRCLST
write PRPHRCLST (indoubt list)- Parameters:
xids- - list of indoubt xa transactions obtained from recover- Throws:
DRDAProtocolException
-
writeXID
write XID- Parameters:
xid- - XID to write- Throws:
DRDAProtocolException
-
getXAResource
-
syncTypeToString
printable syncType for debug output- Parameters:
syncType-- Returns:
- - sync type meaning
-
xaflagsToString
printable xaflags- Parameters:
xaflags-- Returns:
- printable xaflags for debug output
-
processXAException
return xa exception errorCode. print to console for debug output.- Parameters:
xe- - XA Exception
-
getResourceAdapter
ResourceAdapter getResourceAdapter()- Returns:
- The ResourceAdapter instance for the underlying database.
-
rollbackCurrentTransaction
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.
-