[jboss-svn-commits] JBL Code SVN: r37813 - labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Dec 15 11:56:59 EST 2011
Author: tomjenkinson
Date: 2011-12-15 11:56:59 -0500 (Thu, 15 Dec 2011)
New Revision: 37813
Modified:
labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
Log:
JBTM-895 updated so that retrieving an XAResource triggers garbage collection, this is required because garbage collecting the XA resources in a bottom up scenario (e.g. resourceInitiatedRecoveryForRecoveryHelpers) means that any xids that are not eligible for recovery after the first scan may be removed as stale and due to the undocumented _xidScans check above will not be reloaded
Modified: labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java 2011-12-15 16:28:23 UTC (rev 37812)
+++ labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java 2011-12-15 16:56:59 UTC (rev 37813)
@@ -135,15 +135,24 @@
return _whenFirstSeen.containsKey(xidImple);
}
-
- public boolean isStale() {
- long now = System.currentTimeMillis();
- long threshold = _lastValidated+(2*safetyIntervalMillis);
- long diff = now - threshold;
- boolean result = diff > 0;
- return result;
+
+ public boolean remove (Xid xid)
+ {
+ XidImple xidImple = new XidImple(xid);
+
+ if (_whenFirstSeen.containsKey(xidImple)) {
+ _whenFirstSeen.remove(xidImple);
+ _whenLastSeen.remove(xidImple);
+ return true;
+ } else {
+ return false;
+ }
}
+ public boolean isEmpty() {
+ return _whenFirstSeen.isEmpty();
+ }
+
/**
* If supplied xids contains any values seen on prev scans, replace the existing
* XAResource with the supplied one and return true. Otherwise, return false.
Modified: labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2011-12-15 16:28:23 UTC (rev 37812)
+++ labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2011-12-15 16:56:59 UTC (rev 37813)
@@ -196,6 +196,10 @@
bottomUpRecovery();
}
+ // JBTM-895 updated so that retrieving an XAResource triggers garbage collection, this is required because garbage collecting
+ // The XA resources in a bottom up scenario (e.g. resourceInitiatedRecoveryForRecoveryHelpers) means that any xids that are
+ // not eligible for recovery after the first scan may be removed as stale and due to the undocumented _xidScans check above will not be
+ // reloaded
if (_xidScans != null)
{
Enumeration<XAResource> keys = _xidScans.keys();
@@ -205,8 +209,12 @@
XAResource theKey = keys.nextElement();
RecoveryXids xids = _xidScans.get(theKey);
- if (xids.contains(xid))
+ if (xids.remove(xid)) {
+ if (xids.isEmpty()) {
+ _xidScans.remove(theKey);
+ }
return theKey;
+ }
}
}
@@ -364,6 +372,11 @@
return true;
}
+ /**
+ *
+ * JBTM-895 garbage collection is now done when we return XAResources {@see XARecoveryModule#getNewXAResource(XAResourceRecord)}
+ * @see XARecoveryModule#getNewXAResource(XAResourceRecord)
+ */
private void bottomUpRecovery() {
// scan using statically configured plugins;
@@ -371,16 +384,7 @@
// scan using dynamically configured plugins:
resourceInitiatedRecoveryForRecoveryHelpers();
- // garbage collection:
- if (_xidScans != null) {
- Set<XAResource> keys = new HashSet<XAResource>(_xidScans.keySet());
- for(XAResource theKey : keys) {
- RecoveryXids recoveryXids = _xidScans.get(theKey);
- if(recoveryXids.isStale()) {
- _xidScans.remove(theKey);
- }
- }
- }
+ // JBTM-895 garbage collection is now done when we return XAResources {@see XARecoveryModule#getNewXAResource(XAResourceRecord)}
}
/**
More information about the jboss-svn-commits
mailing list