[jboss-svn-commits] JBL Code SVN: r37613 - in labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example: server and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Oct 19 15:17:42 EDT 2011
Author: tomjenkinson
Date: 2011-10-19 15:17:41 -0400 (Wed, 19 Oct 2011)
New Revision: 37613
Removed:
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/CompletionCounter.java
Modified:
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/ExampleDistributedJTATestCase.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResourceRecovery.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java
Log:
JBTM-895 further simplified the example to not count completions - we have unit tests for that
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/ExampleDistributedJTATestCase.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/ExampleDistributedJTATestCase.java 2011-10-19 17:42:29 UTC (rev 37612)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/ExampleDistributedJTATestCase.java 2011-10-19 19:17:41 UTC (rev 37613)
@@ -21,8 +21,6 @@
*/
package com.arjuna.jta.distributed.example;
-import static org.junit.Assert.assertTrue;
-
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
@@ -46,7 +44,6 @@
import org.junit.Test;
import com.arjuna.ats.arjuna.common.CoreEnvironmentBeanException;
-import com.arjuna.jta.distributed.example.server.CompletionCounter;
import com.arjuna.jta.distributed.example.server.IsolatableServersClassLoader;
import com.arjuna.jta.distributed.example.server.LocalServer;
import com.arjuna.jta.distributed.example.server.LookupProvider;
@@ -83,37 +80,6 @@
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
- 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.remove(0);
LocalServer originalServer = getLocalServer(startingServer);
@@ -125,7 +91,7 @@
Transaction originalTransaction = transactionManager.getTransaction();
originalTransaction.registerSynchronization(new TestSynchronization(originalServer.getNodeName()));
- originalTransaction.enlistResource(new TestResource(counter, originalServer.getNodeName()));
+ originalTransaction.enlistResource(new TestResource(originalServer.getNodeName()));
if (!nodesToFlowTo.isEmpty()) {
Integer nextServerNodeName = nodesToFlowTo.get(0);
@@ -137,7 +103,7 @@
Xid currentXid = originalServer.getCurrentXid();
originalServer.storeRootTransaction();
transactionManager.suspend();
- boolean proxyRequired = performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid);
+ boolean proxyRequired = performTransactionalWork(nodesToFlowTo, remainingTimeout, currentXid);
transactionManager.resume(originalTransaction);
// Create a proxy for the new server if necessary, this can orphan
@@ -155,12 +121,11 @@
originalServer.removeRootTransaction(currentXid);
}
transactionManager.commit();
- assertTrue(counter.getCommitCount() == totalNodeCount);
Thread.currentThread().setContextClassLoader(classLoader);
}
- private boolean performTransactionalWork(CompletionCounter counter, List<Integer> nodesToFlowTo, int remainingTimeout, Xid toMigrate)
- throws RollbackException, InvalidTransactionException, IllegalStateException, XAException, SystemException, NotSupportedException {
+ 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);
@@ -172,7 +137,7 @@
TransactionManager transactionManager = currentServer.getTransactionManager();
Transaction transaction = transactionManager.getTransaction();
transaction.registerSynchronization(new TestSynchronization(currentServer.getNodeName()));
- transaction.enlistResource(new TestResource(counter, currentServer.getNodeName()));
+ transaction.enlistResource(new TestResource(currentServer.getNodeName()));
if (!nodesToFlowTo.isEmpty()) {
Integer nextServerNodeName = nodesToFlowTo.get(0);
@@ -183,7 +148,7 @@
// SUSPEND THE TRANSACTION
Xid currentXid = currentServer.getCurrentXid();
transactionManager.suspend();
- boolean proxyRequired = performTransactionalWork(counter, nodesToFlowTo, remainingTimeout, currentXid);
+ boolean proxyRequired = performTransactionalWork(nodesToFlowTo, remainingTimeout, currentXid);
transactionManager.resume(transaction);
if (proxyRequired) {
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java 2011-10-19 17:42:29 UTC (rev 37612)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java 2011-10-19 19:17:41 UTC (rev 37613)
@@ -34,7 +34,6 @@
import javax.transaction.xa.Xid;
import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.jta.distributed.example.server.CompletionCounter;
public class TestResource implements XAResource {
private Xid xid;
@@ -45,15 +44,11 @@
private int serverId;
- private CompletionCounter completionCounter;
-
- public TestResource(CompletionCounter completionCounter, int serverId) {
- this.completionCounter = completionCounter;
+ public TestResource(int serverId) {
this.serverId = serverId;
}
- public TestResource(CompletionCounter completionCounter, int serverId, File file) throws IOException {
- this.completionCounter = completionCounter;
+ public TestResource(int serverId, File file) throws IOException {
this.serverId = serverId;
this.file = file;
DataInputStream fis = new DataInputStream(new FileInputStream(file));
@@ -114,15 +109,13 @@
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) {
+ // String absoluteFile = file.getAbsolutePath();
+ // String newName = absoluteFile.substring(0, absoluteFile.length()
+ // -
+ // 1);
+ // File file2 = new File(newName);
+ // file.renameTo(file2);
file.delete();
}
this.xid = null;
@@ -130,9 +123,6 @@
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();
}
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResourceRecovery.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResourceRecovery.java 2011-10-19 17:42:29 UTC (rev 37612)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResourceRecovery.java 2011-10-19 19:17:41 UTC (rev 37613)
@@ -30,20 +30,18 @@
import org.jboss.tm.XAResourceRecovery;
-import com.arjuna.jta.distributed.example.server.CompletionCounter;
-
public class TestResourceRecovery implements XAResourceRecovery {
private List<TestResource> resources = new ArrayList<TestResource>();
- public TestResourceRecovery(CompletionCounter counter, Integer nodeName) throws IOException {
+ public TestResourceRecovery(Integer nodeName) throws IOException {
File file = new File(System.getProperty("user.dir") + "/distributedjta-example/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));
+ resources.add(new TestResource(nodeName, currentFile));
}
}
}
Deleted: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/CompletionCounter.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/CompletionCounter.java 2011-10-19 17:42:29 UTC (rev 37612)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/CompletionCounter.java 2011-10-19 19:17:41 UTC (rev 37613)
@@ -1,30 +0,0 @@
-/*
- * 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.jta.distributed.example.server;
-
-public interface CompletionCounter {
- public void incrementCommit();
- public void incrementRollback();
- int getCommitCount();
- int getRollbackCount();
- void resetCounters();
-}
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java 2011-10-19 17:42:29 UTC (rev 37612)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java 2011-10-19 19:17:41 UTC (rev 37613)
@@ -56,7 +56,6 @@
import com.arjuna.ats.jbossatx.jta.TransactionManagerService;
import com.arjuna.ats.jta.common.JTAEnvironmentBean;
import com.arjuna.jta.distributed.example.TestResourceRecovery;
-import com.arjuna.jta.distributed.example.server.CompletionCounter;
import com.arjuna.jta.distributed.example.server.DummyRemoteException;
import com.arjuna.jta.distributed.example.server.LocalServer;
import com.arjuna.jta.distributed.example.server.LookupProvider;
@@ -69,7 +68,6 @@
private TransactionManagerService transactionManagerService;
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 {
@@ -142,7 +140,7 @@
recoveryManagerService = new RecoveryManagerService();
recoveryManagerService.create();
recoveryManagerService.addXAResourceRecovery(new ProxyXAResourceRecovery(lookupProvider, nodeName));
- recoveryManagerService.addXAResourceRecovery(new TestResourceRecovery(counter, nodeName));
+ recoveryManagerService.addXAResourceRecovery(new TestResourceRecovery(nodeName));
recoveryManagerService.start();
@@ -219,9 +217,9 @@
try {
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
SubordinateTransaction tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
- return SubordinationManager.getXATerminator().prepare(xid);
+ return SubordinationManager.getXATerminator().prepare(xid);
} finally {
- Thread.currentThread().setContextClassLoader(contextClassLoader);
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
@@ -232,7 +230,7 @@
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
SubordinationManager.getXATerminator().commit(xid, false);
} finally {
- Thread.currentThread().setContextClassLoader(contextClassLoader);
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
@@ -241,9 +239,9 @@
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
- SubordinationManager.getXATerminator().rollback(xid);
+ SubordinationManager.getXATerminator().rollback(xid);
} finally {
- Thread.currentThread().setContextClassLoader(contextClassLoader);
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
@@ -256,7 +254,8 @@
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
+ // 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]);
}
@@ -264,7 +263,7 @@
}
return toReturn.toArray(new Xid[0]);
} finally {
- Thread.currentThread().setContextClassLoader(contextClassLoader);
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
@@ -275,7 +274,7 @@
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
SubordinationManager.getXATerminator().forget(xid);
} finally {
- Thread.currentThread().setContextClassLoader(contextClassLoader);
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
@@ -287,7 +286,7 @@
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
((XATerminatorImple) SubordinationManager.getXATerminator()).beforeCompletion(xid);
} finally {
- Thread.currentThread().setContextClassLoader(contextClassLoader);
+ Thread.currentThread().setContextClassLoader(contextClassLoader);
}
}
More information about the jboss-svn-commits
mailing list