[jboss-svn-commits] JBL Code SVN: r37883 - labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP12_JBTM-842_JBTM-924/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 Feb 9 09:10:01 EST 2012
Author: raggz
Date: 2012-02-09 09:10:01 -0500 (Thu, 09 Feb 2012)
New Revision: 37883
Modified:
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP12_JBTM-842_JBTM-924/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP12_JBTM-842_JBTM-924/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
Log:
JBPAPP-8081 (Backport of JBTM-924)
Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP12_JBTM-842_JBTM-924/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP12_JBTM-842_JBTM-924/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java 2012-02-09 13:54:37 UTC (rev 37882)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP12_JBTM-842_JBTM-924/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/RecoveryXids.java 2012-02-09 14:10:01 UTC (rev 37883)
@@ -41,7 +41,8 @@
public RecoveryXids (XAResource xares)
{
- _xares = xares;
+ _xares = xares;
+ _lastValidated = System.currentTimeMillis();
}
public boolean equals (Object obj)
@@ -135,6 +136,14 @@
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;
+ }
+
/**
* If supplied xids contains any values seen on prev scans, replace the existing
* XAResource with the supplied one and return true. Otherwise, return false.
@@ -149,6 +158,7 @@
for(int i = 0; i < xids.length; i++) {
if(contains(xids[i])) {
_xares = xaResource;
+ _lastValidated = System.currentTimeMillis();
return true;
}
}
@@ -158,6 +168,7 @@
// so fallback to isSameRM as we can't use Xid matching
if(isSameRM(xaResource)) {
_xares = xaResource;
+ _lastValidated = System.currentTimeMillis();
return true;
}
@@ -170,6 +181,7 @@
private final Map<XidImple,Long> _whenLastSeen = new HashMap<XidImple, Long>();
private XAResource _xares;
+ private long _lastValidated;
private static final int safetyIntervalMillis = 10000; // may eventually want to make this configurable?
}
\ No newline at end of file
Modified: labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP12_JBTM-842_JBTM-924/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP12_JBTM-842_JBTM-924/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2012-02-09 13:54:37 UTC (rev 37882)
+++ labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP12_JBTM-842_JBTM-924/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2012-02-09 14:10:01 UTC (rev 37883)
@@ -94,7 +94,6 @@
}
}
-
/**
* @message com.arjuna.ats.internal.jta.recovery.xafirstpass {0} - first
* pass
@@ -193,13 +192,8 @@
+ ".transactionInitiatedRecovery completed");
}
- /*
- * See the comment about this routine!!
- */
+ bottomUpRecovery();
- resourceInitiatedRecovery();
- resourceInitiatedRecoveryForRecoveryHelpers();
-
if (jtaLogger.logger.isDebugEnabled())
{
jtaLogger.logger.debug(DebugLevel.FUNCTIONS,
@@ -241,8 +235,7 @@
public XAResource getNewXAResource(Xid xid)
{
if (_xidScans == null) {
- resourceInitiatedRecovery();
- resourceInitiatedRecoveryForRecoveryHelpers();
+ bottomUpRecovery();
}
if (_xidScans != null)
@@ -486,6 +479,8 @@
{
if (recoveryStatus == XARecoveryResource.WAITING_FOR_RECOVERY)
{
+ // resource initiated recovery not possible (no distribution).
+
problem = false;
if (jtaLogger.loggerI18N
@@ -613,6 +608,25 @@
return true;
}
+ private void bottomUpRecovery() {
+
+ // scan using statically configured plugins;
+ resourceInitiatedRecovery();
+ // 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);
+ }
+ }
+ }
+ }
+
/**
* Now check for any outstanding transactions. If we didn't fail to recover
* them, then roll them back - if they'd got through prepare we would have
More information about the jboss-svn-commits
mailing list