Author: mircea.markus
Date: 2008-04-15 12:50:16 -0400 (Tue, 15 Apr 2008)
New Revision: 5572
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/InvalidateCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheData.java
core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
Log:
JBCACHE-1222 - bug fixing - optimistic locking
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
16:02:29 UTC (rev 5571)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/InvalidateCommand.java 2008-04-15
16:50:16 UTC (rev 5572)
@@ -56,6 +56,7 @@
@Override
public Object perform(InvocationContext ctx)
{
+ //todo - rather than using CacheSPI this can rely in cache loader directly to load
data
Node node = spi.getNode(fqn); // force interceptor chain, load if necessary from
cache loader.
if (log.isTraceEnabled()) log.trace("Invalidating fqn:" + fqn);
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2008-04-15
16:02:29 UTC (rev 5571)
+++
core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2008-04-15
16:50:16 UTC (rev 5572)
@@ -1,6 +1,7 @@
package org.jboss.cache.commands.remote;
import org.jboss.cache.InvocationContext;
+import org.jboss.cache.CacheSPI;
import org.jboss.cache.commands.BaseCommand;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CommandsVisitor;
@@ -8,6 +9,7 @@
import org.jboss.cache.commands.functional.MarshallableCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.invocation.InterceptorChain;
+import org.jboss.cache.invocation.AbstractInvocationDelegate;
import java.util.List;
@@ -22,7 +24,10 @@
public static final int SINGLE_METHOD_ID = 13;
public static final int MULTIPLE_METHOD_ID = 14;
- private InterceptorChain invoker;
+ //todo [mmarkus] extract the invoking oart from AbstractInvocationDelegate and make a
new component that wraps that
+ // logic together with InterceptorChain
+ private AbstractInvocationDelegate invoker;
+
/**
* optimisation - rather than constructing a new list each for scenarios where a
single modification needs
* to be replicated rather use this instance.
@@ -45,17 +50,15 @@
}
@Inject
- public void initialize(InterceptorChain invoker)
+ public void initialize(CacheSPI invoker)
{
- this.invoker = invoker;
+ this.invoker = (AbstractInvocationDelegate) invoker;
}
public Object perform(InvocationContext ctx) throws Throwable
{
if (isSingleCommand()) return processSingleCommand(singleModification);
-
for (MarshallableCommand command : modifications) processSingleCommand(command);
-
return null;
}
@@ -66,8 +69,7 @@
try
{
if (trace) log.trace("Invoking command " + cacheCommand + ", with
originLocal flag set to false.");
-
- Object retVal = invoker.invoke(cacheCommand, false);
+ Object retVal = invoker.invoke(cacheCommand);
// we only need to return values for a set of remote calls; not every call.
if (returnValueForRemoteCall(cacheCommand))
{
@@ -86,8 +88,7 @@
}
else
{
- if (trace)
- log.trace("Caught an exception, but since this is a
putForExternalRead() call, suppressing the exception. Exception is:", ex);
+ if (trace) log.trace("Caught an exception, but since this is a
putForExternalRead() call, suppressing the exception. Exception is:", ex);
result = null;
}
}
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
16:02:29 UTC (rev 5571)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-04-15
16:50:16 UTC (rev 5572)
@@ -12,6 +12,7 @@
import org.jboss.cache.ReplicationException;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.cachedata.InvalidateCommand;
import org.jboss.cache.commands.channel.BlockChannelCommand;
import org.jboss.cache.commands.channel.UnblockChannelCommand;
import org.jboss.cache.commands.functional.TxCacheCommand;
@@ -389,6 +390,12 @@
// --------------------------------------------------------------
+ @Override
+ public Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand
command) throws Throwable
+ {
+ return invokeNextInterceptor(ctx, command);
+ }
+
/**
* Tests if we already have a tx running. If so, register a sync handler for this
method invocation.
* if not, create a local tx if we're using opt locking.
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheData.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheData.java 2008-04-15 16:02:29
UTC (rev 5571)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheData.java 2008-04-15 16:50:16
UTC (rev 5572)
@@ -7,6 +7,7 @@
import org.jboss.cache.Node;
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
@@ -39,6 +40,11 @@
*/
private NodeSPI root;
+ @Inject
+ public void injectDependencies(Configuration configuration)
+ {
+ this.configuration = configuration;
+ }
/**
* Set<Fqn> of Fqns of the topmost node of internal regions that should
Modified:
core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-04-15
16:02:29 UTC (rev 5571)
+++
core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-04-15
16:50:16 UTC (rev 5572)
@@ -1,6 +1,7 @@
package org.jboss.cache.marshall;
import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.remote.*;
import org.jboss.cache.invocation.CacheInvocationDelegate;
import org.jgroups.Channel;
import org.jgroups.MembershipListener;
@@ -55,6 +56,13 @@
{
CacheCommand cmd = (CacheCommand)
req_marshaller.objectFromByteBuffer(req.getBuffer());
+ //todo [mmarkus] this is very ugly and caused by the fact that in the
previous version the call for these methods was not chained.
+ //todo re-thinking of these commands is necessary
+ if (cmd instanceof ReplicateCommand || cmd instanceof
AssignToBuddyGroupCommand || cmd instanceof RemoveFromBuddyGroupCommand ||
+ cmd instanceof AnnounceBuddyPoolNameCommand || cmd instanceof
DataGravitationCleanupCommand || cmd instanceof ClusteredGetCommand)
+ {
+ return cmd.perform(null);
+ }
if (trace) log.trace("[sender=" + req.getSrc() + "], command:
" + cmd);
return cid.invoke(cmd);