Mail Archive Home | jotm-commits List | May 2004 Index
| <-- Date Index --> | <-- Thread Index --> |
Date: Wednesday, May 5, 2004 @ 22:16:41
Author: tonyortiz
Path: /cvsroot/jotm/jotm/src/main/org/objectweb/jotm
Modified: Current.java
support branch id generation in XID
--------------+
Current.java | 174 +++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 152 insertions(+), 22 deletions(-)
Index: jotm/src/main/org/objectweb/jotm/Current.java
diff -u jotm/src/main/org/objectweb/jotm/Current.java:1.36
jotm/src/main/org/objectweb/jotm/Current.java:1.37
--- jotm/src/main/org/objectweb/jotm/Current.java:1.36 Mon May 3 21:49:11
2004
+++ jotm/src/main/org/objectweb/jotm/Current.java Wed May 5 22:16:40
2004
@@ -43,7 +43,7 @@
* 01/12/03 Dean Jennings - synchronizedMap for txXids
*
* --------------------------------------------------------------------------
- * $Id: Current.java,v 1.36 2004/05/03 19:49:11 tonyortiz Exp $
+ * $Id: Current.java,v 1.37 2004/05/05 20:16:40 tonyortiz Exp $
* --------------------------------------------------------------------------
*/
package org.objectweb.jotm;
@@ -55,6 +55,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.Stack;
import java.util.Vector;
import java.util.Enumeration;
@@ -197,14 +198,18 @@
// checks that no transaction is already associated with this thread.
TransactionImpl tx = (TransactionImpl) threadTx.get();
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.get= " + threadTx.toString());
+ }
+
if (tx != null) {
throw new NotSupportedException("Nested transactions not
supported");
}
// builds a new Xid
// - should pass servername + ip addr. (LATER)
- // S.K. XidImpl otid = new XidImpl();
- XidImpl otid = new XidImpl("",0);
+ XidImpl otid = new XidImpl();
+
// creates a new TransactionImpl object
// - May raise SystemException
tx = new TransactionImpl(otid, transactionTimeout);
@@ -225,6 +230,10 @@
// associates transaction with current thread
threadTx.set(tx);
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.set= " + threadTx.toString());
+ }
+
// associates this Tx with the Xid
putTxXid(otid, tx);
@@ -276,7 +285,7 @@
* encounters an unexpected error condition
*/
- public void begin(Xid xid) throws NotSupportedException, SystemException
{
+ public void begin(Xid passxid) throws NotSupportedException,
SystemException {
if (TraceTm.jta.isDebugEnabled()) {
TraceTm.jta.debug("begin inflow transaction, default timeout");
@@ -285,14 +294,21 @@
// checks that no transaction is already associated with this thread.
TransactionImpl tx = (TransactionImpl) threadTx.get();
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.get= " + threadTx.toString());
+ }
+
if (tx != null) {
throw new NotSupportedException("Nested transactions not
supported");
}
+ // stores the passed xid components
+ XidImpl pxid = new XidImpl(passxid);
+
// creates a new TransactionImpl object
// - May raise SystemException
- tx = new TransactionImpl(xid, transactionTimeout);
+ tx = new TransactionImpl(pxid, transactionTimeout);
if (TraceTm.jta.isDebugEnabled()) {
TraceTm.jta.debug("tx=" + tx);
@@ -301,8 +317,12 @@
// associates transaction with current thread
threadTx.set(tx);
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.set= " + threadTx.toString());
+ }
+
// associates this Tx with the Xid
- putTxXid(xid, tx);
+ putTxXid(pxid, tx);
// sets a timer for the transaction
if (timermgr != null) {
@@ -326,7 +346,7 @@
* encounters an unexpected error condition
*/
- public void begin(Xid xid, long timeout) throws NotSupportedException,
SystemException {
+ public void begin(Xid passxid, long timeout) throws
NotSupportedException, SystemException {
if (TraceTm.jta.isDebugEnabled()) {
TraceTm.jta.debug("begin inflow transaction");
@@ -335,14 +355,22 @@
// checks that no transaction is already associated with this thread.
TransactionImpl tx = (TransactionImpl) threadTx.get();
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.get= " + threadTx.toString());
+ }
+
if (tx != null) {
throw new NotSupportedException("Nested transactions not
supported");
}
+
+ // stores the passed xid components
+ XidImpl pxid = new XidImpl(passxid);
+
// creates a new TransactionImpl object
// - May raise SystemException
transactionTimeout = (int) timeout;
- tx = new TransactionImpl(xid, transactionTimeout);
+ tx = new TransactionImpl(pxid, transactionTimeout);
if (TraceTm.jta.isDebugEnabled()) {
TraceTm.jta.debug("tx=" + tx);
@@ -351,8 +379,12 @@
// associates transaction with current thread
threadTx.set(tx);
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.set= " + threadTx.toString());
+ }
+
// associates this Tx with the Xid
- putTxXid(xid, tx);
+ putTxXid(pxid, tx);
// sets a timer for the transaction
if (timermgr != null) {
@@ -450,6 +482,11 @@
// Has not been done in doDetach because we need to
// be in the transactional context for beforeCompletion
threadTx.set(null);
+
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.set= null");
+ }
+
}
}
@@ -480,6 +517,11 @@
}
threadTx.set(null);
+
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.set= null");
+ }
+
// Roll back the transaction. Exceptions may be raised!
tx.rollback();
}
@@ -586,6 +628,11 @@
public Transaction getTransaction() throws SystemException {
Transaction ret = (Transaction) threadTx.get();
+
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.get= " + threadTx.toString());
+ }
+
return ret;
}
@@ -635,6 +682,10 @@
// Check sthat the thread is not already associated to ANOTHER
transaction
Transaction mytx = (Transaction) threadTx.get();
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.get= " + threadTx.toString());
+ }
+
if (mytx != null) {
if (mytx.equals(tobj)) {
if (TraceTm.jta.isDebugEnabled()) {
@@ -655,6 +706,10 @@
// Associates this Tx with the current thread
threadTx.set(tobj);
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.set= " + threadTx.toString());
+ }
+
// attach suspended resources
try {
((TransactionImpl) tobj).doAttach(XAResource.TMRESUME);
@@ -700,6 +755,10 @@
/// TMSUSPEND should be defined in Transaction.
TransactionImpl tx = (TransactionImpl) threadTx.get();
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.get= " + threadTx.toString());
+ }
+
if (tx != null) {
if (TraceTm.jta.isDebugEnabled()) {
@@ -707,6 +766,10 @@
}
tx.doDetach(XAResource.TMSUSPEND);
threadTx.set(null);
+
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.set= null");
+ }
}
return tx;
@@ -974,6 +1037,10 @@
TransactionImpl tx = (TransactionImpl) threadTx.get();
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.get= " + threadTx.toString());
+ }
+
if (tx != null) {
// Free TransactionImpl, if not used only!!!
// This is to avoid memory leaks.
@@ -984,6 +1051,10 @@
// Detaches thread from any transaction
threadTx.set(null);
+
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.set= null");
+ }
}
return;
@@ -1040,6 +1111,10 @@
// if (!isReply) {
threadTx.set(tx);
+
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.set= " + threadTx.toString());
+ }
// }
}
@@ -1079,6 +1154,10 @@
removeTxXid(xid);
threadTx.set(null);
+
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.set= null");
+ }
}
/**
@@ -1094,7 +1173,7 @@
}
/**
- * Get the transaction referenced by Xid.
+ * Get the Xid's of all prepared transactions.
*
* @param xid <code>Xid</code> of the transaction
*/
@@ -1113,18 +1192,61 @@
xidlist = new Vector();
- for (int i=0;i < xidcount; i++) {
- xid = (Xid) txXids.keySet().iterator().next();
+ Set txXidsSet = txXids.keySet();
+
+ synchronized(txXids) {
+
+ Iterator txXidsIterator = txXidsSet.iterator();
+
+ while (txXidsIterator.hasNext()){
+
+ xid = (Xid) txXidsIterator.next();
+ TransactionImpl tx = (TransactionImpl) txXids.get(xid);
+
+ try {
+
+ if (tx.getStatus() == Status.STATUS_PREPARED) {
+ xidlist.add(xid);
+ }
+ } catch (SystemException e) {
+ TraceTm.jotm.error("getPreparedHeuristicsXid system
exception:", e);
+ }
+ }
+ }
+
+ return (Xid[]) xidlist.toArray();
+ }
+
+ /**
+ * Get all Xid's associated with this transaction.
+ *
+ * @param xid <code>Xid</code> of the transaction
+ */
+
+ public Xid[] getAllXid() {
+
+ Vector xidlist;
+ int xidcount;
+ Xid xid;
+
+ xidcount = txXids.size();
+
+ if (xidcount == 0) {
+ return null;
+ }
+
+ xidlist = new Vector();
+
+ Set txXidsSet = txXids.keySet();
+
+ synchronized(txXids) {
- TransactionImpl tx = (TransactionImpl) txXids.get(xid);
+ Iterator txXidsIterator = txXidsSet.iterator();
- try {
- if (tx.getStatus() == Status.STATUS_PREPARED) {
- xidlist.add(xid);
- }
- } catch (SystemException e) {
- TraceTm.jotm.error("getPreparedHeuristicsXid system
exception:", e);
- }
+ while (txXidsIterator.hasNext()){
+ xid = (Xid) txXidsIterator.next();
+ xidlist.add(xid);
+ }
}
return (Xid[]) xidlist.toArray();
@@ -1137,8 +1259,12 @@
public void associateThreadTx(Xid xid) {
- TransactionImpl tx = getTxXid(xid);
- threadTx.set(tx);
+ TransactionImpl tx = getTxXid(xid);
+ threadTx.set(tx);
+
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.set= " + threadTx.toString());
+ }
}
// ------------------------------------------------------------------
@@ -1188,6 +1314,10 @@
void forget() {
threadTx.set(null);
+
+ if (TraceTm.jta.isDebugEnabled()) {
+ TraceTm.jta.debug("threadTx.set= null");
+ }
}
/* Management methods */
| <-- Date Index --> | <-- Thread Index --> |
Powered by MHonArc.
Copyright © 2006-2007, OW2 Consortium | contact | webmaster.