[jboss-svn-commits] JBL Code SVN: r24754 - 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
Fri Jan 16 06:49:20 EST 2009


Author: mark.little at jboss.com
Date: 2009-01-16 06:49:18 -0500 (Fri, 16 Jan 2009)
New Revision: 24754

Modified:
   labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TxControl.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/recovery/TransactionStatusManager.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery/Listener.java
   labs/jbosstm/trunk/ArjunaCore/docs/user_guide/AdministrationGuide.odt
Log:
https://jira.jboss.org/jira/browse/JBTM-464

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml	2009-01-16 07:30:56 UTC (rev 24753)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml	2009-01-16 11:49:18 UTC (rev 24754)
@@ -457,6 +457,10 @@
                 todir="${com.hp.mwlabs.ts.arjuna.reports.dest}">
                 <fileset dir="${com.hp.mwlabs.ts.arjuna.tests.src}" includes="**/ReaperTestCase3.java"/>
             </batchtest>
+        	<batchtest haltonerror="yes" haltonfailure="yes" fork="yes"
+        	        	                todir="${com.hp.mwlabs.ts.arjuna.reports.dest}">
+				<fileset dir="${com.hp.mwlabs.ts.arjuna.tests.src}" includes="**/TxControlUnitTest.java"/>
+        	</batchtest>
         </junit>
     </target>
 

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TxControl.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TxControl.java	2009-01-16 07:30:56 UTC (rev 24753)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TxControl.java	2009-01-16 11:49:18 UTC (rev 24754)
@@ -61,6 +61,17 @@
 
 public class TxControl
 {
+    public static class Shutdown extends Thread
+    {
+        public void run()
+        {
+            if (transactionStatusManager != null)
+            {
+                transactionStatusManager.finalize();
+            }
+        }
+    };
+    
     /**
      * If a timeout is not associated with a transaction when it is created then
      * this value will be used. A value of 0 means that the transaction will
@@ -82,24 +93,53 @@
 		_defaultTimeout = timeout;
 	}
 
-	public static final void enable()
+	/**
+	 * Start the transaction system. This allows new transactions to be created
+	 * and for recovery to execute.
+	 */
+	
+	public static final synchronized void enable()
 	{
-		TxControl.enable = true;
+	    createTransactionStatusManager();
+	    
+	    TxControl.enable = true;
 	}
 
-	public static final void disable()
+	/**
+	 * Stop the transaction system. New transactions will be prevented but
+	 * recovery will be allowed to continue.
+	 */
+	
+	public static final synchronized void disable()
 	{
-		/*
-		 * We could have an implementation that did not return until all
-		 * transactions had finished. However, this could take an arbitrary
-		 * time, especially if participants could fail. Since this information
-		 * is available anyway to the application, let it handle it.
-		 */
-
-		TxControl.enable = false;
+	    disable(false);
 	}
+	
+	/**
+         * Stop the transaction system. New transactions will be prevented and
+         * recovery will cease.
+         * 
+         * WARNING: make sure you know what you are doing when you call this
+         * routine!
+         */
+	
+	public static final synchronized void disable (boolean disableRecovery)
+        {
+            /*
+             * We could have an implementation that did not return until all
+             * transactions had finished. However, this could take an arbitrary
+             * time, especially if participants could fail. Since this information
+             * is available anyway to the application, let it handle it.
+             */
 
-	public static final boolean isEnabled()
+	    if (disableRecovery)
+	        removeTransactionStatusManager();
+
+            TxControl.enable = false;
+        }
+
+
+	public static final synchronized boolean isEnabled()
 	{
 		return TxControl.enable;
 	}
@@ -229,6 +269,35 @@
 		xaNodeName = name;
 	}
 
+	private final static synchronized void createTransactionStatusManager ()
+	{
+	    if (transactionStatusManager == null && _enableTSM)
+	    {
+	        transactionStatusManager = new TransactionStatusManager();
+
+	        _shutdownHook = new Shutdown();
+	        
+	        // add hook to ensure finalize gets called.
+	        Runtime.getRuntime().addShutdownHook(_shutdownHook);
+	    }
+	}
+	
+	private final static synchronized void removeTransactionStatusManager ()
+	{
+	    if (_shutdownHook != null)
+	    {
+	        Runtime.getRuntime().removeShutdownHook(_shutdownHook);
+	        
+	        _shutdownHook = null;
+	        
+	        if (transactionStatusManager != null)
+	        {
+	            transactionStatusManager.finalize();
+	            transactionStatusManager = null;
+	        }
+	    }
+	}
+	
 	static boolean maintainHeuristics = true;
 
 	static boolean asyncCommit = false;
@@ -257,6 +326,12 @@
 
 	static int _defaultTimeout = 60; // 60 seconds
 
+	static boolean _enableTSM = true;
+	
+	static Thread _shutdownHook = null;
+	
+	static Object _lock = new Object();
+	
 	static
 	{
 		String env = arjPropertyManager.propertyManager
@@ -409,29 +484,17 @@
 
 		if (writeNodeName)
 		{
-			arjPropertyManager.propertyManager.setProperty(
-					Environment.XA_NODE_IDENTIFIER, new String(xaNodeName));
+		    arjPropertyManager.propertyManager.setProperty(
+		            Environment.XA_NODE_IDENTIFIER, new String(xaNodeName));
 		}
 
-        
-        String enableTSM = arjPropertyManager.propertyManager.getProperty(Environment.TRANSACTION_STATUS_MANAGER_ENABLE);
-        // run the TSM by default, unless it's turned off explicitly.
-        if (transactionStatusManager == null && !"NO".equalsIgnoreCase(enableTSM))
-		{
-			transactionStatusManager = new TransactionStatusManager();
+		String enableTSM = arjPropertyManager.propertyManager.getProperty(Environment.TRANSACTION_STATUS_MANAGER_ENABLE);
+		// run the TSM by default, unless it's turned off explicitly.
 
-			// add hook to ensure finalize gets called.
-			Runtime.getRuntime().addShutdownHook(new Thread()
-			{
-				public void run()
-				{
-					if (transactionStatusManager != null)
-					{
-						transactionStatusManager.finalize();
-					}
-				}
-			});
-		}
+		if ("NO".equalsIgnoreCase(enableTSM))
+		    _enableTSM = false;
+
+		createTransactionStatusManager();
 	}
 
 }

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/recovery/TransactionStatusManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/recovery/TransactionStatusManager.java	2009-01-16 07:30:56 UTC (rev 24753)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/recovery/TransactionStatusManager.java	2009-01-16 11:49:18 UTC (rev 24754)
@@ -37,7 +37,6 @@
 import com.arjuna.ats.arjuna.utils.Utility ;
 import com.arjuna.ats.internal.arjuna.recovery.Listener ;
 import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusManagerItem ;
-import com.arjuna.ats.arjuna.common.arjPropertyManager;
 
 import com.arjuna.ats.arjuna.logging.tsLogger;
 import com.arjuna.common.util.propertyservice.PropertyManager;
@@ -116,6 +115,8 @@
     * Removes the TransactionStatusManager from the object store
     * and closes down the listener thread.
     */
+   
+   // TODO consider adding a shutdown operation (signature change)
    public void finalize()
    {
        if ( ! _finalizeCalled )

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery/Listener.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery/Listener.java	2009-01-16 07:30:56 UTC (rev 24753)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/recovery/Listener.java	2009-01-16 11:49:18 UTC (rev 24754)
@@ -33,7 +33,6 @@
 
 import java.io.*;
 import java.net.*;
-import java.util.*;
 
 import com.arjuna.ats.arjuna.common.*;
 import com.arjuna.ats.arjuna.logging.FacilityCode;
@@ -143,6 +142,9 @@
 	     if (tsLogger.arjLoggerI18N.isWarnEnabled())
 		 tsLogger.arjLoggerI18N.warn("com.arjuna.ats.internal.arjuna.recovery.Listener_2");
          }
+         catch (final Exception ex)
+         {
+         }
       }
    }
    
@@ -154,6 +156,14 @@
    {
       _stop_listener = true;
       this.interrupt();
+      
+      try
+      {
+          _listener_socket.close();  // in case we're still in accept
+      }
+      catch (final Exception ex)
+      {
+      }
    }
 
    // Socket & port which client(RecoveryManager) connects to.

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




More information about the jboss-svn-commits mailing list