[jboss-svn-commits] JBL Code SVN: r37558 - in labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed: server and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Oct 15 18:17:11 EDT 2011


Author: tomjenkinson
Date: 2011-10-15 18:17:11 -0400 (Sat, 15 Oct 2011)
New Revision: 37558

Modified:
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/LocalServer.java
   labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java
Log:
JBTM-916 updated to allow the harness to cache the current transaction so that we don't need the loop from 1 2 1 2

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java	2011-10-15 22:08:45 UTC (rev 37557)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java	2011-10-15 22:17:11 UTC (rev 37558)
@@ -67,15 +67,15 @@
 		Transaction originalTransaction = transactionManager.getTransaction();
 		originalTransaction.registerSynchronization(new TestSynchronization(originalServer.getNodeName()));
 		originalTransaction.enlistResource(new TestResource(originalServer.getNodeName(), false));
-		Xid toMigrate = originalServer.getCurrentXid();
+		Xid toMigrate = originalServer.storeCurrentTransaction();
 
 		// Loop through the rest of the servers passing the transaction up and
 		// down
-		Transaction suspendedTransaction = originalServer.getTransactionManager().suspend();
+		Transaction suspendedTransaction = transactionManager.suspend();
 		long timeLeftBeforeTransactionTimeout = originalServer.getTimeLeftBeforeTransactionTimeout();
-		List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000, 3000, 2000, 1000, 2000, 3000, 1000, 3000 }));
+		List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000, 3000, 2000, 1000 }));
 		boolean proxyRequired = recursivelyFlowTransaction(nodesToFlowTo, timeLeftBeforeTransactionTimeout, toMigrate);
-		originalServer.getTransactionManager().resume(suspendedTransaction);
+		transactionManager.resume(suspendedTransaction);
 		if (proxyRequired) {
 			XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, originalServer.getNodeName(), 2000);
 			originalTransaction.enlistResource(proxyXAResource);
@@ -85,6 +85,7 @@
 
 		Transaction transaction = transactionManager.getTransaction();
 		transaction.commit();
+		originalServer.removeTransaction(toMigrate);
 	}
 
 	private boolean recursivelyFlowTransaction(List<Integer> nodesToFlowTo, long timeLeftBeforeTransactionTimeout, Xid toMigrate) throws RollbackException,
@@ -96,7 +97,7 @@
 		// Migrate the transaction to the next server
 		int remainingTimeout = (int) (timeLeftBeforeTransactionTimeout / 1000);
 
-		boolean requiresProxyAtPreviousServer = !currentServer.importTransaction(remainingTimeout, toMigrate);
+		boolean requiresProxyAtPreviousServer = !currentServer.getTransaction(remainingTimeout, toMigrate);
 		// Perform work on the migrated transaction
 		TransactionManager transactionManager = currentServer.getTransactionManager();
 		Transaction transaction = transactionManager.getTransaction();
@@ -107,7 +108,7 @@
 			Integer nextServerNodeName = nodesToFlowTo.get(0);
 
 			// SUSPEND THE TRANSACTION
-			Transaction suspendedTransaction = currentServer.getTransactionManager().suspend();
+			Transaction suspendedTransaction = transactionManager.suspend();
 			// FLOW THE TRANSACTION
 			timeLeftBeforeTransactionTimeout = currentServer.getTimeLeftBeforeTransactionTimeout();
 			boolean proxyRequired = recursivelyFlowTransaction(nodesToFlowTo, timeLeftBeforeTransactionTimeout, toMigrate);
@@ -121,7 +122,7 @@
 			// performance
 			// issues
 			// RESUME THE TRANSACTION IN CASE THERE IS MORE WORK
-			currentServer.getTransactionManager().resume(suspendedTransaction);
+			transactionManager.resume(suspendedTransaction);
 			if (proxyRequired) {
 				XAResource proxyXAResource = currentServer.generateProxyXAResource(lookupProvider, currentServer.getNodeName(), nextServerNodeName);
 				suspendedTransaction.enlistResource(proxyXAResource);
@@ -129,8 +130,9 @@
 						nextServerNodeName, toMigrate));
 			}
 		}
+
 		// SUSPEND THE TRANSACTION WHEN YOU ARE READY TO RETURN TO YOUR CALLER
-		currentServer.getTransactionManager().suspend();
+		transactionManager.suspend();
 		return requiresProxyAtPreviousServer;
 	}
 

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/LocalServer.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/LocalServer.java	2011-10-15 22:08:45 UTC (rev 37557)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/LocalServer.java	2011-10-15 22:17:11 UTC (rev 37558)
@@ -7,6 +7,7 @@
 import javax.transaction.RollbackException;
 import javax.transaction.Synchronization;
 import javax.transaction.SystemException;
+import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
@@ -26,9 +27,11 @@
 
 	public long getTimeLeftBeforeTransactionTimeout() throws RollbackException;
 
-	public Xid getCurrentXid() throws SystemException;
+	public Xid storeCurrentTransaction() throws SystemException;
 
-	public boolean importTransaction(int remainingTimeout, Xid toImport) throws XAException, InvalidTransactionException, IllegalStateException,
+	public void removeTransaction(Xid toMigrate);
+
+	public boolean getTransaction(int remainingTimeout, Xid toImport) throws XAException, InvalidTransactionException, IllegalStateException,
 			SystemException;
 
 	public RemoteServer connectTo();
@@ -38,5 +41,4 @@
 	public XAResource generateProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName);
 
 	public Synchronization generateProxySynchronization(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName, Xid toRegisterAgainst);
-
 }

Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java	2011-10-15 22:08:45 UTC (rev 37557)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java	2011-10-15 22:17:11 UTC (rev 37558)
@@ -14,6 +14,7 @@
 import javax.transaction.RollbackException;
 import javax.transaction.Synchronization;
 import javax.transaction.SystemException;
+import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
 import javax.transaction.xa.XAException;
 import javax.transaction.xa.XAResource;
@@ -32,6 +33,7 @@
 import com.arjuna.ats.internal.jbossatx.jta.XAResourceRecordWrappingPluginImpl;
 import com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple;
 import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateXidImple;
 import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinationManager;
 import com.arjuna.ats.jbossatx.jta.RecoveryManagerService;
 import com.arjuna.ats.jbossatx.jta.TransactionManagerService;
@@ -49,6 +51,7 @@
 	private TransactionManagerService transactionManagerService;
 	private boolean offline;
 	private LookupProvider lookupProvider;
+	private Map<SubordinateXidImple, TransactionImple> transactions = new HashMap<SubordinateXidImple, TransactionImple>();
 
 	public void initialise(LookupProvider lookupProvider, Integer serverName) throws CoreEnvironmentBeanException, IOException {
 		this.lookupProvider = lookupProvider;
@@ -145,15 +148,17 @@
 	}
 
 	@Override
-	public boolean importTransaction(int remainingTimeout, Xid toResume) throws XAException, InvalidTransactionException, IllegalStateException,
-			SystemException {
+	public boolean getTransaction(int remainingTimeout, Xid toResume) throws XAException, InvalidTransactionException, IllegalStateException, SystemException {
 		boolean existed = true;
-		SubordinateTransaction importTransaction = SubordinationManager.getTransactionImporter().getImportedTransaction(toResume);
-		if (importTransaction == null) {
-			importTransaction = SubordinationManager.getTransactionImporter().importTransaction(toResume, remainingTimeout);
-			existed = false;
+		Transaction transaction = transactions.get(new SubordinateXidImple(toResume));
+		if (transaction == null) {
+			transaction = SubordinationManager.getTransactionImporter().getImportedTransaction(toResume);
+			if (transaction == null) {
+				transaction = SubordinationManager.getTransactionImporter().importTransaction(toResume, remainingTimeout);
+				existed = false;
+			}
 		}
-		getTransactionManager().resume(importTransaction);
+		transactionManagerService.getTransactionManager().resume(transaction);
 		return existed;
 	}
 
@@ -168,12 +173,19 @@
 	}
 
 	@Override
-	public Xid getCurrentXid() throws SystemException {
+	public Xid storeCurrentTransaction() throws SystemException {
 		TransactionImple transaction = ((TransactionImple) transactionManagerService.getTransactionManager().getTransaction());
-		return transaction.getTxId();
+		Xid txId = transaction.getTxId();
+		transactions.put(new SubordinateXidImple(txId), transaction);
+		return txId;
 	}
 
 	@Override
+	public void removeTransaction(Xid toMigrate) {
+		transactions.remove(new SubordinateXidImple(toMigrate));
+	}
+
+	@Override
 	public XAResource generateProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName) {
 		return new ProxyXAResource(lookupProvider, localServerName, remoteServerName);
 	}



More information about the jboss-svn-commits mailing list