[jboss-svn-commits] JBL Code SVN: r37738 - in labs/jbosstm/branches/JBOSSTS_4_15_0_Final: ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/jca and 7 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Nov 26 09:40:12 EST 2011
Author: tomjenkinson
Date: 2011-11-26 09:40:11 -0500 (Sat, 26 Nov 2011)
New Revision: 37738
Modified:
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/SubordinateJTAXAResourceOrphanFilter.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/jca/XATerminatorImple.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/tests/classes/com/arjuna/ats/jta/xa/XATxConverterTest.java
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/LocalServer.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResourceRecovery.java
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/tests/classes/com/arjuna/ats/jta/distributed/TestResource.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/TestResourceRecovery.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java
labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java
Log:
JBTM-895 do not require the transport to persist the subordinate name
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/SubordinateJTAXAResourceOrphanFilter.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/SubordinateJTAXAResourceOrphanFilter.java 2011-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/recovery/arjunacore/SubordinateJTAXAResourceOrphanFilter.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -47,14 +47,14 @@
@Override
public Vote checkXid(Xid xid) {
- Integer nodeName = XATxConverter.getSubordinateNodeName(new XidImple(xid).getXID());
+ String nodeName = XATxConverter.getSubordinateNodeName(new XidImple(xid).getXID());
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("subordinate node name of " + xid + " is " + nodeName);
}
// It does have an XID
- if (nodeName > 0) {
+ if (nodeName != null) {
if (transactionLog(xid, nodeName)) {
// it's owned by a logged transaction which
// will recover it top down in due course
@@ -76,7 +76,7 @@
* @return <code>boolean</code>true if there is a log file,
* <code>false</code> if there isn't.
*/
- private boolean transactionLog(Xid recoveredResourceXid, Integer recoveredResourceNodeName) {
+ private boolean transactionLog(Xid recoveredResourceXid, String recoveredResourceNodeName) {
XidImple theXid = new XidImple(recoveredResourceXid);
Uid u = theXid.getTransactionUid();
@@ -114,7 +114,7 @@
SubordinateAtomicAction tx = new SubordinateAtomicAction(uid, true);
XidImple transactionXid = (XidImple) tx.getXid();
if (transactionXid.isSameTransaction(recoveredResourceXid)
- && recoveredResourceNodeName == XATxConverter.getSubordinateNodeName(transactionXid.getXID())) {
+ && recoveredResourceNodeName.equals(XATxConverter.getSubordinateNodeName(transactionXid.getXID()))) {
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("Found record for " + theXid);
}
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/jca/XATerminatorImple.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/jca/XATerminatorImple.java 2011-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/jca/XATerminatorImple.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -401,8 +401,8 @@
SubordinateAtomicAction saa = new SubordinateAtomicAction(uid, true);
XidImple loadedXid = (XidImple) saa.getXid();
if (loadedXid.getFormatId() == XATxConverter.FORMAT_ID) {
- Integer loadedXidSubordinateNodeName = XATxConverter.getSubordinateNodeName(loadedXid.getXID());
- if (XATxConverter.getSubordinateNodeName(toRecover.getXID()) == loadedXidSubordinateNodeName) {
+ String loadedXidSubordinateNodeName = XATxConverter.getSubordinateNodeName(loadedXid.getXID());
+ if (XATxConverter.getSubordinateNodeName(toRecover.getXID()).equals(loadedXidSubordinateNodeName)) {
if (Arrays.equals(loadedXid.getGlobalTransactionId(), toRecover.getGlobalTransactionId())) {
if (jtaLogger.logger.isDebugEnabled()) {
jtaLogger.logger.debug("Found record for " + saa);
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java 2011-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -164,31 +164,47 @@
return new String(Arrays.copyOfRange(xid.data, offset, xid.gtrid_length));
}
- public static void setSubordinateNodeName(XID theXid, Integer xaNodeName) {
+ public static void setSubordinateNodeName(XID theXid, String xaNodeName) {
if (theXid == null || theXid.formatID != FORMAT_ID) {
return;
}
+ int length = 0;
+ if (xaNodeName != null) {
+ length = xaNodeName.length();
+ }
int offset = theXid.gtrid_length + Uid.UID_SIZE + 4;
- theXid.data[offset + 0] = (byte) (xaNodeName >>> 24);
- theXid.data[offset + 1] = (byte) (xaNodeName >>> 16);
- theXid.data[offset + 2] = (byte) (xaNodeName >>> 8);
- theXid.data[offset + 3] = (byte) (xaNodeName >>> 0);
+ theXid.data[offset++] = (byte) (length >>> 24);
+ theXid.data[offset++] = (byte) (length >>> 16);
+ theXid.data[offset++] = (byte) (length >>> 8);
+ theXid.data[offset++] = (byte) (length >>> 0);
+ if (length > 0) {
+ byte[] nameAsBytes = xaNodeName.getBytes();
+ System.arraycopy(nameAsBytes, 0, theXid.data, offset, length);
+ }
+ for (int i = offset+length; i < theXid.bqual_length; i++) {
+ theXid.data[i] = 0;
+ }
}
- public static Integer getSubordinateNodeName(XID xid) {
+ public static String getSubordinateNodeName(XID xid) {
// Arjuna.XID()
// don't check the formatId - it may differ e.g. JTA vs. JTS.
if (xid.formatID != FORMAT_ID) {
- return -1;
+ return null;
}
// the node name follows the Uid with no separator, so the only
// way to tell where it starts is to figure out how long the Uid is.
int offset = xid.gtrid_length + Uid.UID_SIZE + 4;
- return (xid.data[offset + 0] << 24)
- + ((xid.data[offset + 1] & 0xFF) << 16)
- + ((xid.data[offset + 2] & 0xFF) << 8)
- + (xid.data[offset + 3] & 0xFF);
+ int length = (xid.data[offset++] << 24)
+ + ((xid.data[offset++] & 0xFF) << 16)
+ + ((xid.data[offset++] & 0xFF) << 8)
+ + (xid.data[offset++] & 0xFF);
+ if (length > 0) {
+ return new String(Arrays.copyOfRange(xid.data, offset, offset+length));
+ } else {
+ return null;
+ }
}
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/tests/classes/com/arjuna/ats/jta/xa/XATxConverterTest.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/tests/classes/com/arjuna/ats/jta/xa/XATxConverterTest.java 2011-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/ArjunaJTA/jta/tests/classes/com/arjuna/ats/jta/xa/XATxConverterTest.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -24,16 +24,16 @@
{
assertEquals(XATxConverter.getNodeName(rootXid.getXID()), "1");
assertEquals(XATxConverter.getEISName(rootXid.getXID()), eisName);
- assertEquals(XATxConverter.getSubordinateNodeName(rootXid.getXID()), new Integer(0));
+ assertEquals(XATxConverter.getSubordinateNodeName(rootXid.getXID()), "0");
}
// TxControl.setXANodeName(2);
- XATxConverter.setSubordinateNodeName(rootXid.getXID(), 1);
+ XATxConverter.setSubordinateNodeName(rootXid.getXID(), "1");
XidImple subordinateXid = new XidImple(rootXid);
{
assertEquals(XATxConverter.getNodeName(subordinateXid.getXID()), "1");
assertEquals(XATxConverter.getEISName(subordinateXid.getXID()), eisName);
- assertEquals(XATxConverter.getSubordinateNodeName(subordinateXid.getXID()), new Integer(1));
+ assertEquals(XATxConverter.getSubordinateNodeName(subordinateXid.getXID()), "1");
}
}
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-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/ExampleDistributedJTATestCase.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -218,7 +218,7 @@
transactionManager.suspend();
// WE CAN NOW PROPAGATE THE TRANSACTION
- DataReturnedFromRemoteServer dataReturnedFromRemoteServer = propagateTransaction(nodesToFlowTo, remainingTimeout, currentXid, 1);
+ DataReturnedFromRemoteServer dataReturnedFromRemoteServer = propagateTransaction(nodesToFlowTo, remainingTimeout, currentXid);
// After the call retuns, resume the local transaction
transactionManager.resume(transaction);
@@ -282,8 +282,7 @@
* @throws NotSupportedException
* @throws IOException
*/
- private DataReturnedFromRemoteServer propagateTransaction(List<String> nodesToFlowTo, int remainingTimeout, Xid toMigrate,
- Integer nextAvailableSubordinateName) throws RollbackException, IllegalStateException, XAException, SystemException, NotSupportedException,
+ private DataReturnedFromRemoteServer propagateTransaction(List<String> nodesToFlowTo, int remainingTimeout, Xid toMigrate) throws RollbackException, IllegalStateException, XAException, SystemException, NotSupportedException,
IOException {
// Do some test setup to initialize this method as it if was being
// invoked in a remote server
@@ -299,10 +298,7 @@
// Check if this server has seen this transaction before - this is
// crucial to ensure that calling servers will only lay down a proxy if
// they are the first visitor to this server.
- boolean requiresProxyAtPreviousServer = !currentServer.getAndResumeTransaction(remainingTimeout, toMigrate, nextAvailableSubordinateName);
- if (requiresProxyAtPreviousServer) {
- nextAvailableSubordinateName++;
- }
+ boolean requiresProxyAtPreviousServer = !currentServer.getAndResumeTransaction(remainingTimeout, toMigrate);
{
// Perform work on the migrated transaction
@@ -348,8 +344,7 @@
// indicate whether this caller is the first client to establish
// the
// subordinate transaction at the remote node
- DataReturnedFromRemoteServer dataReturnedFromRemoteServer = propagateTransaction(nodesToFlowTo, remainingTimeout, currentXid,
- nextAvailableSubordinateName);
+ DataReturnedFromRemoteServer dataReturnedFromRemoteServer = propagateTransaction(nodesToFlowTo, remainingTimeout, currentXid);
// Resume the transaction locally, ready for any more local work
// and
// to add the proxy resource and sync if needed
@@ -362,7 +357,6 @@
transaction.enlistResource(proxyXAResource);
// Register a sync
transaction.registerSynchronization(currentServer.generateProxySynchronization(lookupProvider, nextServerNodeName, toMigrate));
- nextAvailableSubordinateName = dataReturnedFromRemoteServer.getNextAvailableSubordinateName();
} else {
// This will discard the state of this resource, i.e. the
// file
@@ -397,7 +391,7 @@
// Return to the previous caller back over the transport/classloader
// boundary in this case
Thread.currentThread().setContextClassLoader(classLoader);
- return new DataReturnedFromRemoteServer(requiresProxyAtPreviousServer, transactionState, nextAvailableSubordinateName);
+ return new DataReturnedFromRemoteServer(requiresProxyAtPreviousServer, transactionState);
}
/**
@@ -423,12 +417,9 @@
private int transactionState;
- private Integer nextAvailableSubordinateName;
-
- public DataReturnedFromRemoteServer(boolean proxyRequired, int transactionState, Integer nextAvailableSubordinateName) {
+ public DataReturnedFromRemoteServer(boolean proxyRequired, int transactionState) {
this.proxyRequired = proxyRequired;
this.transactionState = transactionState;
- this.nextAvailableSubordinateName = nextAvailableSubordinateName;
}
public boolean isProxyRequired() {
@@ -438,9 +429,5 @@
public int getTransactionState() {
return transactionState;
}
-
- public Integer getNextAvailableSubordinateName() {
- return nextAvailableSubordinateName;
- }
}
}
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-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResource.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -85,7 +85,7 @@
public synchronized int prepare(Xid xid) throws XAException {
System.out.println(" TestResource (" + localServerName + ") XA_PREPARE [" + xid + "]");
- File dir = new File(System.getProperty("user.dir") + "/distributedjta-example/TestResource/" + localServerName + "/");
+ File dir = new File(System.getProperty("user.dir") + "/distributedjta-examples/TestResource/" + localServerName + "/");
dir.mkdirs();
file = new File(dir, new Uid().fileStringForm() + "_");
try {
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-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/TestResourceRecovery.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -40,7 +40,7 @@
private List<TestResource> resources = new ArrayList<TestResource>();
public TestResourceRecovery(String nodeName) throws IOException {
- File file = new File(System.getProperty("user.dir") + "/distributedjta-example/TestResource/" + nodeName + "/");
+ File file = new File(System.getProperty("user.dir") + "/distributedjta-examples/TestResource/" + nodeName + "/");
if (file.exists() && file.isDirectory()) {
File[] listFiles = file.listFiles();
for (int i = 0; i < listFiles.length; i++) {
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/LocalServer.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/LocalServer.java 2011-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/LocalServer.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -124,7 +124,7 @@
* @throws SystemException
* @throws IOException
*/
- public boolean getAndResumeTransaction(int remainingTimeout, Xid toImport, Integer nextAvailableSubordinateName) throws XAException,
+ public boolean getAndResumeTransaction(int remainingTimeout, Xid toImport) throws XAException,
InvalidTransactionException, IllegalStateException, SystemException, IOException;
/**
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java 2011-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResource.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -158,7 +158,7 @@
// prepare but the alternative is to orphan a prepared server
try {
- File dir = new File(System.getProperty("user.dir") + "/distributedjta-example/ProxyXAResource/" + localServerName + "/");
+ File dir = new File(System.getProperty("user.dir") + "/distributedjta-examples/ProxyXAResource/" + localServerName + "/");
dir.mkdirs();
File file = new File(dir, new Uid().fileStringForm());
file.createNewFile();
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResourceRecovery.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResourceRecovery.java 2011-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ProxyXAResourceRecovery.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -44,7 +44,7 @@
private List<ProxyXAResource> resources = new ArrayList<ProxyXAResource>();
public ProxyXAResourceRecovery(LookupProvider lookupProvider, String nodeName) throws IOException {
- File directory = new File(System.getProperty("user.dir") + "/distributedjta-example/ProxyXAResource/" + nodeName + "/");
+ File directory = new File(System.getProperty("user.dir") + "/distributedjta-examples/ProxyXAResource/" + nodeName + "/");
Map<String, Map<Xid, File>> savedData = new HashMap<String, Map<Xid, File>>();
if (directory.exists() && directory.isDirectory()) {
File[] listFiles = directory.listFiles();
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-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/examples/classes/com/arjuna/jta/distributed/example/server/impl/ServerImpl.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -77,7 +77,6 @@
private TransactionManagerService transactionManagerService;
private Map<SubordinateXidImple, TransactionImple> transactions = new HashMap<SubordinateXidImple, TransactionImple>();
private String nodeName;
- private Map<SubordinateXidImple, File> subordinateOrphanDetection = new HashMap<SubordinateXidImple, File>();
public void initialise(LookupProvider lookupProvider, String nodeName, int portOffset) throws CoreEnvironmentBeanException, IOException, SecurityException,
NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
@@ -113,15 +112,15 @@
ObjectStoreEnvironmentBean actionStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(
com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "default");
- actionStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/distributedjta-example/tx-object-store/" + nodeName);
+ actionStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/distributedjta-examples/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") + "/distributedjta-example/tx-object-store/" + nodeName);
+ stateStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/distributedjta-examples/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") + "/distributedjta-example/tx-object-store/" + nodeName);
+ communicationStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/distributedjta-examples/tx-object-store/" + nodeName);
ObjStoreBrowser objStoreBrowser = new ObjStoreBrowser();
Map<String, String> types = new HashMap<String, String>();
@@ -177,7 +176,7 @@
* @throws IOException
*/
@Override
- public boolean getAndResumeTransaction(int remainingTimeout, Xid toResume, Integer nextAvailableSubordinateName) throws XAException, IllegalStateException,
+ public boolean getAndResumeTransaction(int remainingTimeout, Xid toResume) throws XAException, IllegalStateException,
SystemException, IOException {
boolean existed = true;
Transaction transaction = transactions.get(new SubordinateXidImple(toResume));
@@ -185,22 +184,8 @@
transaction = SubordinationManager.getTransactionImporter().getImportedTransaction(toResume);
if (transaction == null) {
- File dir = new File(System.getProperty("user.dir") + "/distributedjta-example/SubordinateNameXANodeNameMap/" + TxControl.getXANodeName());
- dir.mkdirs();
- File file = new File(dir, new Uid().fileStringForm());
- file.createNewFile();
- DataOutputStream fos = new DataOutputStream(new FileOutputStream(file));
- byte[] nodeName = TxControl.getXANodeName().getBytes();
- fos.writeInt(nodeName.length);
- fos.write(nodeName);
- fos.writeInt(nextAvailableSubordinateName);
- fos.writeInt(toResume.getGlobalTransactionId().length);
- fos.write(toResume.getGlobalTransactionId());
-
- subordinateOrphanDetection.put(new SubordinateXidImple(toResume), file);
-
XidImple toImport = new XidImple(toResume);
- XATxConverter.setSubordinateNodeName(toImport.getXID(), nextAvailableSubordinateName);
+ XATxConverter.setSubordinateNodeName(toImport.getXID(), TxControl.getXANodeName());
transaction = SubordinationManager.getTransactionImporter().importTransaction(toImport, remainingTimeout);
existed = false;
@@ -247,7 +232,7 @@
// prepare but the alternative is to orphan a prepared server
Xid currentXid = getCurrentXid();
- File dir = new File(System.getProperty("user.dir") + "/distributedjta-example/ProxyXAResource/" + TxControl.getXANodeName());
+ File dir = new File(System.getProperty("user.dir") + "/distributedjta-examples/ProxyXAResource/" + TxControl.getXANodeName());
dir.mkdirs();
File file = new File(dir, new Uid().fileStringForm());
file.createNewFile();
@@ -298,7 +283,6 @@
try {
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
SubordinationManager.getXATerminator().commit(xid, onePhase);
- subordinateOrphanDetection.remove(new SubordinateXidImple(xid)).delete();
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
@@ -315,54 +299,15 @@
SubordinationManager.getXATerminator().rollback(xid);
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
-
- subordinateOrphanDetection.remove(new SubordinateXidImple(xid)).delete();
}
}
public void recover(Xid toRecover) throws XAException, IOException {
// Work out what the subordinate name would be for these transaction
// for this server
- XidImple recoverable = null;
-
- // Look at the list of subordinate name to XA node name map
- File directory = new File(System.getProperty("user.dir") + "/distributedjta-example/SubordinateNameXANodeNameMap/" + nodeName + "/");
- if (directory.exists() && directory.isDirectory()) {
- File[] listFiles = directory.listFiles();
- for (int i = 0; i < listFiles.length; i++) {
- File file = listFiles[i];
- DataInputStream fis = new DataInputStream(new FileInputStream(file));
- int nodeNameLength = fis.readInt();
- final byte[] nodeNameBytes = new byte[nodeNameLength];
- fis.read(nodeNameBytes, 0, nodeNameLength);
- String nodeName = new String(nodeNameBytes);
-
- // Is the node name this servers node name
- if (nodeName.equals(TxControl.getXANodeName())) {
- // Read in the subordinate name for the encapsulated
- // transaction
- Integer subordinateNodeName = fis.readInt();
- int gtridLength = fis.readInt();
- byte[] gtrid = new byte[gtridLength];
- fis.read(gtrid, 0, gtridLength);
-
- // Check if the transaction in the list the client is
- // requesting
- byte[] requestedGtrid = toRecover.getGlobalTransactionId();
- if (Arrays.equals(gtrid, requestedGtrid)) {
- // Set the subordinate name
- recoverable = new XidImple(toRecover);
- XATxConverter.setSubordinateNodeName(recoverable.getXID(), subordinateNodeName);
- subordinateOrphanDetection.put(new SubordinateXidImple(recoverable), file);
- }
- }
- }
-
- }
-
- if (recoverable != null) {
- ((XATerminatorImple) SubordinationManager.getXATerminator()).doRecover(recoverable);
- }
+ XidImple recoverable = new XidImple(toRecover);
+ XATxConverter.setSubordinateNodeName(recoverable.getXID(), TxControl.getXANodeName());
+ ((XATerminatorImple) SubordinationManager.getXATerminator()).doRecover(recoverable);
}
@Override
@@ -373,7 +318,6 @@
SubordinationManager.getXATerminator().forget(xid);
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
- subordinateOrphanDetection.remove(new SubordinateXidImple(xid)).delete();
}
}
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/TestResource.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/TestResource.java 2011-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/TestResource.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -97,7 +97,7 @@
if (readonly)
return XA_RDONLY;
else {
- File dir = new File(System.getProperty("user.dir") + "/distributedjta/TestResource/" + serverId + "/");
+ File dir = new File(System.getProperty("user.dir") + "/distributedjta-tests/TestResource/" + serverId + "/");
dir.mkdirs();
file = new File(dir, new Uid().fileStringForm() + "_");
try {
Modified: 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/tests/classes/com/arjuna/ats/jta/distributed/TestResourceRecovery.java 2011-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/TestResourceRecovery.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -37,7 +37,7 @@
private List<TestResource> resources = new ArrayList<TestResource>();
public TestResourceRecovery(CompletionCounter counter, String nodeName) throws IOException {
- File file = new File(System.getProperty("user.dir") + "/distributedjta/TestResource/" + nodeName + "/");
+ File file = new File(System.getProperty("user.dir") + "/distributedjta-tests/TestResource/" + nodeName + "/");
if (file.exists() && file.isDirectory()) {
File[] listFiles = file.listFiles();
for (int i = 0; i < listFiles.length; i++) {
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java 2011-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResource.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -123,7 +123,7 @@
// prepare but the alternative is to orphan a prepared server
try {
- File dir = new File(System.getProperty("user.dir") + "/distributedjta/ProxyXAResource/" + localServerName + "/");
+ File dir = new File(System.getProperty("user.dir") + "/distributedjta-tests/ProxyXAResource/" + localServerName + "/");
dir.mkdirs();
File file = new File(dir, new Uid().fileStringForm());
file.createNewFile();
Modified: 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/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java 2011-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ProxyXAResourceRecovery.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -45,7 +45,7 @@
private List<ProxyXAResource> resources = new ArrayList<ProxyXAResource>();
public ProxyXAResourceRecovery(CompletionCounter counter, LookupProvider lookupProvider, String nodeName) throws IOException {
- File directory = new File(System.getProperty("user.dir") + "/distributedjta/ProxyXAResource/" + nodeName + "/");
+ File directory = new File(System.getProperty("user.dir") + "/distributedjta-tests/ProxyXAResource/" + nodeName + "/");
Map<String, Map<Xid, File>> savedData = new HashMap<String, Map<Xid, File>>();
if (directory.exists() && directory.isDirectory()) {
File[] listFiles = directory.listFiles();
Modified: labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java 2011-11-24 07:46:23 UTC (rev 37737)
+++ labs/jbosstm/branches/JBOSSTS_4_15_0_Final/atsintegration/tests/classes/com/arjuna/ats/jta/distributed/server/impl/ServerImpl.java 2011-11-26 14:40:11 UTC (rev 37738)
@@ -83,7 +83,6 @@
private Map<SubordinateXidImple, TransactionImple> transactions = new HashMap<SubordinateXidImple, TransactionImple>();
private RecoveryManager _recoveryManager;
private CompletionCounter counter;
- private Map<SubordinateXidImple, File> subordinateOrphanDetection = new HashMap<SubordinateXidImple, File>();
public void initialise(LookupProvider lookupProvider, String nodeName, int portOffset) throws CoreEnvironmentBeanException, IOException, SecurityException,
NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
@@ -153,15 +152,15 @@
ObjectStoreEnvironmentBean actionStoreObjectStoreEnvironmentBean = com.arjuna.common.internal.util.propertyservice.BeanPopulator.getNamedInstance(
com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean.class, "default");
- actionStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/distributedjta/tx-object-store/" + nodeName);
+ actionStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/distributedjta-tests/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") + "/distributedjta/tx-object-store/" + nodeName);
+ stateStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/distributedjta-tests/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") + "/distributedjta/tx-object-store/" + nodeName);
+ communicationStoreObjectStoreEnvironmentBean.setObjectStoreDir(System.getProperty("user.dir") + "/distributedjta-tests/tx-object-store/" + nodeName);
ObjStoreBrowser objStoreBrowser = new ObjStoreBrowser();
Map<String, String> types = new HashMap<String, String>();
@@ -259,22 +258,8 @@
transaction = SubordinationManager.getTransactionImporter().getImportedTransaction(toResume);
if (transaction == null) {
- File dir = new File(System.getProperty("user.dir") + "/distributedjta/SubordinateNameXANodeNameMap/" + TxControl.getXANodeName());
- dir.mkdirs();
- File file = new File(dir, new Uid().fileStringForm());
- file.createNewFile();
- DataOutputStream fos = new DataOutputStream(new FileOutputStream(file));
- byte[] nodeName = TxControl.getXANodeName().getBytes();
- fos.writeInt(nodeName.length);
- fos.write(nodeName);
- fos.writeInt(nextAvailableSubordinateName);
- fos.writeInt(toResume.getGlobalTransactionId().length);
- fos.write(toResume.getGlobalTransactionId());
-
- subordinateOrphanDetection.put(new SubordinateXidImple(toResume), file);
-
XidImple toImport = new XidImple(toResume);
- XATxConverter.setSubordinateNodeName(toImport.getXID(), nextAvailableSubordinateName);
+ XATxConverter.setSubordinateNodeName(toImport.getXID(), TxControl.getXANodeName());
transaction = SubordinationManager.getTransactionImporter().importTransaction(toImport, remainingTimeout);
existed = false;
@@ -325,7 +310,7 @@
// prepare but the alternative is to orphan a prepared server
Xid currentXid = getCurrentXid();
- File dir = new File(System.getProperty("user.dir") + "/distributedjta/ProxyXAResource/" + getNodeName());
+ File dir = new File(System.getProperty("user.dir") + "/distributedjta-tests/ProxyXAResource/" + getNodeName());
dir.mkdirs();
File file = new File(dir, new Uid().fileStringForm());
file.createNewFile();
@@ -380,13 +365,12 @@
@Override
public void commit(Xid xid, boolean onePhase, boolean recover) throws XAException, IOException {
if (recover) {
- recover(new Xid[] { xid });
+ recover(xid);
}
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
SubordinationManager.getXATerminator().commit(xid, onePhase);
- subordinateOrphanDetection.remove(new SubordinateXidImple(xid)).delete();
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
}
@@ -395,7 +379,7 @@
@Override
public void rollback(Xid xid, boolean recover) throws XAException, IOException {
if (recover) {
- recover(new Xid[] { xid });
+ recover(xid);
}
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
@@ -403,67 +387,26 @@
SubordinationManager.getXATerminator().rollback(xid);
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
- subordinateOrphanDetection.remove(new SubordinateXidImple(xid)).delete();
}
}
- public void recover(Xid[] toRecover) throws XAException, IOException {
+ protected void recover(Xid toRecover) throws XAException, IOException {
// Work out what the subordinate name would be for these transaction
// for this server
- XidImple recoverable = null;
-
- // Look at the list of subordinate name to XA node name map
- File directory = new File(System.getProperty("user.dir") + "/distributedjta/SubordinateNameXANodeNameMap/" + nodeName + "/");
- if (directory.exists() && directory.isDirectory()) {
- File[] listFiles = directory.listFiles();
- for (int i = 0; i < listFiles.length; i++) {
- File file = listFiles[i];
- DataInputStream fis = new DataInputStream(new FileInputStream(file));
- int nodeNameLength = fis.readInt();
- final byte[] nodeNameBytes = new byte[nodeNameLength];
- fis.read(nodeNameBytes, 0, nodeNameLength);
- String nodeName = new String(nodeNameBytes);
-
- // Is the node name this servers node name
- if (nodeName.equals(TxControl.getXANodeName())) {
- // Read in the subordinate name for the encapsulated
- // transaction
- Integer subordinateNodeName = fis.readInt();
- int gtridLength = fis.readInt();
- byte[] gtrid = new byte[gtridLength];
- fis.read(gtrid, 0, gtridLength);
-
- // Check if the transaction in the list the client is
- // requesting
- for (int j = 0; j < toRecover.length; j++) {
- Xid toCheck = toRecover[j];
- byte[] requestedGtrid = toCheck.getGlobalTransactionId();
- if (Arrays.equals(gtrid, requestedGtrid)) {
- // Set the subordinate name
- recoverable = new XidImple(toCheck);
- XATxConverter.setSubordinateNodeName(recoverable.getXID(), subordinateNodeName);
- subordinateOrphanDetection.put(new SubordinateXidImple(recoverable), file);
- }
- }
- }
-
- }
- }
- if (recoverable != null) {
- ((XATerminatorImple) SubordinationManager.getXATerminator()).doRecover(recoverable);
- }
+ XidImple recoverable = new XidImple(toRecover);
+ XATxConverter.setSubordinateNodeName(recoverable.getXID(), TxControl.getXANodeName());
+ ((XATerminatorImple) SubordinationManager.getXATerminator()).doRecover(recoverable);
}
@Override
public void forget(Xid xid) throws XAException, IOException {
- recover(new Xid[] { xid });
+ recover(xid);
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
SubordinationManager.getXATerminator().forget(xid);
} finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
- subordinateOrphanDetection.remove(new SubordinateXidImple(xid)).delete();
}
}
More information about the jboss-svn-commits
mailing list