[jboss-svn-commits] JBL Code SVN: r37807 - in labs/jbosstm/branches/JBOSSTS_4_16: ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/jca and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Dec 15 08:00:16 EST 2011
Author: tomjenkinson
Date: 2011-12-15 08:00:15 -0500 (Thu, 15 Dec 2011)
New Revision: 37807
Modified:
labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/jca/XATerminatorImple.java
labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java
labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java
labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java
labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java
Log:
JBTM-895 updated to ensure that simultaneous recover test runs the recover scans simulataneously as possible and to ensure that the ProxyXAResource Recovery helper is registered *last*
Modified: labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2011-12-15 12:52:55 UTC (rev 37806)
+++ labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/XARecoveryModule.java 2011-12-15 13:00:15 UTC (rev 37807)
@@ -192,10 +192,9 @@
private XAResource getNewXAResource(Xid xid)
{
- // JBTM-895 updated to always call bottomUpRecovery when server is not bounced and subordinate calls recover before we have chance to
-// if (_xidScans == null) {
+ if (_xidScans == null) {
bottomUpRecovery();
-// }
+ }
if (_xidScans != null)
{
Modified: labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/jca/XATerminatorImple.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/jca/XATerminatorImple.java 2011-12-15 12:52:55 UTC (rev 37806)
+++ labs/jbosstm/branches/JBOSSTS_4_16/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/jca/XATerminatorImple.java 2011-12-15 13:00:15 UTC (rev 37807)
@@ -353,7 +353,7 @@
* @return a list of potentially indoubt transactions or <code>null</code>.
*/
- public synchronized Xid[] doRecover (Xid xid, String parentNodeName) throws XAException
+ public Xid[] doRecover (Xid xid, String parentNodeName) throws XAException
{
/*
* Requires going through the objectstore for the states of imported
Modified: labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java 2011-12-15 12:52:55 UTC (rev 37806)
+++ labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java 2011-12-15 13:00:15 UTC (rev 37807)
@@ -36,6 +36,8 @@
import javax.transaction.xa.XAException;
import javax.transaction.xa.Xid;
+import org.jboss.tm.XAResourceRecovery;
+
import com.arjuna.ats.arjuna.common.CoordinatorEnvironmentBean;
import com.arjuna.ats.arjuna.common.CoreEnvironmentBean;
import com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException;
@@ -83,6 +85,10 @@
*
* The addition required for the distributed JTA code is:
* RecoveryManagerService::addSerializableXAResourceDeserializer()
+ *
+ * You must also register with RecoveryManagerService::addXAResourceRecovery
+ * an {@link XAResourceRecovery} for your Proxy XA Resources so that they
+ * can find orphan subordinate transactions.
*/
public void initialise(LookupProvider lookupProvider, String nodeName, int portOffset, String[] clusterBuddies, ClassLoader classLoaderForTransactionManager)
throws CoreEnvironmentBeanException, IOException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
@@ -157,8 +163,11 @@
recoveryManagerService = new RecoveryManagerService();
recoveryManagerService.create();
+ recoveryManagerService.addXAResourceRecovery(new TestResourceRecovery(nodeName));
+ // This MUST be the last XAResourceRecovery class registered or you will
+ // get unexpected recovery results, could add a specific interface for
+ // this?
recoveryManagerService.addXAResourceRecovery(new ProxyXAResourceRecovery(nodeName, clusterBuddies));
- recoveryManagerService.addXAResourceRecovery(new TestResourceRecovery(nodeName));
recoveryManagerService.addSerializableXAResourceDeserializer(new ProxyXAResourceDeserializer());
// recoveryManagerService.start();
Modified: labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java 2011-12-15 12:52:55 UTC (rev 37806)
+++ labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java 2011-12-15 13:00:15 UTC (rev 37807)
@@ -24,6 +24,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@@ -73,8 +74,31 @@
}
}
+ public static boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i = 0; i < children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+
+ // The directory is now empty so delete it
+ return dir.delete();
+ }
+
@AfterClass
public static void tearDown() throws Exception {
+ // Enable it if you need to ensure the folder is empty for some reason
+ if (false) {
+ File file = new File(System.getProperty("user.dir") + "/distributedjta-tests/");
+ boolean delete = !file.exists() ? true : deleteDir(file);
+ if (!delete) {
+ throw new Exception("Could not delete folder");
+ }
+ }
for (int i = 0; i < localServers.length; i++) {
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(localServers[i].getClassLoader());
@@ -242,14 +266,25 @@
reboot("1000");
reboot("2000");
reboot("3000");
-
+
final CompletionCountLock lock = new CompletionCountLock();
-
- getLocalServer("2000").doRecoveryManagerScan(true);
- lock.incrementCount();
+ {
+ new Thread(new Runnable() {
+ public void run() {
+ getLocalServer("2000").doRecoveryManagerScan(true);
+ lock.incrementCount();
+ }
+ }).start();
+ }
- getLocalServer("1000").doRecoveryManagerScan(true);
- lock.incrementCount();
+ {
+ new Thread(new Runnable() {
+ public void run() {
+ getLocalServer("1000").doRecoveryManagerScan(true);
+ lock.incrementCount();
+ }
+ }).start();
+ }
synchronized (lock) {
while (lock.getCount() < 2) {
@@ -324,7 +359,7 @@
reboot("1000");
reboot("2000");
reboot("3000");
-
+
{
assertTrue(completionCounter.getCommitCount("2000") == 0);
@@ -411,7 +446,7 @@
reboot("1000");
reboot("2000");
reboot("3000");
-
+
{
assertTrue(completionCounter.getCommitCount("2000") == 0);
@@ -645,7 +680,7 @@
reboot("1000");
reboot("2000");
reboot("3000");
-
+
getLocalServer("1000").doRecoveryManagerScan(false);
assertTrue(completionCounter.getCommitCount("1000") == 4);
@@ -931,7 +966,6 @@
XAException, SystemException, NotSupportedException, IOException {
String currentServerName = nodesToFlowTo.remove(0);
LocalServer currentServer = getLocalServer(currentServerName);
- System.out.println("Flowed to " + currentServerName);
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(currentServer.getClassLoader());
@@ -1017,7 +1051,6 @@
// Return to the previous caller back over the transport/classloader
// boundary in this case
Thread.currentThread().setContextClassLoader(classLoader);
- System.out.println("Flowed from " + currentServerName);
return new DataReturnedFromRemoteServer(requiresProxyAtPreviousServer, transactionState);
}
@@ -1033,8 +1066,9 @@
return count;
}
- public void incrementCount() {
+ public synchronized void incrementCount() {
this.count++;
+ this.notify();
}
}
Modified: labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java 2011-12-15 12:52:55 UTC (rev 37806)
+++ labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java 2011-12-15 13:00:15 UTC (rev 37807)
@@ -99,7 +99,7 @@
* server about.
*/
@Override
- public int prepare(Xid xid) throws XAException {
+ public int prepare(Xid xid) throws XAException {
System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_PREPARE [" + xid + "]");
Xid toPropagate = migratedXid != null ? migratedXid : xid;
@@ -109,7 +109,7 @@
}
@Override
- public void commit(Xid xid, boolean onePhase) throws XAException {
+ public void commit(Xid xid, boolean onePhase) throws XAException {
System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_COMMIT [" + xid + "]");
Xid toPropagate = migratedXid != null ? migratedXid : xid;
@@ -121,7 +121,7 @@
}
@Override
- public void rollback(Xid xid) throws XAException {
+ public void rollback(Xid xid) throws XAException {
System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_ROLLBACK[" + xid + "]");
Xid toPropagate = migratedXid != null ? migratedXid : xid;
Modified: labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java 2011-12-15 12:52:55 UTC (rev 37806)
+++ labs/jbosstm/branches/JBOSSTS_4_16/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java 2011-12-15 13:00:15 UTC (rev 37807)
@@ -144,8 +144,11 @@
recoveryManagerService = new RecoveryManagerService();
recoveryManagerService.create();
+ recoveryManagerService.addXAResourceRecovery(new TestResourceRecovery(nodeName));
+ // This MUST be the last XAResourceRecovery class registered or you will
+ // get unexpected recovery results, could add a specific interface for
+ // this?
recoveryManagerService.addXAResourceRecovery(new ProxyXAResourceRecovery(nodeName, clusterBuddies));
- recoveryManagerService.addXAResourceRecovery(new TestResourceRecovery(nodeName));
recoveryManagerService.addSerializableXAResourceDeserializer(new ProxyXAResourceDeserializer());
// recoveryManagerService.start();
More information about the jboss-svn-commits
mailing list