Author: manik.surtani(a)jboss.com
Date: 2008-04-11 13:18:06 -0400 (Fri, 11 Apr 2008)
New Revision: 5532
Removed:
core/trunk/src/main/java/org/jboss/cache/marshall/CommandMarshaller.java
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheSPI.java
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
core/trunk/src/main/java/org/jboss/cache/commands/BaseCacheCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/CacheCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
core/trunk/src/main/java/org/jboss/cache/commands/DataVersionCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/EvictFqnCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/ExistsNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetChildrenNamesCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetDataMapCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeyValueCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeysCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/MoveCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutDataMapCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutKeyValueCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveKeyCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/channel/BlockChannelCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/channel/UnblockChannelCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java
core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheLifecycleManager.java
core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java
core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java
core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java
Log:
Added preliminary support for replication of cache commands
Modified: core/trunk/src/main/java/org/jboss/cache/CacheSPI.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-04-11 11:31:00 UTC (rev
5531)
+++ core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-04-11 17:18:06 UTC (rev
5532)
@@ -329,4 +329,14 @@
* @return Set an unmodifiable set of children names, Object.
*/
Set getChildrenNames(String fqn);
+
+ /**
+ * Blocks all broadcast network communications in the cluster.
+ */
+ void block();
+
+ /**
+ * Unblocks a previous block() call so broadcast network communications can resume.
+ */
+ void unblock();
}
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-11 11:31:00 UTC
(rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-11 17:18:06 UTC
(rev 5532)
@@ -13,7 +13,6 @@
import org.jboss.cache.config.RuntimeConfig;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Stop;
-import org.jboss.cache.invocation.CacheInvocationDelegate;
import org.jboss.cache.lock.LockUtil;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.lock.TimeoutException;
@@ -26,7 +25,14 @@
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.ThreadGate;
import org.jboss.cache.util.reflect.ReflectionUtil;
-import org.jgroups.*;
+import org.jgroups.Address;
+import org.jgroups.Channel;
+import org.jgroups.ChannelException;
+import org.jgroups.ChannelFactory;
+import org.jgroups.ExtendedMembershipListener;
+import org.jgroups.JChannel;
+import org.jgroups.StateTransferException;
+import org.jgroups.View;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.RpcDispatcher;
import org.jgroups.blocks.RspFilter;
@@ -35,7 +41,13 @@
import javax.transaction.TransactionManager;
import java.io.NotSerializableException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
/**
* Manager that handles all RPC calls between JBoss Cache instances
@@ -68,7 +80,6 @@
private Notifier notifier;
private CacheSPI spi;
private boolean trace = log.isTraceEnabled();
- private CacheInvocationDelegate cacheInvocationDelegate;
private Marshaller marshaller;
private TransactionManager txManager;
private TransactionTable txTable;
@@ -84,7 +95,6 @@
this.configuration = configuration;
this.notifier = notifier;
this.spi = spi;
- this.cacheInvocationDelegate = cacheInvocationDelegate;
this.marshaller = marshaller;
this.txManager = txManager;
this.txTable = txTable;
@@ -141,7 +151,8 @@
{
throw new CacheException("Unable to fetch state on startup",
ex);
}
- } else
+ }
+ else
{
//otherwise just connect
try
@@ -222,7 +233,8 @@
configuration.setUsingMultiplexer(true);
if (log.isDebugEnabled())
log.debug("Created Multiplexer Channel for cache cluster " +
configuration.getClusterName() + " using stack " +
configuration.getMultiplexerStack());
- } else
+ }
+ else
{
try
{
@@ -230,7 +242,8 @@
{
log.debug("setting cluster properties to default value");
channel = new JChannel(configuration.getDefaultClusterConfig());
- } else
+ }
+ else
{
if (trace)
{
@@ -254,7 +267,7 @@
// always use the InactiveRegionAwareRpcDispatcher - exceptions due to regions not
being active should not propagate to remote
// nodes as errors. - Manik
- disp = new InactiveRegionAwareRpcDispatcher(channel, messageListener, new
MembershipListenerAdaptor(), cacheInvocationDelegate);
+ disp = new InactiveRegionAwareRpcDispatcher(channel, messageListener, new
MembershipListenerAdaptor(), spi);
disp.setRequestMarshaller(marshaller);
disp.setResponseMarshaller(marshaller);
@@ -396,13 +409,11 @@
throw new TimeoutException("State retrieval timed out waiting for flush
unblock.");
}
-// useOutOfBandMessage = false;
+ useOutOfBandMessage = false;
- //todo - handle wiering
- rsps = null;
-// rsps = responseFilter == null
-// ? disp.callRemoteMethods(validMembers, command, modeToUse, timeout,
isUsingBuddyReplication, useOutOfBandMessage)
-// : disp.callRemoteMethods(validMembers, command, modeToUse, timeout,
isUsingBuddyReplication, useOutOfBandMessage, responseFilter);
+ rsps = responseFilter == null
+ ? disp.callRemoteMethods(validMembers, command.toMethodCall(), modeToUse,
timeout, isUsingBuddyReplication, useOutOfBandMessage)
+ : disp.callRemoteMethods(validMembers, command.toMethodCall(), modeToUse,
timeout, isUsingBuddyReplication, useOutOfBandMessage, responseFilter);
// a null response is 99% likely to be due to a marshalling problem - we throw a
NSE, this needs to be changed when
// JGroups supports
http://jira.jboss.com/jira/browse/JGRP-193
@@ -426,12 +437,14 @@
if (rsp.wasSuspected())
{
ex = new SuspectException("Suspected member: " +
rsp.getSender());
- } else
+ }
+ else
{
ex = new TimeoutException("Replication timeout for " +
rsp.getSender());
}
retval.add(new ReplicationException("rsp=" + rsp, ex));
- } else
+ }
+ else
{
Object value = rsp.getValue();
if (value instanceof Exception && !(value instanceof
ReplicationException))
@@ -628,7 +641,7 @@
flushBlockGate.close();
if (log.isDebugEnabled()) log.debug("Block received at " +
getLocalAddress());
- cacheInvocationDelegate.block();
+ spi.block();
if (log.isDebugEnabled()) log.debug("Block processed at " +
getLocalAddress());
}
@@ -640,7 +653,7 @@
{
if (log.isDebugEnabled()) log.debug("UnBlock received at " +
getLocalAddress());
- cacheInvocationDelegate.unblock();
+ spi.unblock();
if (log.isDebugEnabled()) log.debug("UnBlock processed at " +
getLocalAddress());
flushBlockGate.open();
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-04-11 11:31:00 UTC
(rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-04-11 17:18:06 UTC
(rev 5532)
@@ -274,7 +274,7 @@
children.put(child_name, child);
if (gtx != null)
{
- RemoveNodeCommand undoOp = commandsFactory.buildRemoveFqnCommand(gtx,
child_fqn, false, false, false);
+ RemoveNodeCommand undoOp = commandsFactory.buildRemoveNodeCommand(gtx,
child_fqn, false, false, false);
transactionTable.addUndoOperation(gtx, undoOp);
}
}
Modified:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -3,9 +3,18 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.*;
+import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.EvictFqnCommand;
+import org.jboss.cache.commands.GravitateDataCommand;
+import org.jboss.cache.commands.InvalidateCommand;
import org.jboss.cache.commands.cachedata.*;
-import org.jboss.cache.commands.remote.*;
+import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
+import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ClusteredGetCommand;
+import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
@@ -70,7 +79,7 @@
public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand
command) throws Throwable
{
Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildRemoveFqnCommand(command.getGlobalTransaction(), transformed,
command.isEviction(),
+ return factory.buildRemoveNodeCommand(command.getGlobalTransaction(), transformed,
command.isEviction(),
command.isSkipSendingNodeEvents(), command.isCreateUndoOps());
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/BaseCacheCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/BaseCacheCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/commands/BaseCacheCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -2,10 +2,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.config.Configuration;
+import org.jboss.cache.marshall.MethodCall;
+import org.jboss.cache.notifications.Notifier;
/**
* @author Mircea.Markus(a)jboss.com
@@ -13,6 +14,7 @@
*/
public abstract class BaseCacheCommand implements CacheCommand
{
+ protected static final Object[] EMPTY_OBJECT_ARRAY = new Object[]{};
protected Log log = LogFactory.getLog(getClass());
protected Notifier notifier;
protected CacheData cacheData;
@@ -32,7 +34,6 @@
return notifier;
}
-
public CacheData getCacheData()
{
return cacheData;
@@ -42,4 +43,16 @@
{
return spi;
}
+
+ /**
+ * All implementations must override this method, which will provide parameters in the
correct order for replication.
+ *
+ * @return an object array of parameters in the order expected.
+ */
+ protected abstract Object[] getParameters();
+
+ public MethodCall toMethodCall()
+ {
+ return new MethodCall(getMethodId(), getParameters());
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/CacheCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CacheCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CacheCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,15 +1,20 @@
package org.jboss.cache.commands;
import org.jboss.cache.InvocationContext;
+import org.jboss.cache.marshall.MethodCall;
/**
* @author Mircea.Markus(a)jboss.com
* @since 2.2
- * todo - reduce dependencies from CacheSPI many commands depend on CacheSPI only for
invoceation ctxt. inject ctxt rather than entire CacheSPI
+ * todo - reduce dependencies from CacheSPI many commands depend on CacheSPI only
for invoceation ctxt. inject ctxt rather than entire CacheSPI
*/
public interface CacheCommand extends Cloneable
{
public Object perform(InvocationContext ctx) throws Throwable;
public Object accept(InvocationContext ctx, CacheCommandsVisitor handler) throws
Throwable;
+
+ public MethodCall toMethodCall();
+
+ public int getMethodId();
}
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-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,5 +1,6 @@
package org.jboss.cache.commands;
+import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.RPCManager;
@@ -8,7 +9,12 @@
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.channel.BlockChannelCommand;
import org.jboss.cache.commands.channel.UnblockChannelCommand;
-import org.jboss.cache.commands.remote.*;
+import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
+import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ClusteredGetCommand;
+import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
+import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
@@ -18,6 +24,7 @@
import org.jboss.cache.invocation.CacheData;
import org.jboss.cache.invocation.CacheTransactionHelper;
import org.jboss.cache.invocation.InterceptorChain;
+import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
@@ -64,7 +71,7 @@
this.spi = spi;
this.configuration = configuration;
this.tm = txm;
- this.rpcManager =rpc;
+ this.rpcManager = rpc;
this.transactionHelper = txHelper;
this.buddyManager = buddyManager;
this.interceptorChain = interceptorChain;
@@ -127,7 +134,7 @@
return command;
}
- public RemoveNodeCommand buildRemoveFqnCommand(GlobalTransaction gtx, Fqn fqn, boolean
eviction, boolean skipSendingNodeEvents, boolean createUndoOps)
+ public RemoveNodeCommand buildRemoveNodeCommand(GlobalTransaction gtx, Fqn fqn,
boolean eviction, boolean skipSendingNodeEvents, boolean createUndoOps)
{
RemoveNodeCommand command = new RemoveNodeCommand(gtx, fqn, createUndoOps,
skipSendingNodeEvents, eviction);
command.initialize(cacheData, transactionTable, notifier,
configuration.isNodeLockingOptimistic());
@@ -235,7 +242,7 @@
commandList.add(command);
return buildOptimisticPrepareCommand(gtx, commandList, null, null, false);
}
-
+
public AnnounceBuddyPoolNameCommand buildAnnounceBuddyPoolNameCommand(Address address,
String buddyPoolName)
{
AnnounceBuddyPoolNameCommand command = new AnnounceBuddyPoolNameCommand(address,
buddyPoolName);
@@ -271,4 +278,90 @@
{
return new UnblockChannelCommand();
}
+
+ /**
+ * Builds a cache command based on the ID passed in and an object array of parameters
+ *
+ * @param id id of the command to build
+ * @param parameters parameters attached to the command
+ * @return a newly constructed cache command
+ */
+ public CacheCommand fromStream(int id, Object[] parameters)
+ {
+ // todo: must be a better way to do this!!!
+ switch (id)
+ {
+ case ExistsNodeCommand.METHOD_ID:
+ return buildExistsNodeCommand((Fqn) parameters[0]);
+
+ case GetChildrenNamesCommand.METHOD_ID:
+ return buildGetChildrenNamesCommand((Fqn) parameters[0]);
+
+ case GetDataMapCommand.METHOD_ID:
+ return buildGetDataMapCommand((Fqn) parameters[0]);
+
+ case GetKeysCommand.METHOD_ID:
+ return buildGetKeysCommand((Fqn) parameters[0]);
+
+ case GetKeyValueCommand.METHOD_ID:
+ return buildGetKeyValueCommand((Fqn) parameters[0], parameters[1], (Boolean)
parameters[2]);
+
+ case GetNodeCommand.METHOD_ID:
+ return buildGetNodeCommand((Fqn) parameters[0]);
+
+ case MoveCommand.METHOD_ID:
+ return buildMoveCommand((Fqn) parameters[0], (Fqn) parameters[1]);
+
+ case PutDataMapCommand.METHOD_ID:
+ return buildPutDataMapCommand((GlobalTransaction) parameters[0], (Fqn)
parameters[1], (Map) parameters[2], (Boolean) parameters[3], false);
+
+ case PutDataMapCommand.ERASE_METHOD_ID:
+ return buildPutDataMapCommand((GlobalTransaction) parameters[0], (Fqn)
parameters[1], (Map) parameters[2], (Boolean) parameters[3], true);
+
+ case PutKeyValueCommand.METHOD_ID:
+ return buildPutKeyValueCommand((GlobalTransaction) parameters[0], (Fqn)
parameters[1], parameters[2], parameters[3], (Boolean) parameters[4], false);
+
+ case RemoveDataCommand.METHOD_ID:
+ return buildRemoveDataCommand((GlobalTransaction) parameters[0], (Fqn)
parameters[1], (Boolean) parameters[2], (Boolean) parameters[3], (Boolean)
parameters[4]);
+
+ case RemoveKeyCommand.METHOD_ID:
+ return buildRemoveKeyCommand((GlobalTransaction) parameters[0], (Fqn)
parameters[1], parameters[2], (Boolean) parameters[3]);
+
+ case RemoveNodeCommand.METHOD_ID:
+ return buildRemoveNodeCommand((GlobalTransaction) parameters[0], (Fqn)
parameters[1], (Boolean) parameters[2], (Boolean) parameters[3], (Boolean)
parameters[4]);
+
+ // --- transactional method calls
+
+ case PrepareCommand.METHOD_ID:
+ return buildPrepareCommand((GlobalTransaction) parameters[0],
toCacheCommandList((List<MethodCall>) parameters[1]), (Address) parameters[2],
(Boolean) parameters[3]);
+
+ case OptimisticPrepareCommand.METHOD_ID:
+ return buildOptimisticPrepareCommand((GlobalTransaction) parameters[0],
toCacheCommandList((List<MethodCall>) parameters[1]), (Map) parameters[2], (Address)
parameters[3], (Boolean) parameters[4]);
+
+ case CommitCommand.METHOD_ID:
+ return buildCommitCommand((GlobalTransaction) parameters[0]);
+
+ case RollbackCommand.METHOD_ID:
+ return buildRollbackCommand((GlobalTransaction) parameters[0]);
+
+ // --- replicate methods
+ case ReplicateCommand.MULTIPLE_METHOD_ID:
+ return buildReplicateCommand(toCacheCommandList((List<MethodCall>)
parameters[0]));
+
+ case ReplicateCommand.SINGLE_METHOD_ID:
+ MethodCall call = (MethodCall) parameters[0];
+ return buildReplicateCommand(fromStream(call.getMethodId(),
call.getArgs()));
+
+ default:
+ throw new CacheException("Unknown command id " + id +
"!");
+ }
+ }
+
+ private List<CacheCommand> toCacheCommandList(List<MethodCall> calls)
+ {
+ if (calls == null) return null;
+ List<CacheCommand> ccList = new ArrayList<CacheCommand>(calls.size());
+ for (MethodCall mc : calls) ccList.add(fromStream(mc.getMethodId(),
mc.getArgs()));
+ return ccList;
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/DataVersionCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/DataVersionCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/commands/DataVersionCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -16,6 +16,7 @@
/**
* Has data version set? (i.e. not null)
+ * // todo: should this be an abstract class rather than an interface? isVersioned()
is implemented exactly the same way in all subclasses.
*/
public boolean isVersioned();
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/EvictFqnCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/EvictFqnCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/commands/EvictFqnCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -11,8 +11,11 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class EvictFqnCommand implements DataVersionCommand
+public class EvictFqnCommand extends BaseCacheCommand implements DataVersionCommand
{
+ public static final int METHOD_ID = 8;
+ public static final int VERSIONED_METHOD_ID = 9;
+
/* dependencies*/
protected CacheData cacheData;
@@ -24,6 +27,7 @@
{
this.fqn = fqn;
}
+
public void initialize(CacheData cacheData)
{
this.cacheData = cacheData;
@@ -39,6 +43,11 @@
return handler.handleEvictFqnCommand(ctx, this);
}
+ public int getMethodId()
+ {
+ return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
+ }
+
public Fqn getFqn()
{
return fqn;
@@ -58,4 +67,12 @@
{
return dataVersion != null;
}
+
+ protected Object[] getParameters()
+ {
+ if (isVersioned())
+ return new Object[]{fqn, dataVersion};
+ else
+ return new Object[]{fqn};
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -25,8 +25,9 @@
* pertaining to the Fqn passed in is activated, and has an appropriate ClassLoader.
* todo - this should not be a command as none relally visits it. It was inherited this
way from old CacheImpl
*/
-public class GravitateDataCommand implements CacheCommand
+public class GravitateDataCommand extends BaseCacheCommand implements CacheCommand
{
+ public static final int METHOD_ID = 35;
private static final Log log = LogFactory.getLog(GravitateDataCommand.class);
/* dependencies */
@@ -157,6 +158,11 @@
return handler.handleGravitateDataCommand(ctx, this);
}
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
public Fqn getFqn()
{
return fqn;
@@ -166,4 +172,9 @@
{
return searchSubtrees;
}
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{fqn, searchSubtrees};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/ExistsNodeCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/ExistsNodeCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/ExistsNodeCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,10 +1,11 @@
package org.jboss.cache.commands.cachedata;
+import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.cache.commands.BaseCacheCommand;
+import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.commands.CacheCommandsVisitor;
/**
* Checks whether a given node exists in current in-memory state of the cache.
@@ -15,8 +16,10 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class ExistsNodeCommand implements CacheDataCommand
+public class ExistsNodeCommand extends BaseCacheCommand implements CacheDataCommand
{
+ public static final int METHOD_ID = 16;
+
private CacheData cacheData;
private Fqn fqn;
@@ -28,7 +31,7 @@
public void initialize(CacheData cacheData)
{
- this.cacheData = cacheData;
+ this.cacheData = cacheData;
}
public Object perform(InvocationContext ctx)
@@ -46,4 +49,14 @@
{
return fqn;
}
+
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{fqn};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetChildrenNamesCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetChildrenNamesCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetChildrenNamesCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -3,17 +3,24 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.BaseCacheCommand;
+import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.commands.CacheCommandsVisitor;
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
/**
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class GetChildrenNamesCommand implements CacheDataCommand
+public class GetChildrenNamesCommand extends BaseCacheCommand implements
CacheDataCommand
{
+ public static final int METHOD_ID = 23;
+
private CacheData cacheData;
private Fqn fqn;
@@ -60,4 +67,13 @@
return fqn;
}
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{fqn};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetDataMapCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetDataMapCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetDataMapCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,10 +1,11 @@
package org.jboss.cache.commands.cachedata;
+import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.BaseCacheCommand;
+import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.commands.CacheCommandsVisitor;
/**
* Implements functionality defined by {@link
org.jboss.cache.Cache#getData(org.jboss.cache.Fqn)}
@@ -12,8 +13,10 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class GetDataMapCommand implements CacheDataCommand
+public class GetDataMapCommand extends BaseCacheCommand implements CacheDataCommand
{
+ public static final int METHOD_ID = 24;
+
private CacheData cacheData;
private Fqn fqn;
@@ -45,4 +48,13 @@
return fqn;
}
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{fqn};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeyValueCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeyValueCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeyValueCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -5,6 +5,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.BaseCacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.invocation.CacheData;
import org.jboss.cache.notifications.Notifier;
@@ -15,8 +16,10 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class GetKeyValueCommand implements CacheDataCommand
+public class GetKeyValueCommand extends BaseCacheCommand implements CacheDataCommand
{
+ public static final int METHOD_ID = 26;
+
private static final Log log = LogFactory.getLog(GetKeyValueCommand.class);
/* dependencies*/
@@ -84,4 +87,14 @@
{
this.key = key;
}
+
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{fqn, key, sendNodeEvent};
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeysCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeysCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeysCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -3,8 +3,9 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.BaseCacheCommand;
+import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.commands.CacheCommandsVisitor;
import java.util.HashSet;
import java.util.Set;
@@ -15,8 +16,10 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class GetKeysCommand implements CacheDataCommand
+public class GetKeysCommand extends BaseCacheCommand implements CacheDataCommand
{
+ public static final int METHOD_ID = 25;
+
private CacheData cacheData;
private Fqn fqn;
@@ -52,4 +55,13 @@
return fqn;
}
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{fqn};
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetNodeCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetNodeCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetNodeCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,8 +1,9 @@
package org.jboss.cache.commands.cachedata;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.BaseCacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Fqn;
import org.jboss.cache.invocation.CacheData;
/**
@@ -11,8 +12,10 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class GetNodeCommand implements CacheDataCommand
+public class GetNodeCommand extends BaseCacheCommand implements CacheDataCommand
{
+ public static final int METHOD_ID = 31;
+
private CacheData cacheData;
private Fqn fqn;
@@ -42,4 +45,13 @@
return fqn;
}
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{fqn};
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/cachedata/MoveCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/MoveCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/MoveCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -4,6 +4,7 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.BaseCacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.commands.TxCacheCommand;
import org.jboss.cache.invocation.CacheData;
@@ -16,8 +17,10 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class MoveCommand implements TxCacheCommand, CacheDataCommand
+public class MoveCommand extends BaseCacheCommand implements TxCacheCommand,
CacheDataCommand
{
+ public static final int METHOD_ID = 36;
+
/* dependencies */
private CacheData cacheData;
private Notifier notifier;
@@ -121,4 +124,13 @@
return to;
}
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{from, to};
+ }
}
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-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutDataMapCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -5,15 +5,15 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.invocation.CacheData;
+import org.jboss.cache.commands.BaseCacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
-import org.jboss.cache.commands.TxCacheCommand;
import org.jboss.cache.commands.DataVersionCommand;
import org.jboss.cache.commands.GlobalTransactionCommand;
+import org.jboss.cache.commands.TxCacheCommand;
+import org.jboss.cache.invocation.CacheData;
+import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
-import org.jboss.cache.notifications.Notifier;
+import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
@@ -25,8 +25,11 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class PutDataMapCommand implements TxCacheCommand, CacheDataCommand,
DataVersionCommand, GlobalTransactionCommand
+public class PutDataMapCommand extends BaseCacheCommand implements TxCacheCommand,
CacheDataCommand, DataVersionCommand, GlobalTransactionCommand
{
+ public static final int METHOD_ID = 1;
+ public static final int ERASE_METHOD_ID = 2;
+
private static Log log = LogFactory.getLog(PutDataMapCommand.class);
/* dependencies*/
@@ -42,7 +45,9 @@
private boolean eraseContents;
protected DataVersion dataVersion;
- /** internally used for rollback */
+ /**
+ * internally used for rollback
+ */
private Map oldData;
public PutDataMapCommand(GlobalTransaction globalTransaction, Fqn fqn, Map data,
boolean createUndoOps, boolean eraseContents)
@@ -148,4 +153,14 @@
{
this.data = data;
}
+
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{globalTransaction, fqn, data, createUndoOps};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutKeyValueCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutKeyValueCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutKeyValueCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -5,6 +5,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.BaseCacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.commands.DataVersionCommand;
import org.jboss.cache.commands.GlobalTransactionCommand;
@@ -21,11 +22,14 @@
/**
* Implements functionality defined by {@link
org.jboss.cache.CacheSPI#put(org.jboss.cache.Fqn, Object, Object)}.
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class PutKeyValueCommand implements TxCacheCommand, CacheDataCommand,
DataVersionCommand, GlobalTransactionCommand
+public class PutKeyValueCommand extends BaseCacheCommand implements TxCacheCommand,
CacheDataCommand, DataVersionCommand, GlobalTransactionCommand
{
+ public static final int METHOD_ID = 3;
+
private static final Log log = LogFactory.getLog(PutKeyValueCommand.class);
/* dependencies*/
@@ -168,4 +172,14 @@
{
this.value = value;
}
+
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{globalTransaction, fqn, key, value, createUndoOps};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveDataCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveDataCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveDataCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,24 +1,24 @@
package org.jboss.cache.commands.cachedata;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.commands.TxCacheCommand;
+import org.jboss.cache.commands.BaseCacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.commands.DataVersionCommand;
import org.jboss.cache.commands.GlobalTransactionCommand;
+import org.jboss.cache.commands.TxCacheCommand;
+import org.jboss.cache.invocation.CacheData;
+import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
-import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.util.HashMap;
import java.util.Map;
-import java.util.HashMap;
/**
* Implements functionality defined by {@link org.jboss.cache.Cache#remove(String,
Object)}
@@ -26,8 +26,11 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class RemoveDataCommand implements TxCacheCommand, DataVersionCommand,
GlobalTransactionCommand
+public class RemoveDataCommand extends BaseCacheCommand implements TxCacheCommand,
DataVersionCommand, GlobalTransactionCommand
{
+ public static final int METHOD_ID = 7;
+ public static final int VERSIONED_METHOD_ID = 42;
+
private static final Log log = LogFactory.getLog(RemoveDataCommand.class);
/* dependencies*/
@@ -36,7 +39,7 @@
private Notifier notifier;
/* parameters*/
- private GlobalTransaction globalTransaction;
+ private GlobalTransaction globalTransaction;
private Fqn fqn;
private boolean createUndoops;
private boolean sendNodeEvent;
@@ -109,12 +112,14 @@
if (sendNodeEvent)
{
notifier.notifyNodeVisited(fqn, false, ctx);
- } else
+ }
+ else
{// FIXME Bela did this so GUI view can refresh the view after node is evicted. But
this breaks eviction policy, especially AOP!!!!
if (eviction)
{
notifier.notifyNodeEvicted(fqn, false, ctx);
- } else
+ }
+ else
{
notifier.notifyNodeModified(fqn, false,
NodeModifiedEvent.ModificationType.REMOVE_DATA, data, ctx);
}
@@ -126,7 +131,8 @@
if (eviction)
{
notifier.notifyNodeEvicted(fqn, true, ctx);
- } else
+ }
+ else
{
notifier.notifyNodeModified(fqn, true,
NodeModifiedEvent.ModificationType.REMOVE_DATA, data, ctx);
}
@@ -195,5 +201,16 @@
this.globalTransaction = gtx;
}
+ public int getMethodId()
+ {
+ return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
+ }
+ protected Object[] getParameters()
+ {
+ if (isVersioned())
+ return new Object[]{globalTransaction, fqn, eviction, dataVersion};
+ else
+ return new Object[]{globalTransaction, fqn, eviction};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveKeyCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveKeyCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveKeyCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -5,6 +5,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.BaseCacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.commands.DataVersionCommand;
import org.jboss.cache.commands.GlobalTransactionCommand;
@@ -25,8 +26,11 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class RemoveKeyCommand implements TxCacheCommand, CacheDataCommand,
DataVersionCommand, GlobalTransactionCommand
+public class RemoveKeyCommand extends BaseCacheCommand implements TxCacheCommand,
CacheDataCommand, DataVersionCommand, GlobalTransactionCommand
{
+ public static final int METHOD_ID = 6;
+ public static final int VERSIONED_METHOD_ID = 41;
+
private static final Log log = LogFactory.getLog(RemoveKeyCommand.class);
/* dependencies */
@@ -139,4 +143,17 @@
{
this.key = key;
}
+
+ public int getMethodId()
+ {
+ return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ if (isVersioned())
+ return new Object[]{globalTransaction, fqn, key, createUndoOps, dataVersion};
+ else
+ return new Object[]{globalTransaction, fqn, key, createUndoOps};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveNodeCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveNodeCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveNodeCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -5,10 +5,11 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.BaseCacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
-import org.jboss.cache.commands.TxCacheCommand;
import org.jboss.cache.commands.DataVersionCommand;
import org.jboss.cache.commands.GlobalTransactionCommand;
+import org.jboss.cache.commands.TxCacheCommand;
import org.jboss.cache.invocation.CacheData;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.optimistic.DataVersion;
@@ -21,8 +22,11 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class RemoveNodeCommand implements TxCacheCommand, CacheDataCommand,
DataVersionCommand, GlobalTransactionCommand
+public class RemoveNodeCommand extends BaseCacheCommand implements TxCacheCommand,
CacheDataCommand, DataVersionCommand, GlobalTransactionCommand
{
+ public static final int METHOD_ID = 5;
+ public static final int VERSIONED_METHOD_ID = 40;
+
private static final Log log = LogFactory.getLog(RemoveNodeCommand.class);
/*dependencies*/
@@ -84,7 +88,8 @@
{
// if there is no parent node and the fqn is root, found == true otherwise found
== false.
found = targetNode.isValid() && parentNode == null ? fqn.isRoot() :
parentNode.removeChildDirect(targetNode.getFqn().getLastElement());
- } else
+ }
+ else
{
found = targetNode.isValid() && !targetNode.isDeleted();
targetNode.markAsDeleted(true, true);
@@ -114,7 +119,8 @@
if (eviction)
{
notifier.notifyNodeEvicted(fqn, false, ctx);
- } else
+ }
+ else
{
notifier.notifyNodeRemoved(fqn, false, null, ctx);
}
@@ -128,7 +134,8 @@
if (eviction)
{
notifier.notifyNodeEvicted(fqn, true, ctx);
- } else
+ }
+ else
{
notifier.notifyNodeRemoved(fqn, true, n.getDataDirect(), ctx);
}
@@ -208,4 +215,17 @@
{
this.globalTransaction = gtx;
}
+
+ public int getMethodId()
+ {
+ return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ if (isVersioned())
+ return new Object[]{globalTransaction, fqn, createUndoOps,
skipSendingNodeEvents, dataVersion};
+ else
+ return new Object[]{globalTransaction, fqn, createUndoOps,
skipSendingNodeEvents};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/channel/BlockChannelCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/channel/BlockChannelCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/channel/BlockChannelCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,8 +1,9 @@
package org.jboss.cache.commands.channel;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.BaseCacheCommand;
+import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.InvocationContext;
/**
* todo - this is only used by notification interceptor, guess it can be removed and
notifications
@@ -11,8 +12,10 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class BlockChannelCommand implements CacheCommand
+public class BlockChannelCommand extends BaseCacheCommand implements CacheCommand
{
+ public static final int METHOD_ID = 43;
+
public Object perform(InvocationContext ctx) throws Throwable
{
return null;
@@ -22,4 +25,14 @@
{
return handler.handleBlockChannelCommand(ctx, this);
}
+
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return EMPTY_OBJECT_ARRAY;
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/channel/UnblockChannelCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/channel/UnblockChannelCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/channel/UnblockChannelCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,18 +1,21 @@
package org.jboss.cache.commands.channel;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.BaseCacheCommand;
+import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.InvocationContext;
/**
* todo - this is only used by notification interceptor, guess it can be removed and
notifications
* to be performed individually
- *
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class UnblockChannelCommand implements CacheCommand
+public class UnblockChannelCommand extends BaseCacheCommand implements CacheCommand
{
+ public static final int METHOD_ID = 43;
+
public Object perform(InvocationContext ctx) throws Throwable
{
//noop
@@ -23,4 +26,14 @@
{
return handler.handleUnblockChannelCommand(ctx, this);
}
+
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return EMPTY_OBJECT_ARRAY;
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,19 +1,21 @@
package org.jboss.cache.commands.remote;
-import org.jboss.cache.commands.CacheCommandsVisitor;
-import org.jboss.cache.commands.CacheCommand;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.commands.BaseCacheCommand;
+import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jgroups.Address;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class AnnounceBuddyPoolNameCommand implements CacheCommand
+public class AnnounceBuddyPoolNameCommand extends BaseCacheCommand implements
CacheCommand
{
+ public static final int METHOD_ID = 28;
private static final Log log = LogFactory.getLog(AnnounceBuddyPoolNameCommand.class);
/* dependencies*/
@@ -49,6 +51,11 @@
return handler.handleAnnounceBuddyPoolName(ctx, this);
}
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
public Address getAddress()
{
return address;
@@ -58,4 +65,9 @@
{
return buddyPoolName;
}
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{address, buddyPoolName};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -6,6 +6,7 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.commands.BaseCacheCommand;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
@@ -15,8 +16,9 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class AssignToBuddyGroupCommand implements CacheCommand
+public class AssignToBuddyGroupCommand extends BaseCacheCommand implements CacheCommand
{
+ public static final int METHOD_ID = 29;
private static final Log log = LogFactory.getLog(AssignToBuddyGroupCommand.class);
private BuddyManager buddyManager;
@@ -50,6 +52,11 @@
return handler.handleAssignToBuddyGroupCommand(ctx, this);
}
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
public BuddyGroup getGroup()
{
return group;
@@ -59,4 +66,9 @@
{
return state;
}
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{group, state};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,15 +1,16 @@
package org.jboss.cache.commands.remote;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.invocation.CacheData;
+import org.jboss.cache.commands.BaseCacheCommand;
+import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
-import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.cachedata.CacheDataCommand;
+import org.jboss.cache.commands.cachedata.ExistsNodeCommand;
+import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
import org.jboss.cache.commands.cachedata.GetDataMapCommand;
-import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
-import org.jboss.cache.commands.cachedata.ExistsNodeCommand;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.invocation.CacheData;
import java.util.ArrayList;
import java.util.Collections;
@@ -19,8 +20,9 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class ClusteredGetCommand implements CacheCommand
+public class ClusteredGetCommand extends BaseCacheCommand implements CacheCommand
{
+ public static final int METHOD_ID = 22;
private static final Log log = LogFactory.getLog(ClusteredGetCommand.class);
private CacheDataCommand cacheDataComand;
@@ -36,9 +38,9 @@
/**
* A 'clustered get' call, called from a remote ClusteredCacheLoader.
*
+ * @param ctx
* @return a List containing 2 elements: (true or false) and a value (Object). If
buddy replication
* is used one further element is added - an Fqn of the backup subtree in
which this node may be found.
- * @param ctx
*/
public Object perform(InvocationContext ctx) throws Throwable
{
@@ -77,9 +79,14 @@
public Object accept(InvocationContext ctx, CacheCommandsVisitor handler) throws
Throwable
{
- return handler.handleClusteredGetCommand(ctx, this);
+ return handler.handleClusteredGetCommand(ctx, this);
}
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
/**
* Returns true if the call results returned a valid result.
*/
@@ -113,4 +120,9 @@
{
return cacheDataComand;
}
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{cacheDataComand.toMethodCall(), searchBackupSubtrees}; //To
change body of implemented methods use File | Settings | File Templates.
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -6,7 +6,12 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.commands.*;
+import org.jboss.cache.commands.BaseCacheCommand;
+import org.jboss.cache.commands.CacheCommandsVisitor;
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.EvictFqnCommand;
+import org.jboss.cache.commands.GlobalTransactionCommand;
+import org.jboss.cache.commands.TxCacheCommand;
import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
import org.jboss.cache.invocation.CacheData;
import org.jboss.cache.invocation.CacheTransactionHelper;
@@ -23,9 +28,9 @@
* todo this calls other commands through the invocation chain, check wheter
direct call is not okay
* todo it is not natural for this command to extend TxCC, revisit
*/
-public class DataGravitationCleanupCommand implements TxCacheCommand,
GlobalTransactionCommand
+public class DataGravitationCleanupCommand extends BaseCacheCommand implements
TxCacheCommand, GlobalTransactionCommand
{
-
+ public static final int METHOD_ID = 34;
private static final Log log =
LogFactory.getLog(DataGravitationCleanupCommand.class);
/* dependencies */
@@ -93,7 +98,8 @@
}
}
}
- } else
+ }
+ else
{
if (log.isTraceEnabled())
log.trace("DataGravitationCleanup: Evicting primary (" + primary +
") and backup (" + backup + ")");
@@ -109,7 +115,7 @@
private boolean executeRemove(GlobalTransaction gtx, Fqn toRemove) throws Throwable
{
Object result;
- RemoveNodeCommand removeBackupCommand = commandsFactory.buildRemoveFqnCommand(gtx,
toRemove, true, true, false);
+ RemoveNodeCommand removeBackupCommand = commandsFactory.buildRemoveNodeCommand(gtx,
toRemove, true, true, false);
result = invoker.invoke(removeBackupCommand);
return result != null && (Boolean) result;
}
@@ -134,6 +140,11 @@
return handler.handleDataGravitationCleanupCommand(ctx, this);
}
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
public void rollback()
{
//nothing
@@ -158,4 +169,9 @@
{
this.globalTransaction = gtx;
}
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{primary, backup}; //To change body of implemented methods use
File | Settings | File Templates.
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -4,6 +4,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.commands.BaseCacheCommand;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
@@ -11,12 +12,13 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class RemoveFromBuddyGroupCommand implements CacheCommand
+public class RemoveFromBuddyGroupCommand extends BaseCacheCommand implements
CacheCommand
{
+ public static final int METHOD_ID = 30;
private static final Log log = LogFactory.getLog(RemoveFromBuddyGroupCommand.class);
private BuddyManager buddyManager;
-
+
private String groupName;
public RemoveFromBuddyGroupCommand(String groupName)
@@ -43,8 +45,18 @@
return handler.handleRemoveFromBuddyGroupCommand(ctx, this);
}
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
public String getGroupName()
{
return groupName;
}
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{groupName};
+ }
}
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-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,14 +1,16 @@
package org.jboss.cache.commands.remote;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.BaseCacheCommand;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.commands.GravitateDataCommand;
import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.invocation.InterceptorChain;
+import org.jboss.cache.marshall.MethodCall;
+import java.util.ArrayList;
import java.util.List;
-import java.util.ArrayList;
/**
* Command that implements cluster replication logic.
@@ -16,11 +18,14 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class ReplicateCommand implements CacheCommand
+public class ReplicateCommand extends BaseCacheCommand implements CacheCommand
{
+ public static final int SINGLE_METHOD_ID = 13;
+ public static final int MULTIPLE_METHOD_ID = 14;
+
private InterceptorChain invoker;
private List<CacheCommand> modifications;
-
+
/**
* optimiscation - rather than constructing a new list each for scenarios where a
single modification needs
* to be replicated rather use this insance.
@@ -68,7 +73,8 @@
if (returnValueForRemoteCall(cacheCommand))
{
result = retVal;
- } else
+ }
+ else
{
result = null;
}
@@ -78,7 +84,8 @@
if (isForExternalMethod(cacheCommand))
{
throw ex;
- } else result = null;
+ }
+ else result = null;
}
return result;
}
@@ -100,8 +107,28 @@
return handler.handleReplicateCommand(ctx, this);
}
+ public int getMethodId()
+ {
+ return singleModification == null ? MULTIPLE_METHOD_ID : SINGLE_METHOD_ID;
+ }
+
public List<CacheCommand> getModifications()
{
return modifications;
}
+
+ protected Object[] getParameters()
+ {
+ if (singleModification == null)
+ return new Object[]{toMethodCallList()};
+ else
+ return new Object[]{singleModification.toMethodCall()};
+ }
+
+ private List<MethodCall> toMethodCallList()
+ {
+ List<MethodCall> l = new ArrayList<MethodCall>(modifications.size());
+ for (CacheCommand cc : modifications) l.add(cc.toMethodCall());
+ return l;
+ }
}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,9 +1,9 @@
package org.jboss.cache.commands.tx;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.BaseCacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.commands.GlobalTransactionCommand;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
@@ -12,6 +12,8 @@
*/
public class CommitCommand extends BaseCacheCommand implements GlobalTransactionCommand
{
+ public static final int METHOD_ID = 11;
+
private GlobalTransaction globalTransaction;
public CommitCommand(GlobalTransaction globalTransaction)
@@ -39,4 +41,14 @@
{
this.globalTransaction = gtx;
}
+
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{globalTransaction};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,9 +1,9 @@
package org.jboss.cache.commands.tx;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.commands.CacheCommandsVisitor;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.InvocationContext;
import org.jgroups.Address;
import java.util.List;
@@ -15,6 +15,7 @@
*/
public class OptimisticPrepareCommand extends PrepareCommand
{
+ public static final int METHOD_ID = 18;
private Map data;
public OptimisticPrepareCommand(GlobalTransaction gtx, List<? extends
CacheCommand> modifications, Map data, Address address, boolean onePhaseCommit)
@@ -37,4 +38,16 @@
{
return data;
}
+
+ @Override
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ @Override
+ protected Object[] getParameters()
+ {
+ return new Object[]{globalTransaction, modifications, data, localAddress,
onePhaseCommit};
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,9 +1,10 @@
package org.jboss.cache.commands.tx;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.BaseCacheCommand;
+import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
-import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.GlobalTransactionCommand;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jgroups.Address;
@@ -15,8 +16,10 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class PrepareCommand implements CacheCommand, GlobalTransactionCommand
+public class PrepareCommand extends BaseCacheCommand implements CacheCommand,
GlobalTransactionCommand
{
+ public static final int METHOD_ID = 10;
+
protected GlobalTransaction globalTransaction;
protected List<? extends CacheCommand> modifications;
protected Address localAddress;
@@ -73,4 +76,14 @@
{
return modifications != null ? modifications.size() : 0;
}
+
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{globalTransaction, modifications, localAddress,
onePhaseCommit};
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java 2008-04-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,17 +1,20 @@
package org.jboss.cache.commands.tx;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.BaseCacheCommand;
+import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
-import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.GlobalTransactionCommand;
-import org.jboss.cache.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class RollbackCommand implements CacheCommand, GlobalTransactionCommand
+public class RollbackCommand extends BaseCacheCommand implements CacheCommand,
GlobalTransactionCommand
{
+ public static final int METHOD_ID = 12;
+
private GlobalTransaction globalTransaction;
public RollbackCommand(GlobalTransaction globalTransaction)
@@ -38,4 +41,14 @@
{
this.globalTransaction = gtx;
}
+
+ public int getMethodId()
+ {
+ return METHOD_ID;
+ }
+
+ protected Object[] getParameters()
+ {
+ return new Object[]{globalTransaction};
+ }
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -6,6 +6,7 @@
import org.jboss.cache.commands.channel.UnblockChannelCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.notifications.Notifier;
/**
@@ -19,7 +20,8 @@
private Notifier notifier;
private CacheSPI cacheSPI;
- public void setDependencies(Notifier notifier, CacheSPI cacheSPI)
+ @Inject
+ public void injectDependencies(Notifier notifier, CacheSPI cacheSPI)
{
this.notifier = notifier;
this.cacheSPI = cacheSPI;
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -9,8 +9,16 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.*;
-import org.jboss.cache.commands.cachedata.*;
+import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.DataVersionCommand;
+import org.jboss.cache.commands.EvictFqnCommand;
+import org.jboss.cache.commands.GravitateDataCommand;
+import org.jboss.cache.commands.cachedata.PutDataMapCommand;
+import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
+import org.jboss.cache.commands.cachedata.RemoveDataCommand;
+import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
+import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
@@ -27,7 +35,6 @@
import org.jboss.cache.transaction.OptimisticTransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
-import org.apache.commons.logging.LogFactory;
import java.util.ArrayList;
import java.util.List;
@@ -194,7 +201,7 @@
//todo make the interceptor a field
DataVersionPopulator populator = new
DataVersionPopulator(getTransactionWorkspace(gtx));
List<CacheCommand> clonedModifications = new
ArrayList<CacheCommand>(command.getModifications().size());
- for (CacheCommand command1 : command.getModifications())
+ for (CacheCommand command1 : command.getModifications())
{
CacheCommand clone = (CacheCommand) command1.accept(null, populator);
clonedModifications.add(clone);
@@ -208,7 +215,8 @@
log.debug("(" + rpcManager.getLocalAddress() + "):
broadcasting prepare for " + gtx + " (" + command.getModificationsCount() +
" modifications");
}
replicateCall(ctx, toBroadcast, remoteCallSync, ctx.getOptionOverrides());
- } else
+ }
+ else
{
//no members, ignoring
if (log.isDebugEnabled())
@@ -315,7 +323,7 @@
public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand
command) throws Throwable
{
- RemoveNodeCommand clone =
commandsFactory.buildRemoveFqnCommand(command.getGlobalTransaction(), command.getFqn(),
command.isEviction(),
+ RemoveNodeCommand clone =
commandsFactory.buildRemoveNodeCommand(command.getGlobalTransaction(), command.getFqn(),
command.isEviction(),
command.isSkipSendingNodeEvents(), command.isCreateUndoOps());
return setDataVersion(clone, command.getFqn());
}
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -71,12 +71,13 @@
// this.cacheData = cacheData;
// this.commandsFactory = commandsFactory;
// this.transactionHelper = transactionHelper;
-// }
+
+ // }
@Inject
public void initialize(StateTransferManager stateTransferManager, CacheLoaderManager
cacheLoaderManager, Notifier notifier,
- TransactionManager transactionManager, BuddyManager
buddyManager, TransactionTable transactionTable,
- RPCManager rpcManager, RegionManager regionManager,
Marshaller marshaller,
- CacheTransactionHelper transactionHelper,
CommandsFactory commandsFactory, CacheData cacheData)
+ TransactionManager transactionManager, BuddyManager
buddyManager, TransactionTable transactionTable,
+ RPCManager rpcManager, RegionManager regionManager, Marshaller
marshaller,
+ CacheTransactionHelper transactionHelper, CommandsFactory
commandsFactory, CacheData cacheData)
{
this.stateTransferManager = stateTransferManager;
this.cacheLoaderManager = cacheLoaderManager;
@@ -398,7 +399,7 @@
else
{
GlobalTransaction tx = transactionHelper.getCurrentTransaction();
- RemoveNodeCommand command = commandsFactory.buildRemoveFqnCommand(tx, fqn, true,
true, false);
+ RemoveNodeCommand command = commandsFactory.buildRemoveNodeCommand(tx, fqn,
true, true, false);
Object retval = invoke(command);
return retval != null && (Boolean) retval;
}
@@ -574,14 +575,16 @@
{
assertIsConstructed();
BlockChannelCommand command = commandsFactory.buildBlockChannelCommand();
- invoke(command);
+ // need to skip status check here because this typically happens before the cache
is in it's STARTED state
+ invoke(command, true);
}
public void unblock()
{
assertIsConstructed();
UnblockChannelCommand command = commandsFactory.buildUnblockChannelCommand();
- invoke(command);
+ // need to skip status check here because this typically happens before the cache
is in it's STARTED state
+ invoke(command, true);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheLifecycleManager.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/CacheLifecycleManager.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/CacheLifecycleManager.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -2,7 +2,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.NodeFactory;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.RPCManager;
+import org.jboss.cache.RegionManager;
+import org.jboss.cache.Version;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
@@ -26,7 +32,7 @@
private static Log log = LogFactory.getLog(CacheLifecycleManager.class);
private CacheStatus cacheStatus;
-
+
/* dependencies*/
private Configuration configuration;
private Notifier notifier;
@@ -39,7 +45,7 @@
@Inject
- public void initialize(Configuration configuration, Notifier notifier, RegionManager
regionManager, NodeFactory nodeFactory,
+ public void initialize(Configuration configuration, Notifier notifier, RegionManager
regionManager, NodeFactory nodeFactory,
CacheData cacheData, BuddyManager buddyManager, RPCManager
rpcManager,
ComponentRegistry componentRegistry)
{
@@ -140,7 +146,8 @@
log.warn("Needed to call stop() before destroying but stop() "
+
"threw exception. Proceeding to destroy", e);
}
- } else
+ }
+ else
return;
}
@@ -196,6 +203,7 @@
// this will recreate any missing components based on the current config
//todo [mmarkus] updateDependencies should be moved in this class. Component
registry's is not to care
// todo about particular instances that are manipulated there ; it should be keept
generic
+ // todo [MANIK] NOT true. The ComponentRegistry is a state machine and is
responsible for maintaining states and dependencies.
componentRegistry.updateDependencies();
componentRegistry.wireDependencies(cacheData.getRoot());
@@ -275,7 +283,8 @@
};
Runtime.getRuntime().addShutdownHook(shutdownHook);
- } else
+ }
+ else
{
if (log.isTraceEnabled())
log.trace("Not registering a shutdown hook. Configured behavior =
" + configuration.getShutdownHookBehavior());
@@ -407,7 +416,8 @@
category.append(rpcManager.getLocalAddress().toString().replace('.',
'_'));
}
}
- } else
+ }
+ else
{
// we're in LOCAL mode
category.append("_LOCAL");
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java 2008-04-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,5 +1,7 @@
package org.jboss.cache.invocation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.factories.annotations.Inject;
@@ -28,6 +30,8 @@
*/
private InvocationContextContainer invocationContextContainer;
+ private Log log = LogFactory.getLog(InterceptorChain.class);
+
/**
* Constructs an interceptor chain having the supplied interceptor as first.
*/
@@ -201,6 +205,8 @@
ChainedInterceptor it = firstInChain;
while (it.hasNext()) it = it.getNext();
it.setNext(ci);
+ // make sure we nullify the "next" pointer in the last interceptor.
+ ci.setNext(null);
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-04-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -11,6 +11,8 @@
import static org.jboss.cache.Region.Status;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.util.MapCopy;
@@ -67,8 +69,14 @@
useRefs = true;
}
- protected CommandMarshaller commandMarshaller;
+ protected CommandsFactory commandsFactory;
+ @Inject
+ public void injectCommandsFactory(CommandsFactory commandsFactory)
+ {
+ this.commandsFactory = commandsFactory;
+ }
+
// -------- AbstractMarshaller interface
public void objectToObjectStream(Object o, ObjectOutputStream out) throws Exception
@@ -281,10 +289,18 @@
out.writeByte(MAGICNUMBER_REF);
writeReference(out, refMap.get(o));
}
- else if (o instanceof MethodCall)
+ else if (o instanceof MethodCall || o instanceof CacheCommand)
{
// first see if this is a 'known' method call.
- MethodCall call = (MethodCall) o;
+ MethodCall call = null;
+ if (o instanceof CacheCommand)
+ {
+ call = ((CacheCommand) o).toMethodCall();
+ }
+ else
+ {
+ call = (MethodCall) o;
+ }
if (call.getMethodId() > -1)
{
@@ -660,7 +676,8 @@
args[i] = unmarshallObject(in, refMap);
}
}
- return commandMarshaller.unmarshall(methodId, args);
+
+ return commandsFactory.fromStream(methodId, args);
}
private GlobalTransaction unmarshallGlobalTransaction(ObjectInputStream in,
UnmarshalledReferences refMap) throws Exception
Deleted: core/trunk/src/main/java/org/jboss/cache/marshall/CommandMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CommandMarshaller.java 2008-04-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CommandMarshaller.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -1,20 +0,0 @@
-package org.jboss.cache.marshall;
-
-import org.jboss.cache.commands.CacheCommand;
-
-/**
- * @author Mircea.Markus(a)jboss.com
- * @since 2.2
- */
-public class CommandMarshaller
-{
- public CacheCommand unmarshall(int commandId, Object[] args)
- {
- return null;
- }
-
- public byte[] marshall(CacheCommand command)
- {
- return null;
- }
-}
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java 2008-04-11 11:31:00
UTC (rev 5531)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java 2008-04-11 17:18:06
UTC (rev 5532)
@@ -68,6 +68,20 @@
this.methodIdInteger = methodIdInteger;
}
+ /**
+ * Introduced to allow construction by a {@link org.jboss.cache.commands.CacheCommand}
implementation.
+ *
+ * @param methodIdInteger id of method
+ * @param arguments arguments
+ * @since 2.2.0
+ */
+ public MethodCall(int methodIdInteger, Object... arguments)
+ {
+ super();
+ setArgs(arguments);
+ this.methodIdInteger = methodIdInteger;
+ }
+
public void setMethodId(int id)
{
methodIdInteger = id;
Modified:
core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java 2008-04-11
11:31:00 UTC (rev 5531)
+++
core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -427,7 +427,7 @@
assertEquals(fqn, event.getFqn());
assertNull(region.takeLastEventNode());
- RemoveNodeCommand removeNodeCommand = commandsFactory.buildRemoveFqnCommand(null,
fqn, false, false, false);
+ RemoveNodeCommand removeNodeCommand = commandsFactory.buildRemoveNodeCommand(null,
fqn, false, false, false);
invoker.invoke(removeNodeCommand);
assertNull(cache.peek(fqn, false, false));
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2008-04-11
11:31:00 UTC (rev 5531)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2008-04-11
17:18:06 UTC (rev 5532)
@@ -6,7 +6,12 @@
*/
package org.jboss.cache.replicated;
-import org.jboss.cache.*;
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -40,16 +45,7 @@
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- System.out.println("*** In tearDown()");
- if (caches != null)
- {
- for (Cache c : caches)
- {
- c.stop();
- }
- caches = null;
- }
- System.out.println("*** Finished tearDown()");
+ if (caches != null) TestingUtil.killCaches(caches);
}
@SuppressWarnings("unchecked")