Author: mircea.markus
Date: 2008-04-15 09:48:32 -0400 (Tue, 15 Apr 2008)
New Revision: 5569
Modified:
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/InvalidateCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutDataMapCommand.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/test/java/org/jboss/cache/api/DestroyedCacheAPITest.java
Log:
JBCACHE-1222 - bug fixing - optimistic
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-15 11:58:33 UTC
(rev 5568)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-15 13:48:32 UTC
(rev 5569)
@@ -675,6 +675,5 @@
}
}
-
/*------------------- End of MembershipListener ----------------------*/
}
\ No newline at end of file
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-15
11:58:33 UTC (rev 5568)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-04-15
13:48:32 UTC (rev 5569)
@@ -354,6 +354,9 @@
case ReplicateCommand.SINGLE_METHOD_ID:
returnValue = new ReplicateCommand();
break;
+ case InvalidateCommand.METHOD_ID:
+ returnValue = new InvalidateCommand();
+ break;
default:
throw new CacheException("Unknown command id " + id +
"!");
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/InvalidateCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/InvalidateCommand.java 2008-04-15
11:58:33 UTC (rev 5568)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/InvalidateCommand.java 2008-04-15
13:48:32 UTC (rev 5569)
@@ -36,6 +36,11 @@
private boolean isOptimisticLocking;
private TransactionManager transactionManager;
+ public InvalidateCommand()
+ {
+ super(null);
+ }
+
public InvalidateCommand(Fqn fqn)
{
super(fqn);
@@ -53,6 +58,7 @@
{
Node node = spi.getNode(fqn); // force interceptor chain, load if necessary from
cache loader.
+ if (log.isTraceEnabled()) log.trace("Invalidating fqn:" + fqn);
if (node == null)
{
// if pessimistic locking, just return.
@@ -160,4 +166,12 @@
{
return METHOD_ID;
}
+
+ public String toString()
+ {
+ return "InvalidateCommand{" +
+ "dataVersion=" + dataVersion+
+ ", fqn=" + fqn +
+ '}';
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutDataMapCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutDataMapCommand.java 2008-04-15
11:58:33 UTC (rev 5568)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutDataMapCommand.java 2008-04-15
13:48:32 UTC (rev 5569)
@@ -30,7 +30,6 @@
/* dependencies*/
private GlobalTransaction globalTransaction;
- private TransactionTable transactionTable;
/* parameters*/
private Map data;
@@ -51,12 +50,6 @@
this.eraseContents = eraseContents;
}
- @Inject
- public void initialize(TransactionTable txTable)
- {
- this.transactionTable = txTable;
- }
-
public Object perform(InvocationContext ctx)
{
if (log.isTraceEnabled())
@@ -185,4 +178,16 @@
result = 31 * result + (eraseContents ? 1 : 0);
return result;
}
+
+
+ public String toString()
+ {
+ return "PutDataMapCommand{" +
+ "eraseContents=" + eraseContents +
+ ", createUndoOps=" + createUndoOps +
+ ", dataVersion=" + dataVersion +
+ ", data=" + data +
+ ", globalTransaction=" + globalTransaction +
+ '}';
+ }
}
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-15
11:58:33 UTC (rev 5568)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-15
13:48:32 UTC (rev 5569)
@@ -238,6 +238,7 @@
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);
@@ -358,6 +359,7 @@
// 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());
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-15
11:58:33 UTC (rev 5568)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-04-15
13:48:32 UTC (rev 5569)
@@ -12,6 +12,8 @@
import org.jboss.cache.ReplicationException;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.channel.BlockChannelCommand;
+import org.jboss.cache.commands.channel.UnblockChannelCommand;
import org.jboss.cache.commands.functional.TxCacheCommand;
import org.jboss.cache.commands.state.DataVersionCommand;
import org.jboss.cache.commands.state.GlobalTransactionCommand;
@@ -454,9 +456,18 @@
}
}
- /**
- * @param ctx
- */
+ @Override
+ public Object handleBlockChannelCommand(InvocationContext ctx, BlockChannelCommand
command) throws Throwable
+ {
+ return invokeNextInterceptor(ctx, command);
+ }
+
+ @Override
+ public Object handleUnblockChannelCommand(InvocationContext ctx, UnblockChannelCommand
command) throws Throwable
+ {
+ return invokeNextInterceptor(ctx, command);
+ }
+
private void copyForcedCacheModeToTxScope(InvocationContext ctx)
{
Option optionOverride = ctx.getOptionOverrides();
Modified: core/trunk/src/test/java/org/jboss/cache/api/DestroyedCacheAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/DestroyedCacheAPITest.java 2008-04-15
11:58:33 UTC (rev 5568)
+++ core/trunk/src/test/java/org/jboss/cache/api/DestroyedCacheAPITest.java 2008-04-15
13:48:32 UTC (rev 5569)
@@ -34,6 +34,7 @@
private Fqn parent = Fqn.fromString("/test/fqn");
private Fqn child = Fqn.fromString("/test/fqn/child");
private String version;
+ private Node<String,String> root;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -46,6 +47,7 @@
version = cache.getVersion();
cache.getRoot().addChild(parent);
cache.getRoot().addChild(child);
+ root = cache.getRoot();
cache.stop();
cache.destroy();
}
@@ -261,23 +263,6 @@
}
/**
- * Tests that Cache.getRoot() returns a node.
- * <p/>
- * BES 2008/03/22 -- This behavior is not actually documented. Maintainers
- * shouldn't feel constrained from updating this test to match
- * agreed upon behavior changes; I'm just adding it so any changes to the
- * current behavior will trigger failures and ensure that people are aware of
- * the change and agree that it's correct.
- */
- public void testGetRoot()
- {
- Node root = cache.getRoot();
- assertNotNull("have root", root);
- assertEquals(Fqn.ROOT, root.getFqn());
- }
-
-
- /**
* Tests the basic node addition, existence check, get, remove operations.
* Expectation is all will throw an ISE.
* <p/>
@@ -289,7 +274,6 @@
*/
public void testNodeAPI()
{
- Node root = cache.getRoot();
try
{
root.addChild(parent);