[jboss-svn-commits] JBL Code SVN: r5350 - in labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats: arjuna arjuna/coordinator internal/arjuna/coordinator internal/arjuna/template
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Jul 29 03:00:29 EDT 2006
Author: kevin.conner at jboss.com
Date: 2006-07-29 03:00:23 -0400 (Sat, 29 Jul 2006)
New Revision: 5350
Modified:
labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/AtomicAction.java
labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TransactionReaper.java
labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java
labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/coordinator/ReaperThread.java
labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/template/OrderedList.java
labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/template/OrderedListEntry.java
labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/template/OrderedListIterator.java
Log:
New reaper code and fixes or ordered list synchronisation. Includes some debugging
Modified: labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/AtomicAction.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/AtomicAction.java 2006-07-28 22:45:58 UTC (rev 5349)
+++ labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/AtomicAction.java 2006-07-29 07:00:23 UTC (rev 5350)
@@ -37,6 +37,8 @@
import com.arjuna.ats.internal.arjuna.thread.*;
import com.arjuna.ats.arjuna.common.*;
+import java.util.Date;
+
/**
* This is a user-level transaction class, unlike BasicAction. AtomicAction
* takes care of thread-to-action scoping. This is a "one-shot" object, i.e.,
@@ -198,6 +200,7 @@
public int abort ()
{
+ System.out.println("TS_DEBUG: Transaction abort called at " + new Date()) ;
int status = super.cancel();
/*
Modified: labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TransactionReaper.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TransactionReaper.java 2006-07-28 22:45:58 UTC (rev 5349)
+++ labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TransactionReaper.java 2006-07-29 07:00:23 UTC (rev 5350)
@@ -113,8 +113,13 @@
_list = null;
}
- public final long checkingPeriod ()
+ public final synchronized long checkingPeriod ()
{
+ if (_dynamic && (_list.size() > 0))
+ {
+ final ReaperElement head = (ReaperElement)_list.peak() ;
+ return head._absoluteTimeout - System.currentTimeMillis() ;
+ }
return _checkPeriod;
}
@@ -129,12 +134,11 @@
* Timeout is given in milliseconds.
*/
- public final boolean check (long timeout)
+ public final boolean check()
{
if (tsLogger.arjLogger.debugAllowed())
{
- tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ATOMIC_ACTION, "TransactionReaper::check ( "
- + timeout + " )");
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ATOMIC_ACTION, "TransactionReaper::check ()");
}
if (_list.size() == 0)
@@ -151,97 +155,88 @@
{ Long.toString(e._absoluteTimeout) });
}
- if (timeout >= e._absoluteTimeout)
- break;
- else
- {
- iter = null;
- return true;
- }
- }
+ final long now = System.currentTimeMillis() ;
+ System.err.println("TS_DEBUG: Reaper comparing current time " + now + " with transaction lifetime of " + e._absoluteTimeout) ;
- iter = null;
-
- if (e != null)
- {
- /*
- * Only force rollback if the transaction is still running.
- */
-
- if (e._control.running())
+ if (now >= e._absoluteTimeout)
{
- /*
- * If this is a local transaction, then we can roll it back
- * completely. Otherwise, just mark it as rollback only.
- */
+ if (e._control.running())
+ {
+ /*
+ * If this is a local transaction, then we can roll it back
+ * completely. Otherwise, just mark it as rollback only.
+ */
- boolean problem = false;
+ boolean problem = false;
- try
- {
- if (e._control.cancel() == ActionStatus.ABORTED)
+ try
{
- if (tsLogger.arjLoggerI18N.debugAllowed())
+ if (e._control.cancel() == ActionStatus.ABORTED)
{
- tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ATOMIC_ACTION, "com.arjuna.ats.arjuna.coordinator.TransactionReaper_3", new Object[]
- { e._control.get_uid() });
+ if (tsLogger.arjLoggerI18N.debugAllowed())
+ {
+ tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ATOMIC_ACTION, "com.arjuna.ats.arjuna.coordinator.TransactionReaper_3", new Object[]
+ { e._control.get_uid() });
+ }
}
+ else
+ problem = true;
}
- else
- problem = true;
- }
- catch (Exception ex2)
- {
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ catch (Exception ex2)
{
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.coordinator.TransactionReaper_4", new Object[]
- { e._control });
- }
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ {
+ tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.coordinator.TransactionReaper_4", new Object[]
+ { e._control });
+ }
- problem = true;
- }
-
- if (problem)
- {
- boolean error = false;
- boolean printDebug = tsLogger.arjLoggerI18N.isWarnEnabled();
-
- try
- {
- error = !e._control.preventCommit();
+ problem = true;
}
- catch (Exception ex3)
- {
- error = true;
- }
- if (error || printDebug)
+ if (problem)
{
- if (error)
+ boolean error = false;
+ boolean printDebug = tsLogger.arjLoggerI18N.isWarnEnabled();
+
+ try
{
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
- {
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.coordinator.TransactionReaper_5", new Object[]
- { e._control });
- }
+ error = !e._control.preventCommit();
}
- else
+ catch (Exception ex3)
{
- if (tsLogger.arjLoggerI18N.debugAllowed())
+ error = true;
+ }
+
+ if (error || printDebug)
+ {
+ if (error)
{
- tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ATOMIC_ACTION, "com.arjuna.ats.arjuna.coordinator.TransactionReaper_3", new Object[]
- { e._control });
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ {
+ tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.coordinator.TransactionReaper_5", new Object[]
+ { e._control });
+ }
}
+ else
+ {
+ if (tsLogger.arjLoggerI18N.debugAllowed())
+ {
+ tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ATOMIC_ACTION, "com.arjuna.ats.arjuna.coordinator.TransactionReaper_3", new Object[]
+ { e._control });
+ }
+ }
}
}
}
- }
- _list.remove(e);
+ _list.remove(e);
+ }
+ else
+ {
+ break;
+ }
}
- System.gc(); // do some garbage collection while we're at it!
-
return true;
}
@@ -275,24 +270,25 @@
if (timeout == 0)
return true;
- TransactionReaper._lifetime += timeout;
-
- /*
- * If the timeout for this transaction is less than the current timeout
- * for the reaper thread (or one is not set for the reaper thread) then
- * use that timeout and interrupt the thread to get it to recheck.
- */
-
- if ((timeout < _checkPeriod) || (_checkPeriod == Long.MAX_VALUE))
- {
- _checkPeriod = timeout * 1000; // convert to milliseconds!
- TransactionReaper._reaperThread.interrupt();
- }
-
ReaperElement e = new ReaperElement(control, timeout);
synchronized (this)
{
+ TransactionReaper._lifetime += timeout;
+
+ /*
+ * If the timeout for this transaction is less than the current timeout
+ * for the reaper thread (or one is not set for the reaper thread) then
+ * use that timeout and interrupt the thread to get it to recheck.
+ */
+
+ final long timeoutms = timeout*1000 ;
+ if ((timeoutms < _checkPeriod) || (_checkPeriod == Long.MAX_VALUE))
+ {
+ _checkPeriod = timeoutms ; // convert to milliseconds!
+ TransactionReaper._reaperThread.interrupt();
+ }
+
if (_list.insert(e))
return true;
else
@@ -491,7 +487,7 @@
* Don't bother synchronizing as this is only an estimate anyway.
*/
- public static final long transactionLifetime ()
+ public static final synchronized long transactionLifetime ()
{
return TransactionReaper._lifetime;
}
Modified: labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java 2006-07-28 22:45:58 UTC (rev 5349)
+++ labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java 2006-07-29 07:00:23 UTC (rev 5350)
@@ -37,6 +37,8 @@
import com.arjuna.ats.internal.arjuna.template.*;
+import java.util.Date;
+
/**
* Adds support for synchronizations to BasicAction. It does not change thread
* associations either. It also allows any thread to terminate a transaction,
@@ -96,6 +98,7 @@
public int cancel ()
{
+ System.err.println("TS_DEBUG: Transaction cancel called at " + new Date()) ;
if (parent() != null)
parent().removeChildAction(this);
Modified: labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/coordinator/ReaperThread.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/coordinator/ReaperThread.java 2006-07-28 22:45:58 UTC (rev 5349)
+++ labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/coordinator/ReaperThread.java 2006-07-29 07:00:23 UTC (rev 5350)
@@ -34,8 +34,6 @@
import com.arjuna.ats.arjuna.logging.tsLogger;
import com.arjuna.ats.arjuna.logging.FacilityCode;
-import com.arjuna.ats.arjuna.coordinator.BasicAction;
-import com.arjuna.ats.arjuna.coordinator.ActionStatus;
import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
import com.arjuna.common.util.logging.*;
@@ -86,55 +84,54 @@
{
sleepPeriod = reaperObject.checkingPeriod();
- long oldPeriod = sleepPeriod;
- long beforeTime = System.currentTimeMillis();
-
- try
+ if (sleepPeriod > 0)
{
- if (tsLogger.arjLoggerI18N.debugAllowed())
- {
- tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_ATOMIC_ACTION,
- "com.arjuna.ats.internal.arjuna.coordinator.ReaperThread_1",
- new Object[]{Thread.currentThread(),
- Long.toString(sleepPeriod)});
- }
+ long beforeTime = System.currentTimeMillis();
- Thread.sleep(sleepPeriod);
+ try
+ {
+ if (tsLogger.arjLoggerI18N.debugAllowed())
+ {
+ tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_ATOMIC_ACTION,
+ "com.arjuna.ats.internal.arjuna.coordinator.ReaperThread_1",
+ new Object[]{Thread.currentThread(),
+ Long.toString(sleepPeriod)});
+ }
- done = true;
- }
- catch (InterruptedException e1)
- {
- /*
- * Has timeout been changed?
- */
+ System.out.println("TS_DEBUG: Reaper thread will sleep for " + sleepPeriod) ;
- if (reaperObject.checkingPeriod() != oldPeriod)
- {
- done = true;
- }
- else
- {
- long afterTime = System.currentTimeMillis();
+ Thread.sleep(sleepPeriod);
- if (afterTime - beforeTime < reaperObject.checkingPeriod())
+ done = true;
+ }
+ catch (InterruptedException e1)
{
- done = true;
+ long afterTime = System.currentTimeMillis();
+
+ if (afterTime - beforeTime > reaperObject.checkingPeriod())
+ {
+ done = true;
+ }
+ }
+ catch (Exception e2)
+ {
+ done = true;
}
- }
}
- catch (Exception e2)
+ else
{
- done = true;
+ done = true ;
}
}
if (_shutdown)
return;
- reaperObject.check(System.currentTimeMillis());
+ System.out.println("TS_DEBUG: ReaperThread checking state of transactions") ;
+ reaperObject.check();
+
if (reaperObject.numberOfTransactions() == 0)
{
sleepPeriod = Long.MAX_VALUE;
Modified: labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/template/OrderedList.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/template/OrderedList.java 2006-07-28 22:45:58 UTC (rev 5349)
+++ labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/template/OrderedList.java 2006-07-29 07:00:23 UTC (rev 5350)
@@ -217,20 +217,16 @@
{
if (ptr.car() == element) // we mean '==' rather than equals
{
- OrderedListEntry oldcons = ptr;
-
// unlink the cons cell for the element we're removing
if (prev != null)
prev.setfCdr(ptr.cdr());
else
_headOfList = ptr.cdr();
+ ptr.setfCdr(null) ;
_entryCount--;
- // flush the dead cons cell
- oldcons = null;
-
return true;
}
}
@@ -250,6 +246,7 @@
OrderedListElement p = _headOfList.car();
_headOfList = remove.cdr();
+ remove.setfCdr(null) ;
_entryCount--;
remove = null;
@@ -260,6 +257,20 @@
return null;
}
+ public final synchronized OrderedListElement peak()
+ {
+ if (_headOfList != null)
+ {
+ return _headOfList.car();
+ }
+ return null;
+ }
+
+ final synchronized OrderedListEntry head()
+ {
+ return _headOfList;
+ }
+
/**
* Empty the list.
*/
@@ -283,8 +294,8 @@
return _entryCount;
}
-protected OrderedListEntry _headOfList;
-protected long _entryCount;
+private OrderedListEntry _headOfList;
+private long _entryCount;
private boolean _increasing;
Modified: labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/template/OrderedListEntry.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/template/OrderedListEntry.java 2006-07-28 22:45:58 UTC (rev 5349)
+++ labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/template/OrderedListEntry.java 2006-07-29 07:00:23 UTC (rev 5350)
@@ -51,17 +51,17 @@
return _theElement;
}
-public final OrderedListEntry cdr ()
+public synchronized final OrderedListEntry cdr ()
{
return _next;
}
-public final void setfCdr (OrderedListEntry n)
+public synchronized final void setfCdr (OrderedListEntry n)
{
_next = n;
}
-private OrderedListElement _theElement;
+private final OrderedListElement _theElement;
private OrderedListEntry _next;
};
Modified: labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/template/OrderedListIterator.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/template/OrderedListIterator.java 2006-07-28 22:45:58 UTC (rev 5349)
+++ labs/jbosstm/branches/JBOSSTS_4_2_GA_MP2/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/template/OrderedListIterator.java 2006-07-29 07:00:23 UTC (rev 5350)
@@ -48,7 +48,7 @@
public OrderedListIterator (OrderedList L)
{
- ptr = L._headOfList;
+ ptr = L.head();
}
public void finalize ()
@@ -60,7 +60,7 @@
* Return the next item in the list.
*/
-public synchronized OrderedListElement iterate ()
+public OrderedListElement iterate ()
{
if (ptr != null)
{
More information about the jboss-svn-commits
mailing list