[jboss-svn-commits] JBL Code SVN: r30066 - in labs/jbosstm/trunk/ArjunaCore: txoj/classes/com/arjuna/ats/internal/txoj and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Nov 6 15:27:50 EST 2009
Author: mark.little at jboss.com
Date: 2009-11-06 15:27:50 -0500 (Fri, 06 Nov 2009)
New Revision: 30066
Added:
labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/LockFriend.java
labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/LockList.java
labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/LockListIterator.java
Removed:
labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java
labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/StateManagerFriend.java
labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/Lock.java
labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockManager.java
Log:
https://jira.jboss.org/jira/browse/JBTM-647
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/StateManagerFriend.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/StateManagerFriend.java 2009-11-06 19:33:59 UTC (rev 30065)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/StateManagerFriend.java 2009-11-06 20:27:50 UTC (rev 30066)
@@ -36,12 +36,20 @@
import com.arjuna.ats.arjuna.StateManager;
import com.arjuna.ats.arjuna.coordinator.BasicAction;
+import com.arjuna.ats.arjuna.logging.tsLogger;
/**
* Some StateManager methods really shouldn't be available to users to call inadvertently. In
* C++ valid users (specific AbstractRecord instances) were friends of StateManager.
*/
+/**
+ * @message com.arjuna.ats.internal.arjuna.abstractrecords.smf1
+ * [com.arjuna.ats.internal.arjuna.abstractrecords.smf1] - StateManagerFriend.forgetAction
+ * @message com.arjuna.ats.internal.arjuna.abstractrecords.smf2
+ * [com.arjuna.ats.internal.arjuna.abstractrecords.smf2] - StateManagerFriend.destroyed
+ */
+
public class StateManagerFriend
{
public static final boolean forgetAction (StateManager inst,
@@ -59,17 +67,30 @@
}
catch (final Throwable ex)
{
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ tsLogger.arjLoggerI18N
+ .warn("com.arjuna.ats.internal.arjuna.abstractrecords.smf1", ex);
+
return false;
}
}
- public static final void destroyed (StateManager inst) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
+ public static final void destroyed (StateManager inst) //throws NoSuchMethodException, InvocationTargetException, IllegalAccessException
{
- Method m = StateManager.class.getDeclaredMethod("destroyed", (Class[]) null);
-
- m.setAccessible(true);
- m.invoke(inst, (Object[]) null);
- m.setAccessible(false);
+ try
+ {
+ Method m = StateManager.class.getDeclaredMethod("destroyed", (Class[]) null);
+
+ m.setAccessible(true);
+ m.invoke(inst, (Object[]) null);
+ m.setAccessible(false);
+ }
+ catch (final Throwable ex)
+ {
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ tsLogger.arjLoggerI18N
+ .warn("com.arjuna.ats.internal.arjuna.abstractrecords.smf2", ex);
+ }
}
private StateManagerFriend()
Added: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/LockFriend.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/LockFriend.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/LockFriend.java 2009-11-06 20:27:50 UTC (rev 30066)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 1998, 1999, 2000,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: LockList.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.arjuna.ats.internal.txoj;
+
+import java.lang.reflect.Method;
+
+import com.arjuna.ats.txoj.Lock;
+import com.arjuna.ats.txoj.logging.txojLogger;
+
+/**
+ * A friend of Lock.
+ *
+ * @author marklittle
+ */
+
+/**
+ * @message com.arjuna.ats.internal.txoj.lmf1
+ * [com.arjuna.ats.internal.txoj.lmf1] - LockManagerFriend.getLink
+ * @message com.arjuna.ats.internal.txoj.lmf2
+ * [com.arjuna.ats.internal.txoj.lmf2] - LockManagerFriend.setLink
+ */
+
+public class LockFriend
+{
+ public static final Lock getLink (Lock inst)
+ {
+ try
+ {
+ Method m = Lock.class.getDeclaredMethod("getLink", (Class[]) null);
+
+ m.setAccessible(true);
+ Lock l = (Lock) m.invoke(inst, (Object[]) null);
+ m.setAccessible(false);
+
+ return l;
+ }
+ catch (final Throwable ex)
+ {
+ if (txojLogger.aitLoggerI18N.isWarnEnabled())
+ {
+ txojLogger.aitLoggerI18N
+ .warn("com.arjuna.ats.internal.txoj.lmf1", ex);
+ }
+
+ return null;
+ }
+ }
+
+ public static final void setLink (Lock inst, Lock link)
+ {
+ try
+ {
+ Method m = Lock.class.getDeclaredMethod("setLink", Lock.class);
+
+ m.setAccessible(true);
+ m.invoke(inst, link);
+ m.setAccessible(false);
+ }
+ catch (final Throwable ex)
+ {
+ if (txojLogger.aitLoggerI18N.isWarnEnabled())
+ {
+ txojLogger.aitLoggerI18N
+ .warn("com.arjuna.ats.internal.txoj.lmf2", ex);
+ }
+ }
+ }
+
+ private LockFriend ()
+ {
+ }
+}
Copied: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/LockList.java (from rev 30064, labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/LockList.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/LockList.java 2009-11-06 20:27:50 UTC (rev 30066)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 1998, 1999, 2000,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: LockList.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.arjuna.ats.internal.txoj;
+
+import com.arjuna.ats.txoj.Lock;
+
+
+public class LockList
+{
+
+ public LockList()
+ {
+ count = 0;
+ head = null;
+ }
+
+ public void finalize ()
+ {
+ @SuppressWarnings("unused")
+ Lock temp;
+
+ while ((temp = pop()) != null)
+ temp = null; // temp.finalize() ?
+ }
+
+ /*
+ * Insert a new Lock. This returns TRUE if the insertion occurred, false
+ * otherwise. Insertion fails if a matching lock already exists in the list.
+ */
+
+ public final boolean insert (Lock newlock)
+ {
+ LockListIterator next = new LockListIterator(this);
+ Lock current = null;
+
+ while ((current = next.iterate()) != null)
+ {
+ if (current.equals(newlock))
+ {
+ return false;
+ }
+ }
+
+ push(newlock);
+
+ return true;
+ }
+
+ /*
+ * Pop the first element off the list and return it.
+ */
+
+ public final Lock pop ()
+ {
+ Lock current;
+
+ if (count == 0)
+ return null;
+
+ current = (Lock) head;
+ count--;
+ head = LockFriend.getLink(head);
+ LockFriend.setLink(current, null);
+
+ return current;
+ }
+
+ /*
+ * Push a new element at the head of the list. First set the link field to
+ * be the old head, and then set head to be the new element.
+ */
+
+ public final void push (Lock newLock)
+ {
+ LockFriend.setLink(newLock, head);
+ head = newLock;
+ count++;
+ }
+
+ /*
+ * Discard the element following the one pointed at. If it is the first
+ * element (current = 0) then simply change the head pointer. Beware if
+ * current points at the last element or the list is empty! This probably
+ * indicates a bug in the caller.
+ */
+
+ public final void forgetNext (Lock current)
+ {
+ if (count > 0) /* something there to forget */
+ {
+ if (current == null)
+ head = LockFriend.getLink(head);
+ else
+ {
+ Lock nextOne = LockFriend.getLink(current);
+
+ /* See if at list end */
+
+ if (nextOne != null)
+ LockFriend.setLink(current, LockFriend.getLink(nextOne));
+ else
+ {
+ /*
+ * Probably an error - being asked to forget element after
+ * end of list
+ */
+ count++;
+ LockFriend.setLink(current, null); /* force end of list */
+ }
+ }
+
+ count--;
+ }
+ }
+
+ public final int entryCount ()
+ {
+ return count;
+ }
+
+ protected Lock head;
+
+ private int count;
+
+}
Copied: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/LockListIterator.java (from rev 30064, labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/LockListIterator.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/internal/txoj/LockListIterator.java 2009-11-06 20:27:50 UTC (rev 30066)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 1998, 1999, 2000,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: LockListIterator.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.arjuna.ats.internal.txoj;
+
+import com.arjuna.ats.txoj.Lock;
+
+
+public class LockListIterator
+{
+
+ public LockListIterator(LockList L)
+ {
+ currentList = L;
+ next = currentList.head;
+ }
+
+ public final synchronized Lock iterate ()
+ {
+ Lock current = next;
+
+ if (current == null)
+ {
+ return null;
+ }
+ else
+ next = LockFriend.getLink(current);
+
+ return current;
+ }
+
+ public final synchronized void reset ()
+ {
+ next = null;
+ }
+
+ private LockList currentList;
+
+ private Lock next;
+
+}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/Lock.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/Lock.java 2009-11-06 19:33:59 UTC (rev 30065)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/Lock.java 2009-11-06 20:27:50 UTC (rev 30066)
@@ -35,7 +35,8 @@
import com.arjuna.ats.arjuna.*;
import com.arjuna.ats.arjuna.coordinator.*;
import com.arjuna.ats.arjuna.state.*;
-import com.arjuna.ats.arjuna.utils.*;
+import com.arjuna.ats.arjuna.utils.Utility;
+
import java.io.*;
import com.arjuna.ats.txoj.logging.FacilityCode;
@@ -46,14 +47,13 @@
import java.io.IOException;
/**
- * Instances of this class (or derived user classes) are used
- * when trying to set a lock. The default implementation provides a
- * single-write/multiple-reader policy. However, by overridding
- * the appropriate methods, other, type-specific concurrency control
- * locks can be implemented.
- *
+ * Instances of this class (or derived user classes) are used when trying to set
+ * a lock. The default implementation provides a single-write/multiple-reader
+ * policy. However, by overridding the appropriate methods, other, type-specific
+ * concurrency control locks can be implemented.
+ *
* @author Mark Little (mark at arjuna.com)
- * @version $Id: Lock.java 2342 2006-03-30 13:06:17Z $
+ * @version $Id: Lock.java 2342 2006-03-30 13:06:17Z $
* @since JTS 1.0.
*/
@@ -64,109 +64,113 @@
* Create a new lock.
*/
-public Lock ()
+ public Lock()
{
- super(ObjectType.NEITHER);
+ super(ObjectType.NEITHER);
- currentStatus = LockStatus.LOCKFREE;
- nextLock = null;
- lMode = LockMode.WRITE;
- owners = new ActionHierarchy(0);
+ currentStatus = LockStatus.LOCKFREE;
+ nextLock = null;
+ lMode = LockMode.WRITE;
+ owners = new ActionHierarchy(0);
}
/**
- * Create a new Lock object and initialise it. Mode is
- * based upon argument. The value of BasicAction.Current determines the
- * values of the remainder of the fields.
- * If there is no action running the owner field is set to be the
- * application uid created when the application starts.
+ * Create a new Lock object and initialise it. Mode is based upon argument.
+ * The value of BasicAction.Current determines the values of the remainder
+ * of the fields. If there is no action running the owner field is set to be
+ * the application uid created when the application starts.
*/
-public Lock (int lm)
+ public Lock(int lm)
{
- super(ObjectType.NEITHER);
+ super(ObjectType.NEITHER);
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::Lock("+lm+")");
- }
-
- currentStatus = LockStatus.LOCKFREE;
- nextLock = null;
- lMode = lm;
- owners = new ActionHierarchy(0);
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.CONSTRUCTORS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::Lock(" + lm
+ + ")");
+ }
- BasicAction curr = BasicAction.Current();
-
- if (curr == null)
- {
- int currentPid = 0; // ::getpid();
- ActionHierarchy ah = new ActionHierarchy(1); /* max depth of 1 */
+ currentStatus = LockStatus.LOCKFREE;
+ nextLock = null;
+ lMode = lm;
+ owners = new ActionHierarchy(0);
- if (applicUid == null)
- {
- applicUid = new Uid();
- }
-
- if (applicPid != currentPid)
- {
- /*
- * Process id change probably due to a fork(). Get new pid
- * and generate a new Applic_Uid
- */
+ BasicAction curr = BasicAction.Current();
- applicPid = currentPid;
- applicUid = new Uid();
- }
+ if (curr == null)
+ {
+ int currentPid = Utility.getpid(); // ::getpid();
+ ActionHierarchy ah = new ActionHierarchy(1); /* max depth of 1 */
- ah.add(applicUid);
- owners.copy(ah);
- }
- else
- {
- owners.copy(curr.getHierarchy());
- }
+ if (applicUid == null)
+ {
+ applicUid = new Uid();
+ }
+
+ if (applicPid != currentPid)
+ {
+ /*
+ * Process id change probably due to a fork(). Get new pid and
+ * generate a new Applic_Uid
+ */
+
+ applicPid = currentPid;
+ applicUid = new Uid();
+ }
+
+ ah.add(applicUid);
+ owners.copy(ah);
+ }
+ else
+ {
+ owners.copy(curr.getHierarchy());
+ }
}
/**
- * This is used when re-initialising a Lock after
- * retrieval from the object store.
+ * This is used when re-initialising a Lock after retrieval from the object
+ * store.
*/
-public Lock (Uid storeUid)
+ public Lock(Uid storeUid)
{
- super(storeUid, ObjectType.NEITHER);
+ super(storeUid, ObjectType.NEITHER);
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.CONSTRUCTORS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::Lock("+storeUid+")");
- }
-
- currentStatus = LockStatus.LOCKFREE;
- nextLock = null;
- lMode = LockMode.WRITE;
- owners = new ActionHierarchy(0);
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.CONSTRUCTORS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::Lock("
+ + storeUid + ")");
+ }
+
+ currentStatus = LockStatus.LOCKFREE;
+ nextLock = null;
+ lMode = LockMode.WRITE;
+ owners = new ActionHierarchy(0);
}
/**
* General clean up as Lock is deleted.
*/
-public void finalize () throws Throwable
+ public void finalize () throws Throwable
{
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.DESTRUCTORS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock.finalize()");
- }
-
- super.terminate();
-
- owners = null;
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.DESTRUCTORS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock.finalize()");
+ }
- super.finalize();
+ super.terminate();
+
+ owners = null;
+
+ super.finalize();
}
/*
@@ -176,324 +180,347 @@
/**
* @return the mode this lock is currently in, e.g.,
- * <code>LockMode.READ</code>.
+ * <code>LockMode.READ</code>.
*/
-public final int getLockMode ()
+ public final int getLockMode ()
{
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::getLockMode()");
- }
-
- return lMode;
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger
+ .debug(DebugLevel.TRIVIAL_FUNCS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL,
+ "Lock::getLockMode()");
+ }
+
+ return lMode;
}
/**
* @return the identity of the lock's current owner (the transaction id).
*/
-public final Uid getCurrentOwner ()
+ public final Uid getCurrentOwner ()
{
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::getCurrentOwner()");
- }
-
- return owners.getDeepestActionUid();
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL,
+ "Lock::getCurrentOwner()");
+ }
+
+ return owners.getDeepestActionUid();
}
/**
- * @return the transaction hierarchy associated with this
- * lock.
+ * @return the transaction hierarchy associated with this lock.
*/
-public final ActionHierarchy getAllOwners ()
+ public final ActionHierarchy getAllOwners ()
{
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::getAllOwners()");
- }
-
- return owners;
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL,
+ "Lock::getAllOwners()");
+ }
+
+ return owners;
}
/**
* @return the lock's current status.
*/
-public final int getCurrentStatus ()
+ public final int getCurrentStatus ()
{
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::getCurrentStatus()");
- }
-
- return currentStatus;
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL,
+ "Lock::getCurrentStatus()");
+ }
+
+ return currentStatus;
}
/**
- * Change the transaction hierarchy associated with the lock to
- * that provided.
+ * Change the transaction hierarchy associated with the lock to that
+ * provided.
*/
-public final void changeHierarchy (ActionHierarchy newOwner)
+ public final void changeHierarchy (ActionHierarchy newOwner)
{
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::getCurrentOwner()");
- }
-
- owners.copy(newOwner);
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL,
+ "Lock::getCurrentOwner()");
+ }
- if (currentStatus == LockStatus.LOCKFREE)
- currentStatus = LockStatus.LOCKHELD;
+ owners.copy(newOwner);
+
+ if (currentStatus == LockStatus.LOCKFREE)
+ currentStatus = LockStatus.LOCKHELD;
}
/**
* Propagate the lock.
*/
-public final void propagate ()
+ public final void propagate ()
{
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::propagate()");
- }
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::propagate()");
+ }
- owners.forgetDeepest();
+ owners.forgetDeepest();
- currentStatus = LockStatus.LOCKRETAINED;
+ currentStatus = LockStatus.LOCKRETAINED;
}
/**
- * Does this lock imply a modification of the object it is applied
- * to? For example, a READ lock would return false, but a WRITE
- * lock would return true.
- *
- * @return <code>true</code> if this lock implies the object's state
- * will be modified, <code>false</code> otherwise.
+ * Does this lock imply a modification of the object it is applied to? For
+ * example, a READ lock would return false, but a WRITE lock would return
+ * true.
+ *
+ * @return <code>true</code> if this lock implies the object's state will be
+ * modified, <code>false</code> otherwise.
*/
-public boolean modifiesObject ()
+ public boolean modifiesObject ()
{
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::modifiesObject()");
- }
-
- return ((lMode == LockMode.WRITE) ? true : false);
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.TRIVIAL_FUNCS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL,
+ "Lock::modifiesObject()");
+ }
+
+ return ((lMode == LockMode.WRITE) ? true : false);
}
/**
- * Implementation of Lock conflict check. Returns TRUE if there is
- * conflict FALSE otherwise. Does not take account of relationship in
- * the atomic action hierarchy since this is a function of
- * LockManager.
- *
+ * Implementation of Lock conflict check. Returns TRUE if there is conflict
+ * FALSE otherwise. Does not take account of relationship in the atomic
+ * action hierarchy since this is a function of LockManager.
+ *
* @return <code>true</code> if this lock conflicts with the parameter,
- * <code>false</code> otherwise.
+ * <code>false</code> otherwise.
*/
-public boolean conflictsWith (Lock otherLock)
+ public boolean conflictsWith (Lock otherLock)
{
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::conflictsWith("+otherLock+")\n"
- +"\tLock 1:\n"+this+"\n"
- +"\tLock 2:\n"+otherLock);
- }
-
- if (!(getCurrentOwner().equals(otherLock.getCurrentOwner())))
- {
- switch (lMode)
- {
- case LockMode.WRITE:
- return true; /* WRITE conflicts always */
- case LockMode.READ:
- if (otherLock.getLockMode() != LockMode.READ)
- return true;
- break;
- }
- }
-
- return false; /* no conflict between these locks */
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL,
+ "Lock::conflictsWith(" + otherLock + ")\n" + "\tLock 1:\n"
+ + this + "\n" + "\tLock 2:\n" + otherLock);
+ }
+
+ if (!(getCurrentOwner().equals(otherLock.getCurrentOwner())))
+ {
+ switch (lMode)
+ {
+ case LockMode.WRITE:
+ return true; /* WRITE conflicts always */
+ case LockMode.READ:
+ if (otherLock.getLockMode() != LockMode.READ)
+ return true;
+ break;
+ }
+ }
+
+ return false; /* no conflict between these locks */
}
/**
* Overrides Object.equals()
*/
-public boolean equals (Object otherLock)
+ public boolean equals (Object otherLock)
{
- if (otherLock instanceof Lock)
- return equals((Lock) otherLock);
- else
- return false;
+ if (otherLock instanceof Lock)
+ return equals((Lock) otherLock);
+ else
+ return false;
}
/**
* Are the two locks equal?
- *
+ *
* @return <code>true</code> if the locks are equal, <code>false</code>
- * otherwise.
+ * otherwise.
*/
-public boolean equals (Lock otherLock)
+ public boolean equals (Lock otherLock)
{
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.OPERATORS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::equals("+otherLock+")\n"
- +"\tLock 1:\n"+this+"\n"
- +"\tLock 2:\n"+otherLock);
- }
-
- if (this == otherLock)
- return true;
-
- if ((lMode == otherLock.lMode) &&
- (owners.equals(otherLock.owners)) &&
- (currentStatus == otherLock.currentStatus))
- {
- return true;
- }
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.OPERATORS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::equals("
+ + otherLock + ")\n" + "\tLock 1:\n" + this + "\n"
+ + "\tLock 2:\n" + otherLock);
+ }
- return false;
+ if (this == otherLock)
+ return true;
+
+ if ((lMode == otherLock.lMode) && (owners.equals(otherLock.owners))
+ && (currentStatus == otherLock.currentStatus))
+ {
+ return true;
+ }
+
+ return false;
}
/**
* Overrides Object.toString()
*/
-public String toString ()
+ public String toString ()
{
- StringWriter strm = new StringWriter();
+ StringWriter strm = new StringWriter();
- strm.write("Lock object : \n");
- strm.write("\tunique id is : "+get_uid()+"\n");
-
- strm.write("\tcurrent_status : "+LockStatus.printString(currentStatus));
-
- strm.write("\n\tMode : "+LockMode.stringForm(lMode));
-
- strm.write("\n\tOwner List : \n");
- owners.print(new PrintWriter(strm));
+ strm.write("Lock object : \n");
+ strm.write("\tunique id is : " + get_uid() + "\n");
- return strm.toString();
+ strm.write("\tcurrent_status : "
+ + LockStatus.printString(currentStatus));
+
+ strm.write("\n\tMode : " + LockMode.stringForm(lMode));
+
+ strm.write("\n\tOwner List : \n");
+ owners.print(new PrintWriter(strm));
+
+ return strm.toString();
}
/**
* functions inherited from StateManager
*/
-
-public void print (PrintWriter strm)
+
+ public void print (PrintWriter strm)
{
- strm.print(toString());
+ strm.print(toString());
}
/**
* Carefully restore the state of a Lock.
- *
- * @return <code>true</code> if successful, <code>false</code>
- * otherwise.
+ *
+ * @return <code>true</code> if successful, <code>false</code> otherwise.
*/
-public boolean restore_state (InputObjectState os, int ot)
+ public boolean restore_state (InputObjectState os, int ot)
{
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::restore_state("+os+", "+ot+")");
- }
-
- ActionHierarchy ah = new ActionHierarchy(0);
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL,
+ "Lock::restore_state(" + os + ", " + ot + ")");
+ }
- try
- {
- currentStatus = os.unpackInt();
- lMode = os.unpackInt();
- ah.unpack(os);
- owners = ah;
+ ActionHierarchy ah = new ActionHierarchy(0);
- return true;
- }
- catch (IOException e)
- {
- return false;
- }
+ try
+ {
+ currentStatus = os.unpackInt();
+ lMode = os.unpackInt();
+ ah.unpack(os);
+ owners = ah;
+
+ return true;
+ }
+ catch (IOException e)
+ {
+ return false;
+ }
}
/**
* Save the state of a lock object.
- *
- * @return <code>true</code> if successful, <code>false</code>
- * otherwise.
+ *
+ * @return <code>true</code> if successful, <code>false</code> otherwise.
*/
-public boolean save_state (OutputObjectState os, int ot)
+ public boolean save_state (OutputObjectState os, int ot)
{
- if (txojLogger.aitLogger.isDebugEnabled())
- {
- txojLogger.aitLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC,
- FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::save_state("+os+", "+ot+")");
- }
-
- try
- {
- os.packInt(currentStatus);
- os.packInt(lMode);
- owners.pack(os);
+ if (txojLogger.aitLogger.isDebugEnabled())
+ {
+ txojLogger.aitLogger.debug(DebugLevel.FUNCTIONS,
+ VisibilityLevel.VIS_PUBLIC,
+ FacilityCode.FAC_CONCURRENCY_CONTROL, "Lock::save_state("
+ + os + ", " + ot + ")");
+ }
- return os.valid();
- }
- catch (IOException e)
- {
- return false;
- }
+ try
+ {
+ os.packInt(currentStatus);
+ os.packInt(lMode);
+ owners.pack(os);
+
+ return os.valid();
+ }
+ catch (IOException e)
+ {
+ return false;
+ }
}
/**
* Overrides StateManager.type()
*/
-public String type ()
+ public String type ()
{
- return "/StateManager/Lock";
+ return "/StateManager/Lock";
}
/**
* Get the next lock in the chain.
*/
-protected Lock getLink ()
+ protected Lock getLink ()
{
- return nextLock;
+ return nextLock;
}
/**
* Set the next lock in the chain.
*/
-protected void setLink (Lock pointTo)
+ protected void setLink (Lock pointTo)
{
- nextLock = pointTo;
+ nextLock = pointTo;
}
-private int currentStatus;/* Current status of lock */
-private Lock nextLock;
-private int lMode; /* Typically READ or WRITE */
-private ActionHierarchy owners; /* Uid of owner action (faked if none) */
-
-private static Uid applicUid = null; /* In case lock set outside AA */
-private static int applicPid = com.arjuna.ats.arjuna.utils.Utility.getpid(); /* process id */
-
+ private int currentStatus;/* Current status of lock */
+
+ private Lock nextLock;
+
+ private int lMode; /* Typically READ or WRITE */
+
+ private ActionHierarchy owners; /* Uid of owner action (faked if none) */
+
+ private static Uid applicUid = null; /* In case lock set outside AA */
+
+ private static int applicPid = com.arjuna.ats.arjuna.utils.Utility.getpid(); /*
+ * process
+ * id
+ */
+
}
Deleted: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java 2009-11-06 19:33:59 UTC (rev 30065)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockList.java 2009-11-06 20:27:50 UTC (rev 30066)
@@ -1,151 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: LockList.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.arjuna.ats.txoj;
-
-
-public class LockList
-{
-
- public LockList()
- {
- count = 0;
- head = null;
- }
-
- public void finalize ()
- {
- Lock temp = null;
-
- while ((temp = pop()) != null)
- temp = null; // temp.finalize() ?
- }
-
- /*
- * Insert a new Lock. This returns TRUE if the insertion occurred, false
- * otherwise. Insertion fails if a matching lock already exists in the list.
- */
-
- public final boolean insert (Lock newlock)
- {
- LockListIterator next = new LockListIterator(this);
- Lock current = null;
-
- while ((current = next.iterate()) != null)
- {
- if (current.equals(newlock))
- {
- return false;
- }
- }
-
- push(newlock);
-
- return true;
- }
-
- /*
- * Pop the first element off the list and return it.
- */
-
- public final Lock pop ()
- {
- Lock current;
-
- if (count == 0)
- return null;
-
- current = (Lock) head;
- count--;
- head = head.getLink();
- current.setLink(null);
-
- return current;
- }
-
- /*
- * Push a new element at the head of the list. First set the link field to
- * be the old head, and then set head to be the new element.
- */
-
- public final void push (Lock newLock)
- {
- newLock.setLink(head);
- head = newLock;
- count++;
- }
-
- /*
- * Discard the element following the one pointed at. If it is the first
- * element (current = 0) then simply change the head pointer. Beware if
- * current points at the last element or the list is empty! This probably
- * indicates a bug in the caller.
- */
-
- public final void forgetNext (Lock current)
- {
- if (count > 0) /* something there to forget */
- {
- if (current == null)
- head = head.getLink();
- else
- {
- Lock nextOne = current.getLink();
-
- /* See if at list end */
-
- if (nextOne != null)
- current.setLink(nextOne.getLink());
- else
- {
- /*
- * Probably an error - being asked to forget element after
- * end of list
- */
- count++;
- current.setLink(null); /* force end of list */
- }
- }
-
- count--;
- }
- }
-
- public final int entryCount ()
- {
- return count;
- }
-
- protected Lock head;
-
- private int count;
-
-}
Deleted: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java 2009-11-06 19:33:59 UTC (rev 30065)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockListIterator.java 2009-11-06 20:27:50 UTC (rev 30066)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: LockListIterator.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.arjuna.ats.txoj;
-
-
-public class LockListIterator
-{
-
- public LockListIterator(LockList L)
- {
- currentList = L;
- next = currentList.head;
- }
-
- public final synchronized Lock iterate ()
- {
- Lock current = next;
-
- if (current == null)
- {
- return null;
- }
- else
- next = current.getLink();
-
- return current;
- }
-
- public final synchronized void reset ()
- {
- next = null;
- }
-
- private LockList currentList;
-
- private Lock next;
-
-}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockManager.java 2009-11-06 19:33:59 UTC (rev 30065)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/classes/com/arjuna/ats/txoj/LockManager.java 2009-11-06 20:27:50 UTC (rev 30066)
@@ -45,6 +45,8 @@
import com.arjuna.ats.arjuna.coordinator.*;
import com.arjuna.ats.arjuna.state.*;
import com.arjuna.ats.internal.arjuna.common.UidHelper;
+import com.arjuna.ats.internal.txoj.LockList;
+import com.arjuna.ats.internal.txoj.LockListIterator;
import com.arjuna.ats.internal.txoj.abstractrecords.CadaverLockRecord;
import com.arjuna.ats.internal.txoj.abstractrecords.LockRecord;
import com.arjuna.ats.internal.txoj.lockstore.BasicLockStore;
More information about the jboss-svn-commits
mailing list