[jboss-svn-commits] JBL Code SVN: r37646 - in labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration: examples/classes/com/arjuna/jta/distributed/example/server/impl and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Oct 21 03:27:42 EDT 2011
Author: tomjenkinson
Date: 2011-10-21 03:27:41 -0400 (Fri, 21 Oct 2011)
New Revision: 37646
Modified:
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java
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/TestResource.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java
Log:
JBTM-895 added a couple of rollback only tests
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java 2011-10-20 16:49:03 UTC (rev 37645)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java 2011-10-21 07:27:41 UTC (rev 37646)
@@ -133,6 +133,10 @@
this.xid = null;
}
+ public void start(Xid xid, int flags) throws XAException {
+ System.out.println(" TestResource (" + localServerName + ") XA_START [" + xid + "] Flags=" + flags);
+ }
+
public void end(Xid xid, int flags) throws XAException {
System.out.println(" TestResource (" + localServerName + ") XA_END [" + xid + "] Flags=" + flags);
}
@@ -182,8 +186,4 @@
timeout = seconds;
return (true);
}
-
- public void start(Xid xid, int flags) throws XAException {
- System.out.println(" TestResource (" + localServerName + ") XA_START [" + xid + "] Flags=" + flags);
- }
}
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java 2011-10-20 16:49:03 UTC (rev 37645)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java 2011-10-21 07:27:41 UTC (rev 37646)
@@ -229,7 +229,6 @@
if (e.errorCode == XAException.XAER_INVAL) {
// We know that this means that the transaction is not known at
// the remote side
- e.printStackTrace();
}
}
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-20 16:49:03 UTC (rev 37645)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java 2011-10-21 07:27:41 UTC (rev 37646)
@@ -161,7 +161,7 @@
XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, 2000);
originalServer.storeRootTransaction();
transactionManager.suspend();
- performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid, 1, false);
+ performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid, 1, false, false);
transactionManager.resume(originalTransaction);
originalTransaction.enlistResource(proxyXAResource);
// Needs a second resource to make sure we dont get the one
@@ -238,7 +238,7 @@
originalServer.storeRootTransaction();
XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, 2000);
transactionManager.suspend();
- performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid, 2, false);
+ performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid, 2, false, false);
transactionManager.resume(originalTransaction);
originalTransaction.enlistResource(proxyXAResource);
originalServer.removeRootTransaction(currentXid);
@@ -316,7 +316,7 @@
originalServer.storeRootTransaction();
XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, 2000);
transactionManager.suspend();
- performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid, 2, false);
+ performTransactionalWork(null, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid, 2, false, false);
transactionManager.resume(originalTransaction);
originalTransaction.enlistResource(proxyXAResource);
originalServer.removeRootTransaction(currentXid);
@@ -430,7 +430,7 @@
originalServer.storeRootTransaction();
XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, 2000);
transactionManager.suspend();
- performTransactionalWork(counter, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid, 2, false);
+ performTransactionalWork(counter, new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout, currentXid, 2, false, false);
transactionManager.resume(originalTransaction);
originalTransaction.enlistResource(proxyXAResource);
originalServer.removeRootTransaction(currentXid);
@@ -492,7 +492,7 @@
int startingTimeout = 0;
List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 3000, 2000, 1000, 2000, 3000, 1000, 3000 }));
try {
- doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, true);
+ doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, true, false);
} catch (InvalidTransactionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -568,7 +568,7 @@
XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, 2000);
transactionManager.suspend();
performTransactionalWork(getLocalServer(2000).getCompletionCounter(), new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout,
- currentXid, 1, false);
+ currentXid, 1, false, false);
transactionManager.resume(originalTransaction);
originalTransaction.enlistResource(proxyXAResource);
originalServer.removeRootTransaction(currentXid);
@@ -599,7 +599,7 @@
XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, 2000);
transactionManager.suspend();
performTransactionalWork(getLocalServer(2000).getCompletionCounter(), new LinkedList<Integer>(Arrays.asList(new Integer[] { 2000 })), remainingTimeout,
- currentXid, 1, false);
+ currentXid, 1, false, false);
transactionManager.resume(originalTransaction);
originalTransaction.enlistResource(proxyXAResource);
originalTransaction
@@ -615,11 +615,27 @@
}
@Test
+ public void testMigrateTransactionRollbackOnlyCommit() throws NotSupportedException, SystemException, IllegalStateException, RollbackException, XAException,
+ SecurityException, HeuristicMixedException, HeuristicRollbackException, IOException {
+ int startingTimeout = 0;
+ List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 3000, 2000, 1000, 2000, 3000, 1000, 3000 }));
+ doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, true, true);
+ }
+
+ @Test
+ public void testMigrateTransactionRollbackOnlyRollback() throws NotSupportedException, SystemException, IllegalStateException, RollbackException, XAException,
+ SecurityException, HeuristicMixedException, HeuristicRollbackException, IOException {
+ int startingTimeout = 0;
+ List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 3000, 2000, 1000, 2000, 3000, 1000, 3000 }));
+ doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, false, true);
+ }
+
+ @Test
public void testMigrateTransactionCommit() throws NotSupportedException, SystemException, IllegalStateException, RollbackException, XAException,
SecurityException, HeuristicMixedException, HeuristicRollbackException, IOException {
int startingTimeout = 0;
List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 3000, 2000, 1000, 2000, 3000, 1000, 3000 }));
- doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, true);
+ doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, true, false);
}
@Test
@@ -628,7 +644,7 @@
int startingTimeout = 0;
List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 1000, 3000, 1000, 2000, 3000 }));
- doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, true);
+ doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, true, false);
}
@Test
@@ -636,7 +652,7 @@
SecurityException, HeuristicMixedException, HeuristicRollbackException, IOException {
int startingTimeout = 0;
List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 3000, 2000, 1000, 2000, 3000, 1000, 3000 }));
- doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, false);
+ doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, false, false);
}
@Test
@@ -644,7 +660,7 @@
SecurityException, HeuristicMixedException, HeuristicRollbackException, IOException {
int startingTimeout = 0;
List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 1000, 3000, 1000, 2000, 3000 }));
- doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, false);
+ doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, false, false);
}
@Test
@@ -693,7 +709,7 @@
assertTrue(getLocalServer(1000).getCompletionCounter().getRollbackCount() == 2);
}
- private void doRecursiveTransactionalWork(int startingTimeout, List<Integer> nodesToFlowTo, boolean commit) throws NotSupportedException, SystemException,
+ private void doRecursiveTransactionalWork(int startingTimeout, List<Integer> nodesToFlowTo, boolean commit, boolean rollbackOnlyOnLastNode) throws NotSupportedException, SystemException,
RollbackException, IllegalStateException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException, IOException {
// Start out at the first server
@@ -741,12 +757,18 @@
Xid currentXid = originalServer.getCurrentXid();
originalServer.storeRootTransaction();
transactionManager.suspend();
- performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid, 1, true);
+ performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid, 1, true, rollbackOnlyOnLastNode);
transactionManager.resume(originalTransaction);
originalServer.removeRootTransaction(currentXid);
if (commit) {
- transactionManager.commit();
- assertTrue(counter.getCommitCount() == totalNodeCount);
+ try {
+ transactionManager.commit();
+ assertTrue(counter.getCommitCount() == totalNodeCount);
+ } catch (RollbackException e) {
+ if (!rollbackOnlyOnLastNode) {
+ assertTrue(counter.getRollbackCount() == totalNodeCount);
+ }
+ }
} else {
transactionManager.rollback();
assertTrue(counter.getRollbackCount() == totalNodeCount);
@@ -755,7 +777,7 @@
}
private boolean performTransactionalWork(CompletionCounter counter, List<Integer> nodesToFlowTo, int remainingTimeout, Xid toMigrate,
- int numberOfResourcesToRegister, boolean addSynchronization) throws RollbackException, IllegalStateException, XAException, SystemException,
+ int numberOfResourcesToRegister, boolean addSynchronization, boolean rollbackOnlyOnLastNode) throws RollbackException, IllegalStateException, XAException, SystemException,
NotSupportedException, IOException {
Integer currentServerName = nodesToFlowTo.remove(0);
LocalServer currentServer = getLocalServer(currentServerName);
@@ -774,7 +796,11 @@
transaction.enlistResource(new TestResource(counter, currentServer.getNodeName(), false));
}
- if (!nodesToFlowTo.isEmpty()) {
+ if (nodesToFlowTo.isEmpty()) {
+ if (rollbackOnlyOnLastNode) {
+ transaction.setRollbackOnly();
+ }
+ } else {
Integer nextServerNodeName = nodesToFlowTo.get(0);
// FLOW THE TRANSACTION
@@ -786,7 +812,7 @@
transactionManager.suspend();
boolean proxyRequired = performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid, numberOfResourcesToRegister,
- addSynchronization);
+ addSynchronization, rollbackOnlyOnLastNode);
transactionManager.resume(transaction);
// Create a proxy for the new server if necessary, this can orphan
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/TestResource.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/TestResource.java 2011-10-20 16:49:03 UTC (rev 37645)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/TestResource.java 2011-10-21 07:27:41 UTC (rev 37646)
@@ -146,6 +146,10 @@
this.xid = null;
}
+ public void start(Xid xid, int flags) throws XAException {
+ System.out.println(" TestResource (" + serverId + ") XA_START [" + xid + "] Flags=" + flags);
+ }
+
public void end(Xid xid, int flags) throws XAException {
System.out.println(" TestResource (" + serverId + ") XA_END [" + xid + "] Flags=" + flags);
}
@@ -195,8 +199,4 @@
timeout = seconds;
return (true);
}
-
- public void start(Xid xid, int flags) throws XAException {
- System.out.println(" TestResource (" + serverId + ") XA_START [" + xid + "] Flags=" + flags);
- }
}
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java 2011-10-20 16:49:03 UTC (rev 37645)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java 2011-10-21 07:27:41 UTC (rev 37646)
@@ -200,7 +200,6 @@
if (e.errorCode == XAException.XAER_INVAL) {
// We know that this means that the transaction is not known at
// the remote side
- e.printStackTrace();
}
}
More information about the jboss-svn-commits
mailing list