[jboss-svn-commits] JBL Code SVN: r37596 - in labs/jbosstm/branches/JBOSSTS_4_15_0_Final: atsintegration and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Oct 19 04:34:10 EDT 2011
Author: tomjenkinson
Date: 2011-10-19 04:34:09 -0400 (Wed, 19 Oct 2011)
New Revision: 37596
Added:
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestResource.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestResourceRecovery.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestSynchronization.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/CompletionCounter.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/DummyRemoteException.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/IsolatableServersClassLoader.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LocalServer.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LookupProvider.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/RemoteServer.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxySynchronization.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java
Removed:
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestResource.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestResourceRecovery.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestSynchronization.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/DummyRemoteException.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/IsolatableServersClassLoader.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LocalServer.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LookupProvider.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/RemoteServer.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxySynchronization.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/
Modified:
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/.classpath
Log:
JBTM-895 updated to make it clear that this is an example of how to work with distributed JTA
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/.classpath
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/.classpath 2011-10-19 08:29:28 UTC (rev 37595)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/.classpath 2011-10-19 08:34:09 UTC (rev 37596)
@@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="atsintegration/build/classes"/>
<classpathentry kind="src" path="atsintegration/classes"/>
- <classpathentry kind="src" path="atsintegration/tests/classes"/>
+ <classpathentry kind="src" path="atsintegration/examples/classes"/>
<classpathentry kind="src" path="antbuildsystem/classes"/>
<classpathentry kind="src" path="common/classes"/>
<classpathentry kind="src" path="common/tests"/>
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/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-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,148 +0,0 @@
-package com.arjuna.ats.jta.distributed;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException;
-import com.arjuna.ats.jta.distributed.server.IsolatableServersClassLoader;
-import com.arjuna.ats.jta.distributed.server.LocalServer;
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-import com.arjuna.ats.jta.distributed.server.RemoteServer;
-
-public class SimpleIsolatedServers {
- private static LookupProvider lookupProvider = new MyLookupProvider();
- private static LocalServer[] localServers = new LocalServer[3];
- private static RemoteServer[] remoteServers = new RemoteServer[3];
-
- @BeforeClass
- public static void setup() throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, ClassNotFoundException,
- CoreEnvironmentBeanException, IOException, IllegalArgumentException, NoSuchFieldException {
- for (int i = 0; i < localServers.length; i++) {
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- IsolatableServersClassLoader classLoader = new IsolatableServersClassLoader("com.arjuna.ats.jta.distributed.server", contextClassLoader);
- localServers[i] = (LocalServer) classLoader.loadClass("com.arjuna.ats.jta.distributed.server.impl.ServerImpl").newInstance();
- Thread.currentThread().setContextClassLoader(localServers[i].getClass().getClassLoader());
- localServers[i].initialise(lookupProvider, (i + 1) * 1000);
- remoteServers[i] = localServers[i].connectTo();
- Thread.currentThread().setContextClassLoader(contextClassLoader);
- }
- }
-
- @Test
- public void testRecovery() {
- // getLocalServer(3000).doRecoveryManagerScan();
- // getLocalServer(2000).doRecoveryManagerScan();
- getLocalServer(1000).doRecoveryManagerScan();
- }
-
- @Test
- public void testMigrateTransactionCommit() throws NotSupportedException, SystemException, IllegalStateException, RollbackException,
- InvalidTransactionException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException {
-
- File file = new File(System.getProperty("user.dir") + "/tmp/");
- if (file.exists()) {
- file.delete();
- }
- int startingTimeout = 10000;
- List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 3000, 2000, 1000, 2000, 3000, 1000, 3000 }));
-
- // Start out at the first server
- LocalServer originalServer = getLocalServer(1000);
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(originalServer.getClass().getClassLoader());
- TransactionManager transactionManager = originalServer.getTransactionManager();
- transactionManager.setTransactionTimeout(startingTimeout);
- transactionManager.begin();
- Transaction originalTransaction = transactionManager.getTransaction();
- int remainingTimeout = (int) (originalServer.getTimeLeftBeforeTransactionTimeout() / 1000);
- Xid currentXid = originalServer.getCurrentXid();
- originalServer.storeRootTransaction();
- transactionManager.suspend();
- performTransactionalWork(nodesToFlowTo, remainingTimeout, currentXid);
- transactionManager.resume(originalTransaction);
- originalServer.removeRootTransaction(currentXid);
- originalTransaction.commit();
- Thread.currentThread().setContextClassLoader(classLoader);
- }
-
- private boolean performTransactionalWork(List<Integer> nodesToFlowTo, int remainingTimeout, Xid toMigrate) throws RollbackException,
- InvalidTransactionException, IllegalStateException, XAException, SystemException, NotSupportedException {
- Integer currentServerName = nodesToFlowTo.remove(0);
- LocalServer currentServer = getLocalServer(currentServerName);
-
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(currentServer.getClass().getClassLoader());
-
- boolean requiresProxyAtPreviousServer = !currentServer.getAndResumeTransaction(remainingTimeout, toMigrate);
- // Perform work on the migrated transaction
- TransactionManager transactionManager = currentServer.getTransactionManager();
- Transaction transaction = transactionManager.getTransaction();
- transaction.registerSynchronization(new TestSynchronization(currentServer.getNodeName()));
- transaction.enlistResource(new TestResource(currentServer.getNodeName(), false));
-
- if (!nodesToFlowTo.isEmpty()) {
- Integer nextServerNodeName = nodesToFlowTo.get(0);
-
- // FLOW THE TRANSACTION
- remainingTimeout = (int) (currentServer.getTimeLeftBeforeTransactionTimeout() / 1000);
-
- // SUSPEND THE TRANSACTION
- Xid currentXid = currentServer.getCurrentXid();
- transactionManager.suspend();
- boolean proxyRequired = performTransactionalWork(nodesToFlowTo, remainingTimeout, currentXid);
- transactionManager.resume(transaction);
-
- // Create a proxy for the new server if necessary, this can orphan
- // the remote server but XA recovery will handle that on the remote
- // server
- // The alternative is to always create a proxy but this is a
- // performance drain and will result in multiple subordinate
- // transactions and performance issues
- if (proxyRequired) {
- XAResource proxyXAResource = currentServer.generateProxyXAResource(lookupProvider, currentServer.getNodeName(), nextServerNodeName);
- transaction.enlistResource(proxyXAResource);
- transaction.registerSynchronization(currentServer.generateProxySynchronization(lookupProvider, currentServer.getNodeName(), nextServerNodeName,
- toMigrate));
- }
- }
-
- // SUSPEND THE TRANSACTION WHEN YOU ARE READY TO RETURN TO YOUR CALLER
- transactionManager.suspend();
-
- Thread.currentThread().setContextClassLoader(classLoader);
- return requiresProxyAtPreviousServer;
- }
-
- private static LocalServer getLocalServer(Integer jndiName) {
- int index = (jndiName / 1000) - 1;
- return localServers[index];
- }
-
- private static class MyLookupProvider implements LookupProvider {
-
- @Override
- public RemoteServer lookup(Integer jndiName) {
- int index = (jndiName / 1000) - 1;
- return remoteServers[index];
- }
-
- }
-}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java (from rev 37587, 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/examples/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/SimpleIsolatedServers.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,344 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException;
+import com.arjuna.ats.jta.distributed.server.CompletionCounter;
+import com.arjuna.ats.jta.distributed.server.IsolatableServersClassLoader;
+import com.arjuna.ats.jta.distributed.server.LocalServer;
+import com.arjuna.ats.jta.distributed.server.LookupProvider;
+import com.arjuna.ats.jta.distributed.server.RemoteServer;
+
+public class SimpleIsolatedServers {
+ private static LookupProvider lookupProvider = new MyLookupProvider();
+ private static LocalServer[] localServers = new LocalServer[3];
+ private static RemoteServer[] remoteServers = new RemoteServer[3];
+
+ @BeforeClass
+ public static void setup() throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, ClassNotFoundException,
+ CoreEnvironmentBeanException, IOException, IllegalArgumentException, NoSuchFieldException {
+ for (int i = 0; i < localServers.length; i++) {
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ IsolatableServersClassLoader classLoader = new IsolatableServersClassLoader("com.arjuna.ats.jta.distributed.server", contextClassLoader);
+ localServers[i] = (LocalServer) classLoader.loadClass("com.arjuna.ats.jta.distributed.server.impl.ServerImpl").newInstance();
+ Thread.currentThread().setContextClassLoader(localServers[i].getClass().getClassLoader());
+ localServers[i].initialise(lookupProvider, (i + 1) * 1000);
+ remoteServers[i] = localServers[i].connectTo();
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+ }
+ }
+
+ @Test
+ public void testRecovery() throws IOException {
+ assertTrue(getLocalServer(3000).getCompletionCounter().getCommitCount() == 0);
+ assertTrue(getLocalServer(2000).getCompletionCounter().getCommitCount() == 0);
+ assertTrue(getLocalServer(1000).getCompletionCounter().getCommitCount() == 0);
+ // Start out at the first server
+ // getLocalServer(3000).doRecoveryManagerScan();
+ // getLocalServer(2000).doRecoveryManagerScan();
+ getLocalServer(1000).doRecoveryManagerScan();
+
+ assertTrue(getLocalServer(1000).getCompletionCounter().getCommitCount() == 3);
+ assertTrue(getLocalServer(2000).getCompletionCounter().getCommitCount() == 3);
+ assertTrue(getLocalServer(3000).getCompletionCounter().getCommitCount() == 3);
+ }
+
+ @Test
+ public void testMigrateTransactionCommit() throws NotSupportedException, SystemException, IllegalStateException, RollbackException,
+ InvalidTransactionException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException {
+
+ File file = new File(System.getProperty("user.dir") + "/tmp/");
+ if (file.exists()) {
+ file.delete();
+ }
+ 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);
+ }
+
+ @Test
+ public void testMigrateTransactionCommitDiamond() throws NotSupportedException, SystemException, IllegalStateException, RollbackException,
+ InvalidTransactionException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException {
+
+ File file = new File(System.getProperty("user.dir") + "/tmp/");
+ if (file.exists()) {
+ file.delete();
+ }
+ int startingTimeout = 0;
+ List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 1000, 3000, 1000, 2000, 3000 }));
+ doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, true);
+ }
+
+ @Test
+ public void testMigrateTransactionRollback() throws NotSupportedException, SystemException, IllegalStateException, RollbackException,
+ InvalidTransactionException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException {
+
+ File file = new File(System.getProperty("user.dir") + "/tmp/");
+ if (file.exists()) {
+ file.delete();
+ }
+ 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);
+ }
+
+ @Test
+ public void testMigrateTransactionRollbackDiamond() throws NotSupportedException, SystemException, IllegalStateException, RollbackException,
+ InvalidTransactionException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException {
+
+ File file = new File(System.getProperty("user.dir") + "/tmp/");
+ if (file.exists()) {
+ file.delete();
+ }
+ int startingTimeout = 0;
+ List<Integer> nodesToFlowTo = new LinkedList<Integer>(Arrays.asList(new Integer[] { 1000, 2000, 1000, 3000, 1000, 2000, 3000 }));
+ doRecursiveTransactionalWork(startingTimeout, nodesToFlowTo, false);
+ }
+
+ @Test
+ public void testMigrateTransactionSubordinateTimeout() throws NotSupportedException, SystemException, IllegalStateException, RollbackException,
+ InvalidTransactionException, XAException, SecurityException, HeuristicMixedException, HeuristicRollbackException, InterruptedException {
+
+ File file = new File(System.getProperty("user.dir") + "/tmp/");
+ if (file.exists()) {
+ file.delete();
+ }
+ int rootTimeout = 10000;
+ int subordinateTimeout = 1;
+
+ // Start out at the first server
+ CompletionCounter counter = new CompletionCounter() {
+ private int commitCount = 0;
+ private int rollbackCount = 0;
+
+ @Override
+ public void incrementCommit() {
+ commitCount++;
+
+ }
+
+ @Override
+ public void incrementRollback() {
+ rollbackCount++;
+ }
+
+ @Override
+ public int getCommitCount() {
+ return commitCount;
+ }
+
+ @Override
+ public int getRollbackCount() {
+ return rollbackCount;
+ }
+
+ @Override
+ public void resetCounters() {
+ commitCount = 0;
+ rollbackCount = 0;
+ }
+ };
+ LocalServer originalServer = getLocalServer(1000);
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(originalServer.getClass().getClassLoader());
+ TransactionManager transactionManager = originalServer.getTransactionManager();
+ transactionManager.setTransactionTimeout(rootTimeout);
+ transactionManager.begin();
+ Transaction originalTransaction = transactionManager.getTransaction();
+ Xid toMigrate = originalServer.getCurrentXid();
+ originalServer.storeRootTransaction();
+ originalTransaction.enlistResource(new TestResource(counter, originalServer.getNodeName(), false));
+ transactionManager.suspend();
+
+ // Migrate a transaction
+ LocalServer currentServer = getLocalServer(2000);
+ ClassLoader parentsClassLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(currentServer.getClass().getClassLoader());
+ currentServer.getAndResumeTransaction(subordinateTimeout, toMigrate);
+ currentServer.getTransactionManager().getTransaction().enlistResource(new TestResource(counter, currentServer.getNodeName(), false));
+ currentServer.getTransactionManager().suspend();
+ Thread.currentThread().setContextClassLoader(parentsClassLoader);
+
+ // Complete the transaction at the original server
+ transactionManager.resume(originalTransaction);
+ XAResource proxyXAResource = originalServer.generateProxyXAResource(lookupProvider, originalServer.getNodeName(), 2000);
+ originalTransaction.enlistResource(proxyXAResource);
+ originalServer.removeRootTransaction(toMigrate);
+ Thread.currentThread().sleep((subordinateTimeout + 1) * 1000);
+ try {
+ transactionManager.commit();
+ } catch (RollbackException rbe) {
+ // GOOD!
+ assertTrue(counter.getRollbackCount() == 2);
+ } finally {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+ }
+
+ private void doRecursiveTransactionalWork(int startingTimeout, List<Integer> nodesToFlowTo, boolean commit) throws NotSupportedException, SystemException,
+ RollbackException, InvalidTransactionException, IllegalStateException, XAException, SecurityException, HeuristicMixedException,
+ HeuristicRollbackException {
+
+ // Start out at the first server
+ CompletionCounter counter = new CompletionCounter() {
+ private int commitCount = 0;
+ private int rollbackCount = 0;
+
+ @Override
+ public void incrementCommit() {
+ commitCount++;
+
+ }
+
+ @Override
+ public void incrementRollback() {
+ rollbackCount++;
+ }
+
+ @Override
+ public int getCommitCount() {
+ return commitCount;
+ }
+
+ @Override
+ public int getRollbackCount() {
+ return rollbackCount;
+ }
+
+ @Override
+ public void resetCounters() {
+ commitCount = 0;
+ rollbackCount = 0;
+ }
+ };
+ int totalNodeCount = nodesToFlowTo.size();
+ int startingServer = nodesToFlowTo.get(0);
+ LocalServer originalServer = getLocalServer(startingServer);
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(originalServer.getClass().getClassLoader());
+ TransactionManager transactionManager = originalServer.getTransactionManager();
+ transactionManager.setTransactionTimeout(startingTimeout);
+ transactionManager.begin();
+ Transaction originalTransaction = transactionManager.getTransaction();
+ int remainingTimeout = (int) (originalServer.getTimeLeftBeforeTransactionTimeout() / 1000);
+ Xid currentXid = originalServer.getCurrentXid();
+ originalServer.storeRootTransaction();
+ transactionManager.suspend();
+ performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid);
+ transactionManager.resume(originalTransaction);
+ originalServer.removeRootTransaction(currentXid);
+ if (commit) {
+ transactionManager.commit();
+ assertTrue(counter.getCommitCount() == totalNodeCount);
+ } else {
+ transactionManager.rollback();
+ assertTrue(counter.getRollbackCount() == totalNodeCount);
+ }
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+
+ private boolean performTransactionalWork(CompletionCounter counter, List<Integer> nodesToFlowTo, int remainingTimeout, Xid toMigrate)
+ throws RollbackException, InvalidTransactionException, IllegalStateException, XAException, SystemException, NotSupportedException {
+ Integer currentServerName = nodesToFlowTo.remove(0);
+ LocalServer currentServer = getLocalServer(currentServerName);
+
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(currentServer.getClass().getClassLoader());
+
+ boolean requiresProxyAtPreviousServer = !currentServer.getAndResumeTransaction(remainingTimeout, toMigrate);
+ // Perform work on the migrated transaction
+ TransactionManager transactionManager = currentServer.getTransactionManager();
+ Transaction transaction = transactionManager.getTransaction();
+ transaction.registerSynchronization(new TestSynchronization(currentServer.getNodeName()));
+ transaction.enlistResource(new TestResource(counter, currentServer.getNodeName(), false));
+
+ if (!nodesToFlowTo.isEmpty()) {
+ Integer nextServerNodeName = nodesToFlowTo.get(0);
+
+ // FLOW THE TRANSACTION
+ remainingTimeout = (int) (currentServer.getTimeLeftBeforeTransactionTimeout() / 1000);
+
+ // SUSPEND THE TRANSACTION
+ Xid currentXid = currentServer.getCurrentXid();
+ transactionManager.suspend();
+ boolean proxyRequired = performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid);
+ transactionManager.resume(transaction);
+
+ // Create a proxy for the new server if necessary, this can orphan
+ // the remote server but XA recovery will handle that on the remote
+ // server
+ // The alternative is to always create a proxy but this is a
+ // performance drain and will result in multiple subordinate
+ // transactions and performance issues
+ if (proxyRequired) {
+ XAResource proxyXAResource = currentServer.generateProxyXAResource(lookupProvider, currentServer.getNodeName(), nextServerNodeName);
+ transaction.enlistResource(proxyXAResource);
+ transaction.registerSynchronization(currentServer.generateProxySynchronization(lookupProvider, currentServer.getNodeName(), nextServerNodeName,
+ toMigrate));
+ }
+ }
+
+ // SUSPEND THE TRANSACTION WHEN YOU ARE READY TO RETURN TO YOUR CALLER
+ transactionManager.suspend();
+
+ Thread.currentThread().setContextClassLoader(classLoader);
+ return requiresProxyAtPreviousServer;
+ }
+
+ private static LocalServer getLocalServer(Integer jndiName) {
+ int index = (jndiName / 1000) - 1;
+ return localServers[index];
+ }
+
+ private static class MyLookupProvider implements LookupProvider {
+
+ @Override
+ public RemoteServer lookup(Integer jndiName) {
+ int index = (jndiName / 1000) - 1;
+ return remoteServers[index];
+ }
+
+ }
+}
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/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-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestResource.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,191 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-
-package com.arjuna.ats.jta.distributed;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Arrays;
-
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import com.arjuna.ats.arjuna.common.Uid;
-
-public class TestResource implements XAResource {
- private Xid xid;
-
- protected int timeout = 0;
-
- private boolean readonly = false;
-
- private File file;
-
- private int serverId;
-
- public TestResource(int serverId, boolean readonly) {
- this.serverId = serverId;
- this.readonly = readonly;
- }
-
- public TestResource(int serverId, File file) throws IOException {
- this.serverId = serverId;
- this.file = file;
- DataInputStream fis = new DataInputStream(new FileInputStream(file));
- final int formatId = fis.readInt();
- final int gtrid_length = fis.readInt();
- final byte[] gtrid = new byte[gtrid_length];
- fis.read(gtrid, 0, gtrid_length);
- final int bqual_length = fis.readInt();
- final byte[] bqual = new byte[bqual_length];
- fis.read(bqual, 0, bqual_length);
- this.xid = new Xid() {
-
- @Override
- public byte[] getGlobalTransactionId() {
- return gtrid;
- }
-
- @Override
- public int getFormatId() {
- return formatId;
- }
-
- @Override
- public byte[] getBranchQualifier() {
- return bqual;
- }
- };
- }
-
- public synchronized int prepare(Xid xid) throws XAException {
- System.out.println(" TestResource (" + serverId + ") XA_PREPARE [" + xid + "]");
-
- if (readonly)
- return XA_RDONLY;
- else {
- File dir = new File(System.getProperty("user.dir") + "/tmp/TestResource/" + serverId + "/");
- dir.mkdirs();
- file = new File(dir, new Uid().fileStringForm() + "_");
- try {
- file.createNewFile();
- final int formatId = xid.getFormatId();
- final byte[] gtrid = xid.getGlobalTransactionId();
- final int gtrid_length = gtrid.length;
- final byte[] bqual = xid.getBranchQualifier();
- final int bqual_length = bqual.length;
-
- DataOutputStream fos = new DataOutputStream(new FileOutputStream(file));
- fos.writeInt(formatId);
- fos.writeInt(gtrid_length);
- fos.write(gtrid, 0, gtrid_length);
- fos.writeInt(bqual_length);
- fos.write(bqual, 0, bqual_length);
- } catch (IOException e) {
- e.printStackTrace();
- throw new XAException(XAException.XAER_RMERR);
- }
- return XA_OK;
- }
-
- // throw new XAException();
- }
-
- public synchronized void commit(Xid id, boolean onePhase) throws XAException {
- System.out.println(" TestResource (" + serverId + ") XA_COMMIT [" + id + "]");
- // String absoluteFile = file.getAbsolutePath();
- // String newName = absoluteFile.substring(0, absoluteFile.length() -
- // 1);
- // File file2 = new File(newName);
- // file.renameTo(file2);
- if (file != null) {
- file.delete();
- }
- this.xid = null;
- }
-
- public synchronized void rollback(Xid xid) throws XAException {
- System.out.println(" TestResource (" + serverId + ") XA_ROLLBACK[" + xid + "]");
- if (file != null) {
- file.delete();
- }
- this.xid = null;
- }
-
- public void end(Xid xid, int flags) throws XAException {
- System.out.println(" TestResource (" + serverId + ") XA_END [" + xid + "] Flags=" + flags);
- }
-
- public void forget(Xid xid) throws XAException {
- System.out.println(" TestResource (" + serverId + ") XA_FORGET[" + xid + "]");
- }
-
- public int getTransactionTimeout() throws XAException {
- return (timeout);
- }
-
- public boolean isSameRM(XAResource xares) throws XAException {
- if (xares instanceof TestResource) {
- TestResource other = (TestResource) xares;
- if ((this.xid != null && other.xid != null)) {
- if (this.xid.getFormatId() == other.xid.getFormatId()) {
- if (Arrays.equals(this.xid.getGlobalTransactionId(), other.xid.getGlobalTransactionId())) {
- if (Arrays.equals(this.xid.getBranchQualifier(), other.xid.getBranchQualifier())) {
- return true;
- }
- }
- }
- }
- }
- return false;
- }
-
- public Xid[] recover(int flag) throws XAException {
- Xid[] toReturn = null;
- if ((flag & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
- System.out.println(" TestResource (" + serverId + ") RECOVER[XAResource.TMSTARTRSCAN]: " + serverId);
- if (xid != null) {
- toReturn = new Xid[] { xid };
- }
- }
- if ((flag & XAResource.TMENDRSCAN) == XAResource.TMENDRSCAN) {
- System.out.println(" TestResource (" + serverId + ") RECOVER[XAResource.TMENDRSCAN]: " + serverId);
- }
- if (flag == XAResource.TMNOFLAGS) {
- System.out.println(" TestResource (" + serverId + ") RECOVER[XAResource.TMENDRSCAN]: " + serverId);
- }
- return toReturn;
- }
-
- public boolean setTransactionTimeout(int seconds) throws XAException {
- timeout = seconds;
- return (true);
- }
-
- public void start(Xid xid, int flags) throws XAException {
- System.out.println(" TestResource (" + serverId + ") XA_START [" + xid + "] Flags=" + flags);
- }
-}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestResource.java (from rev 37584, 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/examples/classes/com/arjuna/ats/jta/distributed/TestResource.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestResource.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,202 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+
+package com.arjuna.ats.jta.distributed;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.jta.distributed.server.CompletionCounter;
+
+public class TestResource implements XAResource {
+ private Xid xid;
+
+ protected int timeout = 0;
+
+ private boolean readonly = false;
+
+ private File file;
+
+ private int serverId;
+
+ private CompletionCounter completionCounter;
+
+ public TestResource(CompletionCounter completionCounter, int serverId, boolean readonly) {
+ this.completionCounter = completionCounter;
+ this.serverId = serverId;
+ this.readonly = readonly;
+ }
+
+ public TestResource(CompletionCounter completionCounter, int serverId, File file) throws IOException {
+ this.completionCounter = completionCounter;
+ this.serverId = serverId;
+ this.file = file;
+ DataInputStream fis = new DataInputStream(new FileInputStream(file));
+ final int formatId = fis.readInt();
+ final int gtrid_length = fis.readInt();
+ final byte[] gtrid = new byte[gtrid_length];
+ fis.read(gtrid, 0, gtrid_length);
+ final int bqual_length = fis.readInt();
+ final byte[] bqual = new byte[bqual_length];
+ fis.read(bqual, 0, bqual_length);
+ this.xid = new Xid() {
+
+ @Override
+ public byte[] getGlobalTransactionId() {
+ return gtrid;
+ }
+
+ @Override
+ public int getFormatId() {
+ return formatId;
+ }
+
+ @Override
+ public byte[] getBranchQualifier() {
+ return bqual;
+ }
+ };
+ }
+
+ public synchronized int prepare(Xid xid) throws XAException {
+ System.out.println(" TestResource (" + serverId + ") XA_PREPARE [" + xid + "]");
+
+ if (readonly)
+ return XA_RDONLY;
+ else {
+ File dir = new File(System.getProperty("user.dir") + "/tmp/TestResource/" + serverId + "/");
+ dir.mkdirs();
+ file = new File(dir, new Uid().fileStringForm() + "_");
+ try {
+ file.createNewFile();
+ final int formatId = xid.getFormatId();
+ final byte[] gtrid = xid.getGlobalTransactionId();
+ final int gtrid_length = gtrid.length;
+ final byte[] bqual = xid.getBranchQualifier();
+ final int bqual_length = bqual.length;
+
+ DataOutputStream fos = new DataOutputStream(new FileOutputStream(file));
+ fos.writeInt(formatId);
+ fos.writeInt(gtrid_length);
+ fos.write(gtrid, 0, gtrid_length);
+ fos.writeInt(bqual_length);
+ fos.write(bqual, 0, bqual_length);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new XAException(XAException.XAER_RMERR);
+ }
+ return XA_OK;
+ }
+
+ // throw new XAException();
+ }
+
+ public synchronized void commit(Xid id, boolean onePhase) throws XAException {
+ System.out.println(" TestResource (" + serverId + ") XA_COMMIT [" + id + "]");
+ if (completionCounter != null) {
+ completionCounter.incrementCommit();
+ }
+ // String absoluteFile = file.getAbsolutePath();
+ // String newName = absoluteFile.substring(0, absoluteFile.length() -
+ // 1);
+ // File file2 = new File(newName);
+ // file.renameTo(file2);
+ if (file != null) {
+ file.delete();
+ }
+ this.xid = null;
+ }
+
+ public synchronized void rollback(Xid xid) throws XAException {
+ System.out.println(" TestResource (" + serverId + ") XA_ROLLBACK[" + xid + "]");
+ if (completionCounter != null) {
+ completionCounter.incrementRollback();
+ }
+ if (file != null) {
+ file.delete();
+ }
+ this.xid = null;
+ }
+
+ public void end(Xid xid, int flags) throws XAException {
+ System.out.println(" TestResource (" + serverId + ") XA_END [" + xid + "] Flags=" + flags);
+ }
+
+ public void forget(Xid xid) throws XAException {
+ System.out.println(" TestResource (" + serverId + ") XA_FORGET[" + xid + "]");
+ }
+
+ public int getTransactionTimeout() throws XAException {
+ return (timeout);
+ }
+
+ public boolean isSameRM(XAResource xares) throws XAException {
+ if (xares instanceof TestResource) {
+ TestResource other = (TestResource) xares;
+ if ((this.xid != null && other.xid != null)) {
+ if (this.xid.getFormatId() == other.xid.getFormatId()) {
+ if (Arrays.equals(this.xid.getGlobalTransactionId(), other.xid.getGlobalTransactionId())) {
+ if (Arrays.equals(this.xid.getBranchQualifier(), other.xid.getBranchQualifier())) {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public Xid[] recover(int flag) throws XAException {
+ Xid[] toReturn = null;
+ if ((flag & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
+ System.out.println(" TestResource (" + serverId + ") RECOVER[XAResource.TMSTARTRSCAN]: " + serverId);
+ if (xid != null) {
+ toReturn = new Xid[] { xid };
+ }
+ }
+ if ((flag & XAResource.TMENDRSCAN) == XAResource.TMENDRSCAN) {
+ System.out.println(" TestResource (" + serverId + ") RECOVER[XAResource.TMENDRSCAN]: " + serverId);
+ }
+ if (flag == XAResource.TMNOFLAGS) {
+ System.out.println(" TestResource (" + serverId + ") RECOVER[XAResource.TMENDRSCAN]: " + serverId);
+ }
+ return toReturn;
+ }
+
+ public boolean setTransactionTimeout(int seconds) throws XAException {
+ timeout = seconds;
+ return (true);
+ }
+
+ public void start(Xid xid, int flags) throws XAException {
+ System.out.println(" TestResource (" + serverId + ") XA_START [" + xid + "] Flags=" + flags);
+ }
+}
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestResourceRecovery.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/TestResourceRecovery.java 2011-10-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestResourceRecovery.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,34 +0,0 @@
-package com.arjuna.ats.jta.distributed;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.transaction.xa.XAResource;
-
-import org.jboss.tm.XAResourceRecovery;
-
-public class TestResourceRecovery implements XAResourceRecovery {
-
- private List<TestResource> resources = new ArrayList<TestResource>();
-
- public TestResourceRecovery(int serverId) throws IOException {
- File file = new File(System.getProperty("user.dir") + "/tmp/TestResource/" + serverId + "/");
- if (file.exists() && file.isDirectory()) {
- File[] listFiles = file.listFiles();
- for (int i = 0; i < listFiles.length; i++) {
- File currentFile = listFiles[i];
- if (currentFile.getAbsolutePath().endsWith("_")) {
- resources.add(new TestResource(serverId, currentFile));
- }
- }
- }
- }
-
- @Override
- public XAResource[] getXAResources() {
- return resources.toArray(new XAResource[] {});
- }
-
-}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestResourceRecovery.java (from rev 37587, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/TestResourceRecovery.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestResourceRecovery.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestResourceRecovery.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.transaction.xa.XAResource;
+
+import org.jboss.tm.XAResourceRecovery;
+
+import com.arjuna.ats.jta.distributed.server.CompletionCounter;
+
+public class TestResourceRecovery implements XAResourceRecovery {
+
+ private List<TestResource> resources = new ArrayList<TestResource>();
+
+ public TestResourceRecovery(CompletionCounter counter, Integer nodeName) throws IOException {
+ File file = new File(System.getProperty("user.dir") + "/tmp/TestResource/" + nodeName + "/");
+ if (file.exists() && file.isDirectory()) {
+ File[] listFiles = file.listFiles();
+ for (int i = 0; i < listFiles.length; i++) {
+ File currentFile = listFiles[i];
+ if (currentFile.getAbsolutePath().endsWith("_")) {
+ resources.add(new TestResource(counter, nodeName, currentFile));
+ }
+ }
+ }
+ }
+
+ @Override
+ public XAResource[] getXAResources() {
+ return resources.toArray(new XAResource[] {});
+ }
+
+}
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestSynchronization.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/TestSynchronization.java 2011-10-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestSynchronization.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,21 +0,0 @@
-package com.arjuna.ats.jta.distributed;
-
-import javax.transaction.Synchronization;
-
-public class TestSynchronization implements Synchronization {
- private int serverId;
-
- public TestSynchronization(int serverId) {
- this.serverId = serverId;
- }
-
- @Override
- public void beforeCompletion() {
- System.out.println(" TestSynchronization (" + serverId + ") beforeCompletion");
- }
-
- @Override
- public void afterCompletion(int status) {
- System.out.println(" TestSynchronization (" + serverId + ") afterCompletion");
- }
-}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestSynchronization.java (from rev 37587, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/TestSynchronization.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestSynchronization.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/TestSynchronization.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed;
+
+import javax.transaction.Synchronization;
+
+public class TestSynchronization implements Synchronization {
+ private int serverId;
+
+ public TestSynchronization(int serverId) {
+ this.serverId = serverId;
+ }
+
+ @Override
+ public void beforeCompletion() {
+ System.out.println(" TestSynchronization (" + serverId + ") beforeCompletion");
+ }
+
+ @Override
+ public void afterCompletion(int status) {
+ System.out.println(" TestSynchronization (" + serverId + ") afterCompletion");
+ }
+}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/CompletionCounter.java (from rev 37587, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/CompletionCounter.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/CompletionCounter.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/CompletionCounter.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed.server;
+
+public interface CompletionCounter {
+ public void incrementCommit();
+ public void incrementRollback();
+ int getCommitCount();
+ int getRollbackCount();
+ void resetCounters();
+}
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/DummyRemoteException.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/DummyRemoteException.java 2011-10-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/DummyRemoteException.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,7 +0,0 @@
-package com.arjuna.ats.jta.distributed.server;
-
-public class DummyRemoteException extends Exception {
- public DummyRemoteException(String message) {
- super(message);
- }
-}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/DummyRemoteException.java (from rev 37587, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/DummyRemoteException.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/DummyRemoteException.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/DummyRemoteException.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed.server;
+
+public class DummyRemoteException extends Exception {
+ public DummyRemoteException(String message) {
+ super(message);
+ }
+}
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/IsolatableServersClassLoader.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/IsolatableServersClassLoader.java 2011-10-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/IsolatableServersClassLoader.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,69 +0,0 @@
-package com.arjuna.ats.jta.distributed.server;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import sun.misc.Resource;
-import sun.misc.URLClassPath;
-
-public class IsolatableServersClassLoader extends ClassLoader {
-
- private Map<String, Class<?>> clazzMap = new HashMap<String, Class<?>>();
- private URLClassPath ucp;
- private String ignoredPackage;
-
- public IsolatableServersClassLoader(String ignoredPackage, ClassLoader parent) throws SecurityException, NoSuchMethodException, MalformedURLException {
- super(parent);
- this.ignoredPackage = ignoredPackage;
-
- String property = System.getProperty("java.class.path");
- String[] split = property.split(":");
- URL[] urls = new URL[1];
- for (int i = 0; i < urls.length; i++) {
- String url = split[0];
- if (url.endsWith(".jar")) {
- urls[0] = new URL("jar:file:" + url + "/");
- } else {
- urls[0] = new URL("file:" + url + "/");
- }
- }
- this.ucp = new URLClassPath(urls);
- }
-
- @Override
- protected Class<?> findClass(String name) throws ClassNotFoundException {
- if (clazzMap.containsKey(name)) {
- return clazzMap.get(name);
- }
- return super.findClass(name);
- }
-
- public Class<?> loadClass(String name) throws ClassNotFoundException {
- Class<?> clazz = null;
- if (clazzMap.containsKey(name)) {
- clazz = clazzMap.get(name);
- }
- if (!name.startsWith("com.arjuna") || (ignoredPackage != null && name.matches(ignoredPackage + ".[A-Za-z0-9]*"))) {
- clazz = super.loadClass(name);
- } else {
-
- String path = name.replace('.', '/').concat(".class");
- Resource res = ucp.getResource(path, false);
- if (res == null) {
- throw new ClassNotFoundException(name);
- }
- try {
- byte[] classData = res.getBytes();
- clazz = defineClass(name, classData, 0, classData.length);
- clazzMap.put(name, clazz);
- } catch (IOException e) {
- throw new ClassNotFoundException(name, e);
- }
- }
-
- return clazz;
- }
-}
\ No newline at end of file
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/IsolatableServersClassLoader.java (from rev 37587, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/IsolatableServersClassLoader.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/IsolatableServersClassLoader.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/IsolatableServersClassLoader.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed.server;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import sun.misc.Resource;
+import sun.misc.URLClassPath;
+
+public class IsolatableServersClassLoader extends ClassLoader {
+
+ private Map<String, Class<?>> clazzMap = new HashMap<String, Class<?>>();
+ private URLClassPath ucp;
+ private String ignoredPackage;
+
+ public IsolatableServersClassLoader(String ignoredPackage, ClassLoader parent) throws SecurityException, NoSuchMethodException, MalformedURLException {
+ super(parent);
+ this.ignoredPackage = ignoredPackage;
+
+ String property = System.getProperty("java.class.path");
+ String[] split = property.split(":");
+ URL[] urls = new URL[1];
+ for (int i = 0; i < urls.length; i++) {
+ String url = split[0];
+ if (url.endsWith(".jar")) {
+ urls[0] = new URL("jar:file:" + url + "/");
+ } else {
+ urls[0] = new URL("file:" + url + "/");
+ }
+ }
+ this.ucp = new URLClassPath(urls);
+ }
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ if (clazzMap.containsKey(name)) {
+ return clazzMap.get(name);
+ }
+ return super.findClass(name);
+ }
+
+ public Class<?> loadClass(String name) throws ClassNotFoundException {
+ Class<?> clazz = null;
+ if (clazzMap.containsKey(name)) {
+ clazz = clazzMap.get(name);
+ }
+ if (!name.startsWith("com.arjuna") || (ignoredPackage != null && name.matches(ignoredPackage + ".[A-Za-z0-9]*"))) {
+ clazz = super.loadClass(name);
+ } else {
+
+ String path = name.replace('.', '/').concat(".class");
+ Resource res = ucp.getResource(path, false);
+ if (res == null) {
+ throw new ClassNotFoundException(name);
+ }
+ try {
+ byte[] classData = res.getBytes();
+ clazz = defineClass(name, classData, 0, classData.length);
+ clazzMap.put(name, clazz);
+ } catch (IOException e) {
+ throw new ClassNotFoundException(name, e);
+ }
+ }
+
+ return clazz;
+ }
+}
\ No newline at end of file
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/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-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LocalServer.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,46 +0,0 @@
-package com.arjuna.ats.jta.distributed.server;
-
-import java.io.IOException;
-
-import javax.transaction.InvalidTransactionException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException;
-
-public interface LocalServer {
-
- public void initialise(LookupProvider lookupProvider, Integer nodeName) throws CoreEnvironmentBeanException, IOException, SecurityException,
- NoSuchFieldException, IllegalArgumentException, IllegalAccessException;
-
- public Integer getNodeName();
-
- public TransactionManager getTransactionManager() throws NotSupportedException, SystemException;
-
- public void doRecoveryManagerScan();
-
- public long getTimeLeftBeforeTransactionTimeout() throws RollbackException;
-
- public void storeRootTransaction() throws SystemException;
-
- public void removeRootTransaction(Xid toMigrate);
-
- public boolean getAndResumeTransaction(int remainingTimeout, Xid toImport) throws XAException, InvalidTransactionException, IllegalStateException,
- SystemException;
-
- public RemoteServer connectTo();
-
- public XAResource generateProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName);
-
- public Synchronization generateProxySynchronization(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName, Xid toRegisterAgainst);
-
- public Xid extractXid(XAResource proxyXAResource);
-
- public Xid getCurrentXid() throws SystemException;
-}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LocalServer.java (from rev 37587, 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/examples/classes/com/arjuna/ats/jta/distributed/server/LocalServer.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LocalServer.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed.server;
+
+import java.io.IOException;
+
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException;
+
+public interface LocalServer {
+
+ public void initialise(LookupProvider lookupProvider, Integer nodeName) throws CoreEnvironmentBeanException, IOException, SecurityException,
+ NoSuchFieldException, IllegalArgumentException, IllegalAccessException;
+
+ public Integer getNodeName();
+
+ public TransactionManager getTransactionManager() throws NotSupportedException, SystemException;
+
+ public void doRecoveryManagerScan();
+
+ public long getTimeLeftBeforeTransactionTimeout() throws RollbackException;
+
+ public void storeRootTransaction() throws SystemException;
+
+ public void removeRootTransaction(Xid toMigrate);
+
+ public boolean getAndResumeTransaction(int remainingTimeout, Xid toImport) throws XAException, InvalidTransactionException, IllegalStateException,
+ SystemException;
+
+ public RemoteServer connectTo();
+
+ public XAResource generateProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName);
+
+ public Synchronization generateProxySynchronization(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName, Xid toRegisterAgainst);
+
+ public Xid extractXid(XAResource proxyXAResource);
+
+ public Xid getCurrentXid() throws SystemException;
+
+ public CompletionCounter getCompletionCounter();
+}
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LookupProvider.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/LookupProvider.java 2011-10-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LookupProvider.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,5 +0,0 @@
-package com.arjuna.ats.jta.distributed.server;
-
-public interface LookupProvider {
- public RemoteServer lookup(Integer jndiName);
-}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LookupProvider.java (from rev 37587, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/LookupProvider.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LookupProvider.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/LookupProvider.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,26 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed.server;
+
+public interface LookupProvider {
+ public RemoteServer lookup(Integer jndiName);
+}
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/RemoteServer.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/RemoteServer.java 2011-10-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/RemoteServer.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,28 +0,0 @@
-package com.arjuna.ats.jta.distributed.server;
-
-import javax.transaction.HeuristicCommitException;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.Xid;
-
-public interface RemoteServer {
-
- public void setOffline(boolean offline);
-
- public int propagatePrepare(Xid xid) throws XAException, DummyRemoteException;
-
- public void propagateCommit(Xid xid, boolean onePhase) throws IllegalStateException, HeuristicMixedException, HeuristicRollbackException,
- HeuristicCommitException, SystemException, XAException, DummyRemoteException;
-
- public void propagateRollback(Xid xid) throws IllegalStateException, HeuristicMixedException, HeuristicCommitException, HeuristicRollbackException,
- SystemException, XAException, DummyRemoteException;
-
- public Xid[] propagateRecover(int formatId, byte[] gtrid, Integer serverNodeNameToRecoverFor, int flag) throws XAException, DummyRemoteException;
-
- public void propagateForget(Xid xid) throws XAException, DummyRemoteException;
-
- public void propagateBeforeCompletion(Xid xid) throws XAException, SystemException, DummyRemoteException;
-
-}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/RemoteServer.java (from rev 37587, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/RemoteServer.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/RemoteServer.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/RemoteServer.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed.server;
+
+import javax.transaction.SystemException;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.Xid;
+
+public interface RemoteServer {
+
+ public void setOffline(boolean offline);
+
+ public int propagatePrepare(Xid xid) throws XAException, DummyRemoteException;
+
+ public void propagateCommit(Xid xid) throws XAException, DummyRemoteException;
+
+ public void propagateRollback(Xid xid) throws XAException, DummyRemoteException;
+
+ public Xid[] propagateRecover(int formatId, byte[] gtrid, int flag) throws XAException, DummyRemoteException;
+
+ public void propagateForget(Xid xid) throws XAException, DummyRemoteException;
+
+ public void propagateBeforeCompletion(Xid xid) throws XAException, SystemException, DummyRemoteException;
+
+}
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxySynchronization.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxySynchronization.java 2011-10-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxySynchronization.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,43 +0,0 @@
-package com.arjuna.ats.jta.distributed.server.impl;
-
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.Xid;
-
-import com.arjuna.ats.jta.distributed.server.DummyRemoteException;
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-
-public class ProxySynchronization implements Synchronization {
-
- private int localServerName;
- private int remoteServerName;
- private Xid toRegisterAgainst;
- private LookupProvider lookupProvider;
-
- public ProxySynchronization(LookupProvider lookupProvider, int localServerName, int remoteServerName, Xid toRegisterAgainst) {
- this.lookupProvider = lookupProvider;
- this.localServerName = localServerName;
- this.remoteServerName = remoteServerName;
- this.toRegisterAgainst = toRegisterAgainst;
- }
-
- @Override
- public void beforeCompletion() {
- System.out.println("ProxySynchronization (" + localServerName + ":" + remoteServerName + ") beforeCompletion");
- try {
- lookupProvider.lookup(remoteServerName).propagateBeforeCompletion(toRegisterAgainst);
- } catch (XAException e) {
- e.printStackTrace();
- } catch (SystemException e) {
- e.printStackTrace();
- } catch (DummyRemoteException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- public void afterCompletion(int status) {
- // These are not proxied but are handled during local commits
- }
-}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxySynchronization.java (from rev 37587, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxySynchronization.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxySynchronization.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxySynchronization.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed.server.impl;
+
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.Xid;
+
+import com.arjuna.ats.jta.distributed.server.DummyRemoteException;
+import com.arjuna.ats.jta.distributed.server.LookupProvider;
+
+public class ProxySynchronization implements Synchronization {
+
+ private int localServerName;
+ private int remoteServerName;
+ private Xid toRegisterAgainst;
+ private LookupProvider lookupProvider;
+
+ public ProxySynchronization(LookupProvider lookupProvider, int localServerName, int remoteServerName, Xid toRegisterAgainst) {
+ this.lookupProvider = lookupProvider;
+ this.localServerName = localServerName;
+ this.remoteServerName = remoteServerName;
+ this.toRegisterAgainst = toRegisterAgainst;
+ }
+
+ @Override
+ public void beforeCompletion() {
+ System.out.println("ProxySynchronization (" + localServerName + ":" + remoteServerName + ") beforeCompletion");
+ try {
+ lookupProvider.lookup(remoteServerName).propagateBeforeCompletion(toRegisterAgainst);
+ } catch (XAException e) {
+ e.printStackTrace();
+ } catch (SystemException e) {
+ e.printStackTrace();
+ } catch (DummyRemoteException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void afterCompletion(int status) {
+ // These are not proxied but are handled during local commits
+ }
+}
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/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-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,286 +0,0 @@
-package com.arjuna.ats.jta.distributed.server.impl;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import javax.transaction.HeuristicCommitException;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.xa.XAException;
-import javax.transaction.xa.XAResource;
-import javax.transaction.xa.Xid;
-
-import org.jboss.tm.XAResourceWrapper;
-
-import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.jta.distributed.server.DummyRemoteException;
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-
-public class ProxyXAResource implements XAResource, XAResourceWrapper {
-
- private int transactionTimeout;
- private Integer remoteServerName = -1;
- private File file;
- private Integer localServerName;
- private LookupProvider lookupProvider;
- private Xid xid;
-
- public ProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName) {
- this.lookupProvider = lookupProvider;
- this.localServerName = localServerName;
- this.remoteServerName = remoteServerName;
- }
-
- public ProxyXAResource(LookupProvider lookupProvider, Integer localServerName, File file) throws IOException {
- this.lookupProvider = lookupProvider;
- this.localServerName = localServerName;
- this.file = file;
- DataInputStream fis = new DataInputStream(new FileInputStream(file));
- this.remoteServerName = fis.readInt();
- final int formatId = fis.readInt();
- int gtrid_length = fis.readInt();
- final byte[] gtrid = new byte[gtrid_length];
- fis.read(gtrid, 0, gtrid_length);
- int bqual_length = fis.readInt();
- final byte[] bqual = new byte[bqual_length];
- fis.read(bqual, 0, bqual_length);
- this.xid = new Xid() {
- @Override
- public byte[] getBranchQualifier() {
- return bqual;
- }
-
- @Override
- public int getFormatId() {
- return formatId;
- }
-
- @Override
- public byte[] getGlobalTransactionId() {
- return gtrid;
- }
- };
- }
-
- @Override
- public void start(Xid xid, int flags) throws XAException {
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_START [" + xid + "]");
- this.xid = xid;
- }
-
- @Override
- public void end(Xid xid, int flags) throws XAException {
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_END [" + xid + "]");
- this.xid = null;
- }
-
- @Override
- public synchronized int prepare(Xid xid) throws XAException {
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_PREPARE [" + xid + "]");
-
- try {
- File dir = new File(System.getProperty("user.dir") + "/tmp/ProxyXAResource/" + localServerName + "/");
- dir.mkdirs();
- file = new File(dir, new Uid().fileStringForm());
- file.createNewFile();
- DataOutputStream fos = new DataOutputStream(new FileOutputStream(file));
- fos.writeInt(remoteServerName);
- fos.writeInt(xid.getFormatId());
- fos.writeInt(xid.getGlobalTransactionId().length);
- fos.write(xid.getGlobalTransactionId());
- fos.writeInt(xid.getBranchQualifier().length);
- fos.write(xid.getBranchQualifier());
- } catch (IOException e) {
- e.printStackTrace();
- throw new XAException(XAException.XAER_RMERR);
- }
-
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
- int propagatePrepare = lookupProvider.lookup(remoteServerName).propagatePrepare(xid);
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_PREPARED");
- return propagatePrepare;
- } catch (DummyRemoteException ce) {
- throw new XAException(XAException.XA_RETRY);
- } finally {
- Thread.currentThread().setContextClassLoader(contextClassLoader);
- }
-
- }
-
- @Override
- public synchronized void commit(Xid xid, boolean onePhase) throws XAException {
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_COMMIT [" + xid + "]");
-
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
- lookupProvider.lookup(remoteServerName).propagateCommit(xid, onePhase);
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_COMMITED");
- } catch (IllegalStateException e) {
- throw new XAException(XAException.XAER_INVAL);
- } catch (HeuristicMixedException e) {
- throw new XAException(XAException.XA_HEURMIX);
- } catch (HeuristicRollbackException e) {
- throw new XAException(XAException.XA_HEURRB);
- } catch (HeuristicCommitException e) {
- throw new XAException(XAException.XA_HEURCOM);
- } catch (SystemException e) {
- throw new XAException(XAException.XAER_PROTO);
- } catch (DummyRemoteException ce) {
- throw new XAException(XAException.XA_RETRY);
- } finally {
- Thread.currentThread().setContextClassLoader(contextClassLoader);
- }
-
- if (file != null) {
- file.delete();
- }
- }
-
- @Override
- public synchronized void rollback(Xid xid) throws XAException {
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_ROLLBACK[" + xid + "]");
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
- lookupProvider.lookup(remoteServerName).propagateRollback(xid);
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_ROLLBACKED");
- } catch (IllegalStateException e) {
- throw new XAException(XAException.XAER_INVAL);
- } catch (HeuristicMixedException e) {
- throw new XAException(XAException.XA_HEURMIX);
- } catch (HeuristicCommitException e) {
- throw new XAException(XAException.XA_HEURCOM);
- } catch (HeuristicRollbackException e) {
- throw new XAException(XAException.XA_HEURRB);
- } catch (SystemException e) {
- throw new XAException(XAException.XAER_PROTO);
- } catch (DummyRemoteException ce) {
- throw new XAException(XAException.XA_RETRY);
- } finally {
- Thread.currentThread().setContextClassLoader(contextClassLoader);
- }
-
- if (file != null) {
- file.delete();
- }
- }
-
- @Override
- public Xid[] recover(int flag) throws XAException {
- Xid[] recovered = null;
- if ((flag & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVER [XAResource.TMSTARTRSCAN]: "
- + remoteServerName);
- }
- if ((flag & XAResource.TMENDRSCAN) == XAResource.TMENDRSCAN) {
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVER [XAResource.TMENDRSCAN]: "
- + remoteServerName);
- }
-
- if (this.xid != null) {
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
- recovered = lookupProvider.lookup(remoteServerName).propagateRecover(xid.getFormatId(), xid.getGlobalTransactionId(), localServerName, flag);
- } catch (DummyRemoteException ce) {
- throw new XAException(XAException.XA_RETRY);
- } finally {
- Thread.currentThread().setContextClassLoader(contextClassLoader);
- }
- }
-
- for (int i = 0; i < recovered.length; i++) {
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") recovered: " + recovered[i]);
- }
-
- Xid[] toReturn = null;
- if ((flag & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVERD[XAResource.TMSTARTRSCAN]: "
- + remoteServerName);
- toReturn = new Xid[] { xid };
- }
- if ((flag & XAResource.TMENDRSCAN) == XAResource.TMENDRSCAN) {
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVERD[XAResource.TMENDRSCAN]: "
- + remoteServerName);
- }
- return toReturn;
- }
-
- @Override
- public void forget(Xid xid) throws XAException {
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_FORGET [" + xid + "]");
- ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
- try {
- Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
- lookupProvider.lookup(remoteServerName).propagateForget(xid);
- System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_FORGETED[" + xid + "]");
- } catch (DummyRemoteException ce) {
- throw new XAException(XAException.XA_RETRY);
- } finally {
- Thread.currentThread().setContextClassLoader(contextClassLoader);
- }
- }
-
- @Override
- public int getTransactionTimeout() throws XAException {
- return transactionTimeout;
- }
-
- @Override
- public boolean setTransactionTimeout(int seconds) throws XAException {
- this.transactionTimeout = seconds;
- return true;
- }
-
- @Override
- public boolean isSameRM(XAResource xares) throws XAException {
- boolean toReturn = false;
- if (xares instanceof ProxyXAResource) {
- if (((ProxyXAResource) xares).remoteServerName == remoteServerName) {
- toReturn = true;
- }
- }
- return toReturn;
- }
-
- /**
- * I don't think this is used by TM.
- */
- @Override
- public XAResource getResource() {
- return null;
- }
-
- /**
- * I don't think this is used by TM.
- */
- @Override
- public String getProductName() {
- return null;
- }
-
- /**
- * I don't think this is used by TM.
- */
- @Override
- public String getProductVersion() {
- return null;
- }
-
- @Override
- public String getJndiName() {
- return "ProxyXAResource";
- }
-
- public Xid getXid() {
- return xid;
- }
-}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java (from rev 37587, 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/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,287 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed.server.impl;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import javax.transaction.xa.XAException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+
+import org.jboss.tm.XAResourceWrapper;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.arjuna.ats.jta.distributed.server.DummyRemoteException;
+import com.arjuna.ats.jta.distributed.server.LookupProvider;
+
+public class ProxyXAResource implements XAResource, XAResourceWrapper {
+
+ private int transactionTimeout;
+ private Integer remoteServerName = -1;
+ private File file;
+ private Integer localServerName;
+ private LookupProvider lookupProvider;
+ private Xid xid;
+
+ public ProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName) {
+ this.lookupProvider = lookupProvider;
+ this.localServerName = localServerName;
+ this.remoteServerName = remoteServerName;
+ }
+
+ public ProxyXAResource(LookupProvider lookupProvider, Integer localServerName, File file) throws IOException {
+ this.lookupProvider = lookupProvider;
+ this.localServerName = localServerName;
+ this.file = file;
+ DataInputStream fis = new DataInputStream(new FileInputStream(file));
+ this.remoteServerName = fis.readInt();
+ final int formatId = fis.readInt();
+ int gtrid_length = fis.readInt();
+ final byte[] gtrid = new byte[gtrid_length];
+ fis.read(gtrid, 0, gtrid_length);
+ int bqual_length = fis.readInt();
+ final byte[] bqual = new byte[bqual_length];
+ fis.read(bqual, 0, bqual_length);
+ this.xid = new Xid() {
+ @Override
+ public byte[] getBranchQualifier() {
+ return bqual;
+ }
+
+ @Override
+ public int getFormatId() {
+ return formatId;
+ }
+
+ @Override
+ public byte[] getGlobalTransactionId() {
+ return gtrid;
+ }
+ };
+ }
+
+ @Override
+ public void start(Xid xid, int flags) throws XAException {
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_START [" + xid + "]");
+ this.xid = xid;
+ }
+
+ @Override
+ public void end(Xid xid, int flags) throws XAException {
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_END [" + xid + "]");
+ this.xid = null;
+ }
+
+ @Override
+ public synchronized int prepare(Xid xid) throws XAException {
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_PREPARE [" + xid + "]");
+
+ try {
+ File dir = new File(System.getProperty("user.dir") + "/tmp/ProxyXAResource/" + localServerName + "/");
+ dir.mkdirs();
+ file = new File(dir, new Uid().fileStringForm());
+ file.createNewFile();
+ DataOutputStream fos = new DataOutputStream(new FileOutputStream(file));
+ fos.writeInt(remoteServerName);
+ fos.writeInt(xid.getFormatId());
+ fos.writeInt(xid.getGlobalTransactionId().length);
+ fos.write(xid.getGlobalTransactionId());
+ fos.writeInt(xid.getBranchQualifier().length);
+ fos.write(xid.getBranchQualifier());
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new XAException(XAException.XAER_RMERR);
+ }
+
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ int propagatePrepare = lookupProvider.lookup(remoteServerName).propagatePrepare(xid);
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_PREPARED");
+ return propagatePrepare;
+ } catch (DummyRemoteException ce) {
+ throw new XAException(XAException.XA_RETRY);
+ } finally {
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+ }
+
+ }
+
+ /**
+ * The remote side will not accept a one phase optimization.
+ */
+ @Override
+ public synchronized void commit(Xid xid, boolean onePhase) throws XAException {
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_COMMIT [" + xid + "]");
+
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ lookupProvider.lookup(remoteServerName).propagateCommit(xid);
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_COMMITED");
+ } catch (DummyRemoteException ce) {
+ throw new XAException(XAException.XA_RETRY);
+ } finally {
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+ }
+
+ if (file != null) {
+ file.delete();
+ }
+ }
+
+ @Override
+ public synchronized void rollback(Xid xid) throws XAException {
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_ROLLBACK[" + xid + "]");
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ lookupProvider.lookup(remoteServerName).propagateRollback(xid);
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_ROLLBACKED");
+ } catch (DummyRemoteException ce) {
+ throw new XAException(XAException.XA_RETRY);
+ } finally {
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+ }
+
+ if (file != null) {
+ file.delete();
+ }
+ }
+
+ @Override
+ public Xid[] recover(int flag) throws XAException {
+ Xid[] recovered = null;
+ if ((flag & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVER [XAResource.TMSTARTRSCAN]: "
+ + remoteServerName);
+ }
+ if ((flag & XAResource.TMENDRSCAN) == XAResource.TMENDRSCAN) {
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVER [XAResource.TMENDRSCAN]: "
+ + remoteServerName);
+ }
+
+ if (this.xid != null) {
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ recovered = lookupProvider.lookup(remoteServerName).propagateRecover(xid.getFormatId(), xid.getGlobalTransactionId(), flag);
+ } catch (DummyRemoteException ce) {
+ throw new XAException(XAException.XA_RETRY);
+ } finally {
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+ }
+ }
+
+ for (int i = 0; i < recovered.length; i++) {
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") recovered: " + recovered[i]);
+ }
+
+ Xid[] toReturn = null;
+ if ((flag & XAResource.TMSTARTRSCAN) == XAResource.TMSTARTRSCAN) {
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVERD[XAResource.TMSTARTRSCAN]: "
+ + remoteServerName);
+ toReturn = new Xid[] { xid };
+ }
+ if ((flag & XAResource.TMENDRSCAN) == XAResource.TMENDRSCAN) {
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_RECOVERD[XAResource.TMENDRSCAN]: "
+ + remoteServerName);
+ }
+ return toReturn;
+ }
+
+ @Override
+ public void forget(Xid xid) throws XAException {
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_FORGET [" + xid + "]");
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+ try {
+ Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
+ lookupProvider.lookup(remoteServerName).propagateForget(xid);
+ System.out.println(" ProxyXAResource (" + localServerName + ":" + remoteServerName + ") XA_FORGETED[" + xid + "]");
+ } catch (DummyRemoteException ce) {
+ throw new XAException(XAException.XA_RETRY);
+ } finally {
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
+ }
+ }
+
+ @Override
+ public int getTransactionTimeout() throws XAException {
+ return transactionTimeout;
+ }
+
+ @Override
+ public boolean setTransactionTimeout(int seconds) throws XAException {
+ this.transactionTimeout = seconds;
+ return true;
+ }
+
+ @Override
+ public boolean isSameRM(XAResource xares) throws XAException {
+ boolean toReturn = false;
+ if (xares instanceof ProxyXAResource) {
+ if (((ProxyXAResource) xares).remoteServerName == remoteServerName) {
+ toReturn = true;
+ }
+ }
+ return toReturn;
+ }
+
+ /**
+ * I don't think this is used by TM.
+ */
+ @Override
+ public XAResource getResource() {
+ return null;
+ }
+
+ /**
+ * I don't think this is used by TM.
+ */
+ @Override
+ public String getProductName() {
+ return null;
+ }
+
+ /**
+ * I don't think this is used by TM.
+ */
+ @Override
+ public String getProductVersion() {
+ return null;
+ }
+
+ @Override
+ public String getJndiName() {
+ return "ProxyXAResource";
+ }
+
+ public Xid getXid() {
+ return xid;
+ }
+}
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java 2011-10-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,34 +0,0 @@
-package com.arjuna.ats.jta.distributed.server.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.transaction.xa.XAResource;
-
-import org.jboss.tm.XAResourceRecovery;
-
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-
-public class ProxyXAResourceRecovery implements XAResourceRecovery {
-
- private List<ProxyXAResource> resources = new ArrayList<ProxyXAResource>();
-
- public ProxyXAResourceRecovery(LookupProvider lookupProvider, int id) throws IOException {
- File file = new File(System.getProperty("user.dir") + "/tmp/ProxyXAResource/" + id + "/");
- if (file.exists() && file.isDirectory()) {
- File[] listFiles = file.listFiles();
- for (int i = 0; i < listFiles.length; i++) {
- File currentFile = listFiles[i];
- resources.add(new ProxyXAResource(lookupProvider, id, currentFile));
- }
- }
- }
-
- @Override
- public XAResource[] getXAResources() {
- return resources.toArray(new XAResource[] {});
- }
-
-}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java (from rev 37587, labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed.server.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.transaction.xa.XAResource;
+
+import org.jboss.tm.XAResourceRecovery;
+
+import com.arjuna.ats.jta.distributed.server.LookupProvider;
+
+public class ProxyXAResourceRecovery implements XAResourceRecovery {
+
+ private List<ProxyXAResource> resources = new ArrayList<ProxyXAResource>();
+
+ public ProxyXAResourceRecovery(LookupProvider lookupProvider, int id) throws IOException {
+ File file = new File(System.getProperty("user.dir") + "/tmp/ProxyXAResource/" + id + "/");
+ if (file.exists() && file.isDirectory()) {
+ File[] listFiles = file.listFiles();
+ for (int i = 0; i < listFiles.length; i++) {
+ File currentFile = listFiles[i];
+ resources.add(new ProxyXAResource(lookupProvider, id, currentFile));
+ }
+ }
+ }
+
+ @Override
+ public XAResource[] getXAResources() {
+ return resources.toArray(new XAResource[] {});
+ }
+
+}
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/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-17 19:11:35 UTC (rev 37579)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -1,302 +0,0 @@
-package com.arjuna.ats.jta.distributed.server.impl;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.transaction.HeuristicCommitException;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.InvalidTransactionException;
-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;
-import javax.transaction.xa.Xid;
-
-import org.jboss.tm.TransactionTimeoutConfiguration;
-
-import com.arjuna.ats.arjuna.common.CoordinatorEnvironmentBean;
-import com.arjuna.ats.arjuna.common.CoreEnvironmentBean;
-import com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException;
-import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
-import com.arjuna.ats.arjuna.common.RecoveryEnvironmentBean;
-import com.arjuna.ats.arjuna.coordinator.TxControl;
-import com.arjuna.ats.arjuna.recovery.RecoveryManager;
-import com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBrowser;
-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;
-import com.arjuna.ats.jta.common.JTAEnvironmentBean;
-import com.arjuna.ats.jta.distributed.TestResourceRecovery;
-import com.arjuna.ats.jta.distributed.server.DummyRemoteException;
-import com.arjuna.ats.jta.distributed.server.LocalServer;
-import com.arjuna.ats.jta.distributed.server.LookupProvider;
-import com.arjuna.ats.jta.distributed.server.RemoteServer;
-import com.arjuna.ats.jta.xa.XATxConverter;
-import com.arjuna.ats.jta.xa.XidImple;
-
-public class ServerImpl implements LocalServer, RemoteServer {
-
- private int nodeName;
- private RecoveryManagerService recoveryManagerService;
- private TransactionManagerService transactionManagerService;
- private boolean offline;
- private LookupProvider lookupProvider;
- private Map<SubordinateXidImple, TransactionImple> transactions = new HashMap<SubordinateXidImple, TransactionImple>();
- private RecoveryManager _recoveryManager;
-
- public void initialise(LookupProvider lookupProvider, Integer serverName) throws CoreEnvironmentBeanException, IOException, SecurityException,
- NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
- this.lookupProvider = lookupProvider;
- this.nodeName = serverName;
-
- RecoveryEnvironmentBean recoveryEnvironmentBean = com.arjuna.ats.arjuna.common.recoveryPropertyManager.getRecoveryEnvironmentBean();
- recoveryEnvironmentBean.setRecoveryBackoffPeriod(1);
-
- recoveryEnvironmentBean.setRecoveryInetAddress(InetAddress.getByName("localhost"));
- recoveryEnvironmentBean.setRecoveryPort(4712 + serverName);
- recoveryEnvironmentBean.setTransactionStatusManagerInetAddress(InetAddress.getByName("localhost"));
- recoveryEnvironmentBean.setTransactionStatusManagerPort(4713 + serverName);
- List<String> recoveryModuleClassNames = new ArrayList<String>();
-
- recoveryModuleClassNames.add("com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule");
- recoveryModuleClassNames.add("com.arjuna.ats.internal.txoj.recovery.TORecoveryModule");
- recoveryModuleClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule");
- recoveryEnvironmentBean.setRecoveryModuleClassNames(recoveryModuleClassNames);
- List<String> expiryScannerClassNames = new ArrayList<String>();
- expiryScannerClassNames.add("com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner");
- recoveryEnvironmentBean.setExpiryScannerClassNames(expiryScannerClassNames);
- recoveryEnvironmentBean.setRecoveryActivators(null);
-
- CoreEnvironmentBean coreEnvironmentBean = com.arjuna.ats.arjuna.common.arjPropertyManager.getCoreEnvironmentBean();
- coreEnvironmentBean.setSocketProcessIdPort(4714 + serverName);
- coreEnvironmentBean.setNodeIdentifier(serverName);
- coreEnvironmentBean.setSocketProcessIdMaxPorts(1);
-
- CoordinatorEnvironmentBean coordinatorEnvironmentBean = com.arjuna.ats.arjuna.common.arjPropertyManager.getCoordinatorEnvironmentBean();
- coordinatorEnvironmentBean.setEnableStatistics(false);
- coordinatorEnvironmentBean.setDefaultTimeout(300);
- coordinatorEnvironmentBean.setTransactionStatusManagerEnable(false);
- coordinatorEnvironmentBean.setDefaultTimeout(0);
-
- ObjectStoreEnvironmentBean actionStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(
- com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "default");
- actionStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + serverName);
-
- ObjectStoreEnvironmentBean stateStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(
- com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "stateStore");
- stateStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + serverName);
-
- ObjectStoreEnvironmentBean communicationStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator
- .getNamedInstance(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "communicationStore");
- communicationStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + serverName);
-
- ObjStoreBrowser objStoreBrowser = new ObjStoreBrowser();
- Map<String, String> types = new HashMap<String, String>();
- types.put("StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction", "com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean");
- objStoreBrowser.setTypes(types);
-
- JTAEnvironmentBean jTAEnvironmentBean = com.arjuna.ats.jta.common.jtaPropertyManager.getJTAEnvironmentBean();
- jTAEnvironmentBean.setLastResourceOptimisationInterface(org.jboss.tm.LastResource.class);
- jTAEnvironmentBean.setTransactionManagerClassName("com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate");
- jTAEnvironmentBean.setUserTransactionClassName("com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple");
- jTAEnvironmentBean
- .setTransactionSynchronizationRegistryClassName("com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple");
- List<Integer> xaRecoveryNodes = new ArrayList<Integer>();
- xaRecoveryNodes.add(serverName);
- jTAEnvironmentBean.setXaRecoveryNodes(xaRecoveryNodes);
-
- List<String> xaResourceOrphanFilterClassNames = new ArrayList<String>();
-
- xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter");
- xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter");
- xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateJTAXAResourceOrphanFilter");
- jTAEnvironmentBean.setXaResourceOrphanFilterClassNames(xaResourceOrphanFilterClassNames);
- jTAEnvironmentBean.setXAResourceRecordWrappingPlugin(new XAResourceRecordWrappingPluginImpl());
-
- recoveryManagerService = new RecoveryManagerService();
- recoveryManagerService.create();
- recoveryManagerService.addXAResourceRecovery(new ProxyXAResourceRecovery(lookupProvider, serverName));
- recoveryManagerService.addXAResourceRecovery(new TestResourceRecovery(serverName));
- // recoveryManagerService.start();
- _recoveryManager = RecoveryManager.manager();
- RecoveryManager.manager().initialize();
-
- transactionManagerService = new TransactionManagerService();
- TxControl txControl = new com.arjuna.ats.arjuna.coordinator.TxControl();
- transactionManagerService.setJbossXATerminator(new com.arjuna.ats.internal.jbossatx.jta.jca.XATerminator());
- transactionManagerService
- .setTransactionSynchronizationRegistry(new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple());
- transactionManagerService.create();
-
- // Field safetyIntervalMillis =
- // RecoveryXids.class.getDeclaredField("safetyIntervalMillis");
- // safetyIntervalMillis.setAccessible(true);
- // Field modifiersField = Field.class.getDeclaredField("modifiers");
- // modifiersField.setAccessible(true);
- // safetyIntervalMillis.set(null, 0);
- }
-
- @Override
- public void doRecoveryManagerScan() {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader serversClassLoader = this.getClass().getClassLoader();
- Thread.currentThread().setContextClassLoader(serversClassLoader);
- _recoveryManager.scan();
- Thread.currentThread().setContextClassLoader(classLoader);
- }
-
- @Override
- public TransactionManager getTransactionManager() {
- return transactionManagerService.getTransactionManager();
- }
-
- @Override
- public boolean getAndResumeTransaction(int remainingTimeout, Xid toResume) throws XAException, InvalidTransactionException, IllegalStateException,
- SystemException {
- boolean existed = true;
- 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;
- }
- }
- transactionManagerService.getTransactionManager().resume(transaction);
- return existed;
- }
-
- @Override
- public Integer getNodeName() {
- return nodeName;
- }
-
- @Override
- public long getTimeLeftBeforeTransactionTimeout() throws RollbackException {
- return ((TransactionTimeoutConfiguration) transactionManagerService.getTransactionManager()).getTimeLeftBeforeTransactionTimeout(false);
- }
-
- @Override
- public void storeRootTransaction() throws SystemException {
- TransactionImple transaction = ((TransactionImple) transactionManagerService.getTransactionManager().getTransaction());
- Xid txId = transaction.getTxId();
- transactions.put(new SubordinateXidImple(txId), transaction);
- }
-
- @Override
- public Xid getCurrentXid() throws SystemException {
- TransactionImple transaction = ((TransactionImple) transactionManagerService.getTransactionManager().getTransaction());
- return transaction.getTxId();
- }
-
- @Override
- public void removeRootTransaction(Xid toMigrate) {
- transactions.remove(new SubordinateXidImple(toMigrate));
- }
-
- @Override
- public ProxyXAResource generateProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName) {
- return new ProxyXAResource(lookupProvider, localServerName, remoteServerName);
- }
-
- @Override
- public Synchronization generateProxySynchronization(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName, Xid toRegisterAgainst) {
- return new ProxySynchronization(lookupProvider, localServerName, remoteServerName, toRegisterAgainst);
- }
-
- @Override
- public void setOffline(boolean offline) {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
- ClassLoader serversClassLoader = this.getClass().getClassLoader();
- Thread.currentThread().setContextClassLoader(serversClassLoader);
- this.offline = offline;
- Thread.currentThread().setContextClassLoader(classLoader);
- }
-
- @Override
- public RemoteServer connectTo() {
- return this;
- }
-
- @Override
- public int propagatePrepare(Xid xid) throws XAException, DummyRemoteException {
- if (offline) {
- throw new DummyRemoteException("Connection refused to: " + nodeName);
- }
- return SubordinationManager.getTransactionImporter().getImportedTransaction(xid).doPrepare();
- }
-
- @Override
- public void propagateCommit(Xid xid, boolean onePhase) throws IllegalStateException, HeuristicMixedException, HeuristicRollbackException,
- HeuristicCommitException, SystemException, XAException, DummyRemoteException {
- if (offline) {
- throw new DummyRemoteException("Connection refused to: " + nodeName);
- }
- SubordinationManager.getTransactionImporter().getImportedTransaction(xid).doCommit();
- }
-
- @Override
- public void propagateRollback(Xid xid) throws IllegalStateException, HeuristicMixedException, HeuristicCommitException, HeuristicRollbackException,
- SystemException, XAException, DummyRemoteException {
- if (offline) {
- throw new DummyRemoteException("Connection refused to: " + nodeName);
- }
- SubordinationManager.getTransactionImporter().getImportedTransaction(xid).doRollback();
- }
-
- @Override
- public Xid[] propagateRecover(int formatId, byte[] gtrid, Integer serverNodeNameToRecoverFor, int flag) throws XAException, DummyRemoteException {
- if (offline) {
- throw new DummyRemoteException("Connection refused to: " + nodeName);
- }
- List<Xid> toReturn = new ArrayList<Xid>();
- Xid[] recovered = SubordinationManager.getXATerminator().recover(flag);
- if (recovered != null) {
- for (int i = 0; i < recovered.length; i++) {
- // Filter out the transactions that are not owned by this parent
- if (recovered[i].getFormatId() == formatId && Arrays.equals(gtrid, recovered[i].getGlobalTransactionId())
- && XATxConverter.getParentNodeName(((XidImple) recovered[i]).getXID()) == serverNodeNameToRecoverFor) {
- toReturn.add(recovered[i]);
- }
- }
- }
- return toReturn.toArray(new Xid[0]);
- }
-
- @Override
- public void propagateForget(Xid xid) throws XAException, DummyRemoteException {
- if (offline) {
- throw new DummyRemoteException("Connection refused to: " + nodeName);
- }
- SubordinationManager.getXATerminator().forget(xid);
-
- }
-
- @Override
- public void propagateBeforeCompletion(Xid xid) throws XAException, SystemException, DummyRemoteException {
- if (offline) {
- throw new DummyRemoteException("Connection refused to: " + nodeName);
- }
- SubordinateTransaction tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
- tx.doBeforeCompletion();
- }
-
- @Override
- public Xid extractXid(XAResource xaResource) {
- ProxyXAResource proxyXAResource = (ProxyXAResource) xaResource;
- return proxyXAResource.getXid();
- }
-}
Copied: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java (from rev 37587, 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/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java 2011-10-19 08:34:09 UTC (rev 37596)
@@ -0,0 +1,356 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.arjuna.ats.jta.distributed.server.impl;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.transaction.InvalidTransactionException;
+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;
+import javax.transaction.xa.Xid;
+
+import org.jboss.tm.TransactionTimeoutConfiguration;
+
+import com.arjuna.ats.arjuna.common.CoordinatorEnvironmentBean;
+import com.arjuna.ats.arjuna.common.CoreEnvironmentBean;
+import com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException;
+import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean;
+import com.arjuna.ats.arjuna.common.RecoveryEnvironmentBean;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.arjuna.recovery.RecoveryManager;
+import com.arjuna.ats.arjuna.tools.osb.mbean.ObjStoreBrowser;
+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.internal.jta.transaction.arjunacore.jca.XATerminatorImple;
+import com.arjuna.ats.jbossatx.jta.RecoveryManagerService;
+import com.arjuna.ats.jbossatx.jta.TransactionManagerService;
+import com.arjuna.ats.jta.common.JTAEnvironmentBean;
+import com.arjuna.ats.jta.distributed.TestResourceRecovery;
+import com.arjuna.ats.jta.distributed.server.CompletionCounter;
+import com.arjuna.ats.jta.distributed.server.DummyRemoteException;
+import com.arjuna.ats.jta.distributed.server.LocalServer;
+import com.arjuna.ats.jta.distributed.server.LookupProvider;
+import com.arjuna.ats.jta.distributed.server.RemoteServer;
+
+public class ServerImpl implements LocalServer, RemoteServer {
+
+ private int nodeName;
+ private RecoveryManagerService recoveryManagerService;
+ private TransactionManagerService transactionManagerService;
+ private boolean offline;
+ private LookupProvider lookupProvider;
+ private Map<SubordinateXidImple, TransactionImple> transactions = new HashMap<SubordinateXidImple, TransactionImple>();
+ private RecoveryManager _recoveryManager;
+ private CompletionCounter counter;
+
+ public void initialise(LookupProvider lookupProvider, Integer nodeName) throws CoreEnvironmentBeanException, IOException, SecurityException,
+ NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
+ this.lookupProvider = lookupProvider;
+ this.nodeName = nodeName;
+ this.counter = new CompletionCounter() {
+ private int commitCount = 0;
+ private int rollbackCount = 0;
+
+ @Override
+ public void incrementCommit() {
+ commitCount++;
+
+ }
+
+ @Override
+ public void incrementRollback() {
+ rollbackCount++;
+ }
+
+ @Override
+ public int getCommitCount() {
+ return commitCount;
+ }
+
+ @Override
+ public int getRollbackCount() {
+ return rollbackCount;
+ }
+
+ @Override
+ public void resetCounters() {
+ commitCount = 0;
+ rollbackCount = 0;
+ }
+ };
+
+ RecoveryEnvironmentBean recoveryEnvironmentBean = com.arjuna.ats.arjuna.common.recoveryPropertyManager.getRecoveryEnvironmentBean();
+ recoveryEnvironmentBean.setRecoveryBackoffPeriod(1);
+
+ recoveryEnvironmentBean.setRecoveryInetAddress(InetAddress.getByName("localhost"));
+ recoveryEnvironmentBean.setRecoveryPort(4712 + nodeName);
+ recoveryEnvironmentBean.setTransactionStatusManagerInetAddress(InetAddress.getByName("localhost"));
+ recoveryEnvironmentBean.setTransactionStatusManagerPort(4713 + nodeName);
+ List<String> recoveryModuleClassNames = new ArrayList<String>();
+
+ recoveryModuleClassNames.add("com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule");
+ recoveryModuleClassNames.add("com.arjuna.ats.internal.txoj.recovery.TORecoveryModule");
+ recoveryModuleClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule");
+ recoveryEnvironmentBean.setRecoveryModuleClassNames(recoveryModuleClassNames);
+ List<String> expiryScannerClassNames = new ArrayList<String>();
+ expiryScannerClassNames.add("com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner");
+ recoveryEnvironmentBean.setExpiryScannerClassNames(expiryScannerClassNames);
+ recoveryEnvironmentBean.setRecoveryActivators(null);
+
+ CoreEnvironmentBean coreEnvironmentBean = com.arjuna.ats.arjuna.common.arjPropertyManager.getCoreEnvironmentBean();
+ coreEnvironmentBean.setSocketProcessIdPort(4714 + nodeName);
+ coreEnvironmentBean.setNodeIdentifier(nodeName);
+ coreEnvironmentBean.setSocketProcessIdMaxPorts(1);
+
+ CoordinatorEnvironmentBean coordinatorEnvironmentBean = com.arjuna.ats.arjuna.common.arjPropertyManager.getCoordinatorEnvironmentBean();
+ coordinatorEnvironmentBean.setEnableStatistics(false);
+ coordinatorEnvironmentBean.setDefaultTimeout(300);
+ coordinatorEnvironmentBean.setTransactionStatusManagerEnable(false);
+ coordinatorEnvironmentBean.setDefaultTimeout(0);
+
+ ObjectStoreEnvironmentBean actionStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(
+ com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "default");
+ actionStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + nodeName);
+
+ ObjectStoreEnvironmentBean stateStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(
+ com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "stateStore");
+ stateStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + nodeName);
+
+ ObjectStoreEnvironmentBean communicationStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator
+ .getNamedInstance(com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "communicationStore");
+ communicationStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/tmp/tx-object-store/" + nodeName);
+
+ ObjStoreBrowser objStoreBrowser = new ObjStoreBrowser();
+ Map<String, String> types = new HashMap<String, String>();
+ types.put("StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction", "com.arjuna.ats.internal.jta.tools.osb.mbean.jta.JTAActionBean");
+ objStoreBrowser.setTypes(types);
+
+ JTAEnvironmentBean jTAEnvironmentBean = com.arjuna.ats.jta.common.jtaPropertyManager.getJTAEnvironmentBean();
+ jTAEnvironmentBean.setLastResourceOptimisationInterface(org.jboss.tm.LastResource.class);
+ jTAEnvironmentBean.setTransactionManagerClassName("com.arjuna.ats.jbossatx.jta.TransactionManagerDelegate");
+ jTAEnvironmentBean.setUserTransactionClassName("com.arjuna.ats.internal.jta.transaction.arjunacore.UserTransactionImple");
+ jTAEnvironmentBean
+ .setTransactionSynchronizationRegistryClassName("com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple");
+ List<Integer> xaRecoveryNodes = new ArrayList<Integer>();
+ xaRecoveryNodes.add(nodeName);
+ jTAEnvironmentBean.setXaRecoveryNodes(xaRecoveryNodes);
+
+ List<String> xaResourceOrphanFilterClassNames = new ArrayList<String>();
+
+ xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter");
+ xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter");
+ xaResourceOrphanFilterClassNames.add("com.arjuna.ats.internal.jta.recovery.arjunacore.SubordinateJTAXAResourceOrphanFilter");
+ jTAEnvironmentBean.setXaResourceOrphanFilterClassNames(xaResourceOrphanFilterClassNames);
+ jTAEnvironmentBean.setXAResourceRecordWrappingPlugin(new XAResourceRecordWrappingPluginImpl());
+
+ recoveryManagerService = new RecoveryManagerService();
+ recoveryManagerService.create();
+ recoveryManagerService.addXAResourceRecovery(new ProxyXAResourceRecovery(lookupProvider, nodeName));
+ recoveryManagerService.addXAResourceRecovery(new TestResourceRecovery(counter, nodeName));
+
+ // recoveryManagerService.start();
+ _recoveryManager = RecoveryManager.manager();
+ RecoveryManager.manager().initialize();
+
+ transactionManagerService = new TransactionManagerService();
+ TxControl txControl = new com.arjuna.ats.arjuna.coordinator.TxControl();
+ transactionManagerService.setJbossXATerminator(new com.arjuna.ats.internal.jbossatx.jta.jca.XATerminator());
+ transactionManagerService
+ .setTransactionSynchronizationRegistry(new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple());
+ transactionManagerService.create();
+
+ // Field safetyIntervalMillis =
+ // RecoveryXids.class.getDeclaredField("safetyIntervalMillis");
+ // safetyIntervalMillis.setAccessible(true);
+ // Field modifiersField = Field.class.getDeclaredField("modifiers");
+ // modifiersField.setAccessible(true);
+ // safetyIntervalMillis.set(null, 0);
+ }
+
+ @Override
+ public void doRecoveryManagerScan() {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader serversClassLoader = this.getClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader(serversClassLoader);
+
+ _recoveryManager.scan();
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+
+ @Override
+ public TransactionManager getTransactionManager() {
+ return transactionManagerService.getTransactionManager();
+ }
+
+ @Override
+ public boolean getAndResumeTransaction(int remainingTimeout, Xid toResume) throws XAException, InvalidTransactionException, IllegalStateException,
+ SystemException {
+ boolean existed = true;
+ 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;
+ }
+ }
+ transactionManagerService.getTransactionManager().resume(transaction);
+ return existed;
+ }
+
+ @Override
+ public Integer getNodeName() {
+ return nodeName;
+ }
+
+ @Override
+ public long getTimeLeftBeforeTransactionTimeout() throws RollbackException {
+ return ((TransactionTimeoutConfiguration) transactionManagerService.getTransactionManager()).getTimeLeftBeforeTransactionTimeout(false);
+ }
+
+ @Override
+ public void storeRootTransaction() throws SystemException {
+ TransactionImple transaction = ((TransactionImple) transactionManagerService.getTransactionManager().getTransaction());
+ Xid txId = transaction.getTxId();
+ transactions.put(new SubordinateXidImple(txId), transaction);
+ }
+
+ @Override
+ public Xid getCurrentXid() throws SystemException {
+ TransactionImple transaction = ((TransactionImple) transactionManagerService.getTransactionManager().getTransaction());
+ return transaction.getTxId();
+ }
+
+ @Override
+ public void removeRootTransaction(Xid toMigrate) {
+ transactions.remove(new SubordinateXidImple(toMigrate));
+ }
+
+ @Override
+ public ProxyXAResource generateProxyXAResource(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName) {
+ return new ProxyXAResource(lookupProvider, localServerName, remoteServerName);
+ }
+
+ @Override
+ public Synchronization generateProxySynchronization(LookupProvider lookupProvider, Integer localServerName, Integer remoteServerName, Xid toRegisterAgainst) {
+ return new ProxySynchronization(lookupProvider, localServerName, remoteServerName, toRegisterAgainst);
+ }
+
+ @Override
+ public void setOffline(boolean offline) {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ ClassLoader serversClassLoader = this.getClass().getClassLoader();
+ Thread.currentThread().setContextClassLoader(serversClassLoader);
+ this.offline = offline;
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+
+ @Override
+ public RemoteServer connectTo() {
+ return this;
+ }
+
+ @Override
+ public int propagatePrepare(Xid xid) throws XAException, DummyRemoteException {
+ if (offline) {
+ throw new DummyRemoteException("Connection refused to: " + nodeName);
+ }
+ SubordinateTransaction tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
+ return SubordinationManager.getXATerminator().prepare(xid);
+ }
+
+ @Override
+ public void propagateCommit(Xid xid) throws XAException, DummyRemoteException {
+ if (offline) {
+ throw new DummyRemoteException("Connection refused to: " + nodeName);
+ }
+ SubordinationManager.getXATerminator().commit(xid, false);
+ }
+
+ @Override
+ public void propagateRollback(Xid xid) throws XAException, DummyRemoteException {
+ if (offline) {
+ throw new DummyRemoteException("Connection refused to: " + nodeName);
+ }
+ SubordinationManager.getXATerminator().rollback(xid);
+ }
+
+ @Override
+ public Xid[] propagateRecover(int formatId, byte[] gtrid, int flag) throws XAException, DummyRemoteException {
+ if (offline) {
+ throw new DummyRemoteException("Connection refused to: " + nodeName);
+ }
+ List<Xid> toReturn = new ArrayList<Xid>();
+ Xid[] recovered = SubordinationManager.getXATerminator().recover(flag);
+ if (recovered != null) {
+ for (int i = 0; i < recovered.length; i++) {
+ // Filter out the transactions that are not owned by this parent
+ if (recovered[i].getFormatId() == formatId && Arrays.equals(gtrid, recovered[i].getGlobalTransactionId())) {
+ toReturn.add(recovered[i]);
+ }
+ }
+ }
+ return toReturn.toArray(new Xid[0]);
+ }
+
+ @Override
+ public void propagateForget(Xid xid) throws XAException, DummyRemoteException {
+ if (offline) {
+ throw new DummyRemoteException("Connection refused to: " + nodeName);
+ }
+ SubordinationManager.getXATerminator().forget(xid);
+
+ }
+
+ @Override
+ public void propagateBeforeCompletion(Xid xid) throws XAException, SystemException, DummyRemoteException {
+ if (offline) {
+ throw new DummyRemoteException("Connection refused to: " + nodeName);
+ }
+ ((XATerminatorImple) SubordinationManager.getXATerminator()).beforeCompletion(xid);
+ }
+
+ @Override
+ public Xid extractXid(XAResource xaResource) {
+ ProxyXAResource proxyXAResource = (ProxyXAResource) xaResource;
+ return proxyXAResource.getXid();
+ }
+
+ @Override
+ public CompletionCounter getCompletionCounter() {
+ return counter;
+ }
+}
More information about the jboss-svn-commits
mailing list