[jbosscache-commits] JBoss Cache SVN: r7081 - core/trunk/src/main/java/org/jboss/cache/marshall.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Tue Nov 4 09:57:30 EST 2008


Author: mircea.markus
Date: 2008-11-04 09:57:30 -0500 (Tue, 04 Nov 2008)
New Revision: 7081

Modified:
   core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
Log:
replication is always sync for optimistic async caches

Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java	2008-11-04 13:09:38 UTC (rev 7080)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java	2008-11-04 14:57:30 UTC (rev 7081)
@@ -88,7 +88,7 @@
       Configuration c = componentRegistry.getComponent(Configuration.class);
       replicationProcessor = c.getRuntimeConfig().getAsyncSerializationExecutor();
       if (c.getCacheMode().isSynchronous() ||
-            (replicationProcessor == null && c.getSerializationExecutorPoolSize() < 1)) // if an executor has not been injected and the pool size is set
+            (replicationProcessor == null && c.getSerializationExecutorPoolSize() < 1) || requireSyncMarshalling(c)) // if an executor has not been injected and the pool size is set
       {
          // in-process thread.  Not async.
          replicationProcessor = new WithinThreadExecutor();
@@ -113,6 +113,27 @@
       }
    }
 
+   /**
+    * Serial(sync) marshalling should be enabled for async optimistic caches. That is because optimistic async is a 2PC,
+    * which might cause the Commit command to be send before the Prepare command, so replication will fail. This is not
+    * the same for async <b>pessimistic/mvcc</b> replication, as this uses a 1PC. 
+    */
+   private boolean requireSyncMarshalling(Configuration c)
+   {
+      boolean enforceSerialMarshalling =
+            c.getNodeLockingScheme().equals(Configuration.NodeLockingScheme.OPTIMISTIC) && !c.getCacheMode().isInvalidation();
+
+      if (enforceSerialMarshalling)
+      {
+         if (c.getSerializationExecutorPoolSize() > 1 && log.isWarnEnabled())
+         {
+            log.warn("Async optimistic caches do not support serialization pools.");
+         }
+         if (trace) log.trace("Disbaling serial marshalling for opt async cache");
+      }
+      return enforceSerialMarshalling;
+   }
+
    @Override
    public void stop()
    {




More information about the jbosscache-commits mailing list