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

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Apr 16 11:32:16 EDT 2008


Author: mircea.markus
Date: 2008-04-16 11:32:16 -0400 (Wed, 16 Apr 2008)
New Revision: 5579

Modified:
   core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
   core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
   core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java
   core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
Log:
JBCACHE-1222 - bug fixing - optimistic locking

Modified: core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java	2008-04-16 14:33:06 UTC (rev 5578)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java	2008-04-16 15:32:16 UTC (rev 5579)
@@ -321,6 +321,8 @@
 
          case PutDataMapCommand.METHOD_ID:
          case PutDataMapCommand.ERASE_METHOD_ID:
+         case PutDataMapCommand.ERASE_VERSIONED_METHOD_ID:
+         case PutDataMapCommand.VERSIONED_METHOD_ID:
             returnValue = new PutDataMapCommand();
             break;
 

Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java	2008-04-16 14:33:06 UTC (rev 5578)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java	2008-04-16 15:32:16 UTC (rev 5579)
@@ -8,7 +8,6 @@
 
 import java.util.List;
 import java.util.Map;
-import java.util.Collections;
 
 /**
  * @author Mircea.Markus at jboss.com
@@ -87,4 +86,15 @@
       result = 31 * result + (data != null ? data.hashCode() : 0);
       return result;
    }
+   
+   @Override
+   public String toString()
+   {
+      return "OptimisticPrepareCommand{" +
+            "data=" + data +
+            "modifications=" + modifications +
+            ", localAddress=" + localAddress +
+            ", onePhaseCommit=" + onePhaseCommit +
+            '}';
+   }
 }

Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java	2008-04-16 14:33:06 UTC (rev 5578)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java	2008-04-16 15:32:16 UTC (rev 5579)
@@ -110,4 +110,15 @@
       result = 31 * result + (onePhaseCommit ? 1 : 0);
       return result;
    }
+
+
+   @Override
+   public String toString()
+   {
+      return "PrepareCommand{" +
+            "modifications=" + modifications +
+            ", localAddress=" + localAddress +
+            ", onePhaseCommit=" + onePhaseCommit +
+            '}';
+   }
 }

Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java	2008-04-16 14:33:06 UTC (rev 5578)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java	2008-04-16 15:32:16 UTC (rev 5579)
@@ -116,8 +116,7 @@
             result = handleRemotePrepare(ctx, command, command.isOnePhaseCommit());
             scrubTxsOnExit = true;
             incresePrepares();
-         }
-         else
+         } else
          {
             if (trace) log.trace("received my own message (discarding it)");
             result = null;
@@ -324,8 +323,7 @@
             {
                log.debug("Started new local TX as result of remote PREPARE: local TX=" + ltx + " (Status=" + ltx.getStatus() + "), global TX=" + gtx);
             }
-         }
-         else
+         } else
          {
             //this should be valid
             if (!ctx.isValidTransaction())
@@ -357,8 +355,7 @@
             log.debug("creating new tx entry");
             txTable.put(gtx, entry);
             if (trace) log.trace("TxTable contents: " + txTable);
-         }
-         else
+         } else
          {
             entry = txTable.get(gtx);
          }
@@ -370,8 +367,7 @@
          if (configuration.isNodeLockingOptimistic())
          {
             retval = handleOptimisticPrepare(ctx, gtx, ltx, (OptimisticPrepareCommand) command);
-         }
-         else
+         } else
          {
             retval = handlePessimisticPrepare(ctx, ltx, command);
          }
@@ -447,8 +443,7 @@
                   log.warn("Roll back failed encountered", th);
                }
                throw t;
-            }
-            else
+            } else
             {
                throw t;
             }
@@ -509,8 +504,7 @@
       if (gtx != null)
       {
          command = replaceGtx(command, gtx);
-      }
-      else
+      } else
       {
          // get the current globalTransaction from the txTable.
          gtx = txTable.get(tx);
@@ -561,8 +555,7 @@
             {
                if (trace)
                   log.trace("Using one-phase prepare.  Not propagating the prepare call up the stack until called to do so by the sync handler.");
-            }
-            else
+            } else
             {
                invokeNextInterceptor(ctx, command);
             }
@@ -605,8 +598,7 @@
                if (success)
                {
                   ltx.commit();
-               }
-               else
+               } else
                {
                   ltx.rollback();
                }
@@ -758,13 +750,11 @@
             if (configuration.isNodeLockingOptimistic())
             {
                commitCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, null);
-            }
-            else
+            } else
             {
                commitCommand = commandsFactory.buildPrepareCommand(gtx, modifications, rpcManager.getLocalAddress(), true);
             }
-         }
-         else
+         } else
          {
             commitCommand = commandsFactory.buildCommitCommand(gtx);
          }
@@ -863,9 +853,8 @@
       // running a 2-phase commit.
       if (configuration.isNodeLockingOptimistic())
       {
-         prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, null);
-      }
-      else if (configuration.getCacheMode() != Configuration.CacheMode.REPL_ASYNC)
+         prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, modifications, null, rpcManager.getLocalAddress(), false);
+      } else if (configuration.getCacheMode() != Configuration.CacheMode.REPL_ASYNC)
       {
          prepareCommand = commandsFactory.buildPrepareCommand(gtx, modifications, rpcManager.getLocalAddress(),
                false);// don't commit or rollback - wait for call
@@ -891,8 +880,7 @@
       {
          ctx.setExecutingCommand(prepareCommand);
          result = invokeNextInterceptor(ctx, prepareCommand);
-      }
-      else
+      } else
       {
          log.warn("Local transaction does not exist or does not match expected transaction " + gtx);
          throw new CacheException(" local transaction " + ltx + " does not exist or does not match expected transaction " + gtx);
@@ -925,8 +913,7 @@
             {
                log.trace("is a remotely initiated gtx so no need to register a tx for it");
             }
-         }
-         else
+         } else
          {
             if (trace)
             {
@@ -936,12 +923,10 @@
             LocalSynchronizationHandler myHandler = new LocalSynchronizationHandler(gtx, tx, !ctx.isOriginLocal());
             registerHandler(tx, myHandler, ctx, txTable.get(gtx));
          }
-      }
-      else if ((gtx = (GlobalTransaction) rollbackTransactions.get(tx)) != null)
+      } else if ((gtx = (GlobalTransaction) rollbackTransactions.get(tx)) != null)
       {
          if (log.isDebugEnabled()) log.debug("Transaction " + tx + " is already registered and is rolling back.");
-      }
-      else
+      } else
       {
          if (log.isDebugEnabled()) log.debug("Transaction " + tx + " is already registered.");
 




More information about the jbosscache-commits mailing list