[jbosscache-commits] JBoss Cache SVN: r5636 - in core/trunk/src: test/java/org/jboss/cache/options/cachemodelocal and 1 other directory.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Wed Apr 23 05:29:39 EDT 2008
Author: manik.surtani at jboss.com
Date: 2008-04-23 05:29:39 -0400 (Wed, 23 Apr 2008)
New Revision: 5636
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/AsyncInvalidationPessLocksTest.java
Log:
Fixed invalidation interceptor
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-23 08:57:14 UTC (rev 5635)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-23 09:29:39 UTC (rev 5636)
@@ -86,21 +86,19 @@
this.txTable = txTable;
}
- // todo: revisit. This is not used anywhere but it's functionality is necessary. Expecting a bug here.
+ private boolean skipInvalidation(InvocationContext ctx)
+ {
+ Option optionOverride = ctx.getOptionOverrides();
+ if (optionOverride != null && optionOverride.isCacheModeLocal() && (ctx.getTransaction() == null))
+ //|| MethodDeclarations.isTransactionLifecycleMethod(ctx.getMethodCall().getMethodId())))
+ {
+ // skip replication!!
+ return true;
+ }
+ if (trace) log.trace("(" + rpcManager.getLocalAddress() + ") method call " + ctx.getMethodCall());
+ return false;
+ }
-// protected boolean skipMethodCall(InvocationContext ctx)
-// {
-// Option optionOverride = ctx.getOptionOverrides();
-// if (optionOverride != null && optionOverride.isCacheModeLocal() && (ctx.getTransaction() == null ||
-// MethodDeclarations.isTransactionLifecycleMethod(ctx.getMethodCall().getMethodId())))
-// {
-// // skip replication!!
-// return true;
-// }
-// if (trace) log.trace("(" + rpcManager.getLocalAddress() + ") method call " + ctx.getMethodCall());
-// return false;
-// }
-
public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
return handleCrudMethod(ctx, command.getFqn(), null, command);
@@ -239,36 +237,39 @@
private void broadcastInvalidate(List<TxCacheCommand> modifications, GlobalTransaction gtx, Transaction tx, InvocationContext ctx) throws Throwable
{
- if (modifications == null || modifications.isEmpty()) return;
- InvalidationFilterVisitor filterVisitor = new InvalidationFilterVisitor(modifications.size());
- filterVisitor.visitCollection(null, modifications);
+ if (!skipInvalidation(ctx))
+ {
+ if (modifications == null || modifications.isEmpty()) return;
+ InvalidationFilterVisitor filterVisitor = new InvalidationFilterVisitor(modifications.size());
+ filterVisitor.visitCollection(null, modifications);
- if (filterVisitor.containsPutForExternalRead)
- {
- log.debug("Modification list contains a putForExternalRead operation. Not invalidating.");
- }
- else
- {
- try
+ if (filterVisitor.containsPutForExternalRead)
{
- TransactionWorkspace workspace = config.isNodeLockingOptimistic() ? getWorkspace(gtx) : null;
- for (Fqn fqn : filterVisitor.result) invalidateAcrossCluster(fqn, workspace, defaultSynchronous, ctx);
+ log.debug("Modification list contains a putForExternalRead operation. Not invalidating.");
}
- catch (Throwable t)
+ else
{
- log.warn("Unable to broadcast evicts as a part of the prepare phase. Rolling back.", t);
try
{
- tx.setRollbackOnly();
+ TransactionWorkspace workspace = config.isNodeLockingOptimistic() ? getWorkspace(gtx) : null;
+ for (Fqn fqn : filterVisitor.result) invalidateAcrossCluster(fqn, workspace, defaultSynchronous, ctx);
}
- catch (SystemException se)
+ catch (Throwable t)
{
- throw new RuntimeException("setting tx rollback failed ", se);
+ log.warn("Unable to broadcast evicts as a part of the prepare phase. Rolling back.", t);
+ try
+ {
+ tx.setRollbackOnly();
+ }
+ catch (SystemException se)
+ {
+ throw new RuntimeException("setting tx rollback failed ", se);
+ }
+ if (t instanceof RuntimeException)
+ throw (RuntimeException) t;
+ else
+ throw new RuntimeException("Unable to broadcast invalidation messages", t);
}
- if (t instanceof RuntimeException)
- throw (RuntimeException) t;
- else
- throw new RuntimeException("Unable to broadcast invalidation messages", t);
}
}
}
@@ -357,13 +358,16 @@
protected void invalidateAcrossCluster(Fqn fqn, TransactionWorkspace workspace, boolean synchronous, InvocationContext ctx) throws Throwable
{
- // increment invalidations counter if statistics maintained
- incrementInvalidations();
- InvalidateCommand call = commandsFactory.buildInvalidateCommand(fqn);
- call.setDataVersion(getNodeVersion(workspace, fqn));
- if (log.isDebugEnabled()) log.debug("Cache [" + rpcManager.getLocalAddress() + "] replicating " + call);
- // voila, invalidated!
- replicateCall(ctx, call, synchronous, ctx.getOptionOverrides());
+ if (!skipInvalidation(ctx))
+ {
+ // increment invalidations counter if statistics maintained
+ incrementInvalidations();
+ InvalidateCommand call = commandsFactory.buildInvalidateCommand(fqn);
+ call.setDataVersion(getNodeVersion(workspace, fqn));
+ if (log.isDebugEnabled()) log.debug("Cache [" + rpcManager.getLocalAddress() + "] replicating " + call);
+ // voila, invalidated!
+ replicateCall(ctx, call, synchronous, ctx.getOptionOverrides());
+ }
}
private void incrementInvalidations()
Modified: core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/AsyncInvalidationPessLocksTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/AsyncInvalidationPessLocksTest.java 2008-04-23 08:57:14 UTC (rev 5635)
+++ core/trunk/src/test/java/org/jboss/cache/options/cachemodelocal/AsyncInvalidationPessLocksTest.java 2008-04-23 09:29:39 UTC (rev 5636)
@@ -8,18 +8,20 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.misc.TestingUtil;
+import org.testng.annotations.Test;
+ at Test(groups = "functional")
public class AsyncInvalidationPessLocksTest extends CacheModeLocalTestBase
{
- public AsyncInvalidationPessLocksTest()
- {
- cacheMode = Configuration.CacheMode.INVALIDATION_ASYNC;
- nodeLockingScheme = "PESSIMISTIC";
- isInvalidation = true;
- }
+ public AsyncInvalidationPessLocksTest()
+ {
+ cacheMode = Configuration.CacheMode.INVALIDATION_ASYNC;
+ nodeLockingScheme = "PESSIMISTIC";
+ isInvalidation = true;
+ }
- protected void delay()
- {
- TestingUtil.sleepThread(500);
- }
+ protected void delay()
+ {
+ TestingUtil.sleepThread(500);
+ }
}
More information about the jbosscache-commits
mailing list