Author: manik.surtani(a)jboss.com
Date: 2008-03-18 21:05:11 -0400 (Tue, 18 Mar 2008)
New Revision: 5448
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
Log:
JBCACHE-1310 - Marshalling issue with optimistic prepare and an empty modification list
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-03-19
00:31:19 UTC (rev 5447)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-03-19
01:05:11 UTC (rev 5448)
@@ -160,6 +160,32 @@
}
}
+ /**
+ * It does not make sense replicating a transaction method(commit, rollback, prepare)
if one of the following:
+ * <pre>
+ * - call was not initiated here, but on other member of the cluster
+ * - there is no transaction. Why calling a commit if no transaction going on?
+ * - the current transaction did not modufy any data, so other members are not
aware of it
+ * </pre>
+ */
+ protected boolean skipReplicationOfTransactionMethod(InvocationContext ctx)
+ {
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+ boolean isInitiatedHere = gtx != null && !gtx.isRemote();
+ if (trace) log.trace("isInitiatedHere? " + isInitiatedHere + "; gtx
= " + gtx);
+ return !isTransactionalAndLocal(ctx) || !containsModifications(ctx);
+ }
+
+ /**
+ * The call runs in a transaction and it was initiated on this node of the cluster.
+ */
+ protected boolean isTransactionalAndLocal(InvocationContext ctx)
+ {
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+ boolean isInitiatedHere = gtx != null && !gtx.isRemote();
+ return isInitiatedHere && (ctx.getTransaction() != null);
+ }
+
protected boolean isSynchronous(Option option)
{
if (option != null)
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-03-19
00:31:19 UTC (rev 5447)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-03-19
01:05:11 UTC (rev 5448)
@@ -72,12 +72,15 @@
{
// pass up the chain.
Object retval = nextInterceptor(ctx);
- gtx = getGlobalTransaction(ctx);
+ if (!skipReplicationOfTransactionMethod(ctx))
+ {
+ gtx = getGlobalTransaction(ctx);
- if (!gtx.isRemote() && ctx.isOriginLocal())
- {
- // replicate the prepare call.
- broadcastPrepare(ctx.getMethodCall(), gtx, ctx);
+ if (!gtx.isRemote() && ctx.isOriginLocal())
+ {
+ // replicate the prepare call.
+ broadcastPrepare(ctx.getMethodCall(), gtx, ctx);
+ }
}
return retval;
}
@@ -93,7 +96,7 @@
//we dont do anything
try
{
- broadcastCommit(gtx, ctx);
+ if (!skipReplicationOfTransactionMethod(ctx)) broadcastCommit(gtx, ctx);
}
catch (Throwable t)
{
@@ -121,7 +124,7 @@
//we dont do anything
try
{
- broadcastRollback(gtx, ctx);
+ if (!skipReplicationOfTransactionMethod(ctx)) broadcastRollback(gtx, ctx);
}
catch (Throwable t)
{
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-03-19
00:31:19 UTC (rev 5447)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-03-19
01:05:11 UTC (rev 5448)
@@ -41,33 +41,22 @@
protected Object handleCommitMethod(InvocationContext ctx, GlobalTransaction gtx)
throws Throwable
{
- if (skipReplciationOfTransactionMethod(ctx))
- {
- return nextInterceptor(ctx);
- }
- replicateCall(ctx, ctx.getMethodCall(), configuration.isSyncCommitPhase(),
ctx.getOptionOverrides(), true);
+ if (!skipReplicationOfTransactionMethod(ctx))
+ replicateCall(ctx, ctx.getMethodCall(), configuration.isSyncCommitPhase(),
ctx.getOptionOverrides(), true);
return nextInterceptor(ctx);
}
protected Object handlePrepareMethod(InvocationContext ctx, GlobalTransaction gtx,
List modification, Address coordinator, boolean onePhaseCommit) throws Throwable
{
- if (skipReplciationOfTransactionMethod(ctx))
- {
- return nextInterceptor(ctx);
- }
Object retVal = nextInterceptor(ctx);
- runPreparePhase(ctx.getMethodCall(), gtx, ctx);
+ if (!skipReplicationOfTransactionMethod(ctx)) runPreparePhase(ctx.getMethodCall(),
gtx, ctx);
return retVal;
}
protected Object handleRollbackMethod(InvocationContext ctx, GlobalTransaction gtx)
throws Throwable
{
- if (skipReplciationOfTransactionMethod(ctx))
+ if (!skipReplicationOfTransactionMethod(ctx) &&
!ctx.isLocalRollbackOnly())
{
- return nextInterceptor(ctx);
- }
- if (!ctx.isLocalRollbackOnly())
- {
replicateCall(ctx, ctx.getMethodCall(), configuration.isSyncRollbackPhase(),
ctx.getOptionOverrides());
}
return nextInterceptor(ctx);
@@ -88,32 +77,6 @@
}
}
- /**
- * It does not make sense replicating a transaction method(commit, rollback, prepare)
if one of the following:
- * <pre>
- * - call was not initiated here, but on other member of the cluster
- * - there is no transaction. Why calling a commit if no transaction going on?
- * - the current transaction did not modufy any data, so other members are not
aware of it
- * </pre>
- */
- private boolean skipReplciationOfTransactionMethod(InvocationContext ctx)
- {
- GlobalTransaction gtx = ctx.getGlobalTransaction();
- boolean isInitiatedHere = gtx != null && !gtx.isRemote();
- if (trace) log.trace("isInitiatedHere? " + isInitiatedHere + "; gtx
= " + gtx);
- return !isTransactionalAndLocal(ctx) || !containsModifications(ctx);
- }
-
- /**
- * The call runs in a transaction and it was initiated on this node of the cluster.
- */
- private boolean isTransactionalAndLocal(InvocationContext ctx)
- {
- GlobalTransaction gtx = ctx.getGlobalTransaction();
- boolean isInitiatedHere = gtx != null && !gtx.isRemote();
- return isInitiatedHere && (ctx.getTransaction() != null);
- }
-
protected Object handlePutDataMethod(InvocationContext ctx, GlobalTransaction tx, Fqn
fqn, Map data, boolean createUndoOps) throws Throwable
{
return handleCrudMethod(ctx);