[jboss-svn-commits] JBL Code SVN: r36881 - in labs/jbosstm/trunk/ArjunaCore: arjuna/classes/com/arjuna/ats/arjuna/coordinator/abstractrecord and 4 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Apr 9 11:02:03 EDT 2011


Author: mark.little at jboss.com
Date: 2011-04-09 11:02:03 -0400 (Sat, 09 Apr 2011)
New Revision: 36881

Added:
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/HeuristicNotification.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/HeuristicNotificationUnitTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/HeuristicRecord.java
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/TwoPhaseCoordinator.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/abstractrecord/RecordTypeManager.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLogger.java
   labs/jbosstm/trunk/ArjunaCore/docs/user_guide/FailureRecoveryGuide.odt
Log:
https://issues.jboss.org/browse/JBTM-833

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	2011-04-08 20:27:46 UTC (rev 36880)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java	2011-04-09 15:02:03 UTC (rev 36881)
@@ -2794,6 +2794,9 @@
                                     * list to indicate this. Covers statuses like FAILED_ERROR.
                                     */
 
+
+                            updateHeuristic(ok, true);
+                            
                             failedList.insert(recordBeingHandled);
                         }
                     }

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/HeuristicNotification.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/HeuristicNotification.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/HeuristicNotification.java	2011-04-09 15:02:03 UTC (rev 36881)
@@ -0,0 +1,61 @@
+/*
+ * 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) 2011,
+ * @author JBoss Inc.
+ */
+
+package com.arjuna.ats.arjuna.coordinator;
+
+import com.arjuna.ats.arjuna.common.Uid;
+
+/*
+ * @author Mark Little (mark at arjuna.com)
+ * @since 3.0.
+ */
+
+/*
+ * If the caller doesn't want to be informed of heuristics during completion
+ * then it's possible the application (or admin) may still want to be informed.
+ * So special participants can be registered with the transaction which are
+ * triggered during the Synchronization phase and given the true outcome of
+ * the transaction. We do not dictate a specific implementation for what these
+ * participants do with the information (e.g., OTS allows for the CORBA Notification Service
+ * to be used).
+ */
+
+public abstract class HeuristicNotification implements SynchronizationRecord
+{
+    public abstract void heuristicOutcome (int actionStatus);
+    
+    public Uid get_uid ()
+    {
+        return _uid;
+    }
+
+    public boolean beforeCompletion ()
+    {
+        return true;
+    }
+
+    public boolean afterCompletion (int status)
+    {
+        return true;
+    }
+    
+    private Uid _uid = new Uid();
+}
\ No newline at end of file

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java	2011-04-08 20:27:46 UTC (rev 36880)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TwoPhaseCoordinator.java	2011-04-09 15:02:03 UTC (rev 36881)
@@ -101,7 +101,7 @@
 		else
 			outcome = super.Abort();
 
-		afterCompletion(outcome);
+		afterCompletion(outcome, report_heuristics);
 
 		return outcome;
 	}
@@ -323,14 +323,28 @@
 	}
 
 	/**
+         * Drive afterCompletion participants.
+         * 
+         * @param myStatus the outcome of the transaction (ActionStatus.COMMITTED or ActionStatus.ABORTED).
+         * 
+         * @return true if successful, false otherwise.
+         */
+	
+	protected boolean afterCompletion (int myStatus)
+	{
+	    return afterCompletion(myStatus, false);
+	}
+	
+	/**
 	 * Drive afterCompletion participants.
 	 * 
 	 * @param myStatus the outcome of the transaction (ActionStatus.COMMITTED or ActionStatus.ABORTED).
+	 * @param report_heuristics does the caller want to be informed about heurisitics at the point of invocation?
 	 * 
 	 * @return true if successful, false otherwise.
 	 */
 	
-	protected boolean afterCompletion (int myStatus)
+	protected boolean afterCompletion (int myStatus, boolean report_heuristics)
 	{
 		if (myStatus == ActionStatus.RUNNING) {
             tsLogger.i18NLogger.warn_coordinator_TwoPhaseCoordinator_3();
@@ -366,6 +380,24 @@
 					{
 						SynchronizationRecord record = (SynchronizationRecord)stack.pop();
 
+						/*
+						 * If the caller doesn't want to be informed of heuristics during completion
+						 * then it's possible the application (or admin) may still want to be informed.
+						 * So special participants can be registered with the transaction which are
+						 * triggered during the Synchronization phase and given the true outcome of
+						 * the transaction. We do not dictate a specific implementation for what these
+						 * participants do with the information (e.g., OTS allows for the CORBA Notification Service
+						 * to be used).
+						 */
+						
+						if (!report_heuristics)
+						{
+						    if (record instanceof HeuristicNotification)
+						    {
+						        ((HeuristicNotification) record).heuristicOutcome(getHeuristicDecision());
+						    }
+						}
+						
 						try
 						{
 							if (!record.afterCompletion(myStatus)) {

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/abstractrecord/RecordTypeManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/abstractrecord/RecordTypeManager.java	2011-04-08 20:27:46 UTC (rev 36880)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/abstractrecord/RecordTypeManager.java	2011-04-09 15:02:03 UTC (rev 36881)
@@ -60,7 +60,7 @@
                 return _map.get(i).getRecordClass();
         }
         
-        return null;
+        return AbstractRecord.class;
     }
     
     public synchronized int getType (Class<? extends AbstractRecord> c)

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLogger.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLogger.java	2011-04-08 20:27:46 UTC (rev 36880)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/logging/arjunaI18NLogger.java	2011-04-09 15:02:03 UTC (rev 36881)
@@ -144,7 +144,7 @@
 	@LogMessage(level = WARN)
 	public void warn_RecoveryRecord_2();
 
-	@Message(id = 12027, value = "StateManager::terminate() should be invoked in every destructor", format = MESSAGE_FORMAT)
+	@Message(id = 12027, value = "LockManager::terminate() should be invoked in every destructor", format = MESSAGE_FORMAT)
 	@LogMessage(level = WARN)
 	public void warn_StateManager_1();
 

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/HeuristicNotificationUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/HeuristicNotificationUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/HeuristicNotificationUnitTest.java	2011-04-09 15:02:03 UTC (rev 36881)
@@ -0,0 +1,77 @@
+/*
+ * 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.TopLevelAction;
+import com.arjuna.ats.arjuna.coordinator.AddOutcome;
+import com.arjuna.ats.arjuna.coordinator.HeuristicNotification;
+import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.hp.mwtests.ts.arjuna.resources.BasicRecord;
+import com.hp.mwtests.ts.arjuna.resources.HeuristicRecord;
+import com.hp.mwtests.ts.arjuna.resources.SyncRecord;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class HeuristicNotificationUnitTest
+{
+    class DummyHeuristic extends HeuristicNotification
+    {
+        public int getStatus ()
+        {
+            return _status;
+        }
+        
+        @Override
+        public void heuristicOutcome (int actionStatus)
+        {
+            _status = actionStatus;
+        }
+
+        @Override
+        public int compareTo (Object o)
+        {
+            return 0;
+        }
+        
+        private int _status = -1;
+    }
+    
+    @Test
+    public void test () throws Exception
+    {
+        AtomicAction A = new AtomicAction();
+        DummyHeuristic dh = new DummyHeuristic();
+        
+        A.begin();
+        
+        A.add(new BasicRecord());
+        A.add(new BasicRecord());
+        A.add(new HeuristicRecord());
+        
+        A.addSynchronization(dh);
+        
+        A.commit(false);
+        
+        assertEquals(TwoPhaseOutcome.HEURISTIC_MIXED, dh.getStatus());
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/HeuristicRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/HeuristicRecord.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/HeuristicRecord.java	2011-04-09 15:02:03 UTC (rev 36881)
@@ -0,0 +1,150 @@
+/*
+ * 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) 2004,
+ *
+ * Arjuna Technologies Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.  
+ *
+ * $Id: BasicRecord.java 2342 2006-03-30 13:06:17Z  $
+ */
+
+package com.hp.mwtests.ts.arjuna.resources;
+
+import com.arjuna.ats.arjuna.coordinator.*;
+import com.arjuna.ats.arjuna.common.*;
+import com.arjuna.ats.arjuna.state.*;
+
+import java.io.PrintWriter;
+
+public class HeuristicRecord extends AbstractRecord
+{
+
+    public HeuristicRecord()
+    {
+        super(new Uid());
+    }
+
+    public int typeIs()
+    {
+        return RecordType.USER_DEF_FIRST1;
+    }
+
+    public int nestedAbort()
+    {
+        return TwoPhaseOutcome.FINISH_OK;
+    }
+
+    public int nestedCommit()
+    {
+        return TwoPhaseOutcome.FINISH_ERROR;
+    }
+
+    public int nestedPrepare()
+    {
+        return TwoPhaseOutcome.PREPARE_NOTOK;
+    }
+
+    public int topLevelAbort()
+    {
+        return TwoPhaseOutcome.HEURISTIC_ROLLBACK;
+    }
+
+    public int topLevelCommit()
+    {
+        return TwoPhaseOutcome.HEURISTIC_ROLLBACK;
+    }
+
+    public int topLevelPrepare()
+    {
+        return TwoPhaseOutcome.PREPARE_OK;
+    }
+
+    public void print(PrintWriter strm)
+    {
+        strm.println("Shutdown for:");
+        super.print(strm);
+    }
+
+    public boolean doSave()
+    {
+        return true;
+    }
+
+    public boolean save_state(OutputObjectState os, int ot)
+    {
+        return true;
+    }
+
+    public boolean restore_state(InputObjectState os, int ot)
+    {
+        return true;
+    }
+
+    public String type()
+    {
+        return "/StateManager/AbstractRecord/HeuristicRecord";
+    }
+
+    public boolean shouldAdd(AbstractRecord a)
+    {
+        return false;
+    }
+
+    public boolean shouldMerge(AbstractRecord a)
+    {
+        return false;
+    }
+
+    public boolean shouldReplace(AbstractRecord a)
+    {
+        return false;
+    }
+
+    public boolean shouldAlter(AbstractRecord a)
+    {
+        return false;
+    }
+
+    public void merge(AbstractRecord a)
+    {
+    }
+
+    public void alter(AbstractRecord a)
+    {
+    }
+
+    /**
+     * @return <code>Object</code> to be used to order.
+     */
+
+    public Object value()
+    {
+        return null;
+    }
+
+    public void setValue(Object o)
+    {
+    }
+}
+

Modified: labs/jbosstm/trunk/ArjunaCore/docs/user_guide/FailureRecoveryGuide.odt
===================================================================
(Binary files differ)



More information about the jboss-svn-commits mailing list