[jboss-svn-commits] JBL Code SVN: r12794 - labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Jun 23 16:27:21 EDT 2007


Author: mark.little at jboss.com
Date: 2007-06-23 16:27:21 -0400 (Sat, 23 Jun 2007)
New Revision: 12794

Modified:
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TxControl.java
Log:
Related to 179, 180 and 181 (improved statistics gathering).

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	2007-06-23 20:23:40 UTC (rev 12793)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/TxControl.java	2007-06-23 20:27:21 UTC (rev 12794)
@@ -41,288 +41,331 @@
 import com.arjuna.ats.arjuna.recovery.TransactionStatusManager;
 
 /**
- * Transaction configuration object. We have a separate object for
- * this so that other classes can enquire of (and use) this information.
- *
+ * Transaction configuration object. We have a separate object for this so that
+ * other classes can enquire of (and use) this information.
+ * 
  * @author Mark Little (mark at arjuna.com)
- * @version $Id: TxControl.java 2342 2006-03-30 13:06:17Z  $
+ * @version $Id: TxControl.java 2342 2006-03-30 13:06:17Z $
  * @since JTS 2.2.
- *
- * @message com.arjuna.ats.arjuna.coordinator.TxControl_1 [com.arjuna.ats.arjuna.coordinator.TxControl_1] - Name of XA node not defined. Using {0}
- * @message com.arjuna.ats.arjuna.coordinator.TxControl_2 [com.arjuna.ats.arjuna.coordinator.TxControl_2] - Supplied name of node is too long. Using {0}
- * @message com.arjuna.ats.arjuna.coordinator.TxControl_3 [com.arjuna.ats.arjuna.coordinator.TxControl_3] - Supplied name of node contains reserved character '-'. Using {0}
+ * 
+ * @message com.arjuna.ats.arjuna.coordinator.TxControl_1
+ *          [com.arjuna.ats.arjuna.coordinator.TxControl_1] - Name of XA node
+ *          not defined. Using {0}
+ * @message com.arjuna.ats.arjuna.coordinator.TxControl_2
+ *          [com.arjuna.ats.arjuna.coordinator.TxControl_2] - Supplied name of
+ *          node is too long. Using {0}
+ * @message com.arjuna.ats.arjuna.coordinator.TxControl_3
+ *          [com.arjuna.ats.arjuna.coordinator.TxControl_3] - Supplied name of
+ *          node contains reserved character '-'. Using {0}
  */
 
 public class TxControl
 {
 
-	public static final int getDefaultTimeout ()
+	public static final int getDefaultTimeout()
 	{
 		return _defaultTimeout;
 	}
-	
-	public static final void setDefaultTimeout (int timeout)
+
+	public static final void setDefaultTimeout(int timeout)
 	{
 		_defaultTimeout = timeout;
 	}
-	
-    public static final void enable ()
-    {
-	TxControl.enable = true;
-    }
-    
-    public static final 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;
-    }
+	public static final void enable()
+	{
+		TxControl.enable = true;
+	}
 
-    public static final boolean isEnabled ()
-    {
-	return TxControl.enable;
-    }
+	public static final 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.
+		 */
 
-    public static final ClassName getActionStoreType ()
-    {
-	return actionStoreType;
-    }
-    
-    /**
-     * @return the <code>ObjectStore</code> implementation which the
-     * transaction coordinator will use.
-     * @see com.arjuna.ats.arjuna.objectstore.ObjectStore
-     */
+		TxControl.enable = false;
+	}
 
-    public static final ObjectStore getStore ()
-    {
-	/*
-	 * Check for action store once per application. The second
-	 * parameter is the default value, which is returned if no
-	 * other value is specified.
-	 */
-	    
-	if (TxControl.actionStoreType == null)
+	public static final boolean isEnabled()
 	{
-	    String useLog = arjPropertyManager.propertyManager.getProperty(Environment.TRANSACTION_LOG, "OFF");
+		return TxControl.enable;
+	}
 
-	    if (useLog.equals("ON"))
-		TxControl.actionStoreType = new ClassName(ArjunaNames.Implementation_ObjectStore_ActionLogStore());
-	    else
-		TxControl.actionStoreType = new ClassName(arjPropertyManager.propertyManager.getProperty(Environment.ACTION_STORE, ArjunaNames.Implementation_ObjectStore_defaultActionStore().stringForm()));
-
-	    String sharedLog = arjPropertyManager.propertyManager.getProperty(Environment.SHARED_TRANSACTION_LOG, "NO");
-	    
-	    if (sharedLog.equals("YES"))
-		sharedTransactionLog = true;
+	public static final ClassName getActionStoreType()
+	{
+		return actionStoreType;
 	}
 
-	/*
-	 * Defaults to ObjectStore.OS_UNSHARED
+	/**
+	 * @return the <code>ObjectStore</code> implementation which the
+	 *         transaction coordinator will use.
+	 * @see com.arjuna.ats.arjuna.objectstore.ObjectStore
 	 */
-	
-	if (sharedTransactionLog)
-	    return new ObjectStore(actionStoreType, ObjectStore.OS_SHARED);
-	else
-	    return new ObjectStore(actionStoreType);
-    }
 
-    public static final boolean getAsyncPrepare ()
-    {
-	return asyncPrepare;
-    }
+	public static final ObjectStore getStore()
+	{
+		/*
+		 * Check for action store once per application. The second parameter is
+		 * the default value, which is returned if no other value is specified.
+		 */
 
-    public static final boolean getMaintainHeuristics ()
-    {
-	return maintainHeuristics;
-    }
+		if (TxControl.actionStoreType == null)
+		{
+			String useLog = arjPropertyManager.propertyManager.getProperty(
+					Environment.TRANSACTION_LOG, "OFF");
 
-    public static final byte[] getXANodeName ()
-    {
-	return xaNodeName;
-    }
+			if (useLog.equals("ON"))
+				TxControl.actionStoreType = new ClassName(ArjunaNames
+						.Implementation_ObjectStore_ActionLogStore());
+			else
+				TxControl.actionStoreType = new ClassName(
+						arjPropertyManager.propertyManager
+								.getProperty(
+										Environment.ACTION_STORE,
+										ArjunaNames
+												.Implementation_ObjectStore_defaultActionStore()
+												.stringForm()));
 
-    public static void setXANodeName (byte[] name)
-    {
-	xaNodeName = name;
-    }
-    
-    static boolean maintainHeuristics = true;
-    static boolean asyncCommit = false;
-    static boolean asyncPrepare = false;
-    static boolean asyncRollback = false;
-    static boolean onePhase = true;
-    static boolean readonlyOptimisation = true;
-    static boolean enableStatistics = false;
-    static boolean sharedTransactionLog = false;
-    static int     numberOfTransactions = 100;
-    static boolean enable = true;
-    static TransactionStatusManager transactionStatusManager = null;
-    static ClassName actionStoreType = null;
-    static byte[]  xaNodeName = null;
-    static int _defaultTimeout = 60; // 60 seconds
+			String sharedLog = arjPropertyManager.propertyManager.getProperty(
+					Environment.SHARED_TRANSACTION_LOG, "NO");
 
-    static
-    {
-    	String env = arjPropertyManager.propertyManager.getProperty(Environment.DEFAULT_TIMEOUT);
-    	
-    	if (env != null)
-    	{
-    		try
-    		{
-    			Integer in = new Integer(env);
-    			
-    			_defaultTimeout = in.intValue();
-    		}
-    		catch (Exception ex)
-    		{
-    			ex.printStackTrace();
-    		}
-    	}
-    	
-	env = arjPropertyManager.propertyManager.getProperty(Environment.MAINTAIN_HEURISTICS);
-	
-	if (env != null)
-	{
-	    if (env.compareTo("NO") == 0)
-		TxControl.maintainHeuristics = false;
-	}
+			if (sharedLog.equals("YES"))
+				sharedTransactionLog = true;
+		}
 
-	env = arjPropertyManager.propertyManager.getProperty(Environment.ASYNC_COMMIT);
-	    
-	if (env != null)
-	{
-	    if (env.compareTo("YES") == 0)
-		TxControl.asyncCommit = true;
-	}
+		/*
+		 * Defaults to ObjectStore.OS_UNSHARED
+		 */
 
-	env = arjPropertyManager.propertyManager.getProperty(Environment.ASYNC_PREPARE);
-	    
-	if (env != null)
-	{
-	    if (env.compareTo("YES") == 0)
-		TxControl.asyncPrepare = true;
+		if (sharedTransactionLog)
+			return new ObjectStore(actionStoreType, ObjectStore.OS_SHARED);
+		else
+			return new ObjectStore(actionStoreType);
 	}
 
-	env = arjPropertyManager.propertyManager.getProperty(Environment.COMMIT_ONE_PHASE);
-	    
-	if (env != null)
+	public static final boolean getAsyncPrepare()
 	{
-	    if (env.compareTo("NO") == 0)
-		TxControl.onePhase = false;
+		return asyncPrepare;
 	}
 
-	env = arjPropertyManager.propertyManager.getProperty(Environment.ASYNC_ROLLBACK);
-	    
-	if (env != null)
+	public static final boolean getMaintainHeuristics()
 	{
-	    if (env.compareTo("YES") == 0)
-		TxControl.asyncRollback = true;
+		return maintainHeuristics;
 	}
 
-	env = arjPropertyManager.propertyManager.getProperty(Environment.READONLY_OPTIMISATION);
-	    
-	if (env != null)
+	public static final byte[] getXANodeName()
 	{
-	    if (env.compareTo("NO") == 0)
-		TxControl.readonlyOptimisation = false;
+		return xaNodeName;
 	}
 
-	env = arjPropertyManager.propertyManager.getProperty(Environment.ENABLE_STATISTICS);
-	    
-	if (env != null)
+	public static void setXANodeName(byte[] name)
 	{
-	    if (env.compareTo("YES") == 0)
-		TxControl.enableStatistics = true;
+		xaNodeName = name;
 	}
 
-	env = arjPropertyManager.propertyManager.getProperty(Environment.START_DISABLED);
-	    
-	if (env != null)
-	{
-	    if (env.compareTo("YES") == 0)
-		TxControl.enable = false;
-	}
+	static boolean maintainHeuristics = true;
 
-	env = arjPropertyManager.propertyManager.getProperty(Environment.XA_NODE_IDENTIFIER);
-	boolean writeNodeName = false;
-	
-	if (env != null)
-	{
-	    xaNodeName = env.getBytes();
-	}
-	else
-	{
-	    Uid nodeName = new Uid();
-	    
-	    if (tsLogger.arjLoggerI18N.isWarnEnabled())
-	    {
-		tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.coordinator.TxControl_1",
-					    new Object[]{nodeName.stringForm()});
-	    }
+	static boolean asyncCommit = false;
 
-	    xaNodeName = nodeName.stringForm().getBytes();
-	    
-	    writeNodeName = true;
-	}
+	static boolean asyncPrepare = false;
 
-	if (xaNodeName.length > 30)
-	{
-	    Uid nodeName = new Uid();
+	static boolean asyncRollback = false;
 
-	    if (tsLogger.arjLoggerI18N.isWarnEnabled())
-	    {
-		tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.coordinator.TxControl_2",
-					    new Object[]{nodeName.stringForm()});
-	    }
+	static boolean onePhase = true;
 
-	    xaNodeName = nodeName.stringForm().getBytes();
+	static boolean readonlyOptimisation = true;
 
-	    writeNodeName = true;
-	}
+	static boolean enableStatistics = false;
 
-	if ((env != null) && (env.indexOf('-') != -1))
+	static boolean sharedTransactionLog = false;
+
+	static int numberOfTransactions = 100;
+
+	static boolean enable = true;
+
+	static TransactionStatusManager transactionStatusManager = null;
+
+	static ClassName actionStoreType = null;
+
+	static byte[] xaNodeName = null;
+
+	static int _defaultTimeout = 60; // 60 seconds
+
+	static
 	{
-	    Uid nodeName = new Uid();
+		String env = arjPropertyManager.propertyManager
+				.getProperty(Environment.DEFAULT_TIMEOUT);
 
-	    if (tsLogger.arjLoggerI18N.isWarnEnabled())
-	    {
-		tsLogger.arjLoggerI18N.warn("com.arjuna.ats.arjuna.coordinator.TxControl_3",
-					    new Object[]{nodeName.stringForm()});
-	    }
+		if (env != null)
+		{
+			try
+			{
+				Integer in = new Integer(env);
 
-	    xaNodeName = nodeName.stringForm().getBytes();
+				_defaultTimeout = in.intValue();
+			}
+			catch (Exception ex)
+			{
+				ex.printStackTrace();
+			}
+		}
 
-	    writeNodeName = true;
-	}
+		env = arjPropertyManager.propertyManager
+				.getProperty(Environment.MAINTAIN_HEURISTICS);
 
-	if (writeNodeName)
-	{
-	    arjPropertyManager.propertyManager.setProperty(Environment.XA_NODE_IDENTIFIER, new String(xaNodeName));
+		if (env != null)
+		{
+			if (env.compareTo("NO") == 0)
+				TxControl.maintainHeuristics = false;
+		}
+
+		env = arjPropertyManager.propertyManager
+				.getProperty(Environment.ASYNC_COMMIT);
+
+		if (env != null)
+		{
+			if (env.compareTo("YES") == 0)
+				TxControl.asyncCommit = true;
+		}
+
+		env = arjPropertyManager.propertyManager
+				.getProperty(Environment.ASYNC_PREPARE);
+
+		if (env != null)
+		{
+			if (env.compareTo("YES") == 0)
+				TxControl.asyncPrepare = true;
+		}
+
+		env = arjPropertyManager.propertyManager
+				.getProperty(Environment.COMMIT_ONE_PHASE);
+
+		if (env != null)
+		{
+			if (env.compareTo("NO") == 0)
+				TxControl.onePhase = false;
+		}
+
+		env = arjPropertyManager.propertyManager
+				.getProperty(Environment.ASYNC_ROLLBACK);
+
+		if (env != null)
+		{
+			if (env.compareTo("YES") == 0)
+				TxControl.asyncRollback = true;
+		}
+
+		env = arjPropertyManager.propertyManager
+				.getProperty(Environment.READONLY_OPTIMISATION);
+
+		if (env != null)
+		{
+			if (env.compareTo("NO") == 0)
+				TxControl.readonlyOptimisation = false;
+		}
+
+		env = arjPropertyManager.propertyManager
+				.getProperty(Environment.ENABLE_STATISTICS);
+
+		if (env != null)
+		{
+			if (env.compareTo("YES") == 0)
+				TxControl.enableStatistics = true;
+		}
+
+		env = arjPropertyManager.propertyManager
+				.getProperty(Environment.START_DISABLED);
+
+		if (env != null)
+		{
+			if (env.compareTo("YES") == 0)
+				TxControl.enable = false;
+		}
+
+		env = arjPropertyManager.propertyManager
+				.getProperty(Environment.XA_NODE_IDENTIFIER);
+		boolean writeNodeName = false;
+
+		if (env != null)
+		{
+			xaNodeName = env.getBytes();
+		}
+		else
+		{
+			Uid nodeName = new Uid();
+
+			if (tsLogger.arjLoggerI18N.isWarnEnabled())
+			{
+				tsLogger.arjLoggerI18N.warn(
+						"com.arjuna.ats.arjuna.coordinator.TxControl_1",
+						new Object[]
+						{ nodeName.stringForm() });
+			}
+
+			xaNodeName = nodeName.stringForm().getBytes();
+
+			writeNodeName = true;
+		}
+
+		if (xaNodeName.length > 30)
+		{
+			Uid nodeName = new Uid();
+
+			if (tsLogger.arjLoggerI18N.isWarnEnabled())
+			{
+				tsLogger.arjLoggerI18N.warn(
+						"com.arjuna.ats.arjuna.coordinator.TxControl_2",
+						new Object[]
+						{ nodeName.stringForm() });
+			}
+
+			xaNodeName = nodeName.stringForm().getBytes();
+
+			writeNodeName = true;
+		}
+
+		if ((env != null) && (env.indexOf('-') != -1))
+		{
+			Uid nodeName = new Uid();
+
+			if (tsLogger.arjLoggerI18N.isWarnEnabled())
+			{
+				tsLogger.arjLoggerI18N.warn(
+						"com.arjuna.ats.arjuna.coordinator.TxControl_3",
+						new Object[]
+						{ nodeName.stringForm() });
+			}
+
+			xaNodeName = nodeName.stringForm().getBytes();
+
+			writeNodeName = true;
+		}
+
+		if (writeNodeName)
+		{
+			arjPropertyManager.propertyManager.setProperty(
+					Environment.XA_NODE_IDENTIFIER, new String(xaNodeName));
+		}
+
+		if (transactionStatusManager == null)
+		{
+			transactionStatusManager = new TransactionStatusManager();
+
+			// add hook to ensure finalize gets called.
+			Runtime.getRuntime().addShutdownHook(new Thread()
+			{
+				public void run()
+				{
+					if (transactionStatusManager != null)
+					{
+						transactionStatusManager.finalize();
+					}
+				}
+			});
+		}
 	}
-        
-	if ( transactionStatusManager == null )
-	{
-	    transactionStatusManager = new TransactionStatusManager();
-            
-            // add hook to ensure finalize gets called.
-            Runtime.getRuntime().addShutdownHook(new Thread()
-            {
-                public void run()
-                {
-                    if ( transactionStatusManager != null )
-                    {
-                       transactionStatusManager.finalize() ;
-                    }
-                }
-            }) ;
-        }
-    }
 
 }




More information about the jboss-svn-commits mailing list