[jboss-svn-commits] JBL Code SVN: r36765 - labs/jbosstm/trunk/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 Mar 1 09:30:42 EST 2011
Author: jhalliday
Date: 2011-03-01 09:30:41 -0500 (Tue, 01 Mar 2011)
New Revision: 36765
Modified:
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
Log:
Update XAResource recovery scan correlation. JBTM-827
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java 2011-03-01 11:37:42 UTC (rev 36764)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java 2011-03-01 14:30:41 UTC (rev 36765)
@@ -192,15 +192,20 @@
*/
public boolean updateIfEquivalentRM(XAResource xaResource, Xid[] xids)
{
- if(xids == null || xids.length == 0) {
- return false;
+ if(xids != null && xids.length > 0) {
+ for(int i = 0; i < xids.length; i++) {
+ if(contains(xids[i])) {
+ _xares = xaResource;
+ return true;
+ }
+ }
}
- for(int i = 0; i < xids.length; i++) {
- if(contains(xids[i])) {
- _xares = xaResource;
- return true;
- }
+ // either (or both) passes have an empty Xid set,
+ // so fallback to isSameRM as we can't use Xid matching
+ if(isSameRM(xaResource)) {
+ _xares = xaResource;
+ return true;
}
return false;
Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2011-03-01 11:37:42 UTC (rev 36764)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2011-03-01 14:30:41 UTC (rev 36765)
@@ -36,7 +36,6 @@
import com.arjuna.ats.arjuna.objectstore.StoreManager;
import com.arjuna.ats.arjuna.state.*;
import com.arjuna.ats.arjuna.objectstore.StateStatus;
-import com.arjuna.ats.arjuna.coordinator.TxControl;
import com.arjuna.ats.arjuna.recovery.RecoveryModule;
@@ -188,12 +187,12 @@
if (_xidScans != null)
{
- Enumeration keys = _xidScans.keys();
+ Enumeration<XAResource> keys = _xidScans.keys();
while (keys.hasMoreElements())
{
- XAResource theKey = (XAResource) keys.nextElement();
- RecoveryXids xids = (RecoveryXids) _xidScans.get(theKey);
+ XAResource theKey = keys.nextElement();
+ RecoveryXids xids = _xidScans.get(theKey);
if (xids.contains(xid))
return theKey;
@@ -491,21 +490,24 @@
RecoveryXids xidsToRecover = null;
if (_xidScans == null)
- _xidScans = new Hashtable();
+ _xidScans = new Hashtable<XAResource,RecoveryXids>();
else
{
refreshXidScansForEquivalentXAResourceImpl(xares, trans);
- xidsToRecover = (RecoveryXids) _xidScans.get(xares);
+ xidsToRecover = _xidScans.get(xares);
if (xidsToRecover == null)
{
- java.util.Enumeration elements = _xidScans.elements();
+ // this is probably redundant now due to updateIfEquivalentRM,
+ // but in some implementations hashcode/equals does not behave itself.
+
+ java.util.Enumeration<RecoveryXids> elements = _xidScans.elements();
boolean found = false;
while (elements.hasMoreElements())
{
- xidsToRecover = (RecoveryXids) elements.nextElement();
+ xidsToRecover = elements.nextElement();
if (xidsToRecover.isSameRM(xares))
{
@@ -706,24 +708,16 @@
*/
private void refreshXidScansForEquivalentXAResourceImpl(XAResource xares, Xid[] xids)
{
- if(xids == null || xids.length == 0) {
- return;
- }
+ Set<XAResource> keys = new HashSet<XAResource>(_xidScans.keySet());
- Enumeration keys = _xidScans.keys();
+ for(XAResource theKey : keys) {
+ RecoveryXids recoveryXids = _xidScans.get(theKey);
- 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;
+ _xidScans.put(xares, recoveryXids);
}
}
}
@@ -835,7 +829,7 @@
private Hashtable _failures = null;
- private Hashtable _xidScans = null;
+ private Hashtable<XAResource,RecoveryXids> _xidScans = null;
private XARecoveryResourceManager _recoveryManagerClass = null;
More information about the jboss-svn-commits
mailing list