[jbosscache-commits] JBoss Cache SVN: r5413 - in core/trunk/src/main/java/org/jboss/cache: interceptors and 1 other directories.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Mar 11 17:59:36 EDT 2008


Author: mircea.markus
Date: 2008-03-11 17:59:36 -0400 (Tue, 11 Mar 2008)
New Revision: 5413

Modified:
   core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
   core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
Log:
http://jira.jboss.org/jira/browse/JBCACHE-1278

Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java	2008-03-11 21:38:32 UTC (rev 5412)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java	2008-03-11 21:59:36 UTC (rev 5413)
@@ -29,6 +29,7 @@
    // defaults to true.
    private boolean originLocal = true;
    private boolean txHasMods;
+   private boolean cacheLoaderHasMods;
    private boolean localRollbackOnly;
    private MethodCall methodCall;
 
@@ -200,6 +201,7 @@
             ", optionOverrides=" + optionOverrides +
             ", originLocal=" + originLocal +
             ", txHasMods=" + txHasMods +
+            ", cacheLoaderHasMods=" + cacheLoaderHasMods +
             '}';
    }
 
@@ -213,6 +215,19 @@
       txHasMods = b;
    }
 
+   /**
+    * Cache loader might have mods which are different from TX's mods; e.g. when cache is local and passivation is on.
+    */
+   public boolean isCacheLoaderHasMods()
+   {
+      return cacheLoaderHasMods;
+   }
+
+   public void setCacheLoaderHasMods(boolean cacheLoaderHasMods)
+   {
+      this.cacheLoaderHasMods = cacheLoaderHasMods;
+   }
+
    public boolean isLocalRollbackOnly()
    {
       return localRollbackOnly;
@@ -256,6 +271,7 @@
       this.setOriginLocal(template.isOriginLocal());
       this.setTransaction(template.getTransaction());
       this.setTxHasMods(template.isTxHasMods());
+      this.setCacheLoaderHasMods(template.isCacheLoaderHasMods());
    }
 
    public boolean equals(Object o)
@@ -268,6 +284,7 @@
       if (localRollbackOnly != that.localRollbackOnly) return false;
       if (originLocal != that.originLocal) return false;
       if (txHasMods != that.txHasMods) return false;
+      if (cacheLoaderHasMods!= that.cacheLoaderHasMods) return false;
       if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
       {
          return false;

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java	2008-03-11 21:38:32 UTC (rev 5412)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java	2008-03-11 21:59:36 UTC (rev 5413)
@@ -82,7 +82,7 @@
       if (inTransaction())
       {
          if (trace) log.trace("transactional so don't put stuff in the cloader yet.");
-         if (ctx.isTxHasMods())
+         if (ctx.isCacheLoaderHasMods())
          {
             // this is a commit call.
             if (trace) log.trace("Calling loader.commit() for gtx " + gtx);
@@ -130,7 +130,7 @@
       if (inTransaction())
       {
          if (trace) log.trace("transactional so don't put stuff in the cloader yet.");
-         if (ctx.isTxHasMods())
+         if (ctx.isCacheLoaderHasMods())
          {
             // this is a rollback method
             if (preparingTxs.containsKey(gtx))

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java	2008-03-11 21:38:32 UTC (rev 5412)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java	2008-03-11 21:59:36 UTC (rev 5413)
@@ -205,11 +205,11 @@
    private void addToModificationList(GlobalTransaction gtx, MethodCall m, InvocationContext ctx)
    {
       Option opt = ctx.getOptionOverrides();
-//      if (opt == null || !opt.isCacheModeLocal())
-//      {
+      if (opt == null || !opt.isCacheModeLocal())
+      {
          txTable.addModification(gtx, m);
          if (log.isDebugEnabled()) log.debug("Adding Method " + m + " to modification list");
-//      }
+      }
       if (cache.getCacheLoaderManager() != null) txTable.addCacheLoaderModification(gtx, m);
 
    }

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java	2008-03-11 21:38:32 UTC (rev 5412)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java	2008-03-11 21:59:36 UTC (rev 5413)
@@ -865,10 +865,11 @@
     *
     * @param gtx
     */
-   protected void runCommitPhase(InvocationContext ctx, GlobalTransaction gtx, Transaction tx, List modifications, boolean onePhaseCommit)
+   protected void runCommitPhase(InvocationContext ctx, GlobalTransaction gtx, Transaction tx, List modifications, List clModifications, boolean onePhaseCommit)
    {
       // set the hasMods flag in the invocation ctx.  This should not be replicated, just used locally by the interceptors.
       ctx.setTxHasMods(modifications != null && modifications.size() > 0);
+      ctx.setCacheLoaderHasMods(clModifications != null && clModifications.size() > 0);
       try
       {
          MethodCall commitMethod;
@@ -1224,12 +1225,14 @@
                log.error("afterCompletion error: " + status, e);
             }
 
+            if (trace) log.trace("calling aftercompletion for " + gtx);
 
-            if (trace) log.trace("calling aftercompletion for " + gtx);
+            List cacheLoaderModifications = null;
             // set any transaction wide options as current for this thread.
             if (entry != null)
             {
                modifications = entry.getModifications();
+               cacheLoaderModifications = entry.getCacheLoaderModifications();
                ctx.setOptionOverrides(entry.getOption());
             }
             if (tx != null) transactions.remove(tx);
@@ -1241,7 +1244,7 @@
                   // if this is optimistic or sync repl
                   boolean onePhaseCommit = !configuration.isNodeLockingOptimistic() && configuration.getCacheMode() == Configuration.CacheMode.REPL_ASYNC;
                   if (log.isDebugEnabled()) log.debug("Running commit phase.  One phase? " + onePhaseCommit);
-                  runCommitPhase(ctx, gtx, tx, modifications, onePhaseCommit);
+                  runCommitPhase(ctx, gtx, tx, modifications, cacheLoaderModifications, onePhaseCommit);
                   log.debug("Finished commit phase");
                   break;
                case Status.STATUS_UNKNOWN:
@@ -1337,7 +1340,7 @@
          // fetch the modifications before the transaction is committed
          // (and thus removed from the txTable)
          setTransactionalContext(tx, gtx, ctx);
-         if (modifications.size() == 0)
+         if (!entry.existModifications())
          {
             if (trace) log.trace("No modifications in this tx.  Skipping beforeCompletion()");
             return;

Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java	2008-03-11 21:38:32 UTC (rev 5412)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java	2008-03-11 21:59:36 UTC (rev 5413)
@@ -432,4 +432,12 @@
    {
       this.orderedSynchronizationHandler = orderedSynchronizationHandler;
    }
+
+   /**
+    * Returns true if modifications were registered to either modificationList or to class loader modifications list.
+    */
+   public boolean existModifications()
+   {
+      return !modification_list.isEmpty() || !cl_mod_list.isEmpty(); 
+   }
 }




More information about the jbosscache-commits mailing list