[jboss-svn-commits] JBL Code SVN: r28904 - labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Aug 11 12:03:41 EDT 2009


Author: jhalliday
Date: 2009-08-11 12:03:40 -0400 (Tue, 11 Aug 2009)
New Revision: 28904

Modified:
   labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
   labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
Log:
Patch for handling XARecovery across XAResource boundaries. JBTM-602


Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java	2009-08-11 14:02:56 UTC (rev 28903)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java	2009-08-11 16:03:40 UTC (rev 28904)
@@ -178,6 +178,30 @@
 	return false;
     }
 	
+    /**
+     * If supplied xids contains any values seen on prev scans, replace the existing
+     * XAResource with the supplied one and return true. Otherwise, return false.
+     *
+     * @param xaResource
+     * @param xids
+     * @return
+     */
+    public boolean updateIfEquivalentRM(XAResource xaResource, Xid[] xids)
+    {
+        if(xids == null || xids.length == 0) {
+            return false;
+        }
+
+        for(int i = 0; i < xids.length; i++) {
+            if(contains(xids[i])) {
+                _xares = xaResource;
+                return true;
+            }
+        }
+
+        return false;
+    }
+
     private Xid[]      _scanN;
     private Xid[]      _scanM;
     private XAResource _xares;

Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java	2009-08-11 14:02:56 UTC (rev 28903)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java	2009-08-11 16:03:40 UTC (rev 28904)
@@ -807,6 +807,8 @@
 				_xidScans = new Hashtable();
 			else
 			{
+                refreshXidScansForEquivalentXAResourceImpl(xares, trans);
+                
 				xidsToRecover = (RecoveryXids) _xidScans.get(xares);
 
 				if (xidsToRecover == null)
@@ -1165,6 +1167,39 @@
 		return true;
 	}
 
+    /**
+     * For some drivers, isSameRM is connection specific. If we have prev scan results
+     * for the same RM but using a different connection, we need to be able to identify them.
+     * Look at the data from previous scans, identify any for the same RM but different XAResource
+     * by checking for matching Xids, then replace the old XAResource with the supplied one.
+     *
+     * @param xares
+     * @param xids
+     */
+    private void refreshXidScansForEquivalentXAResourceImpl(XAResource xares, Xid[] xids)
+    {
+        if(xids == null || xids.length == 0) {
+            return;
+        }
+
+        Enumeration keys = _xidScans.keys();
+
+        while (keys.hasMoreElements())
+        {
+            XAResource theKey = (XAResource) keys.nextElement();
+            RecoveryXids recoveryXids = (RecoveryXids) _xidScans.get(theKey);
+
+            if(recoveryXids.updateIfEquivalentRM(xares, xids)) {
+                // recoveryXids is for this xares, but was originally obtained using
+                // a different XAResource. rekey the hashtable to use the new one.
+                _xidScans.remove(theKey);
+                theKey = xares;
+                _xidScans.put(theKey, recoveryXids);
+                break;
+            }
+        }
+    }
+
 	/**
 	 * Is there a log file for this transaction?
 	 *



More information about the jboss-svn-commits mailing list