[jboss-svn-commits] JBL Code SVN: r26706 - in labs/jbosstm/trunk/ArjunaCore: arjuna/classes/com/arjuna/ats/arjuna/coordinator and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat May 23 17:24:22 EDT 2009
Author: mark.little at jboss.com
Date: 2009-05-23 17:24:21 -0400 (Sat, 23 May 2009)
New Revision: 26706
Added:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/CheckedActionFactory.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/coordinator/CheckedActionFactoryImple.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/CheckedActionTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/DummyCheckedActionFactory.java
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/Environment.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/CheckedAction.java
labs/jbosstm/trunk/ArjunaCore/docs/user_guide/ProgrammersGuide.odt
Log:
https://jira.jboss.org/jira/browse/JBTM-433
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/Environment.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/Environment.java 2009-05-23 18:24:21 UTC (rev 26705)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/Environment.java 2009-05-23 21:24:21 UTC (rev 26706)
@@ -83,6 +83,7 @@
* <li> RECOVERY_MANAGER_PORT = com.arjuna.ats.internal.arjuna.recovery.recoveryPort
* <li> XA_NODE_IDENTIFIER = com.arjuna.ats.arjuna.xa.nodeIdentifier
* <li> DEFAULT_TIMEOUT = com.arjuna.ats.arjuna.coordinator.defaultTimeout
+ * <li> CHECKEDACTION_FACTORY = com.arjuna.ats.coordinator.checkedActionFactory
* </ul>
*
* @author Mark Little (mark at arjuna.com)
@@ -154,6 +155,7 @@
public static final String PROCESS_IMPLEMENTATION = "com.arjuna.ats.internal.arjuna.utils.processImplementation";
public static final String PROCESS_IDENTIFIER = "com.arjuna.ats.internal.arjuna.utils.pid";
public static final String BEFORECOMPLETION_WHEN_ROLLBACKONLY = "com.arjuna.ats.coordinator.beforeCompletionWhenRollbackOnly";
+ public static final String CHECKEDACTION_FACTORY = "com.arjuna.ats.coordinator.checkedActionFactory";
/**
* Constant that holds the name of the environment property
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java 2009-05-23 18:24:21 UTC (rev 26705)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java 2009-05-23 21:24:21 UTC (rev 26706)
@@ -41,6 +41,7 @@
import com.arjuna.ats.arjuna.objectstore.ObjectStore;
import com.arjuna.ats.arjuna.utils.ThreadUtil;
import com.arjuna.ats.arjuna.utils.Utility;
+import com.arjuna.ats.internal.arjuna.coordinator.CheckedActionFactoryImple;
import com.arjuna.ats.internal.arjuna.thread.*;
import java.util.*;
@@ -48,6 +49,7 @@
import com.arjuna.common.util.logging.*;
+import com.arjuna.ats.arjuna.exceptions.FatalError;
import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
/**
@@ -278,6 +280,12 @@
* @message com.arjuna.ats.arjuna.coordinator.BasicAction_71
* [com.arjuna.ats.arjuna.coordinator.BasicAction_71] - Deactivation of
* atomic action with id {0} and type {1} unexpectedly failed
+ * @message com.arjuna.ats.arjuna.coordinator.checkedactionfactory
+ * [com.arjuna.ats.arjuna.coordinator.checkedactionfactory] - Failed to resolve
+ * CheckedActionFactory class {0}
+ * @message com.arjuna.ats.arjuna.coordinator.cafactoryerror
+ * [com.arjuna.ats.arjuna.coordinator.cafactoryerror] - Cannot continue due to
+ * CheckedActionFactory resolution problem with
*/
public class BasicAction extends StateManager
@@ -309,7 +317,7 @@
recordBeingHandled = null;
heuristicDecision = TwoPhaseOutcome.PREPARE_OK;
- _checkedAction = new CheckedAction();
+ _checkedAction = _checkedActionFactory.getCheckedAction(get_uid(), type());
_childThreads = null;
_childActions = null;
@@ -347,7 +355,7 @@
recordBeingHandled = null;
heuristicDecision = TwoPhaseOutcome.PREPARE_OK;
- _checkedAction = new CheckedAction();
+ _checkedAction = _checkedActionFactory.getCheckedAction(get_uid(), type());
_childThreads = null;
_childActions = null;
@@ -1975,7 +1983,7 @@
recordBeingHandled = null;
heuristicDecision = TwoPhaseOutcome.PREPARE_OK;
- _checkedAction = new CheckedAction();
+ _checkedAction = _checkedActionFactory.getCheckedAction(get_uid(), type());
_childThreads = null;
_childActions = null;
@@ -2010,7 +2018,7 @@
recordBeingHandled = null;
heuristicDecision = TwoPhaseOutcome.PREPARE_OK;
- _checkedAction = new CheckedAction();
+ _checkedAction = _checkedActionFactory.getCheckedAction(get_uid(), type());
_childThreads = null;
_childActions = null;
@@ -4002,8 +4010,7 @@
private BasicAction parentAction;
private AbstractRecord recordBeingHandled;
private int heuristicDecision;
- private CheckedAction _checkedAction; // control what happens if threads
- // active when terminating.
+ private CheckedAction _checkedAction; // control what happens if threads active when terminating.
/*
* We need to keep track of the number of threads associated with each
@@ -4015,6 +4022,42 @@
private Hashtable _childActions;
// private Mutex _lock = new Mutex(); // TODO
+
+ private static CheckedActionFactory _checkedActionFactory;
+
+ static
+ {
+ /*
+ * Make sure this can only be set once. Bad things can happen if the factory changes
+ * during execution.
+ */
+
+ String checkedActionFactory = arjPropertyManager.getPropertyManager().getProperty(Environment.CHECKEDACTION_FACTORY);
+
+ if (checkedActionFactory != null)
+ {
+ try
+ {
+ Class factory = Thread.currentThread().getContextClassLoader().loadClass(checkedActionFactory);
+
+ _checkedActionFactory = (CheckedActionFactory) factory.newInstance();
+ }
+ catch (final Exception ex)
+ {
+ ex.printStackTrace();
+
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ {
+ tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.coordinator.checkedactionfactory",
+ new Object[]{ checkedActionFactory }, ex);
+ }
+
+ throw new FatalError(tsLogger.log_mesg.getString("com.arjuna.ats.arjuna.coordinator.cafactoryerror")+" "+checkedActionFactory, ex);
+ }
+ }
+ else
+ _checkedActionFactory = new CheckedActionFactoryImple();
+ }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/CheckedAction.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/CheckedAction.java 2009-05-23 18:24:21 UTC (rev 26705)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/CheckedAction.java 2009-05-23 21:24:21 UTC (rev 26706)
@@ -37,47 +37,50 @@
import com.arjuna.ats.arjuna.logging.tsLogger;
/**
- * If an action attempts to terminate with threads still active we
- * call an instance of this class to determine what to do. The default
- * simply prints a warning and relies upon the outstanding threads to find
- * out the state of the action later. However, this can be overridden, e.g.,
- * the thread attempting to terminate the action may be made to block.
- *
- * WARNING: watch out for deadlock!
- *
+ * If an action attempts to terminate with threads still active we call an
+ * instance of this class to determine what to do. The default simply prints a
+ * warning and relies upon the outstanding threads to find out the state of the
+ * action later. However, this can be overridden, e.g., the thread attempting to
+ * terminate the action may be made to block. WARNING: watch out for deadlock!
+ *
* @author Mark Little (mark at arjuna.com)
- * @version $Id: CheckedAction.java 2342 2006-03-30 13:06:17Z $
+ * @version $Id: CheckedAction.java 2342 2006-03-30 13:06:17Z $
* @since JTS 1.2.4.
*/
public class CheckedAction
{
-
-public CheckedAction ()
- {
- }
-
/**
- * Called during transaction termination if more than one thread
- * is associated with the transaction. The supplied information
- * should be sufficient for application specific implementations to
- * do useful work (such as synchronizing on the threads).
- *
- * @message com.arjuna.ats.arjuna.coordinator.CheckedAction_1 [com.arjuna.ats.arjuna.coordinator.CheckedAction_1] - CheckedAction::check - atomic action {0} commiting with {1} threads active!
- * @message com.arjuna.ats.arjuna.coordinator.CheckedAction_2 [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] - CheckedAction::check - atomic action {0} aborting with {1} threads active!
+ * Called during transaction termination if more than one thread is
+ * associated with the transaction. The supplied information should be
+ * sufficient for application specific implementations to do useful work
+ * (such as synchronizing on the threads).
+ *
+ * @message com.arjuna.ats.arjuna.coordinator.CheckedAction_1
+ * [com.arjuna.ats.arjuna.coordinator.CheckedAction_1] -
+ * CheckedAction::check - atomic action {0} commiting with {1}
+ * threads active!
+ * @message com.arjuna.ats.arjuna.coordinator.CheckedAction_2
+ * [com.arjuna.ats.arjuna.coordinator.CheckedAction_2] -
+ * CheckedAction::check - atomic action {0} aborting with {1}
+ * threads active!
*/
-public synchronized void check (boolean isCommit, Uid actUid, Hashtable list)
+ public void check (boolean isCommit, Uid actUid, Hashtable list)
{
- if (tsLogger.arjLoggerI18N.isWarnEnabled())
- {
- if (isCommit)
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.coordinator.CheckedAction_1",
- new Object[]{actUid,Integer.toString(list.size())});
- else
- tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.coordinator.CheckedAction_2",
- new Object[]{actUid,Integer.toString(list.size())});
- }
- }
+ if (tsLogger.arjLoggerI18N.isWarnEnabled())
+ {
+ if (isCommit)
+ tsLogger.arjLoggerI18N.warn(
+ "com.arjuna.ats.arjuna.coordinator.CheckedAction_1",
+ new Object[]
+ { actUid, Integer.toString(list.size()) });
+ else
+ tsLogger.arjLoggerI18N.warn(
+ "com.arjuna.ats.arjuna.coordinator.CheckedAction_2",
+ new Object[]
+ { actUid, Integer.toString(list.size()) });
+ }
+ }
}
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/CheckedActionFactory.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/CheckedActionFactory.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/CheckedActionFactory.java 2009-05-23 21:24:21 UTC (rev 26706)
@@ -0,0 +1,52 @@
+/*
+ * 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: CheckedAction.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.arjuna.ats.arjuna.coordinator;
+
+import com.arjuna.ats.arjuna.common.Uid;
+
+/**
+ * Manages the CheckedAction instances on a per transaction basis.
+ */
+
+public interface CheckedActionFactory
+{
+ /**
+ * Return a CheckedAction instance for a transaction. The same instance can be
+ * given to multiple transactions.
+ *
+ * @param txId the transaction id.
+ * @param actionType the type of the transaction.
+ * @return the CheckedAction instance.
+ */
+
+ public CheckedAction getCheckedAction (final Uid txId, final String actionType);
+}
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/coordinator/CheckedActionFactoryImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/coordinator/CheckedActionFactoryImple.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/coordinator/CheckedActionFactoryImple.java 2009-05-23 21:24:21 UTC (rev 26706)
@@ -0,0 +1,48 @@
+/*
+ * 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: CheckedAction.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.arjuna.ats.internal.arjuna.coordinator;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.coordinator.CheckedAction;
+import com.arjuna.ats.arjuna.coordinator.CheckedActionFactory;
+
+/**
+ * Return a checked action instance. The factory
+ */
+
+public class CheckedActionFactoryImple implements CheckedActionFactory
+{
+ public CheckedAction getCheckedAction (final Uid txId, final String actionType)
+ {
+ return new CheckedAction();
+ }
+}
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/CheckedActionTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/CheckedActionTest.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/CheckedActionTest.java 2009-05-23 21:24:21 UTC (rev 26706)
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+package com.hp.mwtests.ts.arjuna.atomicaction;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.common.Environment;
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
+
+public class CheckedActionTest
+{
+ public static void main (String[] args)
+ {
+ try
+ {
+ arjPropertyManager.getPropertyManager().setProperty(Environment.CHECKEDACTION_FACTORY, DummyCheckedActionFactory.class.getCanonicalName());
+
+ AtomicAction A = new AtomicAction();
+
+ A.begin();
+
+ A.commit();
+
+ System.out.println("Test completed "+((success) ? "successfully" : "unsuccessfully"));
+ }
+ catch (final Exception e)
+ {
+
+ }
+ }
+
+ public static boolean success = false;
+}
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/DummyCheckedActionFactory.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/DummyCheckedActionFactory.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/DummyCheckedActionFactory.java 2009-05-23 21:24:21 UTC (rev 26706)
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+package com.hp.mwtests.ts.arjuna.atomicaction;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.coordinator.CheckedAction;
+import com.arjuna.ats.arjuna.coordinator.CheckedActionFactory;
+
+public class DummyCheckedActionFactory implements CheckedActionFactory
+{
+ public CheckedAction getCheckedAction (final Uid txId,
+ final String actionType)
+ {
+ CheckedActionTest.success = true;
+
+ return new CheckedAction();
+ }
+}
Modified: labs/jbosstm/trunk/ArjunaCore/docs/user_guide/ProgrammersGuide.odt
===================================================================
(Binary files differ)
More information about the jboss-svn-commits
mailing list