[infinispan-commits] Infinispan SVN: r2228 - branches/4.1.x/core/src/main/java/org/infinispan/batch.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Mon Aug 16 09:07:15 EDT 2010


Author: galder.zamarreno at jboss.com
Date: 2010-08-16 09:07:14 -0400 (Mon, 16 Aug 2010)
New Revision: 2228

Modified:
   branches/4.1.x/core/src/main/java/org/infinispan/batch/BatchContainer.java
Log:
[ISPN-600] (Embedded JBossTS and TreeCache don't work together) Store thread creating transaction to compare it at commit time and decide whether to call TX.commit or TM.commit.

Modified: branches/4.1.x/core/src/main/java/org/infinispan/batch/BatchContainer.java
===================================================================
--- branches/4.1.x/core/src/main/java/org/infinispan/batch/BatchContainer.java	2010-08-16 13:06:26 UTC (rev 2227)
+++ branches/4.1.x/core/src/main/java/org/infinispan/batch/BatchContainer.java	2010-08-16 13:07:14 UTC (rev 2228)
@@ -66,6 +66,7 @@
             transactionManager.begin();
             bd.nestedInvocationCount = 1;
             bd.suspendTxAfterInvocation = !autoBatch;
+            bd.thread = Thread.currentThread();
 
             // do not suspend if this is from an AutoBatch!
             if (autoBatch)
@@ -103,10 +104,7 @@
             if ((existingTx == null && !autoBatch) || !bd.tx.equals(existingTx))
                transactionManager.resume(bd.tx);
 
-            if (success)
-               transactionManager.commit();
-            else
-               transactionManager.rollback();
+            resolveTransaction(bd, success);
          }
          catch (Exception e) {
             throw new CacheException("Unable to end batch", e);
@@ -125,6 +123,21 @@
       }
    }
 
+   private void resolveTransaction(BatchDetails bd, boolean success) throws Exception {
+      Thread currentThread = Thread.currentThread();
+      if (bd.thread.equals(currentThread)) {
+         if (success)
+            transactionManager.commit();
+         else
+            transactionManager.rollback();
+      } else {
+         if (success)
+            bd.tx.commit();
+         else
+            bd.tx.rollback();
+      }
+   }
+
    public Transaction getBatchTransaction() {
       return batchDetailsTl.get().tx;
    }
@@ -137,5 +150,6 @@
       int nestedInvocationCount;
       boolean suspendTxAfterInvocation;
       Transaction tx;
+      Thread thread;
    }
 }



More information about the infinispan-commits mailing list