JBoss Cache SVN: r5543 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-12 19:00:29 -0400 (Sat, 12 Apr 2008)
New Revision: 5543
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
Log:
Clearer variable naming
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-04-12 23:00:15 UTC (rev 5542)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-04-12 23:00:29 UTC (rev 5543)
@@ -2,7 +2,12 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.*;
+import org.jboss.cache.commands.cachedata.MoveCommand;
+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.PrepareCommand;
@@ -71,7 +76,8 @@
Object returnValue = invokeNextInterceptor(ctx, command);
transactionTable.get(command.getGlobalTransaction()).setForceAsyncReplication(true);
return returnValue;
- } else
+ }
+ else
{
return handleCrudMethod(ctx, command, command.isPutForExternalRead());
}
@@ -111,7 +117,7 @@
* If we are within one transaction we won't do any replication as replication would only be performed at commit time.
* If the operation didn't originate locally we won't do any replication either.
*/
- private Object handleCrudMethod(InvocationContext ctx, CacheCommand command, boolean async)
+ private Object handleCrudMethod(InvocationContext ctx, CacheCommand command, boolean forceAsync)
throws Throwable
{
if (skipReplication(ctx)) return invokeNextInterceptor(ctx, command);
@@ -125,11 +131,12 @@
config.getCacheMode() + ", exclude_self=" + true + ", timeout=" +
config.getSyncReplTimeout());
}
- if (!isSynchronous(ctx.getOptionOverrides()) || async)
+ if (!isSynchronous(ctx.getOptionOverrides()) || forceAsync)
{
// 2. Replicate change to all *other* members (exclude self !)
replicateCall(ctx, command, false, ctx.getOptionOverrides());
- } else
+ }
+ else
{
// REVISIT Needs to exclude itself and apply the local change manually.
// This is needed such that transient field is modified properly in-VM.
16 years, 9 months
JBoss Cache SVN: r5542 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-12 19:00:15 -0400 (Sat, 12 Apr 2008)
New Revision: 5542
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
Log:
Added more logging
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-04-12 22:59:56 UTC (rev 5541)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-04-12 23:00:15 UTC (rev 5542)
@@ -8,15 +8,19 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
-import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.*;
+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;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.config.Option;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.invocation.CacheTransactionHelper;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TxUtil;
@@ -103,7 +107,7 @@
Transaction suspendedTransaction = null;
boolean resumeSuspended = false;
- if (trace) log.trace("Invoked with InvocationContext [" + ctx + "]");
+ if (trace) log.trace("Invoked with command " + command + " and InvocationContext [" + ctx + "]");
try
{
16 years, 9 months
JBoss Cache SVN: r5541 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-12 18:59:56 -0400 (Sat, 12 Apr 2008)
New Revision: 5541
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
Log:
need to RELEASE locks as well for non-tx calls!!
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-12 22:59:30 UTC (rev 5540)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-12 22:59:56 UTC (rev 5541)
@@ -104,7 +104,26 @@
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(), NodeLock.LockType.WRITE, true, false, false, true, null, false);
}
- return invokeNextInterceptor(ctx, command);
+
+ Object retVal = invokeNextInterceptor(ctx, command);
+
+ // we NEED to unlock stuff!!! - Manik
+
+ if (ctx.getGlobalTransaction() == null && ctx.getTransaction() == null)
+ {
+ Thread current = Thread.currentThread();
+ // we are not transactional.
+ try
+ {
+ for (NodeLock nl : ctx.getInvocationLocksAcquired()) nl.release(current);
+ }
+ finally
+ {
+ ctx.clearInvocationLocksAcquired();
+ }
+ }
+
+ return retVal;
}
protected boolean skipMethodCall(InvocationContext ctx)
16 years, 9 months
JBoss Cache SVN: r5540 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-12 18:59:30 -0400 (Sat, 12 Apr 2008)
New Revision: 5540
Modified:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
Log:
Fixed typo
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-04-12 15:34:16 UTC (rev 5539)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-04-12 22:59:30 UTC (rev 5540)
@@ -6,14 +6,14 @@
*/
package org.jboss.cache;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.config.Option;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.transaction.TxUtil;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
import javax.transaction.Transaction;
import java.util.ArrayList;
@@ -184,9 +184,9 @@
}
/**
- for non-tx calls, release any locks acquired. These used to be in a separate Map<Thread, List<NodeLock>> called a lockTable,
- but that has been dropped in facour of storing the invocation-specific locks in the invocation context. Cleaner to have it all
- in one place, plus much more performant.
+ * for non-tx calls, release any locks acquired. These used to be in a separate Map<Thread, List<NodeLock>> called a lockTable,
+ * but that has been dropped in facour of storing the invocation-specific locks in the invocation context. Cleaner to have it all
+ * in one place, plus much more performant.
*/
public void clearInvocationLocksAcquired()
{
@@ -386,9 +386,8 @@
* If the acq timeout if overwritten for current call, then return that one.
* If not overwritten return default value.
*/
- public long getContextLockAcquisitionTimeout(long defaultFalue)
+ public long getContextLockAcquisitionTimeout(long timeout)
{
- long timeout = defaultFalue;
if (getOptionOverrides() != null
&& getOptionOverrides().getLockAcquisitionTimeout() >= 0)
{
16 years, 9 months
JBoss Cache SVN: r5539 - in core/trunk/src/main/java/org/jboss/cache: invocation and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-12 11:34:16 -0400 (Sat, 12 Apr 2008)
New Revision: 5539
Added:
core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
Modified:
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java
Log:
Added a CommandAwareRpcDispatcher
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-12 15:24:21 UTC (rev 5538)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-12 15:34:16 UTC (rev 5539)
@@ -17,6 +17,7 @@
import org.jboss.cache.lock.LockUtil;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.lock.TimeoutException;
+import org.jboss.cache.marshall.CommandAwareRpcDispatcher;
import org.jboss.cache.marshall.InactiveRegionAwareRpcDispatcher;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.marshall.MethodCallWrapper;
@@ -269,7 +270,15 @@
// 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(), spi);
+ // but only if we are using region based marshalling?!??
+ if (configuration.isUseRegionBasedMarshalling())
+ {
+ disp = new InactiveRegionAwareRpcDispatcher(channel, messageListener, new MembershipListenerAdaptor(), spi);
+ }
+ else
+ {
+ disp = new CommandAwareRpcDispatcher(channel, messageListener, new MembershipListenerAdaptor(), spi);
+ }
disp.setRequestMarshaller(marshaller);
disp.setResponseMarshaller(marshaller);
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-04-12 15:24:21 UTC (rev 5538)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-04-12 15:34:16 UTC (rev 5539)
@@ -25,7 +25,7 @@
public abstract class AbstractInvocationDelegate
{
protected Log log = LogFactory.getLog(getClass());
-
+
protected Configuration configuration;
protected InvocationContextContainer invocationContextContainer;
protected CacheLifecycleManager lifecycleManager;
@@ -53,7 +53,7 @@
* @return an Object, the generic return type for the interceptors.
* @throws Throwable in the event of problems
*/
- protected Object invoke(CacheCommand command) throws CacheException
+ public Object invoke(CacheCommand command) throws CacheException
{
assertIsConstructed();
InvocationContext ctx = invocationContextContainer.get();
Added: core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-04-12 15:34:16 UTC (rev 5539)
@@ -0,0 +1,66 @@
+package org.jboss.cache.marshall;
+
+import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.invocation.CacheInvocationDelegate;
+import org.jgroups.Channel;
+import org.jgroups.MembershipListener;
+import org.jgroups.Message;
+import org.jgroups.MessageListener;
+import org.jgroups.blocks.RpcDispatcher;
+
+/**
+ * A JGroups RPC dispatcher that knows how to deal with {@link org.jboss.cache.commands.CacheCommand}s.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.2.0
+ */
+public class CommandAwareRpcDispatcher extends RpcDispatcher
+{
+ protected CacheInvocationDelegate cid;
+ protected boolean trace;
+
+ public CommandAwareRpcDispatcher(Channel channel, MessageListener l, MembershipListener l2, Object server_obj)
+ {
+ super(channel, l, l2, server_obj);
+ cid = (CacheInvocationDelegate) server_obj;
+ trace = log.isTraceEnabled();
+ }
+
+ /**
+ * Message contains a Command. Execute it against *this* object and return result.
+ */
+ @Override
+ public Object handle(Message req)
+ {
+ if (server_obj == null)
+ {
+ if (log.isErrorEnabled()) log.error("no method handler is registered. Discarding request.");
+ return null;
+ }
+
+ if (req == null || req.getLength() == 0)
+ {
+ if (log.isErrorEnabled()) log.error("message or message buffer is null");
+ return null;
+ }
+
+ try
+ {
+ CacheCommand cmd = (CacheCommand) req_marshaller.objectFromByteBuffer(req.getBuffer());
+
+ if (trace) log.trace("[sender=" + req.getSrc() + "], command: " + cmd);
+
+ return cid.invoke(cmd);
+ }
+ catch (Throwable x)
+ {
+ return x;
+ }
+ }
+
+ @Override
+ public String toString()
+ {
+ return getClass().getSimpleName() + "[Outgoing marshaller: " + req_marshaller + "; incoming marshaller: " + rsp_marshaller + "]";
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java 2008-04-12 15:24:21 UTC (rev 5538)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/InactiveRegionAwareRpcDispatcher.java 2008-04-12 15:34:16 UTC (rev 5539)
@@ -12,7 +12,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-public class InactiveRegionAwareRpcDispatcher extends RpcDispatcher
+public class InactiveRegionAwareRpcDispatcher extends CommandAwareRpcDispatcher
{
org.jboss.cache.marshall.Marshaller requestMarshaller;
16 years, 9 months
JBoss Cache SVN: r5538 - core/trunk/src/main/java/org/jboss/cache/marshall.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-12 11:24:21 -0400 (Sat, 12 Apr 2008)
New Revision: 5538
Modified:
core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallWrapper.java
Log:
Added toString
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallWrapper.java 2008-04-12 15:16:19 UTC (rev 5537)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallWrapper.java 2008-04-12 15:24:21 UTC (rev 5538)
@@ -22,4 +22,12 @@
{
return command;
}
+
+
+ public String toString()
+ {
+ return "MethodCallWrapper[" +
+ "command wrapped=" + command +
+ ']';
+ }
}
16 years, 9 months
JBoss Cache SVN: r5537 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 9 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-12 11:16:19 -0400 (Sat, 12 Apr 2008)
New Revision: 5537
Added:
core/trunk/src/main/java/org/jboss/cache/commands/MarshallableCommand.java
core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallWrapper.java
Modified:
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.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/EvictFqnCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/CacheDataCommand.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/BaseRpcInterceptor.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/buddyreplication/BuddyManagerTest.java
Log:
* Updated unmarshalling logic to be implicit in each command.
* Updated commands factory to be able to unmarshall commands.
* Updated cache marshaller to recognise commands
* Deprecated MethodCall
* Introduced MethodCallWrapper to allow compat with JGroups APIs
* Updated RPCManagerImpl to use MethodCallWrappers
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -9,6 +9,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.MarshallableCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.RuntimeConfig;
import org.jboss.cache.factories.annotations.Inject;
@@ -18,6 +19,7 @@
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.marshall.InactiveRegionAwareRpcDispatcher;
import org.jboss.cache.marshall.Marshaller;
+import org.jboss.cache.marshall.MethodCallWrapper;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.remoting.jgroups.CacheMessageListener;
import org.jboss.cache.statetransfer.StateTransferManager;
@@ -362,8 +364,12 @@
return callRemoteMethods(recipients, command, synchronous ? GroupRequest.GET_ALL : GroupRequest.GET_NONE, excludeSelf, timeout, useOutOfBandMessage);
}
- public List<Object> callRemoteMethods(List<Address> recipients, CacheCommand command, int mode, boolean excludeSelf, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception
+ public List<Object> callRemoteMethods(List<Address> recipients, CacheCommand cmd, int mode, boolean excludeSelf, long timeout, RspFilter responseFilter, boolean useOutOfBandMessage) throws Exception
{
+ if (!(cmd instanceof MarshallableCommand))
+ throw new IllegalArgumentException("Command " + cmd + " is not marshallable!");
+
+ MarshallableCommand command = (MarshallableCommand) cmd;
int modeToUse = mode;
int preferredMode;
if ((preferredMode = spi.getInvocationContext().getOptionOverrides().getGroupRequestMode()) > -1)
@@ -412,8 +418,8 @@
useOutOfBandMessage = false;
rsps = responseFilter == null
- ? disp.callRemoteMethods(validMembers, command.toMethodCall(), modeToUse, timeout, isUsingBuddyReplication, useOutOfBandMessage)
- : disp.callRemoteMethods(validMembers, command.toMethodCall(), modeToUse, timeout, isUsingBuddyReplication, useOutOfBandMessage, responseFilter);
+ ? disp.callRemoteMethods(validMembers, new MethodCallWrapper(command), modeToUse, timeout, isUsingBuddyReplication, useOutOfBandMessage)
+ : disp.callRemoteMethods(validMembers, new MethodCallWrapper(command), 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
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -8,6 +8,7 @@
import org.jboss.cache.commands.EvictFqnCommand;
import org.jboss.cache.commands.GravitateDataCommand;
import org.jboss.cache.commands.InvalidateCommand;
+import org.jboss.cache.commands.MarshallableCommand;
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
@@ -171,13 +172,13 @@
public Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
{
- List<CacheCommand> transformed = transformBatch(command.getModifications());
+ List<MarshallableCommand> transformed = transformBatch(command.getModifications());
return factory.buildOptimisticPrepareCommand(command.getGlobalTransaction(), transformed, command.getData(), command.getLocalAddress(), command.isOnePhaseCommit());
}
public Object handleReplicateCommand(InvocationContext ctx, ReplicateCommand command) throws Throwable
{
- List<CacheCommand> transformed = transformBatch(command.getModifications());
+ List<MarshallableCommand> transformed = transformBatch(command.getModifications());
return factory.buildReplicateCommand(transformed);
}
@@ -211,12 +212,12 @@
}
- public List<CacheCommand> transformBatch(List<? extends CacheCommand> toTransform) throws Throwable
+ public List<MarshallableCommand> transformBatch(List<? extends CacheCommand> toTransform) throws Throwable
{
- List<CacheCommand> transformedCommands = new ArrayList<CacheCommand>(toTransform.size());
+ List<MarshallableCommand> transformedCommands = new ArrayList<MarshallableCommand>(toTransform.size());
for (CacheCommand com : toTransform)
{
- transformedCommands.add((CacheCommand) com.accept(null, this));
+ transformedCommands.add((MarshallableCommand) com.accept(null, this));
}
return transformedCommands;
}
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-04-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -17,6 +17,7 @@
import org.jboss.cache.RegionManager;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.MarshallableCommand;
import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
@@ -645,11 +646,11 @@
/**
* @see org.jboss.cache.buddyreplication.BuddyFqnTransformer
*/
- public CacheCommand transformFqns(CacheCommand call)
+ public MarshallableCommand transformFqns(MarshallableCommand call)
{
try
{
- return (CacheCommand) call.accept(null, fqnTransformer);
+ return (MarshallableCommand) call.accept(null, fqnTransformer);
}
catch (Throwable throwable)
{
Modified: core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java 2008-04-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -3,15 +3,19 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.RPCManager;
-import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.MarshallableCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
/**
* Periodically (or when certain size is exceeded) takes elements and replicates them.
@@ -37,7 +41,7 @@
/**
* Holds the replication jobs: LinkedList<MethodCall>
*/
- final List<CacheCommand> elements = new LinkedList<CacheCommand>();
+ final List<MarshallableCommand> elements = new LinkedList<MarshallableCommand>();
/**
* For periodical replication
@@ -133,12 +137,12 @@
*/
public void flush()
{
- List<CacheCommand> toReplicate;
+ List<MarshallableCommand> toReplicate;
synchronized (elements)
{
if (log.isTraceEnabled())
log.trace("flush(): flushing repl queue (num elements=" + elements.size() + ")");
- toReplicate = new ArrayList<CacheCommand>(elements);
+ toReplicate = new ArrayList<MarshallableCommand>(elements);
elements.clear();
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/BaseCacheCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -5,14 +5,13 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.notifications.Notifier;
/**
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public abstract class BaseCacheCommand implements CacheCommand
+public abstract class BaseCacheCommand implements MarshallableCommand
{
protected static final Object[] EMPTY_OBJECT_ARRAY = new Object[]{};
protected Log log = LogFactory.getLog(getClass());
@@ -43,16 +42,4 @@
{
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CacheCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -1,7 +1,6 @@
package org.jboss.cache.commands;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.marshall.MethodCall;
/**
* @author Mircea.Markus(a)jboss.com
@@ -10,11 +9,7 @@
*/
public interface CacheCommand extends Cloneable
{
- public Object perform(InvocationContext ctx) throws Throwable;
+ Object perform(InvocationContext ctx) throws Throwable;
- public Object accept(InvocationContext ctx, CacheCommandsVisitor handler) throws Throwable;
-
- public MethodCall toMethodCall();
-
- public int getMethodId();
+ Object accept(InvocationContext ctx, CacheCommandsVisitor handler) throws Throwable;
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -92,12 +92,12 @@
}
- public ReplicateCommand buildReplicateCommand(CacheCommand command)
+ public ReplicateCommand buildReplicateCommand(MarshallableCommand command)
{
return new ReplicateCommand(command);
}
- public ReplicateCommand buildReplicateCommand(List<CacheCommand> modifications)
+ public ReplicateCommand buildReplicateCommand(List<MarshallableCommand> modifications)
{
return new ReplicateCommand(modifications);
}
@@ -289,72 +289,88 @@
public CacheCommand fromStream(int id, Object[] parameters)
{
// todo: must be a better way to do this!!!
+ MarshallableCommand returnValue;
switch (id)
{
case ExistsNodeCommand.METHOD_ID:
- return buildExistsNodeCommand((Fqn) parameters[0]);
+ returnValue = new ExistsNodeCommand();
+ break;
case GetChildrenNamesCommand.METHOD_ID:
- return buildGetChildrenNamesCommand((Fqn) parameters[0]);
+ returnValue = new GetChildrenNamesCommand();
+ break;
case GetDataMapCommand.METHOD_ID:
- return buildGetDataMapCommand((Fqn) parameters[0]);
+ returnValue = new GetDataMapCommand();
+ break;
case GetKeysCommand.METHOD_ID:
- return buildGetKeysCommand((Fqn) parameters[0]);
+ returnValue = new GetKeysCommand();
+ break;
case GetKeyValueCommand.METHOD_ID:
- return buildGetKeyValueCommand((Fqn) parameters[0], parameters[1], (Boolean) parameters[2]);
+ returnValue = new GetKeyValueCommand();
+ break;
case GetNodeCommand.METHOD_ID:
- return buildGetNodeCommand((Fqn) parameters[0]);
+ returnValue = new GetNodeCommand();
+ break;
case MoveCommand.METHOD_ID:
- return buildMoveCommand((Fqn) parameters[0], (Fqn) parameters[1]);
+ returnValue = new MoveCommand();
+ break;
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);
+ returnValue = new PutDataMapCommand();
+ break;
case PutKeyValueCommand.METHOD_ID:
- return buildPutKeyValueCommand((GlobalTransaction) parameters[0], (Fqn) parameters[1], parameters[2], parameters[3], (Boolean) parameters[4], false);
+ returnValue = new PutKeyValueCommand();
+ break;
case RemoveDataCommand.METHOD_ID:
- return buildRemoveDataCommand((GlobalTransaction) parameters[0], (Fqn) parameters[1], (Boolean) parameters[2], (Boolean) parameters[3], (Boolean) parameters[4]);
+ returnValue = new RemoveDataCommand();
+ break;
case RemoveKeyCommand.METHOD_ID:
- return buildRemoveKeyCommand((GlobalTransaction) parameters[0], (Fqn) parameters[1], parameters[2], (Boolean) parameters[3]);
+ returnValue = new RemoveKeyCommand();
+ break;
case RemoveNodeCommand.METHOD_ID:
- return buildRemoveNodeCommand((GlobalTransaction) parameters[0], (Fqn) parameters[1], (Boolean) parameters[2], (Boolean) parameters[3], (Boolean) parameters[4]);
+ returnValue = new RemoveNodeCommand();
+ break;
// --- transactional method calls
case PrepareCommand.METHOD_ID:
- return buildPrepareCommand((GlobalTransaction) parameters[0], toCacheCommandList((List<MethodCall>) parameters[1]), (Address) parameters[2], (Boolean) parameters[3]);
+ returnValue = new PrepareCommand();
+ break;
case OptimisticPrepareCommand.METHOD_ID:
- return buildOptimisticPrepareCommand((GlobalTransaction) parameters[0], toCacheCommandList((List<MethodCall>) parameters[1]), (Map) parameters[2], (Address) parameters[3], (Boolean) parameters[4]);
+ returnValue = new OptimisticPrepareCommand();
+ break;
case CommitCommand.METHOD_ID:
- return buildCommitCommand((GlobalTransaction) parameters[0]);
+ returnValue = new CommitCommand();
+ break;
case RollbackCommand.METHOD_ID:
- return buildRollbackCommand((GlobalTransaction) parameters[0]);
+ returnValue = new RollbackCommand();
+ break;
// --- 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()));
+ returnValue = new ReplicateCommand();
+ break;
default:
throw new CacheException("Unknown command id " + id + "!");
}
+
+ returnValue.setState(id, parameters);
+ return returnValue;
}
private List<CacheCommand> toCacheCommandList(List<MethodCall> calls)
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/EvictFqnCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -43,7 +43,7 @@
return handler.handleEvictFqnCommand(ctx, this);
}
- public int getMethodId()
+ public int getCommandId()
{
return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
}
@@ -68,11 +68,17 @@
return dataVersion != null;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
if (isVersioned())
return new Object[]{fqn, dataVersion};
else
return new Object[]{fqn};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ fqn = (Fqn) args[0];
+ if (commandId == VERSIONED_METHOD_ID) dataVersion = (DataVersion) args[1];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -158,7 +158,7 @@
return handler.handleGravitateDataCommand(ctx, this);
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
@@ -173,8 +173,14 @@
return searchSubtrees;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{fqn, searchSubtrees};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ fqn = (Fqn) args[0];
+ searchSubtrees = (Boolean) args[1];
+ }
}
Added: core/trunk/src/main/java/org/jboss/cache/commands/MarshallableCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/MarshallableCommand.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/MarshallableCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -0,0 +1,29 @@
+package org.jboss.cache.commands;
+
+/**
+ * Declares methods to expose internals of the command such that a {@link org.jboss.cache.marshall.Marshaller} is able to
+ * marshall the command for streaming over the wire.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.2.0
+ */
+public interface MarshallableCommand extends CacheCommand
+{
+ /**
+ * @return the method id of this command. This is compatible with pre-2.2.0 MethodCall ids.
+ */
+ int getCommandId();
+
+ /**
+ * @return an object array of arguments, compatible with pre-2.2.0 MethodCall args.
+ */
+ Object[] getParameters();
+
+ /**
+ * Sets the state of a command instance with unmarshalled command id and args.
+ *
+ * @param commandId command id to set. This is usually unused but *could* be used in the event of a command having multiple IDs, such as {@link org.jboss.cache.commands.cachedata.PutKeyValueCommand}.
+ * @param args object array of args
+ */
+ void setState(int commandId, Object[] args);
+}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/cachedata/CacheDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/cachedata/CacheDataCommand.java 2008-04-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/CacheDataCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -2,6 +2,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.MarshallableCommand;
/**
* Defines a command that manipulates data on cache.
@@ -9,7 +10,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public interface CacheDataCommand extends CacheCommand
+public interface CacheDataCommand extends MarshallableCommand, CacheCommand
{
/**
* Returns the node on which this command operates.
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/ExistsNodeCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -24,6 +24,10 @@
private Fqn fqn;
+ public ExistsNodeCommand()
+ {
+ }
+
public ExistsNodeCommand(Fqn fqn)
{
this.fqn = fqn;
@@ -50,13 +54,18 @@
return fqn;
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{fqn};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ fqn = (Fqn) args[0];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetChildrenNamesCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -25,6 +25,10 @@
private Fqn fqn;
+ public GetChildrenNamesCommand()
+ {
+ }
+
public GetChildrenNamesCommand(Fqn fqn)
{
this.fqn = fqn;
@@ -67,13 +71,18 @@
return fqn;
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{fqn};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ fqn = (Fqn) args[0];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetDataMapCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -21,6 +21,10 @@
private Fqn fqn;
+ public GetDataMapCommand()
+ {
+ }
+
public GetDataMapCommand(Fqn fqn)
{
this.fqn = fqn;
@@ -48,13 +52,18 @@
return fqn;
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{fqn};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ fqn = (Fqn) args[0];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeyValueCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -31,6 +31,10 @@
private Object key;
boolean sendNodeEvent;
+ public GetKeyValueCommand()
+ {
+ }
+
public GetKeyValueCommand(Fqn<?> fqn, Object key, boolean sendNodeEvent)
{
this.fqn = fqn;
@@ -88,13 +92,20 @@
this.key = key;
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{fqn, key, sendNodeEvent};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ fqn = (Fqn) args[0];
+ key = args[1];
+ sendNodeEvent = (Boolean) args[2];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeysCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -24,6 +24,10 @@
private Fqn fqn;
+ public GetKeysCommand()
+ {
+ }
+
public GetKeysCommand(Fqn fqn)
{
this.fqn = fqn;
@@ -55,13 +59,18 @@
return fqn;
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{fqn};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ fqn = (Fqn) args[0];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetNodeCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -20,6 +20,10 @@
private Fqn fqn;
+ public GetNodeCommand()
+ {
+ }
+
public GetNodeCommand(Fqn fqn)
{
this.fqn = fqn;
@@ -45,13 +49,18 @@
return fqn;
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{fqn};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ fqn = (Fqn) args[0];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/MoveCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -30,6 +30,10 @@
private Fqn from;
private Fqn to;
+ public MoveCommand()
+ {
+ }
+
public MoveCommand(Fqn from, Fqn to)
{
this.from = from;
@@ -124,13 +128,19 @@
return to;
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{from, to};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ from = (Fqn) args[0];
+ to = (Fqn) args[1];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutDataMapCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -50,6 +50,10 @@
*/
private Map oldData;
+ public PutDataMapCommand()
+ {
+ }
+
public PutDataMapCommand(GlobalTransaction globalTransaction, Fqn fqn, Map data, boolean createUndoOps, boolean eraseContents)
{
this.globalTransaction = globalTransaction;
@@ -154,13 +158,22 @@
this.data = data;
}
- public int getMethodId()
+ public int getCommandId()
{
- return METHOD_ID;
+ return eraseContents ? ERASE_METHOD_ID : METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{globalTransaction, fqn, data, createUndoOps};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ globalTransaction = (GlobalTransaction) args[0];
+ fqn = (Fqn) args[1];
+ data = (Map) args[2];
+ createUndoOps = (Boolean) args[3];
+ eraseContents = commandId == ERASE_METHOD_ID;
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutKeyValueCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -51,6 +51,10 @@
*/
private Object oldValue;
+ public PutKeyValueCommand()
+ {
+ }
+
public PutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps, boolean isPutForExternalRead)
{
this.globalTransaction = gtx;
@@ -173,13 +177,22 @@
this.value = value;
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{globalTransaction, fqn, key, value, createUndoOps};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ globalTransaction = (GlobalTransaction) args[0];
+ fqn = (Fqn) args[1];
+ key = args[2];
+ value = args[3];
+ createUndoOps = (Boolean) args[4];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveDataCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -51,6 +51,10 @@
*/
private HashMap originalData;
+ public RemoveDataCommand()
+ {
+ }
+
public void initialize(CacheData cacheData, TransactionTable transactionTable, Notifier notifier)
{
this.cacheData = cacheData;
@@ -201,16 +205,24 @@
this.globalTransaction = gtx;
}
- public int getMethodId()
+ public int getCommandId()
{
return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
if (isVersioned())
- return new Object[]{globalTransaction, fqn, eviction, dataVersion};
+ return new Object[]{globalTransaction, fqn, createUndoops, dataVersion};
else
- return new Object[]{globalTransaction, fqn, eviction};
+ return new Object[]{globalTransaction, fqn, createUndoops};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ globalTransaction = (GlobalTransaction) args[0];
+ fqn = (Fqn) args[1];
+ createUndoops = (Boolean) args[2];
+ if (commandId == VERSIONED_METHOD_ID) dataVersion = (DataVersion) args[3];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveKeyCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -50,6 +50,10 @@
*/
private Object oldValue;
+ public RemoveKeyCommand()
+ {
+ }
+
public RemoveKeyCommand(GlobalTransaction gtx, Fqn fqn, Object key, boolean createUndoOps)
{
this.globalTransaction = gtx;
@@ -144,16 +148,25 @@
this.key = key;
}
- public int getMethodId()
+ public int getCommandId()
{
return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
if (isVersioned())
return new Object[]{globalTransaction, fqn, key, createUndoOps, dataVersion};
else
return new Object[]{globalTransaction, fqn, key, createUndoOps};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ globalTransaction = (GlobalTransaction) args[0];
+ fqn = (Fqn) args[1];
+ key = args[2];
+ createUndoOps = (Boolean) args[3];
+ if (commandId == VERSIONED_METHOD_ID) dataVersion = (DataVersion) args[4];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveNodeCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -47,6 +47,10 @@
private Fqn parentFqn;
private NodeSPI targetNode;
+ public RemoveNodeCommand()
+ {
+ }
+
public RemoveNodeCommand(GlobalTransaction globalTransaction, Fqn fqn, boolean createUndoOps, boolean skipSendingNodeEvents, boolean eviction)
{
this.globalTransaction = globalTransaction;
@@ -216,16 +220,25 @@
this.globalTransaction = gtx;
}
- public int getMethodId()
+ public int getCommandId()
{
return isVersioned() ? VERSIONED_METHOD_ID : METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
if (isVersioned())
return new Object[]{globalTransaction, fqn, createUndoOps, skipSendingNodeEvents, dataVersion};
else
return new Object[]{globalTransaction, fqn, createUndoOps, skipSendingNodeEvents};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ globalTransaction = (GlobalTransaction) args[0];
+ fqn = (Fqn) args[1];
+ createUndoOps = (Boolean) args[2];
+ skipSendingNodeEvents = (Boolean) args[3];
+ if (commandId == VERSIONED_METHOD_ID) dataVersion = (DataVersion) args[4];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/channel/BlockChannelCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -16,6 +16,10 @@
{
public static final int METHOD_ID = 43;
+ public BlockChannelCommand()
+ {
+ }
+
public Object perform(InvocationContext ctx) throws Throwable
{
return null;
@@ -26,13 +30,18 @@
return handler.handleBlockChannelCommand(ctx, this);
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return EMPTY_OBJECT_ARRAY;
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ // no op
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/channel/UnblockChannelCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -16,6 +16,10 @@
{
public static final int METHOD_ID = 43;
+ public UnblockChannelCommand()
+ {
+ }
+
public Object perform(InvocationContext ctx) throws Throwable
{
//noop
@@ -27,13 +31,18 @@
return handler.handleUnblockChannelCommand(ctx, this);
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return EMPTY_OBJECT_ARRAY;
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ // no op
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -25,6 +25,10 @@
private Address address;
private String buddyPoolName;
+ public AnnounceBuddyPoolNameCommand()
+ {
+ }
+
public AnnounceBuddyPoolNameCommand(Address address, String buddyPoolName)
{
this.address = address;
@@ -51,7 +55,7 @@
return handler.handleAnnounceBuddyPoolName(ctx, this);
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
@@ -66,8 +70,14 @@
return buddyPoolName;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{address, buddyPoolName};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ address = (Address) args[0];
+ buddyPoolName = (String) args[1];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -27,6 +27,10 @@
private BuddyGroup group;
private Map<Fqn, byte[]> state;
+ public AssignToBuddyGroupCommand()
+ {
+ }
+
public AssignToBuddyGroupCommand(BuddyGroup group, Map<Fqn, byte[]> state)
{
this.group = group;
@@ -52,7 +56,7 @@
return handler.handleAssignToBuddyGroupCommand(ctx, this);
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
@@ -67,8 +71,14 @@
return state;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{group, state};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ group = (BuddyGroup) args[0];
+ state = (Map) args[1];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -11,6 +11,7 @@
import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
import org.jboss.cache.commands.cachedata.GetDataMapCommand;
import org.jboss.cache.invocation.CacheData;
+import org.jboss.cache.marshall.MethodCallWrapper;
import java.util.ArrayList;
import java.util.Collections;
@@ -29,6 +30,10 @@
private Boolean searchBackupSubtrees;
private CacheData cacheData;
+ public ClusteredGetCommand()
+ {
+ }
+
public ClusteredGetCommand(Boolean searchBackupSubtrees, CacheDataCommand cacheDataComand)
{
this.searchBackupSubtrees = searchBackupSubtrees;
@@ -82,7 +87,7 @@
return handler.handleClusteredGetCommand(ctx, this);
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
@@ -121,8 +126,14 @@
return cacheDataComand;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
- return new Object[]{cacheDataComand.toMethodCall(), searchBackupSubtrees}; //To change body of implemented methods use File | Settings | File Templates.
+ return new Object[]{new MethodCallWrapper(cacheDataComand), searchBackupSubtrees}; //To change body of implemented methods use File | Settings | File Templates.
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ cacheDataComand = (CacheDataCommand) args[0];
+ searchBackupSubtrees = (Boolean) args[1];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -45,6 +45,9 @@
private Fqn primary;
private Fqn backup;
+ public DataGravitationCleanupCommand()
+ {
+ }
public DataGravitationCleanupCommand(Fqn primary, Fqn backup)
{
@@ -140,7 +143,7 @@
return handler.handleDataGravitationCleanupCommand(ctx, this);
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
@@ -170,8 +173,14 @@
this.globalTransaction = gtx;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{primary, backup}; //To change body of implemented methods use File | Settings | File Templates.
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ primary = (Fqn) args[0];
+ backup = (Fqn) args[1];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -21,6 +21,10 @@
private String groupName;
+ public RemoveFromBuddyGroupCommand()
+ {
+ }
+
public RemoveFromBuddyGroupCommand(String groupName)
{
this.groupName = groupName;
@@ -45,7 +49,7 @@
return handler.handleRemoveFromBuddyGroupCommand(ctx, this);
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
@@ -55,8 +59,13 @@
return groupName;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{groupName};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ groupName = (String) args[0];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -5,9 +5,10 @@
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
import org.jboss.cache.commands.GravitateDataCommand;
+import org.jboss.cache.commands.MarshallableCommand;
import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
import org.jboss.cache.invocation.InterceptorChain;
-import org.jboss.cache.marshall.MethodCall;
+import org.jboss.cache.marshall.MethodCallWrapper;
import java.util.ArrayList;
import java.util.List;
@@ -24,27 +25,31 @@
public static final int MULTIPLE_METHOD_ID = 14;
private InterceptorChain invoker;
- private List<CacheCommand> modifications;
+ private List<MarshallableCommand> modifications;
/**
* optimiscation - rather than constructing a new list each for scenarios where a single modification needs
* to be replicated rather use this insance.
*/
- private CacheCommand singleModification;
+ private MarshallableCommand singleModification;
- public ReplicateCommand(CacheCommand toReplicate, InterceptorChain invoker)
+ public ReplicateCommand()
{
- this.modifications = new ArrayList<CacheCommand>();
+ }
+
+ public ReplicateCommand(MarshallableCommand toReplicate, InterceptorChain invoker)
+ {
+ this.modifications = new ArrayList<MarshallableCommand>();
modifications.add(toReplicate);
this.invoker = invoker;
}
- public ReplicateCommand(List<CacheCommand> modifications)
+ public ReplicateCommand(List<MarshallableCommand> modifications)
{
this.modifications = modifications;
}
- public ReplicateCommand(CacheCommand command)
+ public ReplicateCommand(MarshallableCommand command)
{
this.singleModification = command;
}
@@ -55,14 +60,14 @@
{
return processSingleCommand(modifications.get(0));
}
- for (CacheCommand command : modifications)
+ for (MarshallableCommand command : modifications)
{
processSingleCommand(command);
}
return null;
}
- private Object processSingleCommand(CacheCommand cacheCommand)
+ private Object processSingleCommand(MarshallableCommand cacheCommand)
throws Throwable
{
Object result;
@@ -107,28 +112,40 @@
return handler.handleReplicateCommand(ctx, this);
}
- public int getMethodId()
+ public int getCommandId()
{
return singleModification == null ? MULTIPLE_METHOD_ID : SINGLE_METHOD_ID;
}
- public List<CacheCommand> getModifications()
+ public List<MarshallableCommand> getModifications()
{
return modifications;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
if (singleModification == null)
return new Object[]{toMethodCallList()};
else
- return new Object[]{singleModification.toMethodCall()};
+ return new Object[]{new MethodCallWrapper(singleModification)};
}
- private List<MethodCall> toMethodCallList()
+ public void setState(int commandId, Object[] args)
{
- List<MethodCall> l = new ArrayList<MethodCall>(modifications.size());
- for (CacheCommand cc : modifications) l.add(cc.toMethodCall());
+ if (commandId == SINGLE_METHOD_ID)
+ {
+ singleModification = (MarshallableCommand) args[0];
+ }
+ else
+ {
+ modifications = (List<MarshallableCommand>) args[1];
+ }
+ }
+
+ private List<MethodCallWrapper> toMethodCallList()
+ {
+ List<MethodCallWrapper> l = new ArrayList<MethodCallWrapper>(modifications.size());
+ for (MarshallableCommand cc : modifications) l.add(new MethodCallWrapper(cc));
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -16,6 +16,10 @@
private GlobalTransaction globalTransaction;
+ public CommitCommand()
+ {
+ }
+
public CommitCommand(GlobalTransaction globalTransaction)
{
this.globalTransaction = globalTransaction;
@@ -42,13 +46,18 @@
this.globalTransaction = gtx;
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{globalTransaction};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ globalTransaction = (GlobalTransaction) args[0];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -18,6 +18,10 @@
public static final int METHOD_ID = 18;
private Map data;
+ public OptimisticPrepareCommand()
+ {
+ }
+
public OptimisticPrepareCommand(GlobalTransaction gtx, List<? extends CacheCommand> modifications, Map data, Address address, boolean onePhaseCommit)
{
super(gtx, modifications, address, onePhaseCommit);
@@ -40,14 +44,25 @@
}
@Override
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
@Override
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{globalTransaction, modifications, data, localAddress, onePhaseCommit};
}
+
+ @Override
+ public void setState(int commandId, Object[] args)
+ {
+ globalTransaction = (GlobalTransaction) args[0];
+ modifications = (List<? extends CacheCommand>) args[1];
+ data = (Map) args[2];
+ localAddress = (Address) args[3];
+ onePhaseCommit = (Boolean) args[4];
+ }
+
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -25,8 +25,13 @@
protected Address localAddress;
protected boolean onePhaseCommit;
+ public PrepareCommand()
+ {
+ }
+
public PrepareCommand(GlobalTransaction gtx, List<? extends CacheCommand> modifications, Address localAddress, boolean onePhaseCommit)
{
+ this.globalTransaction = gtx;
this.modifications = modifications;
this.localAddress = localAddress;
this.onePhaseCommit = onePhaseCommit;
@@ -77,13 +82,21 @@
return modifications != null ? modifications.size() : 0;
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{globalTransaction, modifications, localAddress, onePhaseCommit};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ globalTransaction = (GlobalTransaction) args[0];
+ modifications = (List<? extends CacheCommand>) args[1];
+ localAddress = (Address) args[2];
+ onePhaseCommit = (Boolean) args[3];
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -17,6 +17,10 @@
private GlobalTransaction globalTransaction;
+ public RollbackCommand()
+ {
+ }
+
public RollbackCommand(GlobalTransaction globalTransaction)
{
this.globalTransaction = globalTransaction;
@@ -42,13 +46,18 @@
this.globalTransaction = gtx;
}
- public int getMethodId()
+ public int getCommandId()
{
return METHOD_ID;
}
- protected Object[] getParameters()
+ public Object[] getParameters()
{
return new Object[]{globalTransaction};
}
+
+ public void setState(int commandId, Object[] args)
+ {
+ globalTransaction = (GlobalTransaction) args[0];
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-04-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -5,21 +5,23 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
-import org.jboss.cache.interceptors.base.ChainedInterceptor;
+import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.cluster.ReplicationQueue;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.cluster.ReplicationQueue;
+import org.jboss.cache.commands.MarshallableCommand;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Option;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.interceptors.base.ChainedInterceptor;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
import org.jgroups.Address;
import javax.transaction.Transaction;
+import java.io.NotSerializableException;
import java.util.List;
/**
@@ -35,14 +37,14 @@
private ReplicationQueue replicationQueue;
private TransactionTable txTable;
private CommandsFactory commandsFactory;
-
+
protected RPCManager rpcManager;
protected boolean defaultSynchronous;
protected Configuration config;
@Inject
public void injectComponents(RPCManager rpcManager, BuddyManager buddyManager, ReplicationQueue replicationQueue,
- Configuration config, TransactionTable txTable, CommandsFactory commandsFactory)
+ Configuration config, TransactionTable txTable, CommandsFactory commandsFactory)
{
this.rpcManager = rpcManager;
this.replicationQueue = replicationQueue;
@@ -91,53 +93,60 @@
replicateCall(ctx, recipients, call, sync, o, true, false);
}
- protected void replicateCall(InvocationContext ctx, List<Address> recipients, CacheCommand call, boolean sync, Option o, boolean wrapCacheCommandInReplicateMethod, boolean useOutOfBandMessage) throws Throwable
+ protected void replicateCall(InvocationContext ctx, List<Address> recipients, CacheCommand c, boolean sync, Option o, boolean wrapCacheCommandInReplicateMethod, boolean useOutOfBandMessage) throws Throwable
{
-
- if (trace) log.trace("Broadcasting call " + call + " to recipient list " + recipients);
- Transaction tx = ctx.getTransaction();
- if (tx != null)
+ if (c instanceof MarshallableCommand)
{
- GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionEntry te = txTable.get(gtx);
- if (te != null)
+ MarshallableCommand call = (MarshallableCommand) c;
+ if (trace) log.trace("Broadcasting call " + call + " to recipient list " + recipients);
+ Transaction tx = ctx.getTransaction();
+ if (tx != null)
{
- if (te.isForceAsyncReplication()) sync = false;
- else if (te.isForceSyncReplication()) sync = true;
+ GlobalTransaction gtx = ctx.getGlobalTransaction();
+ TransactionEntry te = txTable.get(gtx);
+ if (te != null)
+ {
+ if (te.isForceAsyncReplication()) sync = false;
+ else if (te.isForceSyncReplication()) sync = true;
+ }
}
- }
- if (!sync && replicationQueue != null && !usingBuddyReplication)
- {
- if (log.isDebugEnabled()) log.debug("Putting call " + call + " on the replication queue.");
- replicationQueue.add(commandsFactory.buildReplicateCommand(call));
- }
- else
- {
- if (usingBuddyReplication) call = buddyManager.transformFqns(call);
-
- List<Address> callRecipients = recipients;
- if (callRecipients == null)
+ if (!sync && replicationQueue != null && !usingBuddyReplication)
{
- callRecipients = usingBuddyReplication ? buddyManager.getBuddyAddresses() : rpcManager.getMembers();
- if (trace)
- log.trace("Setting call recipients to " + callRecipients + " since the original list of recipients passed in is null.");
+ if (log.isDebugEnabled()) log.debug("Putting call " + call + " on the replication queue.");
+ replicationQueue.add(commandsFactory.buildReplicateCommand(call));
}
+ else
+ {
+ if (usingBuddyReplication) call = buddyManager.transformFqns(call);
- long syncReplTimeout = o.getSyncReplTimeout();
- if (syncReplTimeout < 0) syncReplTimeout = config.getSyncReplTimeout();
+ List<Address> callRecipients = recipients;
+ if (callRecipients == null)
+ {
+ callRecipients = usingBuddyReplication ? buddyManager.getBuddyAddresses() : rpcManager.getMembers();
+ if (trace)
+ log.trace("Setting call recipients to " + callRecipients + " since the original list of recipients passed in is null.");
+ }
- CacheCommand toCall = wrapCacheCommandInReplicateMethod ? commandsFactory.buildReplicateCommand(call) : call;
+ long syncReplTimeout = o.getSyncReplTimeout();
+ if (syncReplTimeout < 0) syncReplTimeout = config.getSyncReplTimeout();
- List rsps = rpcManager.callRemoteMethods(callRecipients,
- toCall,
- sync, // is synchronised?
- true, // ignore self?
- (int) syncReplTimeout,
- useOutOfBandMessage
- );
- if (trace) log.trace("responses=" + rsps);
- if (sync) checkResponses(rsps);
+ CacheCommand toCall = wrapCacheCommandInReplicateMethod ? commandsFactory.buildReplicateCommand(call) : call;
+
+ List rsps = rpcManager.callRemoteMethods(callRecipients,
+ toCall,
+ sync, // is synchronised?
+ true, // ignore self?
+ (int) syncReplTimeout,
+ useOutOfBandMessage
+ );
+ if (trace) log.trace("responses=" + rsps);
+ if (sync) checkResponses(rsps);
+ }
}
+ else
+ {
+ throw new NotSerializableException("The command is of type " + c.getClass().getName() + ", and is not an instance of " + MarshallableCommand.class.getName());
+ }
}
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -12,6 +12,7 @@
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.MarshallableCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -289,31 +290,24 @@
out.writeByte(MAGICNUMBER_REF);
writeReference(out, refMap.get(o));
}
- else if (o instanceof MethodCall || o instanceof CacheCommand)
+ else if (o instanceof MethodCallWrapper || o instanceof MarshallableCommand)
{
- // TODO: throw an exception if we ever attempt to marshall a MethodCall. MethodCalls should not be used hereafter, and should be rewritten as a lean wrapper around a JGroups method call for interfacing with JGroups APIs.
+ MarshallableCommand command = o instanceof MethodCallWrapper ? ((MethodCallWrapper) o).getCommand() : (MarshallableCommand) o;
- // first see if this is a 'known' method call.
- MethodCall call = null;
- if (o instanceof CacheCommand)
+ if (command.getCommandId() > -1)
{
- call = ((CacheCommand) o).toMethodCall();
- }
- else
- {
- call = (MethodCall) o;
- }
-
- if (call.getMethodId() > -1)
- {
out.writeByte(MAGICNUMBER_METHODCALL);
- marshallMethodCall(call, out, refMap);
+ marshallCommand(command, out, refMap);
}
else
{
throw new IllegalArgumentException("MethodCall does not have a valid method id. Was this method call created with MethodCallFactory?");
}
}
+ else if (o instanceof org.jgroups.blocks.MethodCall)
+ {
+ throw new IllegalArgumentException("Usage of a legacy MethodCall object!!");
+ }
else if (o instanceof MarshalledValue)
{
out.writeByte(MAGICNUMBER_MARSHALLEDVALUE);
@@ -462,10 +456,10 @@
out.writeObject(s);
}
- private void marshallMethodCall(MethodCall methodCall, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception
+ private void marshallCommand(MarshallableCommand command, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception
{
- out.writeShort(methodCall.getMethodId());
- Object[] args = methodCall.getArgs();
+ out.writeShort(command.getCommandId());
+ Object[] args = command.getParameters();
byte numArgs = (byte) (args == null ? 0 : args.length);
out.writeByte(numArgs);
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-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MethodCall.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -24,7 +24,9 @@
* Thanks to Elias Ross/genman for this info.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @deprecated - in favour of {@link org.jboss.cache.commands.CacheCommand} instances. Will be removed in 3.X.
*/
+@Deprecated
public class MethodCall extends org.jgroups.blocks.MethodCall
{
private static boolean trace = LogFactory.getLog(MethodCall.class).isTraceEnabled();
@@ -68,20 +70,6 @@
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;
Added: core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallWrapper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallWrapper.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/MethodCallWrapper.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -0,0 +1,25 @@
+package org.jboss.cache.marshall;
+
+import org.jboss.cache.commands.MarshallableCommand;
+
+/**
+ * This wrapper class is used when passing in {@link org.jboss.cache.commands.CacheCommand}s into JGroups RPC APIs.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @see org.jboss.cache.commands.CacheCommand
+ * @since 2.2.0
+ */
+public class MethodCallWrapper extends org.jgroups.blocks.MethodCall
+{
+ private MarshallableCommand command;
+
+ public MethodCallWrapper(MarshallableCommand command)
+ {
+ this.command = command;
+ }
+
+ public MarshallableCommand getCommand()
+ {
+ return command;
+ }
+}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-04-12 13:22:00 UTC (rev 5536)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-04-12 15:16:19 UTC (rev 5537)
@@ -7,8 +7,8 @@
package org.jboss.cache.buddyreplication;
import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.MarshallableCommand;
import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.config.BuddyReplicationConfig;
@@ -154,7 +154,7 @@
{
Fqn fqn1 = Fqn.ROOT;
- CacheCommand call1 = commandsFactory.buildPutKeyValueCommand(null, fqn1, "key", "value", false, false);
+ MarshallableCommand call1 = commandsFactory.buildPutKeyValueCommand(null, fqn1, "key", "value", false, false);
ReplicateCommand call2 = commandsFactory.buildReplicateCommand(call1);
BuddyManager bm = createBasicBuddyManager();
@@ -178,7 +178,7 @@
PutKeyValueCommand call2 = commandsFactory.buildPutKeyValueCommand(null, fqn2, "key", "value", false, false);
PutKeyValueCommand call3 = commandsFactory.buildPutKeyValueCommand(null, fqn3, "key", "value", false, false);
PutKeyValueCommand call4 = commandsFactory.buildPutKeyValueCommand(null, fqn4, "key", "value", false, false);
- List<CacheCommand> list = new ArrayList<CacheCommand>();
+ List<MarshallableCommand> list = new ArrayList<MarshallableCommand>();
list.add(call1);
list.add(call2);
list.add(call3);
@@ -189,7 +189,7 @@
BuddyManager bm = createBasicBuddyManager();
ReplicateCommand newReplicatedCall = (ReplicateCommand) bm.transformFqns(call5);
- List<CacheCommand> l = (List<CacheCommand>) newReplicatedCall.getModifications();
+ List<MarshallableCommand> l = newReplicatedCall.getModifications();
// should use object refs to transform the original MethodCall.
String expected = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/null";
16 years, 9 months
JBoss Cache SVN: r5536 - core/trunk/src/test/resources.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-12 09:22:00 -0400 (Sat, 12 Apr 2008)
New Revision: 5536
Modified:
core/trunk/src/test/resources/log4j.xml
Log:
Do NOT check in trace level logging into SVN as it slows down Hudsonvi src/test/resources/log4j.xml
Modified: core/trunk/src/test/resources/log4j.xml
===================================================================
--- core/trunk/src/test/resources/log4j.xml 2008-04-11 17:34:14 UTC (rev 5535)
+++ core/trunk/src/test/resources/log4j.xml 2008-04-12 13:22:00 UTC (rev 5536)
@@ -63,7 +63,7 @@
<!-- ================ -->
<category name="org.jboss.cache">
- <priority value="TRACE"/>
+ <priority value="WARN"/>
</category>
<category name="org.jboss.tm">
@@ -79,7 +79,7 @@
<!-- ======================= -->
<root>
- <appender-ref ref="CONSOLE"/>
+ <!-- <appender-ref ref="CONSOLE"/> -->
<appender-ref ref="FILE"/>
</root>
16 years, 9 months
JBoss Cache SVN: r5535 - core/trunk/src/main/java/org/jboss/cache/marshall.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-11 13:34:14 -0400 (Fri, 11 Apr 2008)
New Revision: 5535
Modified:
core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
Log:
Added todo
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 17:22:15 UTC (rev 5534)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-04-11 17:34:14 UTC (rev 5535)
@@ -291,6 +291,8 @@
}
else if (o instanceof MethodCall || o instanceof CacheCommand)
{
+ // TODO: throw an exception if we ever attempt to marshall a MethodCall. MethodCalls should not be used hereafter, and should be rewritten as a lean wrapper around a JGroups method call for interfacing with JGroups APIs.
+
// first see if this is a 'known' method call.
MethodCall call = null;
if (o instanceof CacheCommand)
16 years, 9 months
JBoss Cache SVN: r5534 - in core/tags/2.1.1.CR2: src/main/java/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-11 13:22:15 -0400 (Fri, 11 Apr 2008)
New Revision: 5534
Modified:
core/tags/2.1.1.CR2/pom.xml
core/tags/2.1.1.CR2/src/main/java/org/jboss/cache/Version.java
Log:
CR2
Modified: core/tags/2.1.1.CR2/pom.xml
===================================================================
--- core/tags/2.1.1.CR2/pom.xml 2008-04-11 17:20:02 UTC (rev 5533)
+++ core/tags/2.1.1.CR2/pom.xml 2008-04-11 17:22:15 UTC (rev 5534)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-core-version>2.1.1-SNAPSHOT</jbosscache-core-version>
+ <jbosscache-core-version>2.1.1.CR2</jbosscache-core-version>
</properties>
<parent>
<groupId>org.jboss.cache</groupId>
@@ -342,7 +342,7 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
- <jbosscache-core-version>2.1.1-SNAPSHOT-JBossAS</jbosscache-core-version>
+ <jbosscache-core-version>2.1.1.CR2-JBossAS</jbosscache-core-version>
</properties>
<dependencies>
<dependency>
Modified: core/tags/2.1.1.CR2/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/tags/2.1.1.CR2/src/main/java/org/jboss/cache/Version.java 2008-04-11 17:20:02 UTC (rev 5533)
+++ core/tags/2.1.1.CR2/src/main/java/org/jboss/cache/Version.java 2008-04-11 17:22:15 UTC (rev 5534)
@@ -11,10 +11,10 @@
@Immutable
public class Version
{
- public static final String version = "2.1.1-SNAPSHOT";
+ public static final String version = "2.1.1.CR2";
public static final String codename = "Alegrias";
//public static final String cvs = "$Id: Version.java 4592 2007-10-10 16:44:36Z manik.surtani(a)jboss.com $";
- static final byte[] version_id = {'0', '2', '1', '1', 'S'};
+ static final byte[] version_id = {'0', '2', '1', '1', 'C'};
private static final int MAJOR_SHIFT = 11;
private static final int MINOR_SHIFT = 6;
16 years, 9 months