JBoss Cache SVN: r5533 - core/tags.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-11 13:20:02 -0400 (Fri, 11 Apr 2008)
New Revision: 5533
Added:
core/tags/2.1.1.CR2/
Log:
Copied: core/tags/2.1.1.CR2 (from rev 5532, core/branches/2.1.X)
16 years, 9 months
JBoss Cache SVN: r5532 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 10 other directories.
by jbosscache-commits@lists.jboss.org
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")
16 years, 9 months
JBoss Cache SVN: r5531 - support/trunk/common.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-11 07:31:00 -0400 (Fri, 11 Apr 2008)
New Revision: 5531
Modified:
support/trunk/common/pom.xml
Log:
Removed emma
Modified: support/trunk/common/pom.xml
===================================================================
--- support/trunk/common/pom.xml 2008-04-11 11:29:00 UTC (rev 5530)
+++ support/trunk/common/pom.xml 2008-04-11 11:31:00 UTC (rev 5531)
@@ -281,12 +281,14 @@
</configuration>
</plugin>
<!-- EMMA report -->
+<!--
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>emma-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<inherited>true</inherited>
</plugin>
+-->
</plugins>
</reporting>
<properties>
16 years, 9 months
JBoss Cache SVN: r5530 - in core/trunk/src/test/java/org/jboss/cache: buddyreplication and 4 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-11 07:29:00 -0400 (Fri, 11 Apr 2008)
New Revision: 5530
Modified:
core/trunk/src/test/java/org/jboss/cache/TreeNodeTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
core/trunk/src/test/java/org/jboss/cache/transaction/ReplicatedTransactionDeadlockTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java
Log:
Updated code that uses deprecated Fqn constructors
Modified: core/trunk/src/test/java/org/jboss/cache/TreeNodeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/TreeNodeTest.java 2008-04-10 23:33:56 UTC (rev 5529)
+++ core/trunk/src/test/java/org/jboss/cache/TreeNodeTest.java 2008-04-11 11:29:00 UTC (rev 5530)
@@ -36,12 +36,12 @@
cache.put(Fqn.fromString("/a/b/c"), key, "test");
Node<Object, Object> node = cache.getNode(Fqn.fromString("/a/b"));
assertFalse(node.getChildren().isEmpty());
- assertTrue(node.getChild(new Fqn<String>("c")) != null);
+ assertTrue(node.getChild(Fqn.fromElements("c")) != null);
Fqn fqn = Fqn.fromString("/e/f");
cache.put(fqn, "1", "1");
node = cache.getNode(Fqn.fromString("/e"));
assertFalse(node.getChildren().isEmpty());
- assertTrue(node.getChild(new Fqn<String>("f")) != null);
+ assertTrue(node.getChild(Fqn.fromElements("f")) != null);
}
}
\ No newline at end of file
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java 2008-04-10 23:33:56 UTC (rev 5529)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java 2008-04-11 11:29:00 UTC (rev 5530)
@@ -73,12 +73,12 @@
assert caches.get(1).peek(BuddyManager.getBackupRoot(caches.get(2).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
assert caches.get(1).peek(BuddyManager.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
assert caches.get(1).peek(BuddyManager.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
- assert caches.get(1).peek(new Fqn(BuddyManager.getDeadBackupRoot(caches.get(0).getLocalAddress()), new Integer(1)), false) != null : "Should have dead node as a defunct backup root.";
+ assert caches.get(1).peek(Fqn.fromRelativeElements(BuddyManager.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) != null : "Should have dead node as a defunct backup root.";
assert caches.get(2).peek(BuddyManager.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have self as a backup root.";
assert caches.get(2).peek(BuddyManager.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
assert caches.get(2).peek(BuddyManager.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
- assert caches.get(2).peek(new Fqn(BuddyManager.getDeadBackupRoot(caches.get(0).getLocalAddress()), new Integer(1)), false) == null : "Should not have dead node as a defunct backup root.";
+ assert caches.get(2).peek(Fqn.fromRelativeElements(BuddyManager.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
}
System.out.println("***** Killed original data owner, about to call a get on a different cache instance. *****");
@@ -103,13 +103,13 @@
assert caches.get(1).peek(BuddyManager.getBackupRoot(caches.get(2).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
assert caches.get(1).peek(BuddyManager.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
assert caches.get(1).peek(BuddyManager.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
- assert caches.get(1).peek(new Fqn(BuddyManager.getDeadBackupRoot(caches.get(0).getLocalAddress()), new Integer(1)), false) == null : "Should not have dead node as a defunct backup root.";
+ assert caches.get(1).peek(Fqn.fromRelativeElements(BuddyManager.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
assert caches.get(1).peek(BuddyManager.getDeadBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a defunct backup root.";
assert caches.get(2).peek(BuddyManager.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have self as a backup root.";
assert caches.get(2).peek(BuddyManager.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
assert caches.get(2).peek(BuddyManager.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
- assert caches.get(2).peek(new Fqn(BuddyManager.getDeadBackupRoot(caches.get(0).getLocalAddress()), new Integer(1)), false) == null : "Should not have dead node as a defunct backup root.";
+ assert caches.get(2).peek(Fqn.fromRelativeElements(BuddyManager.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
}
assertTrue("Should be false", !caches.get(1).exists(fqn));
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java 2008-04-10 23:33:56 UTC (rev 5529)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ConcurrentEvictionTest.java 2008-04-11 11:29:00 UTC (rev 5530)
@@ -11,8 +11,11 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
+import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.config.*;
import org.jboss.cache.misc.TestingUtil;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.fail;
@@ -20,10 +23,10 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Properties;
-import java.util.List;
-import java.util.ArrayList;
-import java.io.IOException;
/**
* Tests cache behavior in the presence of concurrent passivation.
@@ -72,7 +75,7 @@
CacheLoaderConfig.IndividualCacheLoaderConfig iclc = new CacheLoaderConfig.IndividualCacheLoaderConfig();
iclc.setClassName("org.jboss.cache.loader.FileCacheLoader");
Properties p = new Properties();
- p.put("location", tmpDir + cacheLoaderDir);
+ p.put("location", tmpDir + cacheLoaderDir);
iclc.setProperties(p);
iclc.setAsync(false);
iclc.setFetchPersistentState(true);
@@ -87,7 +90,7 @@
ec.setDefaultEvictionPolicyClass("org.jboss.cache.eviction.LRUPolicy");
ec.setWakeupIntervalSeconds(5);
- EvictionRegionConfig erc = UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("_default_", 5000, 1000);
+ EvictionRegionConfig erc = UnitTestCacheConfigurationFactory.buildLruEvictionRegionConfig("_default_", 5000, 1000);
List<EvictionRegionConfig> erConfigs = new ArrayList<EvictionRegionConfig>();
erConfigs.add(erc);
ec.setEvictionRegionConfigs(erConfigs);
@@ -110,7 +113,7 @@
// region's maxNodes so we know eviction will kick in
for (int i = 0; i < 1000; i++)
{
- cache_.put(new Fqn<Object>(base, i / 100), i, "value");
+ cache_.put(Fqn.fromRelativeElements(base, i / 100), i, "value");
}
// Loop for long enough to have 5 runs of the eviction thread
@@ -120,7 +123,7 @@
// If any get returns null, that's a failure
for (int i = 0; i < 1000; i++)
{
- Fqn<Object> fqn = new Fqn<Object>(base, i / 100);
+ Fqn<Object> fqn = Fqn.fromRelativeElements(base, i / 100);
Integer key = i;
assertNotNull("found value under Fqn " + fqn + " and key " + key,
cache_.get(fqn, key));
Modified: core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java 2008-04-10 23:33:56 UTC (rev 5529)
+++ core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java 2008-04-11 11:29:00 UTC (rev 5530)
@@ -491,18 +491,18 @@
startLoader(false, null);
- checkChildren(new Fqn<String>(), null);
+ checkChildren(Fqn.ROOT, null);
checkChildren(Fqn.fromString("/key0"), null);
loader.put(Fqn.fromString("/key0"), null);
- checkChildren(new Fqn<String>(), new String[]{"key0"});
+ checkChildren(Fqn.ROOT, new String[]{"key0"});
loader.put(Fqn.fromString("/key1/x"), null);
- checkChildren(new Fqn<String>(), new String[]{"key0", "key1"});
+ checkChildren(Fqn.ROOT, new String[]{"key0", "key1"});
checkChildren(Fqn.fromString("/key1"), new String[]{"x"});
loader.remove(Fqn.fromString("/key1/x"));
- checkChildren(new Fqn<String>(), new String[]{"key0", "key1"});
+ checkChildren(Fqn.ROOT, new String[]{"key0", "key1"});
checkChildren(Fqn.fromString("/key0"), null);
checkChildren(Fqn.fromString("/key1"), null);
@@ -533,7 +533,7 @@
"\u0000", "\u0001"});
loader.put(Fqn.fromString("/\u0001"), null);
- checkChildren(new Fqn<String>(), new String[]{"key0", "key1", "\u0001"});
+ checkChildren(Fqn.ROOT, new String[]{"key0", "key1", "\u0001"});
loader.put(Fqn.fromString("/\u0001/\u0001"), null);
checkChildren(Fqn.fromString("/\u0001"), new String[]{"\u0001"});
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-04-10 23:33:56 UTC (rev 5529)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-04-11 11:29:00 UTC (rev 5530)
@@ -1400,21 +1400,21 @@
throws Exception
{
- checkChildren(new Fqn(), null);
+ checkChildren(Fqn.ROOT, null);
checkChildren(Fqn.fromString("/key0"), null);
loader.put(Fqn.fromString("/key0"), null);
addDelay();
- checkChildren(new Fqn(), new String[]{"key0"});
+ checkChildren(Fqn.ROOT, new String[]{"key0"});
loader.put(Fqn.fromString("/key1/x"), null);
addDelay();
- checkChildren(new Fqn(), new String[]{"key0", "key1"});
+ checkChildren(Fqn.ROOT, new String[]{"key0", "key1"});
checkChildren(Fqn.fromString("/key1"), new String[]{"x"});
loader.remove(Fqn.fromString("/key1/x"));
addDelay();
- checkChildren(new Fqn(), new String[]{"key0", "key1"});
+ checkChildren(Fqn.ROOT, new String[]{"key0", "key1"});
checkChildren(Fqn.fromString("/key0"), null);
checkChildren(Fqn.fromString("/key1"), null);
@@ -1448,7 +1448,7 @@
// "\u0000", "\u0001"});
//
// loader.put(Fqn.fromString("/\u0001"), null);
- // checkChildren(new Fqn(), new String[] { "key0", "key1", "\u0001" });
+ // checkChildren(Fqn.ROOT, new String[] { "key0", "key1", "\u0001" });
//
// loader.put(Fqn.fromString("/\u0001/\u0001"), null);
// checkChildren(Fqn.fromString("/\u0001"), new String[] { "\u0001" });
Modified: core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-04-10 23:33:56 UTC (rev 5529)
+++ core/trunk/src/test/java/org/jboss/cache/loader/ClusteredCacheLoaderTest.java 2008-04-11 11:29:00 UTC (rev 5530)
@@ -158,9 +158,9 @@
public void testGetChildrenNames() throws Exception
{
cache1.put(fqn, key, "value");
- Fqn<String> child1 = new Fqn<String>(fqn, "child1");
- Fqn<String> child2 = new Fqn<String>(fqn, "child2");
- Fqn<String> child3 = new Fqn<String>(fqn, "child3");
+ Fqn child1 = Fqn.fromRelativeElements(fqn, "child1");
+ Fqn child2 = Fqn.fromRelativeElements(fqn, "child2");
+ Fqn child3 = Fqn.fromRelativeElements(fqn, "child3");
cache1.put(child1, key, "value");
cache1.put(child2, key, "value");
cache1.put(child3, key, "value");
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-04-10 23:33:56 UTC (rev 5529)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-04-11 11:29:00 UTC (rev 5530)
@@ -13,8 +13,8 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
-import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.misc.TestingUtil;
import static org.testng.AssertJUnit.*;
@@ -39,7 +39,7 @@
Configuration c;
Fqn<String> A = Fqn.fromString("/a");
Fqn<String> I = Fqn.fromString("/i");
- Fqn<String> A_B = new Fqn<String>(A, "b");
+ Fqn A_B = Fqn.fromRelativeElements(A, "b");
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-04-10 23:33:56 UTC (rev 5529)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-04-11 11:29:00 UTC (rev 5530)
@@ -235,7 +235,7 @@
// replication queue takes a list of replicate() MethodCalls and wraps them in a single replicate call.
List<MethodCall> calls = new ArrayList<MethodCall>();
- Fqn f = new Fqn<Object>("BlahBlah", 3, false);
+ Fqn f = Fqn.fromElements("BlahBlah", 3, false);
String k = "key", v = "value";
MethodCall actualCall = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal_id, null, f, k, v, true);
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/ReplicatedTransactionDeadlockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/ReplicatedTransactionDeadlockTest.java 2008-04-10 23:33:56 UTC (rev 5529)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/ReplicatedTransactionDeadlockTest.java 2008-04-11 11:29:00 UTC (rev 5530)
@@ -5,7 +5,6 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -215,7 +214,7 @@
log.warn("begin");
tx.begin();
log.warn("put");
- srcCache.put(new Fqn<String>("Node"), Boolean.FALSE, Boolean.TRUE);
+ srcCache.put("/Node", Boolean.FALSE, Boolean.TRUE);
log.warn("commit");
tx.commit();
log.warn("leave");
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java 2008-04-10 23:33:56 UTC (rev 5529)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java 2008-04-11 11:29:00 UTC (rev 5530)
@@ -1022,7 +1022,7 @@
public void testRootNodeRemoval() throws Exception
{
Fqn root = Fqn.ROOT;
- Fqn<Integer> fqn = new Fqn<Integer>(1);
+ Fqn<Integer> fqn = Fqn.fromElements(1);
//put first time
tx.begin();
this.cache.put(fqn, "k", "v");
@@ -1076,7 +1076,7 @@
{
@SuppressWarnings("unchecked")
Fqn<Object> root = Fqn.ROOT;
- Fqn<Object> fqn = new Fqn<Object>(root, 1);
+ Fqn<Object> fqn = Fqn.fromRelativeElements(root, 1);
//put first time
tx.begin();
this.cache.put(fqn, "k", "v");
16 years, 9 months
JBoss Cache SVN: r5529 - in core/trunk/src: main/java/org/jboss/cache/loader/bdbje and 18 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-10 19:33:56 -0400 (Thu, 10 Apr 2008)
New Revision: 5529
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java
core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java
core/trunk/src/test/java/org/jboss/cache/FqnTest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java
core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
core/trunk/src/test/java/org/jboss/cache/integration/hibernate/HibernateIntegrationTestUtil.java
core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java
core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ComparatorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java
Log:
Updated code that uses deprecated Fqn constructors
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -1,5 +1,6 @@
package org.jboss.cache.interceptors;
+import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Modification;
@@ -9,8 +10,8 @@
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.cachedata.RemoveKeyCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
@@ -25,7 +26,6 @@
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
-import org.apache.commons.logging.LogFactory;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
@@ -327,7 +327,7 @@
{
for (Object child : childrenNames)
{
- recursiveMove(new Fqn(fqn, child), new Fqn(newFqn, child));
+ recursiveMove(Fqn.fromRelativeElements(fqn, child), Fqn.fromRelativeElements(newFqn, child));
}
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -6,12 +6,18 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.*;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeFactory;
+import org.jboss.cache.NodeNotExistsException;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.TxCacheCommand;
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.invocation.CacheData;
import org.jboss.cache.loader.CacheLoaderManager;
@@ -22,7 +28,6 @@
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.apache.commons.logging.LogFactory;
import java.util.Collections;
import java.util.HashMap;
@@ -100,7 +105,8 @@
if (workspaceNode != null)
{
setVersioning(ctx, workspace, workspaceNode);
- } else
+ }
+ else
{
// "fail-more-silently" patch thanks to Owen Taylor - JBCACHE-767
if ((ctx.getOptionOverrides() == null || !ctx.getOptionOverrides().isFailSilently()))
@@ -121,7 +127,8 @@
if (workspaceNode != null)
{
setVersioning(ctx, workspace, workspaceNode);
- } else
+ }
+ else
{
// "fail-more-silently" patch thanks to Owen Taylor - JBCACHE-767
if ((ctx.getOptionOverrides() == null || !ctx.getOptionOverrides().isFailSilently()))
@@ -192,7 +199,8 @@
{
if (trace) log.debug("Unable to find node " + command.getFqn() + " in workspace.");
result = null;
- } else
+ }
+ else
{
//add this node into the wrokspace
notifier.notifyNodeVisited(command.getFqn(), true, ctx);
@@ -214,7 +222,8 @@
{
if (trace) log.trace("unable to find node " + fqn + " in workspace.");
result = null;
- } else
+ }
+ else
{
notifier.notifyNodeVisited(fqn, true, ctx);
Object keySet = workspaceNode.getKeys();
@@ -234,7 +243,8 @@
{
if (trace) log.trace("unable to find node " + command.getFqn() + " in workspace.");
result = null;
- } else
+ }
+ else
{
notifier.notifyNodeVisited(command.getFqn(), true, ctx);
Object data = workspaceNode.getData();
@@ -254,7 +264,8 @@
{
if (trace) log.trace("Unable to find node " + command.getFqn() + " in workspace.");
result = null;
- } else
+ }
+ else
{
notifier.notifyNodeVisited(command.getFqn(), true, ctx);
Object nameSet = workspaceNode.getChildrenNames();
@@ -274,11 +285,13 @@
{
if (trace) log.trace("Unable to find node " + command.getFqn() + " in workspace.");
result = null;
- } else if (workspaceNode.isDeleted())
+ }
+ else if (workspaceNode.isDeleted())
{
if (trace) log.trace("Attempted to retrieve node " + command.getFqn() + " but it has been deleted!");
result = null;
- } else
+ }
+ else
{
notifier.notifyNodeVisited(command.getFqn(), true, ctx);
workspace.addNode(workspaceNode);
@@ -300,7 +313,8 @@
if (trace) log.trace("Setting versioning for node " + workspaceNode.getFqn() + " to explicit");
workspaceNode.setVersioningImplicit(false);
- } else
+ }
+ else
{
if (trace) log.trace("Setting versioning for node " + workspaceNode.getFqn() + " to implicit");
workspaceNode.setVersioningImplicit(true);
@@ -375,11 +389,11 @@
// now that we have the parent and target nodes:
// first correct the pointers at the pruning point
- oldParent.removeChild(new Fqn(nodeName));
+ oldParent.removeChild(nodeName);
// parent pointer is calculated on the fly using Fqns.
// now adjust Fqns of node and all children.
- Fqn nodeNewFqn = new Fqn(parent.getFqn(), nodeFqn.getLastElement());
+ Fqn nodeNewFqn = Fqn.fromRelativeElements(parent.getFqn(), nodeFqn.getLastElement());
// pre-notify
notifier.notifyNodeMoved(nodeFqn, nodeNewFqn, true, ctx);
@@ -401,14 +415,14 @@
*/
private void recursiveMoveNode(InvocationContext ctx, WorkspaceNode node, Fqn newBase, TransactionWorkspace ws)
{
- Fqn newFqn = new Fqn(newBase, node.getFqn().getLastElement());
+ Fqn newFqn = Fqn.fromRelativeElements(newBase, node.getFqn().getLastElement());
WorkspaceNode movedNode = fetchWorkspaceNode(ctx, newFqn, ws, true, true);
movedNode.putAll(node.getData());
// invoke children
for (Object n : node.getChildrenNames())
{
- WorkspaceNode child = fetchWorkspaceNode(ctx, new Fqn(node.getFqn(), n), ws, false, true);
+ WorkspaceNode child = fetchWorkspaceNode(ctx, Fqn.fromRelativeElements(node.getFqn(), n), ws, false, true);
if (child != null) recursiveMoveNode(ctx, child, newFqn, ws);
}
}
@@ -467,7 +481,8 @@
{
if (trace) log.trace("marking node " + toDelete.getFqn() + " as deleted");
toDelete.markAsDeleted(true);
- } else
+ }
+ else
{
break;// no more children, we came to the end
}
@@ -553,7 +568,8 @@
if (undeleteIfNecessary)
{
undeleteWorkspaceNode(workspaceNode, fetchWorkspaceNode(ctx, fqn.getParent(), workspace, true, includeInvalidNodes));
- } else
+ }
+ else
{
// don't return deleted nodes if undeleteIfNecessary is false!
workspaceNode = null;
Modified: core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -700,7 +700,7 @@
{
for (String child : children)
{
- doRemove(txn, new Fqn(child));
+ doRemove(txn, Fqn.fromElements(child));
}
}
}
@@ -1020,7 +1020,7 @@
while (tupleInput.available() > 0)
{
String part = tupleInput.readString();
- name = new Fqn(name, part);
+ name = Fqn.fromRelativeElements(name, part);
}
return name;
}
Modified: core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/main/java/org/jboss/cache/loader/jdbm/JdbmCacheLoader.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -239,7 +239,7 @@
*/
private Fqn keys(Fqn name)
{
- return new Fqn(name, KEYS);
+ return Fqn.fromRelativeElements(name, KEYS);
}
/**
@@ -247,7 +247,7 @@
*/
private Fqn key(Fqn name, Object key)
{
- return new Fqn(name, KEYS, nullMask(key));
+ return Fqn.fromRelativeElements(name, KEYS, nullMask(key));
}
/**
@@ -663,7 +663,7 @@
BTree bt = tree;
int size = (bt == null) ? -1 : bt.size();
return "JdbmCacheLoader locationStr=" + config.getLocation() +
- " size=" + size;
+ " size=" + size;
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -1,13 +1,5 @@
package org.jboss.cache.loader.s3;
-import java.io.BufferedInputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import net.jcip.annotations.ThreadSafe;
import net.noderunner.amazon.s3.Bucket;
import net.noderunner.amazon.s3.Connection;
@@ -16,14 +8,21 @@
import net.noderunner.amazon.s3.ListResponse;
import net.noderunner.amazon.s3.Response;
import net.noderunner.amazon.s3.S3Object;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.loader.AbstractCacheLoader;
+import java.io.BufferedInputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
/**
* Uses the Amazon S3 service for storage.
* See http://aws.amazon.com/ for information.
@@ -53,7 +52,6 @@
* parent nodes, this can potentially need to inconsistencies. To disable caching,
* set {@link S3LoaderConfig#setParentCache} to false.
* <p/>
- *
*
* @author Elias Ross
* @version $Id: JdbmCacheLoader.java 4298 2007-08-15 18:30:00Z genman $
@@ -83,7 +81,7 @@
* Zero depth prefix.
*/
private final char DEPTH_0 = 'A';
-
+
/**
* Stateless connection; thread safe.
*/
@@ -93,6 +91,7 @@
* Map classes to characters.
*/
private static Map<Class<?>, Character> prefix = new HashMap<Class<?>, Character>();
+
static
{
prefix.put(Byte.class, 'B');
@@ -435,7 +434,7 @@
log.trace("remove children: " + children);
for (String child : children)
{
- remove(new Fqn(name, child));
+ remove(Fqn.fromRelativeElements(name, child));
}
}
Response response = connection.delete(getBucket(), key(name));
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-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CacheMarshaller200.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -17,7 +17,11 @@
import org.jgroups.Address;
import org.jgroups.stack.IpAddress;
-import java.io.*;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
import java.util.*;
/**
@@ -65,7 +69,6 @@
protected CommandMarshaller commandMarshaller;
-
// -------- AbstractMarshaller interface
public void objectToObjectStream(Object o, ObjectOutputStream out) throws Exception
@@ -683,7 +686,7 @@
{
elements.add(unmarshallObject(in, refMap));
}
- fqn = new Fqn(elements, true);
+ fqn = Fqn.fromList(elements);
}
else
{
Modified: core/trunk/src/test/java/org/jboss/cache/FqnTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/FqnTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/FqnTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -44,7 +44,7 @@
public void testNull()
{
- Fqn fqn = new Fqn();
+ Fqn fqn = Fqn.ROOT;
log("null fqn is " + fqn);
assert 0 == fqn.size();
int hcode = fqn.hashCode();
@@ -53,7 +53,7 @@
public void testOne()
{
- Fqn<Integer> fqn = new Fqn<Integer>(22);
+ Fqn<Integer> fqn = Fqn.fromElements(22);
log("one fqn is " + fqn);
assert 1 == fqn.size();
int hcode = fqn.hashCode();
@@ -62,8 +62,8 @@
public void testEmptyFqn()
{
- Fqn f1 = new Fqn();
- Fqn f2 = new Fqn();
+ Fqn f1 = Fqn.ROOT;
+ Fqn f2 = Fqn.ROOT;
assert f1.equals(f2);
}
@@ -73,7 +73,7 @@
log("fqn is " + fqn);
assert 3 == fqn.size();
- Fqn<String> fqn2 = new Fqn<String>("a", "b", "c");
+ Fqn<String> fqn2 = Fqn.fromElements("a", "b", "c");
log("fqn2 is " + fqn2);
assert 3 == fqn.size();
assert fqn.equals(fqn2);
@@ -82,11 +82,11 @@
public void testHereogeneousNames()
{
- Fqn<Object> fqn = new Fqn<Object>("string", 38, true);
+ Fqn fqn = Fqn.fromElements("string", 38, true);
log("fqn is " + fqn);
assert 3 == fqn.size();
- Fqn<Object> fqn2 = new Fqn<Object>("string", 38, true);
+ Fqn fqn2 = Fqn.fromElements("string", 38, true);
assert fqn.equals(fqn2);
assert fqn.hashCode() == fqn2.hashCode();
}
@@ -94,7 +94,7 @@
public void testHashcode()
{
Fqn fqn1, fqn2;
- fqn1 = new Fqn<Object>("a", "b", "c");
+ fqn1 = Fqn.fromElements("a", "b", "c");
fqn2 = Fqn.fromString("/a/b/c");
log("fqn is " + fqn1);
assert fqn1.equals(fqn2);
@@ -108,7 +108,7 @@
public void testHashcode2()
{
- Fqn<Integer> fqn = new Fqn<Integer>(-1);
+ Fqn<Integer> fqn = Fqn.fromElements(-1);
log("one fqn is " + fqn);
assert fqn.size() == 1;
int hcode = fqn.hashCode();
@@ -117,24 +117,22 @@
public void testEquals()
{
- Fqn<String> fqn1 = new Fqn<String>("person/test");
+ Fqn<String> fqn1 = Fqn.fromElements("person/test");
- Fqn<String> f1;
- Fqn<String> f2;
- Fqn<String> f3;
+ Fqn f1, f2, f3;
- f1 = new Fqn<String>(fqn1, "0");
- f2 = new Fqn<String>(fqn1, "1");
- f3 = new Fqn<String>(fqn1, "2");
+ f1 = Fqn.fromRelativeElements(fqn1, "0");
+ f2 = Fqn.fromRelativeElements(fqn1, "1");
+ f3 = Fqn.fromRelativeElements(fqn1, "2");
- HashMap<Fqn<String>, String> map = new HashMap<Fqn<String>, String>();
+ HashMap<Fqn, String> map = new HashMap<Fqn, String>();
map.put(f1, "0");
map.put(f2, "1");
map.put(f3, "2");
- assert map.get(new Fqn<String>(fqn1, "0")) != null;
- assert map.get(new Fqn<String>(fqn1, "1")) != null;
- assert map.get(new Fqn<String>(fqn1, "2")) != null;
+ assert map.get(Fqn.fromRelativeElements(fqn1, "0")) != null;
+ assert map.get(Fqn.fromRelativeElements(fqn1, "1")) != null;
+ assert map.get(Fqn.fromRelativeElements(fqn1, "2")) != null;
}
@@ -163,27 +161,27 @@
public void testEquals3()
{
- Fqn<Object> f1;
+ Fqn f1;
Fqn<?> f2;
- f1 = new Fqn<Object>("a", 322649, Boolean.TRUE);
- f2 = new Fqn<String>();
+ f1 = Fqn.fromElements("a", 322649, Boolean.TRUE);
+ f2 = Fqn.ROOT;
assert !f1.equals(f2);
assert !f2.equals(f1);
f2 = Fqn.fromString("a/322649/TRUE");
assert !f1.equals(f2);
- f2 = new Fqn<Object>("a", 322649, Boolean.FALSE);
+ f2 = Fqn.fromElements("a", 322649, Boolean.FALSE);
assert !f1.equals(f2);
- f2 = new Fqn<Object>("a", 322649, Boolean.TRUE);
+ f2 = Fqn.fromElements("a", 322649, Boolean.TRUE);
assert f1.equals(f2);
}
public void testEquals3WithMarshalling() throws Exception
{
- Fqn<Object> f1, f2;
- f1 = new Fqn<Object>("a", 322649, Boolean.TRUE);
+ Fqn f1, f2;
+ f1 = Fqn.fromElements("a", 322649, Boolean.TRUE);
f2 = marshalAndUnmarshal(f1);
assert f1.equals(f2);
assert f2.equals(f1);
@@ -192,11 +190,11 @@
f3 = marshalAndUnmarshal(f3);
assert !f1.equals(f3);
- f2 = new Fqn<Object>("a", 322649, Boolean.FALSE);
+ f2 = Fqn.fromElements("a", 322649, Boolean.FALSE);
f2 = marshalAndUnmarshal(f2);
assert !f1.equals(f2);
- f2 = new Fqn<Object>("a", 322649, Boolean.TRUE);
+ f2 = Fqn.fromElements("a", 322649, Boolean.TRUE);
f2 = marshalAndUnmarshal(f2);
assert f1.equals(f2);
}
@@ -210,7 +208,6 @@
assert !fqn.equals(null);
}
- @Test(groups = {"functional"})
public void testClone() throws CloneNotSupportedException
{
Fqn<String> fqn1 = Fqn.fromString("/a/b/c");
@@ -221,13 +218,13 @@
public void testNullElements() throws CloneNotSupportedException
{
- Fqn<Object> fqn0 = new Fqn<Object>((Object) null);
+ Fqn<Object> fqn0 = Fqn.fromElements((Object) null);
assert 1 == fqn0.size();
- Fqn<Object> fqn1 = new Fqn<Object>("NULL", null, 0);
+ Fqn fqn1 = Fqn.fromElements("NULL", null, 0);
assert 3 == fqn1.size();
- Fqn<Object> fqn2 = new Fqn<Object>("NULL", null, 0);
+ Fqn fqn2 = Fqn.fromElements("NULL", null, 0);
assert fqn1.hashCode() == fqn2.hashCode();
assert fqn1.equals(fqn2);
assert fqn1.equals(fqn1.clone());
@@ -237,12 +234,12 @@
{
Fqn<String> fqn = Fqn.fromString("/a/b/c");
assert 3 == fqn.size();
- Fqn<Object> tmp_fqn = new Fqn<Object>();
+ Fqn<Object> tmp_fqn = Fqn.ROOT;
assert 0 == tmp_fqn.size();
for (int i = 0; i < fqn.size(); i++)
{
String s = fqn.get(i);
- tmp_fqn = new Fqn<Object>(tmp_fqn, s);
+ tmp_fqn = Fqn.fromRelativeElements(tmp_fqn, s);
assert tmp_fqn.size() == i + 1;
}
assert 3 == tmp_fqn.size();
@@ -270,7 +267,7 @@
public void testParentage()
{
- Fqn<String> fqnRoot = new Fqn<String>();
+ Fqn<String> fqnRoot = Fqn.ROOT;
Fqn<String> parent = fqnRoot.getParent();
assert parent.equals(fqnRoot);
@@ -293,7 +290,7 @@
public void testRoot()
{
- Fqn<String> fqn = new Fqn<String>();
+ Fqn<String> fqn = Fqn.ROOT;
assert fqn.isRoot();
fqn = Fqn.fromString("/one/two");
@@ -302,11 +299,11 @@
public void testGetName()
{
- Fqn<Integer> integerFqn = new Fqn<Integer>(1);
+ Fqn<Integer> integerFqn = Fqn.fromElements(1);
assert "1".equals(integerFqn.getLastElementAsString());
Object object = new Object();
- Fqn<Object> objectFqn = new Fqn<Object>(object);
+ Fqn<Object> objectFqn = Fqn.fromElements(object);
assert object.toString().equals(objectFqn.getLastElementAsString());
}
@@ -316,16 +313,15 @@
assert f.equals(f.clone());
}
- @Test(groups = {"functional"})
public void testCloningOtherTypes() throws CloneNotSupportedException
{
- Fqn<Object> f = new Fqn<Object>("blah", 10, Boolean.TRUE);
+ Fqn f = Fqn.fromElements("blah", 10, Boolean.TRUE);
assert f.equals(f.clone());
}
public void testRemovalNonString() throws Exception
{
- Fqn<Object> f = new Fqn<Object>("test", 1);
+ Fqn f = Fqn.fromElements("test", 1);
Configuration c = new Configuration();
c.setCacheMode("LOCAL");
@@ -358,16 +354,16 @@
assert f.equals(f2);
- Fqn<Integer> f3 = new Fqn<Integer>(1, 2, 3, 5);
+ Fqn<Integer> f3 = Fqn.fromElements(1, 2, 3, 5);
- Fqn<Integer> f4 = new Fqn<Integer>(1, 2, 3);
+ Fqn<Integer> f4 = Fqn.fromElements(1, 2, 3);
assert f3.getParent().equals(f4);
}
public void testSize()
{
- Fqn f = new Fqn();
+ Fqn f = Fqn.ROOT;
assert f.size() == 0;
assert f.isRoot();
@@ -380,18 +376,35 @@
assert !f.isRoot();
}
+// public void testIntermediateFqns()
+// {
+// Fqn lastCreated = Fqn.fromString("/a/b");
+// Fqn target = Fqn.fromString("/a/b/c/d/e/f");
+//
+// List<Fqn> intermediates = new ArrayList<Fqn>();
+// intermediates.add(Fqn.fromString("/a/b/c"));
+// intermediates.add(Fqn.fromString("/a/b/c/d"));
+// intermediates.add(Fqn.fromString("/a/b/c/d/e"));
+//
+// System.out.println("Expecting " + intermediates);
+// System.out.println("Was: " + target.getIntermediateFqns(lastCreated));
+//
+// assert target.getIntermediateFqns(lastCreated).equals(intermediates);
+// }
+
+ //
public void testGenerations()
{
- Fqn<Integer> f = new Fqn<Integer>(1, 2, 3, 4, 5, 6, 7);
+ Fqn<Integer> f = Fqn.fromElements(1, 2, 3, 4, 5, 6, 7);
assert f.equals(f.getAncestor(f.size()));
assert f.getParent().equals(f.getAncestor(f.size() - 1));
assert Fqn.ROOT.equals(f.getAncestor(0));
- assert new Fqn<Integer>(1).equals(f.getAncestor(1));
- assert new Fqn<Integer>(1, 2).equals(f.getAncestor(2));
- assert new Fqn<Integer>(1, 2, 3).equals(f.getAncestor(3));
- assert new Fqn<Integer>(1, 2, 3, 4).equals(f.getAncestor(4));
- assert new Fqn<Integer>(1, 2, 3, 4, 5).equals(f.getAncestor(5));
+ assert Fqn.fromElements(1).equals(f.getAncestor(1));
+ assert Fqn.fromElements(1, 2).equals(f.getAncestor(2));
+ assert Fqn.fromElements(1, 2, 3).equals(f.getAncestor(3));
+ assert Fqn.fromElements(1, 2, 3, 4).equals(f.getAncestor(4));
+ assert Fqn.fromElements(1, 2, 3, 4, 5).equals(f.getAncestor(5));
try
{
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -16,7 +16,11 @@
import org.testng.annotations.Test;
import javax.transaction.TransactionManager;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* Tests {@link org.jboss.cache.Node}-centric operations
@@ -229,8 +233,8 @@
public void testGetChildrenUnderTx() throws Exception
{
- Fqn<String> A_B = new Fqn<String>(A, B);
- Fqn<String> A_C = new Fqn<String>(A, C);
+ Fqn A_B = Fqn.fromRelativeFqn(A, B);
+ Fqn A_C = Fqn.fromRelativeFqn(A, C);
tm.begin();
cache.put(A_B, "1", "1");
cache.put(A_C, "2", "2");
@@ -285,7 +289,7 @@
assertEquals("value", rootNode.getChild(A).getChild(B).get("key"));
assertEquals("value", rootNode.getChild(A).getChild(B).getChild(C).get("key"));
- assertNull(rootNode.getChild(new Fqn<String>("nonexistent")));
+ assertNull(rootNode.getChild(Fqn.fromElements("nonexistent")));
}
public void testClearingData()
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -110,7 +110,7 @@
assertEquals(vB, cache1.getRoot().getChild(A).getChild(B).get(k));
assertInvalidated(cache2, A, "Should be invalidated");
- assertInvalidated(cache2, new Fqn(A, B.getLastElement()), "Should be invalidated");
+ assertInvalidated(cache2, Fqn.fromRelativeElements(A, B.getLastElement()), "Should be invalidated");
// now move...
cache1.move(nodeB.getFqn(), Fqn.ROOT);
@@ -138,7 +138,7 @@
public void testReplTxCommit() throws Exception
{
- Fqn A_B = new Fqn<String>(A, B);
+ Fqn A_B = Fqn.fromRelativeFqn(A, B);
nodeA = rootNode.addChild(A);
nodeB = nodeA.addChild(B);
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeSPITest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -116,7 +116,7 @@
// put some stuff in the root node
String childName = "childName";
String newChild = "newChild";
- root.addChild(new Fqn<String>(childName));
+ root.addChild(Fqn.fromElements(childName));
Set childrenDirect = root.getChildrenDirect();
try
@@ -130,7 +130,7 @@
}
// now test defensive copy
- root.addChild(new Fqn<String>(newChild));
+ root.addChild(Fqn.fromElements(newChild));
assertTrue("root.addChild() should have succeeded", root.getChildrenNamesDirect().contains(newChild));
assertTrue("getChildrenDirect() should have made a defensive copy of the data collection object", !childrenDirect.contains(newChild));
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -119,13 +119,11 @@
Fqn mainD = Fqn.fromString("/d/e/f");
caches.get(0).put(mainD, "name", "Joe");
- Fqn group = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
- BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress()));
- Fqn testA = new Fqn(group, mainA);
+ Fqn testA = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), mainA);
assertEquals("/a replicated", "Joe", caches.get(1).get(testA, "name"));
assertNull("No backup of /a", caches.get(2).get(testA, "name"));
- Fqn testD = new Fqn(group, mainD);
+ Fqn testD = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), mainD);
assertEquals("/d replicated", "Joe", caches.get(1).get(testD, "name"));
assertNull("No backup of /d", caches.get(2).get(testD, "name"));
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -114,8 +114,8 @@
regionA.registerContextClassLoader(getClass().getClassLoader());
regionA.activate();
- Fqn<String> fqn = new Fqn<String>(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
- fqn = new Fqn<String>(fqn, A_B);
+ Fqn fqn = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
+ fqn = Fqn.fromRelativeFqn(fqn, A_B);
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cache1.put(fqn, "name", JOE);
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -140,11 +140,11 @@
System.out.println("*** Testing cache 1:");
assertIsBuddy(caches.get(1), caches.get(0), true);
- assert caches.get(0).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress())), false) == null : "Should not have backup region for self";
- assert caches.get(0).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(1).getLocalAddress())), false) != null : "Should have backup region for buddy";
+ assert caches.get(0).peek(BuddyManager.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for self";
+ assert caches.get(0).peek(BuddyManager.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have backup region for buddy";
- assert caches.get(1).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress())), false) != null : "Should have backup region for buddy";
- assert caches.get(1).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(1).getLocalAddress())), false) == null : "Should not have backup region for self";
+ assert caches.get(1).peek(BuddyManager.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have backup region for buddy";
+ assert caches.get(1).peek(BuddyManager.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have backup region for self";
caches.add(createCache(1, null));
@@ -162,17 +162,17 @@
System.out.println("1 Lock info: " + CachePrinter.printCacheLockingInfo(caches.get(1)));
System.out.println("2 Lock info: " + CachePrinter.printCacheLockingInfo(caches.get(2)));
- assert caches.get(0).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress())), false) == null : "Should not have backup region for self";
- assert caches.get(0).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(1).getLocalAddress())), false) == null : "Should have backup region for non-buddy";
- assert caches.get(0).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(2).getLocalAddress())), false) != null : "Should have backup region for buddy";
+ assert caches.get(0).peek(BuddyManager.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for self";
+ assert caches.get(0).peek(BuddyManager.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should have backup region for non-buddy";
+ assert caches.get(0).peek(BuddyManager.getBackupRoot(caches.get(2).getLocalAddress()), false) != null : "Should have backup region for buddy";
- assert caches.get(1).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress())), false) != null : "Should have backup region for buddy";
- assert caches.get(1).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(1).getLocalAddress())), false) == null : "Should not have backup region for self";
- assert caches.get(1).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(2).getLocalAddress())), false) == null : "Should not have backup region for non-buddy";
+ assert caches.get(1).peek(BuddyManager.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have backup region for buddy";
+ assert caches.get(1).peek(BuddyManager.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have backup region for self";
+ assert caches.get(1).peek(BuddyManager.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have backup region for non-buddy";
- assert caches.get(2).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress())), false) == null : "Should not have backup region for non-buddy";
- assert caches.get(2).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(1).getLocalAddress())), false) != null : "Should have backup region for buddy";
- assert caches.get(2).peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE, BuddyManager.getGroupNameFromAddress(caches.get(2).getLocalAddress())), false) == null : "Should not have backup region for self";
+ assert caches.get(2).peek(BuddyManager.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for non-buddy";
+ assert caches.get(2).peek(BuddyManager.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have backup region for buddy";
+ assert caches.get(2).peek(BuddyManager.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have backup region for self";
// ensure no state transfer has happened!!
assert caches.get(2).peek(Fqn.fromString("/cache0"), false) == null : "Unnecessary state should not have been transferred!";
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-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -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.CacheCommand;
import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.config.BuddyReplicationConfig;
@@ -31,6 +31,7 @@
{
CommandsFactory commandsFactory = new CommandsFactory();
+
/**
* Constructs a buddy manager using the default buddy locator but with some specific properties.
*
@@ -202,7 +203,7 @@
public void testGetActualFqn()
{
- Fqn<String> x = new Fqn<String>("x");
+ Fqn<String> x = Fqn.fromString("/x");
Fqn backup = BuddyFqnTransformer.getBackupFqn("y", x);
assertEquals(x, BuddyFqnTransformer.getActualFqn(backup));
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/RemoveRootBuddyTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -27,7 +27,7 @@
{
String key = String.valueOf(opCount);
String value = String.valueOf(opCount);
- Fqn f = new Fqn("test", key);
+ Fqn f = Fqn.fromElements("test", key);
cache1.put(f, key, value);
}
cache1.removeNode(Fqn.ROOT);
Modified: core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/demo/JBossCacheGUI.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -569,7 +569,7 @@
/**
* Recursively adds GUI nodes starting from fqn
*/
- private void addGuiNode(Fqn<String> fqn)
+ private void addGuiNode(Fqn fqn)
{
Set<Object> children;
@@ -584,7 +584,7 @@
{
for (Object child_name : children)
{
- addGuiNode(new Fqn<String>(fqn, (String) child_name));
+ addGuiNode(Fqn.fromRelativeElements(fqn, child_name));
}
}
}
@@ -595,7 +595,7 @@
Fqn<String> fqnToPath;
if (path.length == 0) fqnToPath = Fqn.ROOT;
List<String> elements = convertMyNodeArrayToStringArray(path);
- fqnToPath = new Fqn<String>(elements);
+ fqnToPath = Fqn.fromList(elements);
if (root.hasChild(fqnToPath))
{
return root.getChild(fqnToPath);
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUPolicyTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -214,7 +214,7 @@
// then the child, leaving behind an empty parent
Fqn<String> parent = Fqn.fromString(rootStr + "parent");
cache.put(parent, "key", "value");
- cache.put(new Fqn<String>(parent, "child"), "key", "value");
+ cache.put(Fqn.fromRelativeElements(parent, "child"), "key", "value");
// Give eviction time to run a few times, then confirm parent
// is completely gone
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/OptimisticEvictionTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -3,14 +3,14 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.xml.XmlHelper;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.interceptors.EvictionInterceptor;
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import org.jboss.cache.xml.XmlHelper;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.AfterMethod;
@@ -39,7 +39,7 @@
//Initial number of nodes
private static final int NUMBER_NODES = 256;
- private Fqn<Object> region = new Fqn<Object>("testingRegion");
+ private Fqn region = Fqn.fromElements("testingRegion");
private TransactionManager txManager;
private CacheSPI<Object, Object> cache;
@@ -78,7 +78,7 @@
" </config>\n" +
" </attribute>";
Element element = XmlHelper.stringToElement(xml);
- return XmlConfigurationParser.parseEvictionConfig(element);
+ return XmlConfigurationParser.parseEvictionConfig(element);
}
@AfterMethod(alwaysRun = true)
@@ -109,7 +109,7 @@
//Initialize the cache via a map
for (int i = 0; i < NUMBER_NODES; i++)
{
- cache.put(new Fqn<Object>(region, i), i, i);
+ cache.put(Fqn.fromRelativeElements(region, i), i, i);
}
for (int i = 0; i < NUMBER_OF_RUNS; i++)
@@ -158,7 +158,7 @@
// then the child, leaving behind an empty parent
Fqn<String> parent = Fqn.fromString(rootStr + "parent");
cache.put(parent, "key", "value");
- cache.put(new Fqn<String>(parent, "child"), "key", "value");
+ cache.put(Fqn.fromRelativeElements(parent, "child"), "key", "value");
// Give eviction time to run a few times, then confirm parent
// is completely gone
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ProgrammaticLRUPolicyTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -23,12 +23,16 @@
package org.jboss.cache.eviction;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.RegionManager;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
-import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.xml.XmlHelper;
@@ -67,7 +71,7 @@
{
Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
CacheFactory<Object, Integer> instance = new DefaultCacheFactory();
- cache_ = (CacheSPI)instance.createCache(conf, false);
+ cache_ = (CacheSPI) instance.createCache(conf, false);
conf.getEvictionConfig().setWakeupIntervalSeconds(5);
cache_.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
cache_.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
@@ -135,7 +139,7 @@
topEC.getDefaultEventQueueSize());
// Fqn is the region name
Integer ii = 1;
- Fqn fqn = new Fqn<Integer>(ii);
+ Fqn fqn = Fqn.fromElements(ii);
regionManager.getRegion(fqn, true).setEvictionPolicy(erc.getEvictionPolicyConfig());
}
@@ -143,12 +147,12 @@
{
addStringBasedRegion();
- String rootStr = "/programmatic/";
+ String rootStr = "programmatic";
for (int i = 0; i < 10; i++)
{
String str = rootStr;
Integer in = i;
- Fqn<Object> fqn = new Fqn<Object>(new Fqn<Object>(str), in);
+ Fqn fqn = Fqn.fromElements(rootStr, in);
try
{
cache_.put(fqn, str, str);
@@ -161,7 +165,7 @@
}
Integer in = 3;
- Fqn<Object> fqn = new Fqn<Object>(new Fqn<Object>(rootStr), in);
+ Fqn fqn = Fqn.fromElements(rootStr, in);
try
{
String val = (String) cache_.get(fqn, in);
@@ -194,11 +198,11 @@
addObjectBasedRegion();
Integer ii = 1;
- Fqn<Object> rootfqn = new Fqn<Object>(ii);
+ Fqn<Integer> rootfqn = Fqn.fromElements(ii);
for (int i = 0; i < 10; i++)
{
Integer in = i;
- Fqn<Object> fqn = new Fqn<Object>(rootfqn, in);
+ Fqn<Object> fqn = Fqn.fromRelativeElements(rootfqn, in);
try
{
cache_.put(fqn, in, in);
@@ -213,7 +217,7 @@
try
{
Integer in = 3;
- Fqn<Object> fqn = new Fqn<Object>(rootfqn, in);
+ Fqn<Object> fqn = Fqn.fromRelativeElements(rootfqn, in);
Object val = cache_.get(fqn, in);
assertNotNull("DataNode should be empty ", val);
}
@@ -229,7 +233,7 @@
try
{
Integer in = 3;
- Fqn<Object> fqn = new Fqn<Object>(rootfqn, in);
+ Fqn<Object> fqn = Fqn.fromRelativeElements(rootfqn, in);
Object val = cache_.get(fqn, in);
assertNull("DataNode should be empty ", val);
}
Modified: core/trunk/src/test/java/org/jboss/cache/integration/hibernate/HibernateIntegrationTestUtil.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/integration/hibernate/HibernateIntegrationTestUtil.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/integration/hibernate/HibernateIntegrationTestUtil.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -26,18 +26,18 @@
/**
* Utilities related to the Hibernate integration tests.
- *
+ *
* @author Brian Stansberry
*/
public class HibernateIntegrationTestUtil
{
public static final Fqn<String> TS_BASE_FQN = Fqn.fromString("/TS");
public static final Fqn<String> REGION_PREFIX_FQN = Fqn.fromString("/test");
- public static final Fqn<String> TS_FQN = new Fqn<String>(TS_BASE_FQN, new Fqn<String>(REGION_PREFIX_FQN, Fqn.fromString("/org/hibernate/cache/UpdateTimestampsCache")));
+ public static final Fqn TS_FQN = Fqn.fromRelativeFqn(TS_BASE_FQN, Fqn.fromRelativeFqn(REGION_PREFIX_FQN, Fqn.fromString("/org/hibernate/cache/UpdateTimestampsCache")));
public static final String ITEM = "item";
-
+
/**
- * Prevent instantiation.
+ * Prevent instantiation.
*/
private HibernateIntegrationTestUtil()
{
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-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -6,10 +6,22 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.Region;
+import org.jboss.cache.RegionManager;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.cachedata.*;
+import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
+import org.jboss.cache.commands.cachedata.GetNodeCommand;
+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.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
import org.jboss.cache.eviction.DummyEvictionConfiguration;
@@ -176,7 +188,7 @@
NodeSPI child = root;
for (int i = 0; i < fqn.size(); i++)
{
- child = child.addChildDirect(new Fqn(fqn.get(i)));
+ child = child.addChildDirect(Fqn.fromElements(fqn.get(i)));
}
assert child.getFqn().equals(fqn);
Modified: core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/invalidation/InvalidationInterceptorTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -515,7 +515,7 @@
root1.addChild(fqn);
assertEquals(true, root1.hasChild(fqn));
- Fqn<String> child = new Fqn(fqn, "child");
+ Fqn child = Fqn.fromRelativeElements(fqn, "child");
cache1.putForExternalRead(child, "key", "value");
cache2.putForExternalRead(child, "key", "value");
assertEquals("value", cache1.get(child, "key"));
Modified: core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/loader/BdbjeTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -43,7 +43,7 @@
private static final int STREAM_HEADER_LENGTH = 4;
private static final String envHome = ".";
- private static final Fqn<String> FQN = new Fqn<String>("key");
+ private static final Fqn<String> FQN = Fqn.fromString("/key");
private CacheSPI cache;
private CacheLoader loader;
@@ -222,8 +222,8 @@
startLoader(transactional, null);
/* One FQN only. */
- doPutTests(new Fqn<String>("key"));
- doRemoveTests(new Fqn<String>("key"));
+ doPutTests(FQN);
+ doRemoveTests(FQN);
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
MarshalledValueOutputStream os = new MarshalledValueOutputStream(baos);
@@ -231,20 +231,24 @@
os.close();
/* Add three FQNs, middle FQN last. */
- doPutTests(new Fqn<String>("key1"));
- doPutTests(new Fqn<String>("key3"));
- doPutTests(new Fqn<String>("key2"));
- assertEquals(4, loader.get(new Fqn<String>("key1")).size());
- assertEquals(4, loader.get(new Fqn<String>("key2")).size());
- assertEquals(4, loader.get(new Fqn<String>("key3")).size());
+ Fqn<String> k1 = Fqn.fromString("/key1");
+ Fqn<String> k2 = Fqn.fromString("/key2");
+ Fqn<String> k3 = Fqn.fromString("/key3");
+ doPutTests(k1);
+ doPutTests(k3);
+ doPutTests(k2);
+ assertEquals(4, loader.get(k1).size());
+ assertEquals(4, loader.get(k2).size());
+ assertEquals(4, loader.get(k3).size());
+
/* Remove middle FQN first, then the others. */
- doRemoveTests(new Fqn<String>("key2"));
- doRemoveTests(new Fqn<String>("key3"));
- doRemoveTests(new Fqn<String>("key1"));
- assertEquals(null, loader.get(new Fqn<String>("key1")));
- assertEquals(null, loader.get(new Fqn<String>("key2")));
- assertEquals(null, loader.get(new Fqn<String>("key3")));
+ doRemoveTests(k2);
+ doRemoveTests(k3);
+ doRemoveTests(k1);
+ assertEquals(null, loader.get(k1));
+ assertEquals(null, loader.get(k2));
+ assertEquals(null, loader.get(k3));
baos = new ByteArrayOutputStream(1024);
os = new MarshalledValueOutputStream(baos);
@@ -334,11 +338,16 @@
startLoader(false, null);
/* Create top level node implicitly. */
- assertTrue(!loader.exists(new Fqn<String>("key0")));
+ Fqn k0 = Fqn.fromString("/key0");
+ Fqn k1 = Fqn.fromString("/key1");
+ Fqn k2 = Fqn.fromString("/key2");
+ Fqn k3 = Fqn.fromString("/key3");
+
+ assertTrue(!loader.exists(k0));
loader.put(Fqn.fromString("/key0/level1/level2"), null);
assertTrue(loader.exists(Fqn.fromString("/key0/level1/level2")));
assertTrue(loader.exists(Fqn.fromString("/key0/level1")));
- assertTrue(loader.exists(new Fqn<String>("key0")));
+ assertTrue(loader.exists(k0));
/* Remove leaf, leaving implicitly created middle level. */
loader.put(Fqn.fromString("/key0/x/y"), null);
@@ -349,19 +358,19 @@
assertTrue(loader.exists(Fqn.fromString("/key0/x")));
/* Delete top level to delete everything. */
- loader.remove(new Fqn<String>("key0"));
- assertTrue(!loader.exists(new Fqn<String>("key0")));
+ loader.remove(k0);
+ assertTrue(!loader.exists(k0));
assertTrue(!loader.exists(Fqn.fromString("/key0/level1/level2")));
assertTrue(!loader.exists(Fqn.fromString("/key0/level1")));
assertTrue(!loader.exists(Fqn.fromString("/key0/x")));
/* Add three top level nodes as context. */
- loader.put(new Fqn<String>("key1"), null);
- loader.put(new Fqn<String>("key2"), null);
- loader.put(new Fqn<String>("key3"), null);
- assertTrue(loader.exists(new Fqn<String>("key1")));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(loader.exists(new Fqn<String>("key3")));
+ loader.put(k1, null);
+ loader.put(k2, null);
+ loader.put(k3, null);
+ assertTrue(loader.exists(k1));
+ assertTrue(loader.exists(k2));
+ assertTrue(loader.exists(k3));
/* Put /key3/level1/level2. level1 should be implicitly created. */
assertTrue(!loader.exists(Fqn.fromString("/key3/level1")));
@@ -371,9 +380,9 @@
assertTrue(loader.exists(Fqn.fromString("/key3/level1")));
/* Context nodes should still be intact. */
- assertTrue(loader.exists(new Fqn<String>("key1")));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(loader.exists(new Fqn<String>("key3")));
+ assertTrue(loader.exists(k1));
+ assertTrue(loader.exists(k2));
+ assertTrue(loader.exists(k3));
/* Remove middle level only. */
loader.remove(Fqn.fromString("/key3/level1"));
@@ -381,37 +390,37 @@
assertTrue(!loader.exists(Fqn.fromString("/key3/level1")));
/* Context nodes should still be intact. */
- assertTrue(loader.exists(new Fqn<String>("key1")));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(loader.exists(new Fqn<String>("key3")));
+ assertTrue(loader.exists(k1));
+ assertTrue(loader.exists(k2));
+ assertTrue(loader.exists(k3));
/* Delete first root, leaving other roots. */
- loader.remove(new Fqn<String>("key1"));
- assertTrue(!loader.exists(new Fqn<String>("key1")));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(loader.exists(new Fqn<String>("key3")));
+ loader.remove(k1);
+ assertTrue(!loader.exists(k1));
+ assertTrue(loader.exists(k2));
+ assertTrue(loader.exists(k3));
/* Delete last root, leaving other roots. */
- loader.remove(new Fqn<String>("key3"));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(!loader.exists(new Fqn<String>("key3")));
+ loader.remove(k3);
+ assertTrue(loader.exists(k2));
+ assertTrue(!loader.exists(k3));
/* Delete final root, leaving none. */
- loader.remove(new Fqn<String>("key2"));
- assertTrue(!loader.exists(new Fqn<String>("key0")));
- assertTrue(!loader.exists(new Fqn<String>("key1")));
- assertTrue(!loader.exists(new Fqn<String>("key2")));
- assertTrue(!loader.exists(new Fqn<String>("key3")));
+ loader.remove(k2);
+ assertTrue(!loader.exists(k0));
+ assertTrue(!loader.exists(k1));
+ assertTrue(!loader.exists(k2));
+ assertTrue(!loader.exists(k3));
/* Repeat all tests above using put(Fqn,Object,Object) and get(Fqn) */
- assertNull(loader.get(new Fqn<String>("key0")));
+ assertNull(loader.get(k0));
loader.put(Fqn.fromString("/key0/level1/level2"), "a", "b");
assertNotNull(loader.get(Fqn.fromString("/key0/level1/level2")));
assertNotNull(loader.get(Fqn.fromString("/key0/level1")));
- assertNotNull(loader.get(new Fqn<String>("key0")));
+ assertNotNull(loader.get(k0));
assertEquals(0, loader.get(Fqn.fromString("/key0/level1")).size());
- assertEquals(0, loader.get(new Fqn<String>("key0")).size());
+ assertEquals(0, loader.get(k0).size());
loader.put(Fqn.fromString("/key0/x/y"), "a", "b");
@@ -423,18 +432,18 @@
assertNotNull(loader.get(Fqn.fromString("/key0/x")));
assertEquals(0, loader.get(Fqn.fromString("/key0/x")).size());
- loader.remove(new Fqn<String>("key0"));
- assertNull(loader.get(new Fqn<String>("key0")));
+ loader.remove(k0);
+ assertNull(loader.get(k0));
assertNull(loader.get(Fqn.fromString("/key0/level1/level2")));
assertNull(loader.get(Fqn.fromString("/key0/level1")));
assertNull(loader.get(Fqn.fromString("/key0/x")));
- loader.put(new Fqn<String>("key1"), "a", "b");
- loader.put(new Fqn<String>("key2"), "a", "b");
- loader.put(new Fqn<String>("key3"), "a", "b");
- assertNotNull(loader.get(new Fqn<String>("key1")));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNotNull(loader.get(new Fqn<String>("key3")));
+ loader.put(k1, "a", "b");
+ loader.put(k2, "a", "b");
+ loader.put(k3, "a", "b");
+ assertNotNull(loader.get(k1));
+ assertNotNull(loader.get(k2));
+ assertNotNull(loader.get(k3));
assertNull(loader.get(Fqn.fromString("/key3/level1")));
assertNull(loader.get(Fqn.fromString("/key3/level1/level2")));
@@ -443,32 +452,32 @@
assertNotNull(loader.get(Fqn.fromString("/key3/level1")));
assertEquals(0, loader.get(Fqn.fromString("/key3/level1")).size());
- assertNotNull(loader.get(new Fqn<String>("key1")));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNotNull(loader.get(new Fqn<String>("key3")));
+ assertNotNull(loader.get(k1));
+ assertNotNull(loader.get(k2));
+ assertNotNull(loader.get(k3));
loader.remove(Fqn.fromString("/key3/level1"));
assertNull(loader.get(Fqn.fromString("/key3/level1/level2")));
assertNull(loader.get(Fqn.fromString("/key3/level1")));
- assertNotNull(loader.get(new Fqn<String>("key1")));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNotNull(loader.get(new Fqn<String>("key3")));
+ assertNotNull(loader.get(k1));
+ assertNotNull(loader.get(k2));
+ assertNotNull(loader.get(k3));
- loader.remove(new Fqn<String>("key1"));
- assertNull(loader.get(new Fqn<String>("key1")));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNotNull(loader.get(new Fqn<String>("key3")));
+ loader.remove(k1);
+ assertNull(loader.get(k1));
+ assertNotNull(loader.get(k2));
+ assertNotNull(loader.get(k3));
- loader.remove(new Fqn<String>("key3"));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNull(loader.get(new Fqn<String>("key3")));
+ loader.remove(k3);
+ assertNotNull(loader.get(k2));
+ assertNull(loader.get(k3));
- loader.remove(new Fqn<String>("key2"));
- assertNull(loader.get(new Fqn<String>("key0")));
- assertNull(loader.get(new Fqn<String>("key1")));
- assertNull(loader.get(new Fqn<String>("key2")));
- assertNull(loader.get(new Fqn<String>("key3")));
+ loader.remove(k2);
+ assertNull(loader.get(k0));
+ assertNull(loader.get(k1));
+ assertNull(loader.get(k2));
+ assertNull(loader.get(k3));
stopLoader();
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderConnectionTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -52,7 +52,7 @@
cache.removeNode(Fqn.fromString("C"));
for (int i = 0; i < 100; i++)
{
- cache.put(new Fqn("C", Integer.toString(i)), "Blah", Integer.toString(i));
+ cache.put(Fqn.fromElements("C", Integer.toString(i)), "Blah", Integer.toString(i));
System.out.println("added " + i + " dummy node to Jboss cache.");
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/loader/TcpCacheServerTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -6,8 +6,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.jmx.CacheJmxWrapper;
import org.jboss.cache.loader.tcp.TcpCacheServer;
import org.jboss.cache.misc.TestingUtil;
@@ -180,7 +180,7 @@
private void usabilityCheck() throws Exception
{
- Fqn<String> fqn = new Fqn<String>("key");
+ Fqn<String> fqn = Fqn.fromString("/key");
assertFalse("Fqn does not exist in loader", loader.exists(fqn));
/* put(Fqn,Object,Object) and get(Fqn,Object) */
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -8,11 +8,12 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.RegionManager;
+import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
-import static org.testng.AssertJUnit.*;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -114,7 +115,7 @@
public void testStringBasedFqn() throws Exception
{
- Fqn fqn = new Fqn<Object>("JSESSIONID", "1010.10.5:3000", "1234567890", "1");
+ Fqn fqn = Fqn.fromElements("JSESSIONID", "1010.10.5:3000", "1234567890", "1");
byte[] asBytes = marshaller.objectToByteBuffer(fqn);
System.out.println("Marshalled to " + asBytes.length + " bytes");
Object o2 = marshaller.objectFromByteBuffer(asBytes);
@@ -123,7 +124,7 @@
public void testNonStringBasedFqn() throws Exception
{
- Fqn fqn = new Fqn<Object>(3, false);
+ Fqn fqn = Fqn.fromElements(3, false);
byte[] asBytes = marshaller.objectToByteBuffer(fqn);
Object o2 = marshaller.objectFromByteBuffer(asBytes);
assertEquals(fqn, o2);
@@ -131,7 +132,7 @@
public void testMethodCall() throws Exception
{
- Fqn fqn = new Fqn<Object>(3, false);
+ Fqn fqn = Fqn.fromElements(3, false);
MethodCall call = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal_id, fqn, "key", "value", true);
byte[] asBytes = marshaller.objectToByteBuffer(call);
Object o2 = marshaller.objectFromByteBuffer(asBytes);
@@ -145,7 +146,7 @@
public void testNestedMethodCall() throws Exception
{
- Fqn fqn = new Fqn<Object>(3, false);
+ Fqn fqn = Fqn.fromElements(3, false);
MethodCall call = MethodCallFactory.create(MethodDeclarations.putKeyValMethodLocal_id, fqn, "key", "value", true);
MethodCall replicateCall = MethodCallFactory.create(MethodDeclarations.replicateMethod_id, call);
byte[] asBytes = marshaller.objectToByteBuffer(replicateCall);
@@ -250,7 +251,7 @@
MethodCall call = MethodCallFactory.create(MethodDeclarations.replicateAllMethod_id, calls);
byte[] buf = marshaller.objectToByteBuffer(call);
- //todo - revisit after refactoring
+ //todo - revisit after refactoring
// assertMethodCallsEquals(call, (MethodCall) marshaller.objectFromByteBuffer(buf));
}
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/CacheListenerTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -258,7 +258,7 @@
cache.move(n1.getFqn(), n2.getFqn());
//expected
- Fqn<String> newFqn = new Fqn<String>(newParent, fqn.getLastElement());
+ Fqn newFqn = Fqn.fromRelativeElements(newParent, fqn.getLastElement());
List<Event> expected = new ArrayList<Event>();
if (optLocking)
@@ -444,7 +444,7 @@
Transaction tx = tm.getTransaction();
cache.move(n1.getFqn(), n2.getFqn());
//expected
- Fqn<String> newFqn = new Fqn<String>(newParent, fqn.getLastElement());
+ Fqn newFqn = Fqn.fromRelativeElements(newParent, fqn.getLastElement());
List<Event> expected = new ArrayList<Event>();
expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, newFqn, false, null, NODE_MOVED));
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ComparatorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ComparatorTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ComparatorTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -43,10 +43,10 @@
public void testOneNullCompare()
{
- Fqn<String> fqn1 = new Fqn<String>(new ArrayList<String>());
+ Fqn<String> fqn1 = Fqn.fromList(new ArrayList<String>());
List<String> temp = new ArrayList<String>();
temp.add("one");
- Fqn<String> fqn2 = new Fqn<String>(temp);
+ Fqn<String> fqn2 = Fqn.fromList(temp);
assertTrue(comp.compare(fqn1, fqn2) < 0);
assertTrue(comp.compare(fqn2, fqn1) > 0);
@@ -54,11 +54,11 @@
public void testNotComparableCompare()
{
- Fqn<String> fqn1 = new Fqn<String>(new ArrayList<String>());
+ Fqn<String> fqn1 = Fqn.fromList(new ArrayList<String>());
List<String> temp = new ArrayList<String>();
temp.add("one");
- Fqn fqn2 = new Fqn<String>(temp);
+ Fqn fqn2 = Fqn.fromList(temp);
assertTrue(comp.compare(fqn1, fqn2) < 0);
assertTrue(comp.compare(fqn2, fqn1) > 0);
@@ -130,7 +130,7 @@
List<Object> temp = new ArrayList<Object>();
temp.add(1234);
- Fqn<Object> fqn2 = new Fqn<Object>(temp);
+ Fqn<Object> fqn2 = Fqn.fromList(temp);
assertTrue(comp.compare(fqn1, fqn2) > 0);
assertTrue(comp.compare(fqn2, fqn1) < 0);
@@ -142,11 +142,11 @@
public void testOrdinaryObjectCompare()
{
- Fqn<Object> fqn1 = new Fqn<Object>(new XYZ(), new ABC());
- Fqn<Object> fqn2 = new Fqn<Object>("XYZ", "ABC");
- Fqn<Object> fqn3 = new Fqn<Object>("XYZ", new ABC());
+ Fqn<Object> fqn1 = Fqn.fromElements(new XYZ(), new ABC());
+ Fqn fqn2 = Fqn.fromElements("XYZ", "ABC");
+ Fqn<Object> fqn3 = Fqn.fromElements("XYZ", new ABC());
- Fqn<Object> fqn4 = new Fqn<Object>("XYZ", new XYZ());
+ Fqn<Object> fqn4 = Fqn.fromElements("XYZ", new XYZ());
assertEquals(0, comp.compare(fqn1, fqn2));
assertEquals(0, comp.compare(fqn1, fqn3));
@@ -155,23 +155,9 @@
assertEquals(true, comp.compare(fqn4, fqn1) > 0);
}
- /*
- public void testNullComparator()
- {
- Fqn fqn1 = new Fqn(new Object[] {"a", null, "c"});
- Fqn fqn2 = new Fqn(new Object[] {"a", "d", "c"});
- Fqn fqn3 = new Fqn(new Object[] {"a", null});
-
- assertEquals(0, comp.compare(fqn1, fqn1));
- assertEquals(true, comp.compare(fqn1, fqn2) > 0);
- assertEquals(true, comp.compare(fqn2, fqn1) < 0);
- assertEquals(true, comp.compare(fqn1, fqn3) < 0);
- assertEquals(true, comp.compare(fqn3, fqn1) > 0);
- }
- */
-
private static class XYZ
{
+ @Override
public String toString()
{
return "XYZ";
@@ -180,6 +166,7 @@
private static class ABC
{
+ @Override
public String toString()
{
return "ABC";
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -338,7 +338,7 @@
try
{
cache.getTransactionManager().begin();
- cache.put(new Fqn<String>(f, getName()), "a", "b");
+ cache.put(Fqn.fromRelativeElements(f, getName()), "a", "b");
cache.getTransactionManager().commit();
}
catch (Exception e)
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/ConcurrentPassivationTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -62,13 +62,13 @@
public void testConcurrentPassivation() throws Exception
{
- Fqn<Object> base = new Fqn<Object>("/org/jboss/test/data/concurrent/passivation");
+ Fqn base = Fqn.fromElements("/org/jboss/test/data/concurrent/passivation");
// Create a bunch of nodes; more than the /org/jboss/test/data
// region's maxNodes so we know eviction will kick in
for (int i = 0; i < 35000; i++)
{
- cache.put(new Fqn<Object>(base, i / 100), i, "value");
+ cache.put(Fqn.fromRelativeElements(base, i / 100), i, "value");
}
// Loop for long enough to have 5 runs of the eviction thread
@@ -81,7 +81,7 @@
// If any get returns null, that's a failure
for (int i = 0; i < 35000; i++)
{
- Fqn<Object> fqn = new Fqn<Object>(base, i / 100);
+ Fqn<Object> fqn = Fqn.fromRelativeElements(base, i / 100);
assertNotNull("Get on Fqn " + fqn + " returned null", cache.getNode(fqn));
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationActivationCallbacksTestCase.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -123,7 +123,7 @@
public void testSimpleLifecycle() throws Exception
{
- Fqn<String> fqn = new Fqn<String>(BASE, "bean1");
+ Fqn fqn = Fqn.fromRelativeElements(BASE, "bean1");
cache.put(fqn, "bean", "A bean");
//TestingUtil.sleepThread(3000);
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -977,12 +977,14 @@
{
/* Create top level node implicitly. */
- assertTrue(!loader.exists(new Fqn<String>("key0")));
+ Fqn k0 = Fqn.fromString("/key0");
+
+ assertTrue(!loader.exists(k0));
loader.put(Fqn.fromString("/key0/level1/level2"), null);
addDelay();
assertTrue(loader.exists(Fqn.fromString("/key0/level1/level2")));
assertTrue(loader.exists(Fqn.fromString("/key0/level1")));
- assertTrue(loader.exists(new Fqn<String>("key0")));
+ assertTrue(loader.exists(k0));
/* Remove leaf, leaving implicitly created middle level. */
loader.put(Fqn.fromString("/key0/x/y"), null);
@@ -995,9 +997,9 @@
assertTrue(loader.exists(Fqn.fromString("/key0/x")));
/* Delete top level to delete everything. */
- loader.remove(new Fqn<String>("key0"));
+ loader.remove(k0);
addDelay();
- assertTrue(!loader.exists(new Fqn<String>("key0")));
+ assertTrue(!loader.exists(k0));
assertTrue(!loader.exists(Fqn.fromString("/key0/level1/level2")));
assertTrue(!loader.exists(Fqn.fromString("/key0/level1")));
assertTrue(!loader.exists(Fqn.fromString("/key0/x")));
@@ -1051,20 +1053,20 @@
/* Delete final root, leaving none. */
loader.remove(Fqn.fromString("/key2"));
addDelay();
- assertTrue(!loader.exists(new Fqn<String>("key0")));
+ assertTrue(!loader.exists(k0));
assertTrue(!loader.exists(Fqn.fromString("/key1")));
assertTrue(!loader.exists(Fqn.fromString("/key2")));
assertTrue(!loader.exists(Fqn.fromString("/key3")));
/* Repeat all tests above using put(Fqn,Object,Object) and get(Fqn) */
- assertNull(loader.get(new Fqn<String>("key0")));
+ assertNull(loader.get(k0));
loader.put(Fqn.fromString("/key0/level1/level2"), "a", "b");
addDelay();
assertNotNull(loader.get(Fqn.fromString("/key0/level1/level2")));
assertNotNull(loader.get(Fqn.fromString("/key0/level1")));
assertTrue(loader.get(Fqn.fromString("/key0/level1")).isEmpty());
- assertNotNull(loader.get(new Fqn<String>("key0")));
+ assertNotNull(loader.get(k0));
assertTrue(loader.get(Fqn.fromString("/key0")).isEmpty());
loader.put(Fqn.fromString("/key0/x/y"), "a", "b");
@@ -1078,9 +1080,9 @@
assertNotNull(loader.get(Fqn.fromString("/key0/x")));
assertTrue(loader.get(Fqn.fromString("/key0/x")).isEmpty());
- loader.remove(new Fqn<String>("key0"));
+ loader.remove(k0);
addDelay();
- assertNull(loader.get(new Fqn<String>("key0")));
+ assertNull(loader.get(k0));
assertNull(loader.get(Fqn.fromString("/key0/level1/level2")));
assertNull(loader.get(Fqn.fromString("/key0/level1")));
assertNull(loader.get(Fqn.fromString("/key0/x")));
@@ -1127,7 +1129,7 @@
loader.remove(Fqn.fromString("/key2"));
addDelay();
- assertNull(loader.get(new Fqn<String>("key0")));
+ assertNull(loader.get(k0));
assertNull(loader.get(Fqn.fromString("/key1")));
assertNull(loader.get(Fqn.fromString("/key2")));
assertNull(loader.get(Fqn.fromString("/key3")));
@@ -1140,21 +1142,21 @@
throws Exception
{
- checkChildren(new Fqn(), null);
+ checkChildren(Fqn.ROOT, null);
checkChildren(Fqn.fromString("/key0"), null);
loader.put(Fqn.fromString("/key0"), null);
addDelay();
- checkChildren(new Fqn(), new String[]{"key0"});
+ checkChildren(Fqn.ROOT, new String[]{"key0"});
loader.put(Fqn.fromString("/key1/x"), null);
addDelay();
- checkChildren(new Fqn(), new String[]{"key0", "key1"});
+ checkChildren(Fqn.ROOT, new String[]{"key0", "key1"});
checkChildren(Fqn.fromString("/key1"), new String[]{"x"});
loader.remove(Fqn.fromString("/key1/x"));
addDelay();
- checkChildren(new Fqn(), new String[]{"key0", "key1"});
+ checkChildren(Fqn.ROOT, new String[]{"key0", "key1"});
checkChildren(Fqn.fromString("/key0"), null);
checkChildren(Fqn.fromString("/key1"), null);
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/ForcedStateTransferTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -103,7 +103,7 @@
{
this.cache = cache;
this.value = value;
- this.fqn = new Fqn<String>(Fqn.fromString(rootFqn), value);
+ this.fqn = Fqn.fromRelativeElements(Fqn.fromString(rootFqn), value);
}
public void run()
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransferConcurrencyTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -145,7 +145,7 @@
for (int j = 0; j < count; j++)
{
- Fqn fqn = new Fqn<String>(A_B, names[j]);
+ Fqn fqn = Fqn.fromRelativeElements(A_B, names[j]);
assertEquals("Incorrect value for " + fqn + " on activator " + names[i],
"VALUE", activators[i].getCacheValue(fqn));
// System.out.println(names[i] + ":" + fqn + " = " + activators[i].getCacheValue(fqn));
@@ -672,7 +672,7 @@
createAndActivateRegion(cache, A_B);
// waitUntillAllChachesActivatedRegion();
System.out.println(name + " activated region" + " " + System.currentTimeMillis());
- Fqn<String> childFqn = new Fqn<String>(A_B, name);
+ Fqn childFqn = Fqn.fromRelativeElements(A_B, name);
cache.put(childFqn, "KEY", "VALUE");
// System.out.println(name + " put fqn " + childFqn + " " + System.currentTimeMillis());
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java 2008-04-10 23:12:19 UTC (rev 5528)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelReadCommittedNodeCreationRollbackTest.java 2008-04-10 23:33:56 UTC (rev 5529)
@@ -93,7 +93,7 @@
System.out.println("Writing /a/1");
// Create an empty parent node and a node with data
- Fqn<String> a1 = new Fqn<String>(PARENT, "1");
+ Fqn a1 = Fqn.fromRelativeElements(PARENT, "1");
cache.put(a1, KEY, VALUE);
// notify the second thread it can write
@@ -145,7 +145,7 @@
System.out.println("writing a2");
// create a second child under parent
- Fqn<String> a2 = new Fqn<String>(PARENT, "2");
+ Fqn a2 = Fqn.fromRelativeElements(PARENT, "2");
try
{
cache.put(a2, KEY, VALUE);
16 years, 9 months
JBoss Cache SVN: r5528 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 6 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-04-10 19:12:19 -0400 (Thu, 10 Apr 2008)
New Revision: 5528
Added:
core/trunk/src/test/java/org/jboss/cache/invocation/
core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/ChainedInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheData.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/lock/LockManager.java
core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainTestBase.java
Log:
JBCACHE-1222 - updated wiering and bug fixing
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-04-10 04:27:48 UTC (rev 5527)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -323,9 +323,8 @@
private boolean isNonBootstrapClass(Class<?> componentClass)
{
- return !(componentClass.equals(CacheSPI.class) ||
- componentClass.equals(CacheLifecycleManager.class) || componentClass.equals(Cache.class) ||
- componentClass.equals(CacheData.class) || componentClass.equals(ComponentRegistry.class) ||
+ return !(componentClass.equals(CacheSPI.class) || componentClass.equals(CacheLifecycleManager.class) ||
+ componentClass.equals(Cache.class) || componentClass.equals(ComponentRegistry.class) ||
componentClass.equals(Configuration.class));
}
Modified: core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-04-10 04:27:48 UTC (rev 5527)
+++ core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -39,53 +39,41 @@
if (i == null)
{
i = clazz.newInstance();
- // add this interceptor as a NAMED component into the registry
componentRegistry.registerComponent(clazz.getName(), i, clazz);
} else
{
// wipe next/last chaining!!
- i.setLast(null);
i.setNext(null);
}
return i;
}
- /**
- * Adds an interceptor at the end of the chain
- */
- private void addInterceptor(ChainedInterceptor first, ChainedInterceptor i)
- {
- if (first == null) return;
- while (first.getNext() != null) first = first.getNext();
- first.setNext(i);
- }
-
public InterceptorChain buildInterceptorChain() throws IllegalAccessException, InstantiationException, ClassNotFoundException
{
boolean optimistic = configuration.isNodeLockingOptimistic();
// load the icInterceptor first
- ChainedInterceptor first = setFirstInterceptor(createInterceptor(InvocationContextInterceptor.class));
+ ChainedInterceptor first = createInterceptor(InvocationContextInterceptor.class);
InterceptorChain interceptorChain = new InterceptorChain(first);
// load the cache management interceptor next
if (configuration.getExposeManagementStatistics())
- interceptorChain.addInterceptor(first, CacheMgmtInterceptor.class);
+ interceptorChain.appendIntereceptor(createInterceptor(CacheMgmtInterceptor.class));
// load the tx interceptor
- interceptorChain.addInterceptor(first, TxInterceptor.class);
+ interceptorChain.appendIntereceptor(createInterceptor(TxInterceptor.class));
if (configuration.isUseLazyDeserialization())
- interceptorChain.addInterceptor(first, MarshalledValueInterceptor.class);
- interceptorChain.addInterceptor(first, NotificationInterceptor.class);
+ interceptorChain.appendIntereceptor(createInterceptor(MarshalledValueInterceptor.class));
+ interceptorChain.appendIntereceptor(createInterceptor(NotificationInterceptor.class));
switch (configuration.getCacheMode())
{
case REPL_SYNC:
case REPL_ASYNC:
- interceptorChain.addInterceptor(first, optimistic ? OptimisticReplicationInterceptor.class : ReplicationInterceptor.class);
+ interceptorChain.appendIntereceptor(optimistic ? createInterceptor(OptimisticReplicationInterceptor.class) : createInterceptor(ReplicationInterceptor.class));
break;
case INVALIDATION_SYNC:
case INVALIDATION_ASYNC:
- interceptorChain.addInterceptor(first, InvalidationInterceptor.class);
+ interceptorChain.appendIntereceptor(createInterceptor(InvalidationInterceptor.class));
break;
case LOCAL:
//Nothing...
@@ -93,52 +81,42 @@
if (!optimistic)
{
- interceptorChain.addInterceptor(first, PessimisticLockInterceptor.class);
-// addInterceptor(first, UnlockInterceptor.class);
+ interceptorChain.appendIntereceptor(createInterceptor(PessimisticLockInterceptor.class));
}
if (configuration.isUsingCacheLoaders())
{
if (configuration.getCacheLoaderConfig().isPassivation())
{
- interceptorChain.addInterceptor(first, ActivationInterceptor.class);
- interceptorChain.addInterceptor(first, PassivationInterceptor.class);
-
+ interceptorChain.appendIntereceptor(createInterceptor(ActivationInterceptor.class));
+ interceptorChain.appendIntereceptor(createInterceptor(PassivationInterceptor.class));
} else
{
- interceptorChain.addInterceptor(first, CacheLoaderInterceptor.class);
- interceptorChain.addInterceptor(first, CacheStoreInterceptor.class);
+ interceptorChain.appendIntereceptor(createInterceptor(CacheLoaderInterceptor.class));
+ interceptorChain.appendIntereceptor(createInterceptor(CacheStoreInterceptor.class));
}
}
if (configuration.isUsingBuddyReplication())
- interceptorChain.addInterceptor(first, DataGravitatorInterceptor.class);
+ interceptorChain.appendIntereceptor(createInterceptor(DataGravitatorInterceptor.class));
if (optimistic)
{
- interceptorChain.addInterceptor(first, OptimisticLockingInterceptor.class);
- interceptorChain.addInterceptor(first, OptimisticValidatorInterceptor.class);
- interceptorChain.addInterceptor(first, OptimisticCreateIfNotExistsInterceptor.class);
+ interceptorChain.appendIntereceptor(createInterceptor(OptimisticLockingInterceptor.class));
+ interceptorChain.appendIntereceptor(createInterceptor(OptimisticValidatorInterceptor.class));
+ interceptorChain.appendIntereceptor(createInterceptor(OptimisticCreateIfNotExistsInterceptor.class));
}
// eviction interceptor to come before the optimistic node interceptor
if (configuration.getEvictionConfig() != null && configuration.getEvictionConfig().isValidConfig())
- interceptorChain.addInterceptor(first, EvictionInterceptor.class);
+ interceptorChain.appendIntereceptor(createInterceptor(EvictionInterceptor.class));
- if (optimistic) interceptorChain.addInterceptor(first, OptimisticNodeInterceptor.class);
-
+ if (optimistic) interceptorChain.appendIntereceptor(createInterceptor(OptimisticNodeInterceptor.class));
ChainedInterceptor callInterceptor = createInterceptor(CallInterceptor.class);
- addInterceptor(first, callInterceptor);
- interceptorChain.setLastInterceptorPointer(callInterceptor);
+ interceptorChain.appendIntereceptor(callInterceptor);
+ if (log.isTraceEnabled()) log.trace("Finished building interceptor chain.");
return interceptorChain;
}
-
- public ChainedInterceptor setFirstInterceptor(ChainedInterceptor i)
- {
- componentRegistry.registerComponent(ChainedInterceptor.class.getName(), i, ChainedInterceptor.class);
- return i;
- }
-
@Override
@SuppressWarnings("unchecked")
protected <T> T construct(String componentName, Class<T> componentType)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -155,6 +155,6 @@
transactionTable.addCacheLoaderModification(gtx, command);
}
}
- return command;
+ return result;
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -22,27 +22,26 @@
package org.jboss.cache.interceptors;
import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.interceptors.base.ChainedInterceptor;
-import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.EvictFqnCommand;
import org.jboss.cache.commands.InvalidateCommand;
+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.tx.PrepareCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.cachedata.*;
+import org.jboss.cache.commands.tx.PrepareCommand;
+import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.interceptors.base.ChainedInterceptor;
+import org.jboss.cache.marshall.MethodDeclarations;
import java.util.Collections;
import java.util.Map;
@@ -55,7 +54,7 @@
*/
public abstract class Interceptor extends ChainedInterceptor implements InterceptorMBean
{
- protected Interceptor next = null, last = null;
+ protected Interceptor next = null;
protected CacheSPI<?, ?> cache;
protected Log log = null;
protected Configuration configuration;
@@ -121,16 +120,6 @@
statsEnabled = enabled;
}
- public Interceptor getLast()
- {
- return last;
- }
-
- public void setLast(Interceptor last)
- {
- this.last = last;
- }
-
/**
* This implementation returns an empty Map. If individual Interceptors wish to expose statistics, they can override this
* method.
@@ -153,8 +142,6 @@
return getClass().getName()
+ "{next: "
+ (getNext() == null ? null : getNext().getClass())
- + "; last: "
- + (getLast() == null ? null : getLast().getClass())
+ "}";
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -10,6 +10,7 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
import org.jboss.cache.ReplicationException;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.DataVersionCommand;
@@ -73,10 +74,19 @@
private long rollbacks = 0;
private GlobalTransactionCommandsVisitor globalTransactionCommandsVisitor;
- public TxInterceptor()
+
+ @Inject
+ public void intialize(Configuration configuration, CommandsFactory commandsFactory, RPCManager rpcManager,
+ CacheTransactionHelper transactionHelper, Notifier notifier, InvocationContextContainer icc,
+ CacheLifecycleManager lifecycleManager)
{
- log = LogFactory.getLog(getClass());
- trace = log.isTraceEnabled();
+ this.configuration = configuration;
+ this.commandsFactory = commandsFactory;
+ this.rpcManager = rpcManager;
+ this.transactionHelper = transactionHelper;
+ this.notifier = notifier;
+ this.invocationContextContainer = icc;
+ this.lifecycleManager = lifecycleManager;
}
@SuppressWarnings("unchecked")
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/ChainedInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/ChainedInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/ChainedInterceptor.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -20,8 +20,6 @@
private ChainedInterceptor next;
- private ChainedInterceptor last;
-
protected Log log;
protected boolean trace;
@@ -55,21 +53,16 @@
return next;
}
- public void setNext(ChainedInterceptor next)
+ public boolean hasNext()
{
- this.next = next;
+ return getNext() != null;
}
- public ChainedInterceptor getLast()
+ public void setNext(ChainedInterceptor next)
{
- return last;
+ this.next = next;
}
- public void setLast(ChainedInterceptor last)
- {
- this.last = last;
- }
-
public Object invokeNextInterceptor(InvocationContext ctx, CacheCommand command) throws Throwable
{
return command.accept(ctx, getNext());
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheData.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheData.java 2008-04-10 04:27:48 UTC (rev 5527)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheData.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -571,4 +571,8 @@
}
}
+ public void setRoot(NodeSPI root)
+ {
+ this.root = root;
+ }
}
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-10 04:27:48 UTC (rev 5527)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -56,11 +56,27 @@
{
}
+// @Inject
+// public void initialize(CacheData cacheData)
+// {
+// this.stateTransferManager = stateTransferManager;
+// this.cacheLoaderManager = cacheLoaderManager;
+// this.notifier = notifier;
+// this.transactionManager = transactionManager;
+// this.buddyManager = buddyManager;
+// this.transactionTable = transactionTable;
+// this.rpcManager = rpcManager;
+// this.regionManager = regionManager;
+// this.marshaller = marshaller;
+// 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)
+ CacheTransactionHelper transactionHelper, CommandsFactory commandsFactory, CacheData cacheData)
{
this.stateTransferManager = stateTransferManager;
this.cacheLoaderManager = cacheLoaderManager;
@@ -71,7 +87,7 @@
this.rpcManager = rpcManager;
this.regionManager = regionManager;
this.marshaller = marshaller;
- this.cacheData = new CacheData();
+ this.cacheData = cacheData;
this.commandsFactory = commandsFactory;
this.transactionHelper = transactionHelper;
}
@@ -126,7 +142,7 @@
public List<ChainedInterceptor> getInterceptorChain()
{
- return invoker.getInterceptorsList();
+ return invoker.getInterceptorsAsList();
}
public void removeInterceptor(int position)
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-10 04:27:48 UTC (rev 5527)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheLifecycleManager.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -25,7 +25,6 @@
{
private static Log log = LogFactory.getLog(CacheLifecycleManager.class);
- private NodeSPI root;
private CacheStatus cacheStatus;
/* dependencies*/
@@ -198,7 +197,7 @@
//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
componentRegistry.updateDependencies();
- componentRegistry.wireDependencies(root);
+ componentRegistry.wireDependencies(cacheData.getRoot());
cacheStatus = CacheStatus.STARTING;
@@ -354,8 +353,8 @@
// unset transaction manager reference
cacheStatus = CacheStatus.STOPPED;
// empty in-memory state
- root.clearDataDirect();
- root.removeChildrenDirect();
+ cacheData.getRoot().clearDataDirect();
+ cacheData.getRoot().removeChildrenDirect();
}
//todo - this should reather be implemented as follows:
@@ -381,10 +380,10 @@
// if we don't already have a root or the new (temp) root is of a different class (optimistic vs pessimistic) to
// the current root, then we use the new one.
- Class currentRootType = root == null ? null : ((NodeInvocationDelegate) root).getDelegationTarget().getClass();
+ Class currentRootType = cacheData.getRoot() == null ? null : ((NodeInvocationDelegate) cacheData.getRoot()).getDelegationTarget().getClass();
Class tempRootType = ((NodeInvocationDelegate) tempRoot).getDelegationTarget().getClass();
- if (!tempRootType.equals(currentRootType)) root = tempRoot;
+ if (!tempRootType.equals(currentRootType)) cacheData.setRoot(tempRoot);
}
/**
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-10 04:27:48 UTC (rev 5527)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -1,193 +1,187 @@
package org.jboss.cache.invocation;
-import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.factories.InterceptorChainFactory;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.ChainedInterceptor;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.LinkedList;
import java.util.List;
/**
- * The purpose of this class is to build and manage additional interceptor chains.
+ * Knows how to build and manage an chain of interceptors. Also in charge with invoking methods on the chain.
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
public class InterceptorChain
{
+ /**
+ * reference to the first interceptor in the chain
+ */
private ChainedInterceptor firstInChain;
- private ComponentRegistry componentRegistry;
-
+ /**
+ * used for invoking commands on the chain
+ */
private InvocationContextContainer invocationContextContainer;
+ /**
+ * Constructs an interceptor chain having the supplied interceptor as first.
+ */
public InterceptorChain(ChainedInterceptor first)
{
this.firstInChain = first;
}
@Inject
- public void initialize(InvocationContextContainer invocationContextContainer, ComponentRegistry componentRegistry)
+ public void initialize(InvocationContextContainer invocationContextContainer)
{
this.invocationContextContainer = invocationContextContainer;
- this.componentRegistry = componentRegistry;
}
- public synchronized void addInterceptor(ChainedInterceptor i, int position)
+ /**
+ * Inserts the given interceptor at the specified position in the chain (o based indexing).
+ * If the position is invalid (e.g. 5 and there are only 2 interceptors in the chain) this is a no-op.
+ */
+ public synchronized void addInterceptor(ChainedInterceptor interceptor, int position)
{
- List<ChainedInterceptor> interceptors = getInterceptorsList();
- interceptors.add(position, i);
- // now correct the chaining of interceptors...
- ChainedInterceptor linkedChain = correctInterceptorChaining(interceptors);
- setFirstInChain(linkedChain);
- }
+ if (position == 0)
+ {
+ interceptor.setNext(firstInChain);
+ firstInChain = interceptor;
+ return;
+ }
+ if (firstInChain == null) return;
+ ChainedInterceptor it = firstInChain;
+ int index = 0;
+ while (it != null)
+ {
+ if (++index == position)
+ {
+ interceptor.setNext(it.getNext());
+ it.setNext(interceptor);
+ return;
+ }
+ it = it.getNext();
- public synchronized void removeInterceptor(int position)
- {
- List<ChainedInterceptor> i = getInterceptorsList();
- i.remove(position);
- setFirstInChain(correctInterceptorChaining(i));
+ }
}
/**
- * "Fixes" the next() and last() pointers for each interceptor, based on the order presented in the list passed in, and
- * also re-assesses dependencies for each interceptor, injecting dependencies accordingingly.
- *
- * @param interceptors interceptor chain to correct
- * @return the first interceptor in the chain.
+ * Removes the interceptor at the given postion.
+ * If the position is invalid (e.g. 5 and there are only 2 interceptors in the chain) this is a no-op.
*/
- public ChainedInterceptor correctInterceptorChaining(List<ChainedInterceptor> interceptors)
+ public synchronized void removeInterceptor(int position)
{
- ChainedInterceptor first = null, last = null;
- for (ChainedInterceptor next : interceptors)
+ if (firstInChain == null) return;
+ if (position == 0)
{
- if (first == null)
+ firstInChain = firstInChain.getNext();
+ return;
+ }
+ ChainedInterceptor it = firstInChain;
+ int index = 0;
+ while (it != null)
+ {
+ if (++index == position)
{
- first = last = next;
- continue;
+ if (it.getNext() == null) return; //nothing to remove
+ it.setNext(it.getNext().getNext());
}
- last.setNext(next);
- last = next;
+ it = it.getNext();
}
-
- if (last != null) last.setNext(null);
-
- // now set the 'last' pointer.
- ChainedInterceptor i = setLastInterceptorPointer(last);
- return i;
}
- public ChainedInterceptor setLastInterceptorPointer(ChainedInterceptor last)
+ /**
+ * Returns the number of interceptors in the chain.
+ */
+ public int size()
{
- ChainedInterceptor i = firstInChain;
- while (i != null)
+ int size = 0;
+ ChainedInterceptor it = firstInChain;
+ while (it != null)
{
- i.setLast(last);
- i = i.getNext();
+ size++;
+ it = it.getNext();
}
- return firstInChain;
+ return size;
+
}
-
- public List<ChainedInterceptor> getInterceptorsList()
+ /**
+ * Returns an unmofiable list with all the interceptors in sequence.
+ * If first in chain is null an empty list is returned.
+ */
+ public List<ChainedInterceptor> getInterceptorsAsList()
{
- List<ChainedInterceptor> result;
- if (firstInChain == null)
- {
- result = null;
- }
- int num = 1;
- ChainedInterceptor tmp = firstInChain;
- while ((tmp = tmp.getNext()) != null)
- {
- num++;
- }
- List<ChainedInterceptor> retval = new ArrayList<ChainedInterceptor>(num);
- tmp = firstInChain;
- num = 0;
- do
- {
- retval.add(tmp);
- tmp = tmp.getNext();
- }
- while (tmp != null);
- return Collections.unmodifiableList(retval);
+ return Collections.unmodifiableList(getInterceptorsAsListModifiable());
}
- private void setFirstInChain(ChainedInterceptor startOfNewChain)
+ /**
+ * Removes all the occurences of supplied interceptor type from the chain.
+ */
+ public synchronized void removeInterceptor(Class<? extends ChainedInterceptor> clazz)
{
- firstInChain = startOfNewChain;
- }
-
- public synchronized void removeInterceptor(Class<? extends ChainedInterceptor> interceptorType)
- {
- List<ChainedInterceptor> interceptors = getInterceptorsList();
- int position = -1;
- boolean found = false;
- for (ChainedInterceptor interceptor : interceptors)
+ if (firstInChain.getClass() == clazz)
{
- position++;
- if (interceptor.getClass().equals(interceptorType))
+ firstInChain = firstInChain.getNext();
+ }
+ ChainedInterceptor it = firstInChain.getNext();
+ ChainedInterceptor prevIt = firstInChain;
+ while (it != null)
+ {
+ if (it.getClass() == clazz)
{
- found = true;
- break;
+ prevIt.setNext(it.getNext());
}
+ prevIt = it;
+ it = it.getNext();
}
- if (found)
- {
- interceptors.remove(position);
- setFirstInChain(correctInterceptorChaining(interceptors));
- }
}
- public synchronized boolean addInterceptor(ChainedInterceptor i, Class<? extends ChainedInterceptor> afterInterceptor)
+ /**
+ * Adds a new interceptor in list after an interceptor of a given type.
+ *
+ * @return true if the interceptor was added; i.e. the afterInterceptor exists
+ */
+ public synchronized boolean addInterceptor(ChainedInterceptor toAdd, Class<? extends ChainedInterceptor> afterInterceptor)
{
- List<ChainedInterceptor> interceptors = getInterceptorsList();
- int position = -1;
- boolean found = false;
- for (ChainedInterceptor interceptor : interceptors)
+ ChainedInterceptor it = firstInChain;
+ while (it != null)
{
- position++;
- if (interceptor.getClass().equals(afterInterceptor))
+ if (it.getClass().equals(afterInterceptor))
{
- found = true;
- break;
+ toAdd.setNext(it.getNext());
+ it.setNext(toAdd);
+ return true;
}
+ it = it.getNext();
}
-
- if (found)
- {
- interceptors.add(++position, i);
- setFirstInChain(correctInterceptorChaining(interceptors));
- // make sure I start the last 2 "manually startable" components
- }
- return found;
+ return false;
}
+ /**
+ * Returns the chain as a list.
+ */
public List<ChainedInterceptor> asList()
{
- return asList(this.firstInChain);
- }
-
- public List<ChainedInterceptor> asList(ChainedInterceptor interceptor)
- {
- if (interceptor == null)
+ List<ChainedInterceptor> result;
+ if (this.firstInChain == null)
{
- return null;
+ result = null;
}
int num = 1;
- ChainedInterceptor tmp = interceptor;
+ ChainedInterceptor tmp = this.firstInChain;
while ((tmp = tmp.getNext()) != null)
{
num++;
}
List<ChainedInterceptor> retval = new ArrayList<ChainedInterceptor>(num);
- tmp = interceptor;
+ tmp = this.firstInChain;
num = 0;
do
{
@@ -195,10 +189,21 @@
tmp = tmp.getNext();
}
while (tmp != null);
- return retval;
+ result = retval;
+ return result;
}
/**
+ * Appends at the end.
+ */
+ public void appendIntereceptor(ChainedInterceptor ci)
+ {
+ ChainedInterceptor it = firstInChain;
+ while (it.hasNext()) it = it.getNext();
+ it.setNext(ci);
+ }
+
+ /**
* Walks the command through the interceptor chain. The received ctx is being passed in.
*/
public Object invoke(InvocationContext ctx, CacheCommand command) throws Throwable
@@ -215,4 +220,26 @@
InvocationContext ctxt = invocationContextContainer.get();
return cacheCommand.accept(ctxt, firstInChain);
}
+
+ public ChainedInterceptor getFirstInChain()
+ {
+ return firstInChain;
+ }
+
+ private List<ChainedInterceptor> getInterceptorsAsListModifiable()
+ {
+ if (firstInChain == null)
+ {
+ return Collections.EMPTY_LIST;
+ }
+ List<ChainedInterceptor> retval = new LinkedList<ChainedInterceptor>();
+ ChainedInterceptor tmp = firstInChain;
+ do
+ {
+ retval.add(tmp);
+ tmp = tmp.getNext();
+ }
+ while (tmp != null);
+ return retval;
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-04-10 04:27:48 UTC (rev 5527)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -29,7 +29,7 @@
private static Log log = LogFactory.getLog(LockManager.class);
private Configuration configuration;
- private long lockAcquisitionTimeout = configuration.getLockAcquisitionTimeout();
+ private long lockAcquisitionTimeout;
private CacheData cacheData;
private NodeSPI rootNode;
private TransactionTable txTable;
Modified: core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainTestBase.java 2008-04-10 04:27:48 UTC (rev 5527)
+++ core/trunk/src/test/java/org/jboss/cache/factories/InterceptorChainTestBase.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -11,19 +11,6 @@
*/
public abstract class InterceptorChainTestBase
{
- protected void assertLast(ChainedInterceptor first, ChainedInterceptor last)
- {
- assertNotNull("First interceptor in the chain cannot be null", first);
- assertNotNull("Last interceptor in the chain cannot be null", last);
-
- ChainedInterceptor i = first;
- while (i != null)
- {
- assertEquals("Expected last interceptor (in " + i + ") to be " + last, last, i.getLast());
- i = i.getNext();
- }
- }
-
protected void assertInterceptorLinkage(List<ChainedInterceptor> list)
{
ChainedInterceptor previous = null;
@@ -39,7 +26,5 @@
previous = i;
}
-
- assertLast(list.get(0), previous);
}
}
\ No newline at end of file
Added: core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/invocation/InterceptorChainTest.java 2008-04-10 23:12:19 UTC (rev 5528)
@@ -0,0 +1,164 @@
+package org.jboss.cache.invocation;
+
+import org.jboss.cache.interceptors.*;
+import org.jboss.cache.interceptors.base.ChainedInterceptor;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tests functionality defined by InterceptorChain.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 2.2
+ */
+@Test(groups = {"functional"})
+public class InterceptorChainTest
+{
+ private ChainedInterceptor icInterceptor;
+ private ChainedInterceptor invalidationInterceptor;
+ private ChainedInterceptor txInterceptor;
+ private ChainedInterceptor pessimisticInterceptor;
+ private ChainedInterceptor callInterceptor;
+ private InterceptorChain chain;
+
+ @BeforeMethod
+ public void setUp()
+ {
+ icInterceptor = create(InvocationContextInterceptor.class);
+ invalidationInterceptor = create(InvalidationInterceptor.class);
+ txInterceptor = create(TxInterceptor.class);
+ pessimisticInterceptor = create(PessimisticLockInterceptor.class);
+ callInterceptor = create(CallInterceptor.class);
+ chain = new InterceptorChain(icInterceptor);
+ }
+
+ public void testGetIntercpetorsAsList() throws Throwable
+ {
+ invalidationInterceptor.setNext(txInterceptor);
+ txInterceptor.setNext(pessimisticInterceptor);
+ pessimisticInterceptor.setNext(callInterceptor);
+
+ InterceptorChain chain = new InterceptorChain(invalidationInterceptor);
+ List<ChainedInterceptor> expectedList = new ArrayList<ChainedInterceptor>();
+ expectedList.add(invalidationInterceptor);
+ expectedList.add(txInterceptor);
+ expectedList.add(pessimisticInterceptor);
+ expectedList.add(callInterceptor);
+
+ assert chain.getInterceptorsAsList().equals(expectedList);
+ }
+
+ public void testAddAtPosition() throws Throwable
+ {
+ chain.addInterceptor(invalidationInterceptor, 1);
+ assert invalidationInterceptor.equals(icInterceptor.getNext());
+
+ chain.addInterceptor(pessimisticInterceptor,1);
+ assert pessimisticInterceptor.equals(icInterceptor.getNext());
+ assert invalidationInterceptor.equals(pessimisticInterceptor.getNext());
+ assert invalidationInterceptor.getNext() == null;
+
+ chain.addInterceptor(callInterceptor, 3);
+ assert invalidationInterceptor.getNext().equals(callInterceptor);
+ }
+
+ public void testAddAtPositionIncremented()
+ {
+ chain.addInterceptor(txInterceptor,1);
+ chain.addInterceptor(invalidationInterceptor,2);
+ chain.addInterceptor(pessimisticInterceptor,3);
+ chain.addInterceptor(callInterceptor,4);
+ assert icInterceptor.getNext().equals(txInterceptor);
+ assert txInterceptor.getNext().equals(invalidationInterceptor);
+ assert invalidationInterceptor.getNext().equals(pessimisticInterceptor);
+ assert pessimisticInterceptor.getNext().equals(callInterceptor);
+ }
+
+ public void testRemoveAtPostion() throws Throwable
+ {
+ chain.addInterceptor(txInterceptor,1);
+ chain.addInterceptor(invalidationInterceptor,2);
+ chain.addInterceptor(pessimisticInterceptor,3);
+ chain.addInterceptor(callInterceptor,4);
+
+ chain.removeInterceptor(4);
+ assert chain.size() == 4;
+ assert pessimisticInterceptor.getNext() == null;
+
+ chain.removeInterceptor(0);
+ assert chain.size() == 3;
+ chain.getFirstInChain().equals(txInterceptor);
+
+ chain.removeInterceptor(1);
+ assert chain.size() == 2;
+ assert txInterceptor.getNext().equals(pessimisticInterceptor);
+ }
+
+ public void testGetSize()
+ {
+ assert chain.size() == 1;
+ chain.addInterceptor(txInterceptor,1);
+ assert chain.size() == 2;
+ chain.addInterceptor(invalidationInterceptor,2);
+ assert chain.size() == 3;
+ chain.addInterceptor(pessimisticInterceptor,3);
+ assert chain.size() == 4;
+ chain.addInterceptor(callInterceptor,4);
+ assert chain.size() == 5;
+ }
+
+ public void testAppendInterceptor()
+ {
+ chain.appendIntereceptor(txInterceptor);
+ assert chain.size() == 2;
+ assert icInterceptor.getNext().equals(txInterceptor);
+
+ chain.appendIntereceptor(invalidationInterceptor);
+ assert chain.size() == 3;
+ assert txInterceptor.getNext().equals(invalidationInterceptor);
+ }
+
+ public void removeInterceptorWithtType()
+ {
+ chain.addInterceptor(txInterceptor,1);
+ chain.addInterceptor(invalidationInterceptor,2);
+ chain.addInterceptor(pessimisticInterceptor,3);
+ chain.addInterceptor(callInterceptor,4);
+
+ chain.removeInterceptor(InvalidationInterceptor.class);
+ assert chain.size() == 4;
+ assert txInterceptor.getNext().equals(pessimisticInterceptor);
+
+ chain.removeInterceptor(InvocationContextInterceptor.class);
+ assert chain.size() == 3;
+ assert chain.getFirstInChain().equals(txInterceptor);
+
+ chain.removeInterceptor(CallInterceptor.class);
+ assert chain.size() == 2;
+ assert pessimisticInterceptor.getNext() == null;
+ }
+
+ public void addInterceptorWithType()
+ {
+ assert chain.addInterceptor(invalidationInterceptor, icInterceptor.getClass());
+ assert icInterceptor.getNext().equals(invalidationInterceptor);
+
+ chain.addInterceptor(txInterceptor, icInterceptor.getClass());
+ assert icInterceptor.getNext().equals(txInterceptor);
+ assert txInterceptor.getNext().equals(invalidationInterceptor);
+ }
+
+ public ChainedInterceptor create(Class<? extends ChainedInterceptor> toInstantiate)
+ {
+ try
+ {
+ return toInstantiate.newInstance();
+ } catch (Throwable th)
+ {
+ throw new RuntimeException(th);
+ }
+ }
+}
16 years, 9 months
JBoss Cache SVN: r5527 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 20 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-04-10 00:27:48 -0400 (Thu, 10 Apr 2008)
New Revision: 5527
Added:
core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveNodeCommand.java
Removed:
core/trunk/src/main/java/org/jboss/cache/commands/CacheCommandsFactory.java
core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCacheCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveFqnCommand.java
core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java
Modified:
core/trunk/src/main/java/org/jboss/cache/CacheSPI.java
core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.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/buddyreplication/BuddyManager.java
core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java
core/trunk/src/main/java/org/jboss/cache/commands/CacheCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/CacheCommandsVisitor.java
core/trunk/src/main/java/org/jboss/cache/commands/EvictFqnCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/InvalidateCommand.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/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/commands/visitors/AbstractCommandsVisitor.java
core/trunk/src/main/java/org/jboss/cache/commands/visitors/DataVersionCommandsVisitor.java
core/trunk/src/main/java/org/jboss/cache/commands/visitors/GlobalTransactionCommandsVisitor.java
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/UnlockInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/ChainedInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.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/CacheTransactionHelper.java
core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java
core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
core/trunk/src/test/resources/log4j.xml
Log:
JBCACHE-1222 - wiering CommandsFactory changes
Modified: core/trunk/src/main/java/org/jboss/cache/CacheSPI.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -278,9 +278,10 @@
*
* @param fqn the fqn to gravitate
* @param searchBuddyBackupSubtrees if true, buddy backup subtrees are searched and if false, they are not.
+ * @param ctx
* @return a GravitateResult which contains the data for the gravitation
*/
- GravitateResult gravitateData(Fqn<?> fqn, boolean searchBuddyBackupSubtrees);
+ GravitateResult gravitateData(Fqn<?> fqn, boolean searchBuddyBackupSubtrees, InvocationContext ctx);
/**
* Returns a Set<Fqn> of Fqns of the topmost node of internal regions that
Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -115,18 +115,15 @@
protected CacheSPI<K, V> createAndWire(Configuration configuration) throws Exception
{
- CacheLifecycleManager cache = new CacheLifecycleManager(configuration);
+ CacheLifecycleManager lifecycleManager = new CacheLifecycleManager(configuration);
CacheSPI<K, V> spi = new CacheInvocationDelegate<K, V>();
- bootstrap(cache, spi, configuration);
+ bootstrap(lifecycleManager, spi, configuration);
componentRegistry.wire();
return spi;
}
/**
- * Bootstraps this factory with a Configuration and a ComponentRegistry
- *
- * @param cache
- * @param configuration
+ * Bootstraps this factory with a Configuration and a ComponentRegistry.
*/
protected void bootstrap(CacheLifecycleManager lifecycleManager, CacheSPI spi, Configuration configuration)
{
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -78,8 +78,7 @@
@Inject
private void setupDependencies(CacheMessageListener messageListener, Configuration configuration, Notifier notifier,
- CacheSPI spi, Marshaller marshaller, CacheInvocationDelegate invocationDelegate,
- TransactionTable txTable, TransactionManager txManager)
+ CacheSPI spi, Marshaller marshaller, TransactionTable txTable, TransactionManager txManager)
{
this.messageListener = messageListener;
this.configuration = configuration;
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -9,8 +9,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.jboss.cache.AbstractNode.NodeFlags.*;
-import org.jboss.cache.commands.CacheCommandsFactory;
-import org.jboss.cache.commands.cachedata.RemoveFqnCommand;
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
import org.jboss.cache.factories.annotations.CacheInjectionMethods;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.lock.IdentityLock;
@@ -61,7 +61,7 @@
private final Map data = new HashMap();
private NodeSPI delegate;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
/**
* Constructs a new node with an FQN of Root.
@@ -107,7 +107,7 @@
}
@Inject
- private void injectDependencies(CacheSPI spi, TransactionTable impl, CacheCommandsFactory commandsFactory)
+ private void injectDependencies(CacheSPI spi, TransactionTable impl, CommandsFactory commandsFactory)
{
this.cache = spi;
this.transactionTable = impl;
@@ -274,7 +274,7 @@
children.put(child_name, child);
if (gtx != null)
{
- RemoveFqnCommand undoOp = commandsFactory.buildRemoveFqnCommand(gtx, child_fqn, false, false);
+ RemoveNodeCommand undoOp = commandsFactory.buildRemoveFqnCommand(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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -3,18 +3,9 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CacheCommandsFactory;
-import org.jboss.cache.commands.EvictFqnCommand;
-import org.jboss.cache.commands.GravitateDataCacheCommand;
-import org.jboss.cache.commands.InvalidateCommand;
+import org.jboss.cache.commands.*;
import org.jboss.cache.commands.cachedata.*;
-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.remote.*;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
@@ -42,7 +33,7 @@
private String buddyGroupName;
- private CacheCommandsFactory factory;
+ private CommandsFactory factory;
public BuddyFqnTransformer(String buddyGroupName)
{
@@ -65,29 +56,29 @@
public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildPutDataMapCommand(transformed, command.getData(),
+ return factory.buildPutDataMapCommand(null, transformed, command.getData(),
command.isCreateUndoOps(), command.isEraseContents());
}
public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildPutKeyValueCommand(transformed, command.getKey(),
+ return factory.buildPutKeyValueCommand(null, transformed, command.getKey(),
command.getValue(), command.isCreateUndoOps(), command.isPutForExternalRead());
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildRemoveFqnCommand(transformed, command.isEviction(),
- command.isSkipSendingNodeEvents(), command.isCreateUndoOps(), command.getDataVersion());
+ return factory.buildRemoveFqnCommand(command.getGlobalTransaction(), transformed, command.isEviction(),
+ command.isSkipSendingNodeEvents(), command.isCreateUndoOps());
}
public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildRemoveDataCommand(transformed, command.isCreateUndoops(),
- command.isSendNodeEvent(), command.isEviction(), command.getDataVersion());
+ return factory.buildRemoveDataCommand(command.getGlobalTransaction(), transformed, command.isCreateUndoops(),
+ command.isSendNodeEvent(), command.isEviction());
}
public Object handleEvictFqnCommand(InvocationContext ctx, EvictFqnCommand command) throws Throwable
@@ -99,13 +90,13 @@
public Object handleInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
{
Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildInvalidateCommand(transformed, command.getVersionToInvalidate());
+ return factory.buildInvalidateCommand(transformed);
}
public Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
{
Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildRemoveKeyCommand(transformed, command.getKey(), command.isCreateUndoOps());
+ return factory.buildRemoveKeyCommand(null, transformed, command.getKey(), command.isCreateUndoOps());
}
public Object handleGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
@@ -151,7 +142,7 @@
return factory.buildMoveCommand(transformedFrom, transformedTo);
}
- public Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCacheCommand command) throws Throwable
+ public Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
{
Fqn transformed = getBackupFqn(command.getFqn());
return factory.buildGravitateDataCacheCommand(transformed, command.isSearchSubtrees());
@@ -159,20 +150,20 @@
public Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
{
- List<CacheCommand> toTransform = command.getModifications();
- List<CacheCommand> transformedCommands = transformBatch(toTransform);
- return factory.buildPrepareCommand(transformedCommands, command.getAddress(), command.isOnePhaseCommit());
+ List<? extends CacheCommand> toTransform = command.getModifications();
+ List<? extends CacheCommand> transformedCommands = transformBatch(toTransform);
+ return factory.buildPrepareCommand(null, transformedCommands, command.getLocalAddress(), command.isOnePhaseCommit());
}
public Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
{
- return factory.buildRollbackCommand();
+ return factory.buildRollbackCommand(null);
}
public Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
{
List<CacheCommand> transformed = transformBatch(command.getModifications());
- return factory.buildOptimisticPrepareCommand(transformed, command.getData(), command.getAddress(), command.isOnePhaseCommit());
+ return factory.buildOptimisticPrepareCommand(command.getGlobalTransaction(), transformed, command.getData(), command.getLocalAddress(), command.isOnePhaseCommit());
}
public Object handleReplicateCommand(InvocationContext ctx, ReplicateCommand command) throws Throwable
@@ -211,7 +202,7 @@
}
- public List<CacheCommand> transformBatch(List<CacheCommand> toTransform) throws Throwable
+ public List<CacheCommand> transformBatch(List<? extends CacheCommand> toTransform) throws Throwable
{
List<CacheCommand> transformedCommands = new ArrayList<CacheCommand>(toTransform.size());
for (CacheCommand com : toTransform)
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -16,7 +16,7 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
@@ -65,7 +65,7 @@
BuddyFqnTransformer fqnTransformer;
- CacheCommandsFactory commandsFactory;
+ CommandsFactory commandsFactory;
/**
* back-refernce to the CacheImpl object
@@ -174,7 +174,7 @@
@Inject
private void injectDependencies(CacheSPI cache, Configuration configuration, RegionManager regionManager,
StateTransferManager stateTransferManager, RPCManager rpcManager, Notifier notifier,
- CacheCommandsFactory factory)
+ CommandsFactory factory)
{
this.cache = cache;
this.configuration = configuration;
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/cluster/ReplicationQueue.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -4,7 +4,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.RPCManager;
import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
@@ -51,7 +51,7 @@
private RPCManager rpcManager;
private Configuration configuration;
private boolean enabled;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
public boolean isEnabled()
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CacheCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -9,7 +9,7 @@
*/
public interface CacheCommand extends Cloneable
{
- public Object perform() throws Throwable;
+ public Object perform(InvocationContext ctx) throws Throwable;
public Object accept(InvocationContext ctx, CacheCommandsVisitor handler) throws Throwable;
}
Deleted: core/trunk/src/main/java/org/jboss/cache/commands/CacheCommandsFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CacheCommandsFactory.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CacheCommandsFactory.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,323 +0,0 @@
-package org.jboss.cache.commands;
-
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.RPCManager;
-import org.jboss.cache.buddyreplication.BuddyGroup;
-import org.jboss.cache.commands.cachedata.*;
-import org.jboss.cache.commands.remote.*;
-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.commands.channel.BlockChannelCommand;
-import org.jboss.cache.commands.channel.UnblockChannelCommand;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.invocation.CacheTransactionHelper;
-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.jgroups.Address;
-
-import javax.transaction.TransactionManager;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Mircea.Markus(a)jboss.com
- * @since 2.2
- */
-public class CacheCommandsFactory
-{
- private Notifier notifier;
- private TransactionTable transactionTable;
- private CacheData cacheData;
- private CacheSPI spi;
- private Configuration configuration;
- private TransactionManager tm;
- private RPCManager rpcManager;
- CacheTransactionHelper transactionHelper;
-
-
- public CacheCommandsFactory(Notifier notifier, TransactionTable transactionTable, CacheData cacheData, CacheSPI spi)
- {
- this.notifier = notifier;
- this.transactionTable = transactionTable;
- this.cacheData = cacheData;
- this.spi = spi;
- }
-
- public CacheCommandsFactory()
- {
- }
-
- public PutDataMapCommand buildPutDataMapCommand(Fqn fqn, Map data, boolean createUndoOps, boolean eraseContents)
- {
- GlobalTransaction tx = transactionHelper.getCurrentTransaction();
- PutDataMapCommand putDataMapCommand = new PutDataMapCommand(fqn, data, createUndoOps, eraseContents);
- return putDataMapCommand;
- }
-
- public ReplicateCommand buildReplicateCommand(CacheCommand command)
- {
- return new ReplicateCommand(command);
- }
-
- public PrepareCommand buildPrepareCommand(GlobalTransaction gtx, CacheCommand command, boolean onePhaseCommit)
- {
- //params: GlobalTransaction global_tx, List modifications, Address coord, boolean onePhaseCommit
- //MethodDeclarations.prepareMethod_id, globalTransaction, mods, cache.getLocalAddress(), syncCommunications
- Address localAddress = rpcManager.getLocalAddress();
- List<CacheCommand> modList = new ArrayList<CacheCommand>(1);
- modList.add(command);
- return new PrepareCommand(modList, localAddress, onePhaseCommit);
- }
-
- public CommitCommand buildCommitCommand(GlobalTransaction gtx)
- {
- return new CommitCommand(gtx);
- }
-
- public DataGravitationCleanupCommand buildDataGravitationCleanupCommand(Fqn primaryFqn, Fqn backupFqn)
- {
- return new DataGravitationCleanupCommand(primaryFqn, backupFqn);
- }
-
- public GravitateDataCacheCommand buildGravitateDataCacheCommand(Fqn fqn, Boolean searchSubtrees)
- {
- return new GravitateDataCacheCommand(fqn, searchSubtrees);
- }
-
- public PutKeyValueCommand buildPutKeyValueCommand(Fqn fqn, Object key, Object value, boolean createUndoOps, boolean putForExternalRead)
- {
- PutKeyValueCommand command = new PutKeyValueCommand(fqn, key, value, createUndoOps, putForExternalRead);
- return command;
- }
-
- public RemoveFqnCommand buildRemoveFqnCommand(Fqn fqn, boolean eviction, boolean skipSendingNodeEvents, boolean createUndoOps, DataVersion version)
- {
- RemoveFqnCommand command = new RemoveFqnCommand(fqn, createUndoOps, skipSendingNodeEvents, eviction, version);
- return command;
- }
-
- public RemoveDataCommand buildRemoveDataCommand(Fqn fqn, boolean createUndoops, boolean sendNodeEvent, boolean eviction, DataVersion version)
- {
- RemoveDataCommand command = new RemoveDataCommand(fqn, createUndoops, sendNodeEvent, eviction, version);
- return command;
- }
-
- public EvictFqnCommand buildEvictFqnCommand(Fqn fqn)
- {
- EvictFqnCommand command = new EvictFqnCommand(fqn);
- return command;
- }
-
- public InvalidateCommand buildInvalidateCommand(Fqn fqn, DataVersion versionToInvalidate)
- {
- InvalidateCommand command = new InvalidateCommand(fqn, versionToInvalidate);
- return command;
- }
-
- public RemoveKeyCommand buildRemoveKeyCommand(Fqn fqn, Object key, boolean createUndoOps)
- {
- RemoveKeyCommand command = new RemoveKeyCommand(fqn, key, createUndoOps);
- return command;
- }
-
- public GetDataMapCommand buildGetDataMapCommand(Fqn fqn)
- {
- GetDataMapCommand command = new GetDataMapCommand(fqn);
- return command;
- }
-
- public ExistsNodeCommand buildExistsNodeCommand(Fqn fqn)
- {
- ExistsNodeCommand command = new ExistsNodeCommand(fqn);
- return command;
- }
-
- public GetKeyValueCommand buildGetKeyValueCommand(Fqn<?> fqn, Object key, boolean sendNodeEvent)
- {
- GetKeyValueCommand command = new GetKeyValueCommand(fqn, key, sendNodeEvent);
- return command;
- }
-
- public GetNodeCommand buildGetNodeCommand(Fqn fqn)
- {
- GetNodeCommand command = new GetNodeCommand(fqn);
- return command;
- }
-
- public GetKeysCommand buildGetKeysCommand(Fqn fqn)
- {
- GetKeysCommand command = new GetKeysCommand(fqn);
- return command;
- }
-
- public GetChildrenNamesCommand buildGetChildrenNamesCommand(Fqn fqn)
- {
- GetChildrenNamesCommand command = new GetChildrenNamesCommand(fqn);
- return command;
- }
-
- public MoveCommand buildMoveCommand(Fqn from, Fqn to)
- {
- MoveCommand command = new MoveCommand(from, to);
- return command;
- }
-
- public GravitateDataCacheCommand buildGravitateDataCacheCommand(Fqn fqn, boolean searchSubtrees)
- {
- GravitateDataCacheCommand command = new GravitateDataCacheCommand(fqn, searchSubtrees);
- return command;
- }
-
- public PrepareCommand buildPrepareCommand(List modifications, Address address, boolean onePhaseCommit)
- {
- PrepareCommand command = new PrepareCommand(modifications, address, onePhaseCommit);
- return command;
- }
-
- /**
- * // commitCommand = MethodCallFactory.create(MethodDeclarations.prepareMethod_id,
-// gtx, modifications, cache.getLocalAddress(),
-// true);
- */
- public PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List modifications, Address address, boolean onePhaseCommit)
- {
- PrepareCommand command = new PrepareCommand(modifications, address, onePhaseCommit);
- return command;
- }
-
- public RollbackCommand buildRollbackCommand()
- {
- RollbackCommand command = new RollbackCommand();
- return command;
- }
-
- public OptimisticPrepareCommand buildOptimisticPrepareCommand(List<CacheCommand> modifications, Map data, Address address, boolean onePhaseCommit)
- {
- OptimisticPrepareCommand command = new OptimisticPrepareCommand(modifications, data, address, onePhaseCommit);
- return command;
- }
-
- /**
- * MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod_id, gtx, entry.getModifications(), null, gtx.getAddress(), Boolean.FALSE);
- */
- public OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, List<TxCacheCommand> modifications, CacheCommand command, Object address, Boolean aFalse)
- {
- Address localAddress = rpcManager.getLocalAddress();
- return new OptimisticPrepareCommand(localAddress, command);
- }
-
- public ReplicateCommand buildReplicateCommand(List<CacheCommand> modifications)
- {
- ReplicateCommand command = new ReplicateCommand(modifications);
- return command;
- }
-
- public AnnounceBuddyPoolNameCommand buildAnnounceBuddyPoolNameCommand(Address address, String buddyPoolName)
- {
- AnnounceBuddyPoolNameCommand command = new AnnounceBuddyPoolNameCommand(address, buddyPoolName);
- return command;
- }
-
- public RemoveFromBuddyGroupCommand buildRemoveFromBuddyGroupCommand(String groupName)
- {
- RemoveFromBuddyGroupCommand command = new RemoveFromBuddyGroupCommand(groupName);
- return command;
- }
-
- public AssignToBuddyGroupCommand buildAssignToBuddyGroupCommand(BuddyGroup group, Map<Fqn, byte[]> state)
- {
- AssignToBuddyGroupCommand command = new AssignToBuddyGroupCommand(group, state);
- return command;
- }
-
- public ClusteredGetCommand buildClusteredGetCommand(Boolean searchBackupSubtrees, CacheDataCommand cacheDataComand)
- {
- ClusteredGetCommand command = new ClusteredGetCommand(searchBackupSubtrees, cacheDataComand);
- return command;
- }
-
- public BlockChannelCommand buildBlockChannelCommand()
- {
- return new BlockChannelCommand();
- }
-
- public UnblockChannelCommand buildUnblockChannelCommand()
- {
- return new UnblockChannelCommand();
- }
-
- public RemoveFqnCommand buildRemoveFqnCommand(GlobalTransaction gtx, Fqn child_fqn, boolean b, boolean b1)
- {
- return null; //To change body of created methods use File | Settings | File Templates.
- }
-
- public PutKeyValueCommand buildPutKeyValueCommand(Fqn fqn1, Object key, Object value)
- {
- return null; //To change body of created methods use File | Settings | File Templates.
- }
-
- public RemoveDataCommand buildRemoveDataCommand(GlobalTransaction tx, Fqn fqn, boolean b)
- {
- //To change body of created methods use File | Settings | File Templates.
- return null;
- }
-
- public RemoveKeyCommand buildRemoveKeyCommand(GlobalTransaction tx, Fqn<?> fqn, Object key, boolean b)
- {
- return null; //To change body of created methods use File | Settings | File Templates.
- }
-
- public PutKeyValueCommand buildPutKeyValueCommand(GlobalTransaction tx, Fqn<?> fqn, Object key, Object value, boolean putForExternalRead)
- {
- return null; //To change body of created methods use File | Settings | File Templates.
- }
-
- /**
- * putForExternalReadMethodLocal_id
- */
- public PutKeyValueCommand buildPutKeyValueCommand(Object o, Fqn<?> fqn, Object key, Object value)
- {
- return null; //To change body of created methods use File | Settings | File Templates.
- }
-
- /*
- MethodCallFactory.create(MethodDeclarations.clusteredGetMethod_id, call, false)
- */
- public ClusteredGetCommand buildClusteredGetCommand(CacheCommand call, boolean cacheDataComand)
- {
- return null; //To change body of created methods use File | Settings | File Templates.
- }
-
- /*
- MethodCallFactory.create(MethodDeclarations.putDataMethodLocal_id, globalTransaction, fqn, oldData , false);
- */
- public PutDataMapCommand buildPutDataMapCommand(GlobalTransaction gtx, Fqn fqn, Map oldData, boolean eraseContents)
- {
- return null; //To change body of created methods use File | Settings | File Templates.
- }
-
- /**
- * From commitMethod = MethodCallFactory.create(MethodDeclarations.optimisticPrepareMethod_id,
- // gtx, modifications, null, cache.getLocalAddress(), true);
- from data gravitation interceptor
- */
- public OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, Object o)
- {
- return null;
- }
-
- /**
- * MethodCallFactory.create(MethodDeclarations.rollbackMethod_id, gtx)
- */
- public RollbackCommand buildRollbackCommand(GlobalTransaction gtx)
- {
- return null; //To change body of created methods use File | Settings | File Templates.
- }
-}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/CacheCommandsVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CacheCommandsVisitor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CacheCommandsVisitor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -61,7 +61,7 @@
1 - removeNodeMethodLocal_id
2 - removeNodeVersionedMethodLocal_id
*/
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand removeFqnCommand) throws Throwable;
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand removeNodeCommand) throws Throwable;
/*
equiv of old:
@@ -136,7 +136,7 @@
equiv of old:
1 - dataGravitationMethod_id
*/
- public Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCacheCommand gravitateDataCacheCommand) throws Throwable;
+ public Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand gravitateDataCommand) throws Throwable;
/*
prepareMethod_id
Copied: core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java (from rev 5526, core/trunk/src/main/java/org/jboss/cache/commands/CacheCommandsFactory.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -0,0 +1,274 @@
+package org.jboss.cache.commands;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.RPCManager;
+import org.jboss.cache.buddyreplication.BuddyGroup;
+import org.jboss.cache.buddyreplication.BuddyManager;
+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.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.Configuration;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.invocation.CacheData;
+import org.jboss.cache.invocation.CacheTransactionHelper;
+import org.jboss.cache.invocation.InterceptorChain;
+import org.jboss.cache.notifications.Notifier;
+import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.cache.transaction.TransactionTable;
+import org.jgroups.Address;
+
+import javax.transaction.TransactionManager;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Factory for all types of cache commands.
+ * Here are some of the purposes of this class:
+ * <pre>
+ * - not creating <code>CacheCommands</code> directly (i.e. through new usage) as this would reduce unit testability
+ * - reduce the coupling between commands and other components. e.g. considering a commands that needs to knwo whether
+ * locking type is optimistic, we will pass in a 'optimistic' boolean flag rather than entire Configuration object
+ * </pre>
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 2.2
+ */
+public class CommandsFactory
+{
+ private Notifier notifier;
+ private TransactionTable transactionTable;
+ private CacheData cacheData;
+ private CacheSPI spi;
+ private Configuration configuration;
+ private TransactionManager tm;
+ private RPCManager rpcManager;
+ private CacheTransactionHelper transactionHelper;
+ private BuddyManager buddyManager;
+ private InterceptorChain interceptorChain;
+
+ @Inject
+ public void initialize(Notifier notifier, TransactionTable transactionTable, CacheData cacheData, CacheSPI spi,
+ Configuration configuration, TransactionManager txm, RPCManager rpc, CacheTransactionHelper txHelper,
+ BuddyManager buddyManager, InterceptorChain interceptorChain)
+ {
+ this.notifier = notifier;
+ this.transactionTable = transactionTable;
+ this.cacheData = cacheData;
+ this.spi = spi;
+ this.configuration = configuration;
+ this.tm = txm;
+ this.rpcManager =rpc;
+ this.transactionHelper = txHelper;
+ this.buddyManager = buddyManager;
+ this.interceptorChain = interceptorChain;
+ }
+
+ public PutDataMapCommand buildPutDataMapCommand(GlobalTransaction gtx, Fqn fqn, Map data, boolean createUndoOps, boolean eraseContents)
+ {
+ PutDataMapCommand putDataMapCommand = new PutDataMapCommand(gtx, fqn, data, createUndoOps, eraseContents);
+ putDataMapCommand.initialize(cacheData, notifier, transactionTable);
+ return putDataMapCommand;
+ }
+
+ public PutKeyValueCommand buildPutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps, boolean putForExternalRead)
+ {
+ PutKeyValueCommand command = new PutKeyValueCommand(gtx, fqn, key, value, createUndoOps, putForExternalRead);
+ command.initialize(cacheData, notifier, transactionTable);
+ return command;
+ }
+
+
+ public ReplicateCommand buildReplicateCommand(CacheCommand command)
+ {
+ return new ReplicateCommand(command);
+ }
+
+ public ReplicateCommand buildReplicateCommand(List<CacheCommand> modifications)
+ {
+ return new ReplicateCommand(modifications);
+ }
+
+ public PrepareCommand buildPrepareCommand(GlobalTransaction gtx, CacheCommand command, boolean onePhaseCommit)
+ {
+ Address localAddress = rpcManager.getLocalAddress();
+ List<CacheCommand> modList = new ArrayList<CacheCommand>(1);
+ modList.add(command);
+ return buildPrepareCommand(gtx, modList, localAddress, onePhaseCommit);
+ }
+
+ public PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List<? extends CacheCommand> modifications, Address address, boolean onePhaseCommit)
+ {
+ return new PrepareCommand(gtx, modifications, address, onePhaseCommit);
+ }
+
+ public CommitCommand buildCommitCommand(GlobalTransaction gtx)
+ {
+ return new CommitCommand(gtx);
+ }
+
+ public DataGravitationCleanupCommand buildDataGravitationCleanupCommand(Fqn primaryFqn, Fqn backupFqn)
+ {
+ DataGravitationCleanupCommand command = new DataGravitationCleanupCommand(primaryFqn, backupFqn);
+ command.initialize(buddyManager, interceptorChain, transactionHelper, this, cacheData);
+ return command;
+ }
+
+ public GravitateDataCommand buildGravitateDataCommand(Fqn fqn, Boolean searchSubtrees)
+ {
+ GravitateDataCommand command = new GravitateDataCommand(fqn, searchSubtrees);
+ command.initialize(spi, rpcManager, cacheData);
+ return command;
+ }
+
+ public RemoveNodeCommand buildRemoveFqnCommand(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());
+ return command;
+ }
+
+ public RemoveDataCommand buildRemoveDataCommand(GlobalTransaction gtx, Fqn fqn, boolean createUndoops, boolean sendNodeEvent, boolean eviction)
+ {
+ RemoveDataCommand command = new RemoveDataCommand(gtx, fqn, createUndoops, sendNodeEvent, eviction);
+ command.initialize(cacheData, transactionTable, notifier);
+ return command;
+ }
+
+ public EvictFqnCommand buildEvictFqnCommand(Fqn fqn)
+ {
+ EvictFqnCommand command = new EvictFqnCommand(fqn);
+ command.initialize(cacheData);
+ return command;
+ }
+
+ public InvalidateCommand buildInvalidateCommand(Fqn fqn)
+ {
+ InvalidateCommand command = new InvalidateCommand(fqn);
+ command.initialize(cacheData, notifier, spi, tm, configuration.isNodeLockingOptimistic());
+ return command;
+ }
+
+ public RemoveKeyCommand buildRemoveKeyCommand(GlobalTransaction tx, Fqn<?> fqn, Object key, boolean b)
+ {
+ RemoveKeyCommand command = new RemoveKeyCommand(tx, fqn, key, b);
+ command.initialize(cacheData, notifier, transactionTable);
+ return command;
+ }
+
+ public GetDataMapCommand buildGetDataMapCommand(Fqn fqn)
+ {
+ GetDataMapCommand command = new GetDataMapCommand(fqn);
+ command.initialize(cacheData);
+ return command;
+ }
+
+ public ExistsNodeCommand buildExistsNodeCommand(Fqn fqn)
+ {
+ ExistsNodeCommand command = new ExistsNodeCommand(fqn);
+ command.initialize(cacheData);
+ return command;
+ }
+
+ public GetKeyValueCommand buildGetKeyValueCommand(Fqn<?> fqn, Object key, boolean sendNodeEvent)
+ {
+ GetKeyValueCommand command = new GetKeyValueCommand(fqn, key, sendNodeEvent);
+ command.initialize(cacheData, notifier);
+ return command;
+ }
+
+ public GetNodeCommand buildGetNodeCommand(Fqn fqn)
+ {
+ GetNodeCommand command = new GetNodeCommand(fqn);
+ command.initialize(cacheData);
+ return command;
+ }
+
+ public GetKeysCommand buildGetKeysCommand(Fqn fqn)
+ {
+ GetKeysCommand command = new GetKeysCommand(fqn);
+ command.initialize(cacheData);
+ return command;
+ }
+
+ public GetChildrenNamesCommand buildGetChildrenNamesCommand(Fqn fqn)
+ {
+ GetChildrenNamesCommand command = new GetChildrenNamesCommand(fqn);
+ command.initialize(cacheData);
+ return command;
+ }
+
+ public MoveCommand buildMoveCommand(Fqn from, Fqn to)
+ {
+ MoveCommand command = new MoveCommand(from, to);
+ command.initialize(cacheData, notifier, transactionTable);
+ return command;
+ }
+
+ public GravitateDataCommand buildGravitateDataCacheCommand(Fqn fqn, boolean searchSubtrees)
+ {
+ GravitateDataCommand command = new GravitateDataCommand(fqn, searchSubtrees);
+ command.initialize(spi, rpcManager, cacheData);
+ return command;
+ }
+
+ public RollbackCommand buildRollbackCommand(GlobalTransaction gtx)
+ {
+ return new RollbackCommand(gtx);
+ }
+
+ public OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, List<? extends CacheCommand> modifications, Map data, Address address, boolean onePhaseCommit)
+ {
+ return new OptimisticPrepareCommand(gtx, modifications, data, address, onePhaseCommit);
+ }
+
+
+ public OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, CacheCommand command)
+ {
+ List<CacheCommand> commandList = new ArrayList<CacheCommand>(1);
+ commandList.add(command);
+ return buildOptimisticPrepareCommand(gtx, commandList, null, null, false);
+ }
+
+ public AnnounceBuddyPoolNameCommand buildAnnounceBuddyPoolNameCommand(Address address, String buddyPoolName)
+ {
+ AnnounceBuddyPoolNameCommand command = new AnnounceBuddyPoolNameCommand(address, buddyPoolName);
+ command.initialize(buddyManager);
+ return command;
+ }
+
+ public RemoveFromBuddyGroupCommand buildRemoveFromBuddyGroupCommand(String groupName)
+ {
+ RemoveFromBuddyGroupCommand command = new RemoveFromBuddyGroupCommand(groupName);
+ command.initialize(buddyManager);
+ return command;
+ }
+
+ public AssignToBuddyGroupCommand buildAssignToBuddyGroupCommand(BuddyGroup group, Map<Fqn, byte[]> state)
+ {
+ AssignToBuddyGroupCommand command = new AssignToBuddyGroupCommand(group, state);
+ command.initialize(buddyManager);
+ return command;
+ }
+
+ public ClusteredGetCommand buildClusteredGetCommand(Boolean searchBackupSubtrees, CacheDataCommand cacheDataComand)
+ {
+ return new ClusteredGetCommand(searchBackupSubtrees, cacheDataComand);
+ }
+
+ public BlockChannelCommand buildBlockChannelCommand()
+ {
+ return new BlockChannelCommand();
+ }
+
+ public UnblockChannelCommand buildUnblockChannelCommand()
+ {
+ return new UnblockChannelCommand();
+ }
+}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/EvictFqnCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -6,13 +6,17 @@
import org.jboss.cache.optimistic.DataVersion;
/**
+ * Implements functionality defined by {@link org.jboss.cache.CacheSPI#evict(org.jboss.cache.Fqn)}
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
public class EvictFqnCommand implements DataVersionCommand
{
+ /* dependencies*/
protected CacheData cacheData;
+ /* parameters*/
protected Fqn fqn;
protected DataVersion dataVersion;
@@ -20,15 +24,19 @@
{
this.fqn = fqn;
}
+ public void initialize(CacheData cacheData)
+ {
+ this.cacheData = cacheData;
+ }
- public Object perform()
+ public Object perform(InvocationContext ctx)
{
return cacheData.evict(fqn);
}
public Object accept(InvocationContext ctx, CacheCommandsVisitor handler) throws Throwable
{
- return handler.handleEvictFqnCommand(ctx, this);
+ return handler.handleEvictFqnCommand(ctx, this);
}
public Fqn getFqn()
Deleted: core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCacheCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCacheCommand.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCacheCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,170 +0,0 @@
-package org.jboss.cache.commands;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.RPCManager;
-import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
-import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.marshall.NodeData;
-import org.jboss.cache.notifications.Notifier;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.TreeSet;
-
-/**
- * Used with buddy replication's data gravitation interceptor. If marshalling is necessary, ensure that the cache is
- * configured to use {@link org.jboss.cache.config.Configuration#useRegionBasedMarshalling} and the {@link org.jboss.cache.Region}
- * 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 GravitateDataCacheCommand implements CacheCommand
-{
- private static final Log log = LogFactory.getLog(GravitateDataCacheCommand.class);
-
- /* dependencies */
- private CacheSPI spi;
- private RPCManager rpcManager;
- private CacheData cacheData;
-
- /* parametres */
- private Fqn fqn;
- private boolean searchSubtrees;
-
- public void init(Notifier notifier, CacheData cacheData, CacheSPI spi, Configuration configuration, RPCManager manager)
- {
- rpcManager = manager;
- }
-
- public GravitateDataCacheCommand(Fqn fqn, boolean searchSubtrees)
- {
- this.fqn = fqn;
- this.searchSubtrees = searchSubtrees;
- }
-
- public Object perform()
- {
- // for now, perform a very simple series of getData calls.
- InvocationContext ctx = spi.getInvocationContext();
- if (log.isTraceEnabled()) log.trace("Caller is asking for " + fqn);
- try
- {
- ctx.setOriginLocal(false);
- // use a get() call into the cache to make sure cache loading takes place.
- // no need to cache the original skipDataGravitation setting here - it will always be false of we got here!!
- ctx.getOptionOverrides().setSkipDataGravitation(true);
- Node actualNode = spi.getNode(fqn);
- ctx.getOptionOverrides().setSkipDataGravitation(false);
-
- if (log.isTraceEnabled()) log.trace("In local tree, this is " + actualNode);
-
- Fqn backupNodeFqn = null;
- if (actualNode == null && searchSubtrees)
- {
- log.trace("Looking at backup trees.");
- NodeSPI backupSubtree = cacheData.findNode(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
- if (backupSubtree != null)
- {
- // need to loop through backupSubtree's children
- Set childNames = backupSubtree.getChildrenNamesDirect();
- if (childNames != null)
- {
- for (Object childName : childNames)
- {
- // childName is the name of a buddy group since all child names in this
- // collection are direct children of BUDDY_BACKUP_SUBTREE_FQN
- Fqn backupRoot = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, childName);
- if (BuddyManager.isDeadBackupRoot(backupRoot))
- {
- //actualNode = searchDeadRoot(backupRoot, fqn);
- Set<Integer> deadChildNames = new TreeSet<Integer>(spi.getChildrenNames(backupRoot));
- Integer[] elems = deadChildNames.toArray(new Integer[]{});
-
- // these are integers. we need to start with the highest/most recent.
- for (int i = elems.length - 1; i > -1; i--)
- {
- Integer versionOfDefunctData = elems[i];
- backupNodeFqn = Fqn.fromRelativeFqn(Fqn.fromRelativeElements(backupRoot, versionOfDefunctData), fqn);
-
- // use a get() call into the cache to make sure cache loading takes place.
- ctx.getOptionOverrides().setSkipDataGravitation(true);
- actualNode = spi.peek(backupNodeFqn, false);
- ctx.getOptionOverrides().setSkipDataGravitation(false);
-
- // break out of the inner loop searching through the dead node's various backups
- if (actualNode != null) break;
- }
- }
- else
- {
- backupNodeFqn = Fqn.fromRelativeFqn(backupRoot, fqn);
- // use a get() call into the cache to make sure cache loading takes place.
- ctx.getOptionOverrides().setSkipDataGravitation(true);
- actualNode = spi.getNode(backupNodeFqn);
- ctx.getOptionOverrides().setSkipDataGravitation(false);
- }
-
- if (log.isTraceEnabled())
- log.trace("Looking for " + backupNodeFqn + ". Search result: " + actualNode);
-
- // break out of outer loop searching through all available backups.
- if (actualNode != null) break;
- }
- }
- }
- }
-
- if (actualNode == null)
- {
- return GravitateResult.noDataFound();
- }
- else
- {
- // make sure we LOAD data for this node!!
- actualNode.getData();
- }
-
- if (backupNodeFqn == null && searchSubtrees)
- {
- backupNodeFqn = BuddyFqnTransformer.getBackupFqn(BuddyManager.getGroupNameFromAddress(rpcManager.getLocalAddress()), fqn);
- }
-
- List<NodeData> list = cacheData.getNodeData(new LinkedList<NodeData>(), (NodeSPI) actualNode);
-
- return GravitateResult.subtreeResult(list, backupNodeFqn);
- }
- catch (RuntimeException re)
- {
- if (log.isTraceEnabled()) log.trace("Caught throwable", re);
- throw re;
- }
- finally
- {
- ctx.setOriginLocal(true);
- }
- }
-
- public Object accept(InvocationContext ctx, CacheCommandsVisitor handler) throws Throwable
- {
- return handler.handleGravitateDataCommand(ctx, this);
- }
-
- public Fqn getFqn()
- {
- return fqn;
- }
-
- public boolean isSearchSubtrees()
- {
- return searchSubtrees;
- }
-}
Copied: core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCommand.java (from rev 5526, core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCacheCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCommand.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -0,0 +1,169 @@
+package org.jboss.cache.commands;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.RPCManager;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
+import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.buddyreplication.GravitateResult;
+import org.jboss.cache.invocation.CacheData;
+import org.jboss.cache.marshall.NodeData;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * Used with buddy replication's data gravitation interceptor. If marshalling is necessary, ensure that the cache is
+ * configured to use {@link org.jboss.cache.config.Configuration#useRegionBasedMarshalling} and the {@link org.jboss.cache.Region}
+ * 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
+{
+ private static final Log log = LogFactory.getLog(GravitateDataCommand.class);
+
+ /* dependencies */
+ private CacheSPI spi; //todo ugly dependency, revisit
+ private RPCManager rpcManager;
+ private CacheData cacheData;
+
+ /* parametres */
+ private Fqn fqn;
+ private boolean searchSubtrees;
+
+ public GravitateDataCommand(Fqn fqn, boolean searchSubtrees)
+ {
+ this.fqn = fqn;
+ this.searchSubtrees = searchSubtrees;
+ }
+
+ public void initialize(CacheSPI spi, RPCManager manager, CacheData cacheData)
+ {
+ this.spi = spi;
+ this.rpcManager = manager;
+ rpcManager = manager;
+ }
+
+ public Object perform(InvocationContext ctx)
+ {
+ // for now, perform a very simple series of getData calls.
+ if (log.isTraceEnabled()) log.trace("Caller is asking for " + fqn);
+ try
+ {
+ ctx.setOriginLocal(false);
+ // use a get() call into the cache to make sure cache loading takes place.
+ // no need to cache the original skipDataGravitation setting here - it will always be false of we got here!!
+ ctx.getOptionOverrides().setSkipDataGravitation(true);
+ Node actualNode = spi.getNode(fqn);
+ ctx.getOptionOverrides().setSkipDataGravitation(false);
+
+ if (log.isTraceEnabled()) log.trace("In local tree, this is " + actualNode);
+
+ Fqn backupNodeFqn = null;
+ if (actualNode == null && searchSubtrees)
+ {
+ log.trace("Looking at backup trees.");
+ NodeSPI backupSubtree = cacheData.findNode(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
+ if (backupSubtree != null)
+ {
+ // need to loop through backupSubtree's children
+ Set childNames = backupSubtree.getChildrenNamesDirect();
+ if (childNames != null)
+ {
+ for (Object childName : childNames)
+ {
+ // childName is the name of a buddy group since all child names in this
+ // collection are direct children of BUDDY_BACKUP_SUBTREE_FQN
+ Fqn backupRoot = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, childName);
+ if (BuddyManager.isDeadBackupRoot(backupRoot))
+ {
+ //actualNode = searchDeadRoot(backupRoot, fqn);
+ Set<Integer> deadChildNames = new TreeSet<Integer>(spi.getChildrenNames(backupRoot));
+ Integer[] elems = deadChildNames.toArray(new Integer[]{});
+
+ // these are integers. we need to start with the highest/most recent.
+ for (int i = elems.length - 1; i > -1; i--)
+ {
+ Integer versionOfDefunctData = elems[i];
+ backupNodeFqn = Fqn.fromRelativeFqn(Fqn.fromRelativeElements(backupRoot, versionOfDefunctData), fqn);
+
+ // use a get() call into the cache to make sure cache loading takes place.
+ ctx.getOptionOverrides().setSkipDataGravitation(true);
+ actualNode = spi.peek(backupNodeFqn, false);
+ ctx.getOptionOverrides().setSkipDataGravitation(false);
+
+ // break out of the inner loop searching through the dead node's various backups
+ if (actualNode != null) break;
+ }
+ }
+ else
+ {
+ backupNodeFqn = Fqn.fromRelativeFqn(backupRoot, fqn);
+ // use a get() call into the cache to make sure cache loading takes place.
+ ctx.getOptionOverrides().setSkipDataGravitation(true);
+ actualNode = spi.getNode(backupNodeFqn);
+ ctx.getOptionOverrides().setSkipDataGravitation(false);
+ }
+
+ if (log.isTraceEnabled())
+ log.trace("Looking for " + backupNodeFqn + ". Search result: " + actualNode);
+
+ // break out of outer loop searching through all available backups.
+ if (actualNode != null) break;
+ }
+ }
+ }
+ }
+
+ if (actualNode == null)
+ {
+ return GravitateResult.noDataFound();
+ }
+ else
+ {
+ // make sure we LOAD data for this node!!
+ actualNode.getData();
+ }
+
+ if (backupNodeFqn == null && searchSubtrees)
+ {
+ backupNodeFqn = BuddyFqnTransformer.getBackupFqn(BuddyManager.getGroupNameFromAddress(rpcManager.getLocalAddress()), fqn);
+ }
+
+ List<NodeData> list = cacheData.getNodeData(new LinkedList<NodeData>(), (NodeSPI) actualNode);
+
+ return GravitateResult.subtreeResult(list, backupNodeFqn);
+ }
+ catch (RuntimeException re)
+ {
+ if (log.isTraceEnabled()) log.trace("Caught throwable", re);
+ throw re;
+ }
+ finally
+ {
+ ctx.setOriginLocal(true);
+ }
+ }
+
+ public Object accept(InvocationContext ctx, CacheCommandsVisitor handler) throws Throwable
+ {
+ return handler.handleGravitateDataCommand(ctx, this);
+ }
+
+ public Fqn getFqn()
+ {
+ return fqn;
+ }
+
+ public boolean isSearchSubtrees()
+ {
+ return searchSubtrees;
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/InvalidateCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/InvalidateCommand.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/InvalidateCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,18 +1,18 @@
package org.jboss.cache.commands;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.cache.*;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.invocation.CacheData;
+import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.marshall.MethodCall;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.config.Configuration;
import org.jboss.cache.optimistic.DataVersion;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
+import java.util.Collections;
import java.util.Map;
-import java.util.Collections;
/**
* Very much like an evict(), except that regardless of whether there is a child present, this call will never
@@ -29,50 +29,56 @@
*/
public class InvalidateCommand extends EvictFqnCommand
{
- private Configuration configuration;
- private Notifier notifier;
- private CacheSPI spi;
-
private static final Log log = LogFactory.getLog(InvalidateCommand.class);
+ /* dependencies*/
+ private boolean isOptimisticLocking;
+ private Notifier notifier;
+ private CacheSPI cacheSpi;//todo this is ugly, revisit
private TransactionManager transactionManager;
- private DataVersion versionToInvalidate;
-
- public InvalidateCommand(Fqn fqn, DataVersion versionToInvalidate)
+ public InvalidateCommand(Fqn fqn)
{
super(fqn);
- this.versionToInvalidate = versionToInvalidate;
}
- public Object perform()
+ public void initialize(CacheData cacheData, Notifier notifier, CacheSPI cacheSPI, TransactionManager txManager, boolean isOptimisticLocking)
{
- Node node = spi.getNode(fqn); // force interceptor chain, load if necessary from cache loader.
+ super.initialize(cacheData);
+ this.notifier = notifier;
+ this.cacheSpi = cacheSPI;
+ this.transactionManager = txManager;
+ this.isOptimisticLocking = isOptimisticLocking;
+ }
+ public Object perform(InvocationContext ctx)
+ {
+ Node node = cacheSpi.getNode(fqn); // force interceptor chain, load if necessary from cache loader.
+
if (node == null)
{
// if pessimistic locking, just return.
- if (!configuration.isNodeLockingOptimistic()) return null;
+ if (!isOptimisticLocking) return null;
// check if a tombstone already exists
NodeSPI nodeSPI = cacheData.peek(fqn, false, true);
if (nodeSPI == null)
{
- if (versionToInvalidate == null)
+ if (dataVersion == null)
{
if (log.isTraceEnabled())
log.trace("Would have created a tombstone since the node doesn't exist, but the version to invalidate is null and hence cannot create a tombstone!");
return null;
}
if (log.isTraceEnabled())
- log.trace("Node doesn't exist; creating a tombstone with data version " + versionToInvalidate);
+ log.trace("Node doesn't exist; creating a tombstone with data version " + dataVersion);
// create the node we need.
Map m = Collections.emptyMap();
- InvocationContext ic = spi.getInvocationContext();
+ InvocationContext ic = cacheSpi.getInvocationContext();
Option o = ic.getOptionOverrides();
boolean origCacheModeLocal = o.isCacheModeLocal();
o.setCacheModeLocal(true);
- o.setDataVersion(versionToInvalidate);
+ o.setDataVersion(dataVersion);
// if we are in a tx this call should happen outside of any tx
try
{
@@ -81,7 +87,7 @@
{
suspended = transactionManager.suspend();
}
- spi.put(fqn, m);
+ cacheSpi.put(fqn, m);
if (suspended != null) transactionManager.resume(suspended);
ic.getOptionOverrides().setCacheModeLocal(origCacheModeLocal);
}
@@ -94,19 +100,19 @@
node = nodeSPI;
}
- if (configuration.isNodeLockingOptimistic())
+ if (isOptimisticLocking)
removeData();
else
- super.perform();
+ super.perform(ctx);
// mark the node to be removed (and all children) as invalid so anyone holding a direct reference to it will
// be aware that it is no longer valid.
((NodeSPI) node).setValid(false, true);
- if (versionToInvalidate != null)
+ if (dataVersion != null)
{
NodeSPI n = cacheData.peek(fqn, false, true);
- n.setVersion(versionToInvalidate);
+ n.setVersion(dataVersion);
}
return null;
}
@@ -117,13 +123,13 @@
MethodCall undo_op = null;
// Find the node. This will lock it (if <tt>locking</tt> is true) and
// add the temporarily created parent nodes to the TX's node list if tx != null)
- NodeSPI n = cacheData.findNode(fqn, versionToInvalidate);
+ NodeSPI n = cacheData.findNode(fqn, dataVersion);
if (n == null)
{
log.warn("node " + fqn + " not found");
return;
}
- InvocationContext ctx = spi.getInvocationContext();
+ InvocationContext ctx = cacheSpi.getInvocationContext();
notifier.notifyNodeEvicted(fqn, true, ctx);
n.clearDataDirect();
n.setDataLoaded(false);
@@ -140,6 +146,6 @@
public DataVersion getVersionToInvalidate()
{
- return versionToInvalidate;
+ return dataVersion;
}
}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/ExistsNodeCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -7,7 +7,6 @@
import org.jboss.cache.commands.CacheCommandsVisitor;
/**
- * /**
* Checks whether a given node exists in current in-memory state of the cache.
* Does not acquire any locks in doing so (result may be dirty read). Does
* not attempt to load nodes from a cache loader (may return false if a
@@ -27,8 +26,13 @@
this.fqn = fqn;
}
- public Object perform()
+ public void initialize(CacheData cacheData)
{
+ this.cacheData = cacheData;
+ }
+
+ public Object perform(InvocationContext ctx)
+ {
Node n = cacheData.peek(fqn, false);
return n != null;
}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetChildrenNamesCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -14,7 +14,6 @@
*/
public class GetChildrenNamesCommand implements CacheDataCommand
{
-
private CacheData cacheData;
private Fqn fqn;
@@ -24,8 +23,13 @@
this.fqn = fqn;
}
- public Object perform()
+ public void initialize(CacheData cacheData)
{
+ this.cacheData = cacheData;
+ }
+
+ public Object perform(InvocationContext ctx)
+ {
NodeSPI n = cacheData.findNode(fqn);
if (n == null) return null;
Set childNames = new HashSet();
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetDataMapCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -7,10 +7,12 @@
import org.jboss.cache.commands.CacheCommandsVisitor;
/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#getData(org.jboss.cache.Fqn)}
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
-public class GetDataMapCommand implements CacheDataCommand
+public class GetDataMapCommand implements CacheDataCommand
{
private CacheData cacheData;
@@ -21,8 +23,13 @@
this.fqn = fqn;
}
- public Object perform()
+ public void initialize(CacheData cacheData)
{
+ this.cacheData = cacheData;
+ }
+
+ public Object perform(InvocationContext ctx)
+ {
NodeSPI n = cacheData.findNode(fqn);
if (n == null) return null;
return n.getDataDirect();
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeyValueCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,16 +1,17 @@
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.commands.CacheCommandsVisitor;
+import org.jboss.cache.invocation.CacheData;
import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.commands.CacheCommandsVisitor;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
+ * Implements functionality defined by {@link org.jboss.cache.CacheSPI#get(String, Object)}
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
@@ -18,10 +19,11 @@
{
private static final Log log = LogFactory.getLog(GetKeyValueCommand.class);
+ /* dependencies*/
private CacheData cacheData;
private Notifier notifier;
- private CacheSPI spi;
+ /* parameters */
private Fqn<?> fqn;
private Object key;
boolean sendNodeEvent;
@@ -33,9 +35,14 @@
this.sendNodeEvent = sendNodeEvent;
}
- public Object perform()
+ public void initialize(CacheData cacheData, Notifier notifier)
{
- InvocationContext ctx = spi.getInvocationContext();
+ this.cacheData = cacheData;
+ this.notifier = notifier;
+ }
+
+ public Object perform(InvocationContext ctx)
+ {
if (log.isTraceEnabled())
{
log.trace(new StringBuffer("_get(").append("\"").append(fqn).append("\", \"").append(key).append("\", \"").
@@ -57,6 +64,7 @@
{
return handler.handleGetKeyValueCommand(ctx, this);
}
+
public Fqn getFqn()
{
return fqn;
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetKeysCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -10,12 +10,13 @@
import java.util.Set;
/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#getKeys(org.jboss.cache.Fqn)}
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
public class GetKeysCommand implements CacheDataCommand
{
-
private CacheData cacheData;
private Fqn fqn;
@@ -25,8 +26,13 @@
this.fqn = fqn;
}
- public Object perform()
+ public void initialize(CacheData cacheData)
{
+ this.cacheData = cacheData;
+ }
+
+ public Object perform(InvocationContext ctx)
+ {
NodeSPI n = cacheData.findNode(fqn);
if (n == null)
{
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/GetNodeCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -6,12 +6,15 @@
import org.jboss.cache.invocation.CacheData;
/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#getNode(org.jboss.cache.Fqn)}
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
public class GetNodeCommand implements CacheDataCommand
{
private CacheData cacheData;
+
private Fqn fqn;
public GetNodeCommand(Fqn fqn)
@@ -19,8 +22,13 @@
this.fqn = fqn;
}
- public Object perform()
+ public void initialize(CacheData cacheData)
{
+ this.cacheData = cacheData;
+ }
+
+ public Object perform(InvocationContext ctx)
+ {
return cacheData.findNode(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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/MoveCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,6 +1,5 @@
package org.jboss.cache.commands.cachedata;
-import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeNotExistsException;
@@ -12,17 +11,19 @@
import org.jboss.cache.transaction.TransactionTable;
/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#move(org.jboss.cache.Fqn, org.jboss.cache.Fqn)}
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
public class MoveCommand implements TxCacheCommand, CacheDataCommand
{
-
+ /* dependencies */
private CacheData cacheData;
private Notifier notifier;
- private CacheSPI spi;
private TransactionTable transactionTable;
+ /* params */
private Fqn from;
private Fqn to;
@@ -32,15 +33,22 @@
this.to = to;
}
- public Object perform()
+ public void initialize(CacheData cacheData, Notifier notifier, TransactionTable txTable)
{
- _move(from, to, false);
+ this.cacheData = cacheData;
+ this.notifier = notifier;
+ this.transactionTable = txTable;
+ }
+
+ public Object perform(InvocationContext ctx)
+ {
+ _move(from, to, false, ctx);
return null;
}
public void rollback()
{
- _move(Fqn.fromRelativeElements(to, from.getLastElement()), from.getParent(), true);
+ _move(Fqn.fromRelativeElements(to, from.getLastElement()), from.getParent(), true, null);
}
@@ -55,7 +63,7 @@
return handler.handleMoveCommand(ctx, this);
}
- public void _move(Fqn nodeToMoveFqn, Fqn newParentFqn, boolean skipNotifications)
+ public void _move(Fqn nodeToMoveFqn, Fqn newParentFqn, boolean skipNotifications, InvocationContext ctx)
{
// the actual move algorithm.
NodeSPI newParent = cacheData.findNode(newParentFqn);
@@ -79,7 +87,6 @@
// first correct the pointers at the pruning point
oldParent.removeChildDirect(nodeName);
newParent.addChild(nodeName, node);
- InvocationContext ctx = spi.getInvocationContext();
// parent pointer is calculated on the fly using Fqns.
// notify
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutDataMapCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -20,6 +20,8 @@
import java.util.Map;
/**
+ * Implements functionality defined by {@link org.jboss.cache.CacheSPI#put(String, java.util.Map)}
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
@@ -29,10 +31,9 @@
/* dependencies*/
private GlobalTransaction globalTransaction;
- private TransactionTable transactionTable;
private CacheData cacheData;
private Notifier notifier;
- private CacheSPI spi;
+ private TransactionTable transactionTable;
/* parameters*/
private Fqn fqn;
@@ -41,44 +42,31 @@
private boolean eraseContents;
protected DataVersion dataVersion;
- /* internally used for rollback */
+ /** internally used for rollback */
private Map oldData;
- public void initialize(GlobalTransaction tx, CacheData cacheData, Notifier notifier, CacheSPI spi, TransactionTable txTable)
+ public PutDataMapCommand(GlobalTransaction globalTransaction, Fqn fqn, Map data, boolean createUndoOps, boolean eraseContents)
{
- this.globalTransaction = tx;
- this.cacheData = cacheData;
- this.notifier = notifier;
- this.spi = spi;
- this.transactionTable = txTable;
- }
-
- /**
- * old MethodDeclaratuions#putDataErase
- */
- public PutDataMapCommand(Fqn fqn, Map data, boolean createUndoOps, boolean eraseContents)
- {
+ this.globalTransaction = globalTransaction;
this.fqn = fqn;
this.data = data;
this.createUndoOps = createUndoOps;
this.eraseContents = eraseContents;
}
- /**
- * old MethodDeclaratuions#putDataMethodLocal
- */
- public PutDataMapCommand(GlobalTransaction globalTransaction, Fqn fqn, Map data, boolean createUndoOps)
+ public void initialize(CacheData cacheData, Notifier notifier, TransactionTable txTable)
{
- this(fqn, data, createUndoOps, false);
+ this.cacheData = cacheData;
+ this.notifier = notifier;
+ this.transactionTable = txTable;
}
- public Object perform()
+ public Object perform(InvocationContext ctx)
{
if (log.isTraceEnabled())
{
log.trace("perform(" + globalTransaction + ", \"" + fqn + "\", " + data + " undo=" + createUndoOps + " erase=" + eraseContents + ")");
}
- InvocationContext ctx = spi.getInvocationContext();//todo getInvocationContext() should not be in CacheSPI, perhaps in base command class
NodeSPI nodeSPI = cacheData.findNodeCheck(globalTransaction, fqn, false);
oldData = nodeSPI.getDataDirect();
notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.PUT_MAP, oldData, ctx);
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/PutKeyValueCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,26 +1,26 @@
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.NodeSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.commands.TxCacheCommand;
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.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
-import org.jboss.cache.notifications.event.NodeModifiedEvent;
-import org.jboss.cache.notifications.Notifier;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.util.Collections;
import java.util.Map;
-import java.util.Collections;
/**
+ * 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
*/
@@ -29,13 +29,12 @@
private static final Log log = LogFactory.getLog(PutKeyValueCommand.class);
/* dependencies*/
- private GlobalTransaction globalTransaction;
+ private TransactionTable transactionTable;
private CacheData cacheData;
private Notifier notifier;
- private TransactionTable transactionTable;
- private CacheSPI spi;
/* parametres */
+ private GlobalTransaction globalTransaction;
private Fqn fqn;
private Object key;
private Object value;
@@ -48,8 +47,9 @@
*/
private Object oldValue;
- public PutKeyValueCommand(Fqn fqn, Object key, Object value, boolean createUndoOps, boolean isPutForExternalRead)
+ public PutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps, boolean isPutForExternalRead)
{
+ this.globalTransaction = gtx;
this.fqn = fqn;
this.key = key;
this.value = value;
@@ -57,14 +57,20 @@
this.isPutForExternalRead = isPutForExternalRead;
}
- public Object perform()
+ public void initialize(CacheData cacheData, Notifier notifier, TransactionTable transactionTable)
{
+ this.transactionTable = transactionTable;
+ this.notifier = notifier;
+ this.cacheData = cacheData;
+ }
+
+ public Object perform(InvocationContext ctx)
+ {
if (log.isTraceEnabled())
{
log.trace(new StringBuffer("perform(").append(globalTransaction).append(", \"").
append(fqn).append("\", k=").append(key).append(", v=").append(value).append(")"));
}
- InvocationContext ctx = spi.getInvocationContext();
// if this is a rollback then don't fire notifications.
boolean isRollback = false;
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveDataCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -21,6 +21,8 @@
import java.util.HashMap;
/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#remove(String, Object)}
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
@@ -29,32 +31,40 @@
private static final Log log = LogFactory.getLog(RemoveDataCommand.class);
/* dependencies*/
- private GlobalTransaction globalTransaction;
private CacheData cacheData;
private TransactionTable transactionTable;
- private CacheSPI spi;
private Notifier notifier;
/* parameters*/
+ private GlobalTransaction globalTransaction;
private Fqn fqn;
private boolean createUndoops;
private boolean sendNodeEvent;
private boolean eviction;
private DataVersion dataVersion;
- /** internally used var*/
+ /**
+ * internally used for rollback.
+ */
private HashMap originalData;
- public RemoveDataCommand(Fqn fqn, boolean createUndoops, boolean sendNodeEvent, boolean eviction, DataVersion dataVersion)
+ public void initialize(CacheData cacheData, TransactionTable transactionTable, Notifier notifier)
{
+ this.cacheData = cacheData;
+ this.transactionTable = transactionTable;
+ this.notifier = notifier;
+ }
+
+ public RemoveDataCommand(GlobalTransaction gtx, Fqn fqn, boolean createUndoops, boolean sendNodeEvent, boolean eviction)
+ {
+ this.globalTransaction = gtx;
this.fqn = fqn;
this.createUndoops = createUndoops;
this.sendNodeEvent = sendNodeEvent;
this.eviction = eviction;
- this.dataVersion = dataVersion;
}
- public Object perform()
+ public Object perform(InvocationContext ctx)
{
if (log.isTraceEnabled()) log.trace("perform(" + globalTransaction + ", \"" + fqn + "\")");
NodeSPI targetNode = cacheData.findNode(fqn, dataVersion);
@@ -65,7 +75,6 @@
}
Map data = targetNode.getDataDirect();
- InvocationContext ctx = spi.getInvocationContext();
prepareDataForRollback(data);
notifyBefore(data, ctx);
Deleted: core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveFqnCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveFqnCommand.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveFqnCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,213 +0,0 @@
-package org.jboss.cache.commands.cachedata;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.NodeSPI;
-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.config.Configuration;
-import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionTable;
-
-/**
- * @author Mircea.Markus(a)jboss.com
- * @since 2.2
- */
-public class RemoveFqnCommand implements TxCacheCommand, CacheDataCommand, DataVersionCommand, GlobalTransactionCommand
-{
- private static final Log log = LogFactory.getLog(RemoveFqnCommand.class);
-
- /*dependencies*/
- private GlobalTransaction globalTransaction;
- private NodeSPI targetNode;
- private CacheSPI spi;
- private CacheData cacheData;
- private Configuration configuration;
- private TransactionTable transactionTable;
- private Notifier notifier;
-
- /*parameters*/
- private Fqn fqn;
- private boolean createUndoOps;
- private boolean skipSendingNodeEvents;
- private boolean eviction;
- private DataVersion dataVersion;
-
- /*internal data for rollback */
- private Fqn parentFqn;
-
- public RemoveFqnCommand(Fqn fqn, boolean createUndoOps, boolean skipSendingNodeEvents, boolean eviction, DataVersion dataVersion)
- {
- this.fqn = fqn;
- this.createUndoOps = createUndoOps;
- this.skipSendingNodeEvents = skipSendingNodeEvents;
- this.eviction = eviction;
- this.dataVersion = dataVersion;
- }
-
- /**
- * Old: removeNodeMethodLocal
- */
- public RemoveFqnCommand(Fqn fqn, boolean createUndoOps, boolean skipSendingNodeEvents)
- {
- this(fqn, createUndoOps, skipSendingNodeEvents, false, null);
- }
-
-
- public Object perform()
- {
- NodeSPI parentNode;
- if (log.isTraceEnabled()) log.trace("perform(" + globalTransaction + ", \"" + fqn + "\", undo=" + createUndoOps + ")");
- InvocationContext ctx = spi.getInvocationContext();
-
- // Find the node. This will add the temporarily created parent nodes to the TX's node list if globalTransaction != null)
- targetNode = cacheData.findNode(fqn, dataVersion, true);
- if (targetNode == null)
- {
- if (log.isTraceEnabled()) log.trace("node " + fqn + " not found");
- return false;
- }
-
- notifyBeforeEviction(targetNode, ctx);
-
- parentNode = targetNode.getParent();
- boolean found;
-
- // remove subtree from parent
- if (eviction || configuration.isNodeLockingOptimistic())
- {
- // 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
- {
- found = targetNode.isValid() && !targetNode.isDeleted();
- targetNode.markAsDeleted(true, true);
- }
-
- if (eviction && parentNode != null)
- {
- parentNode.setChildrenLoaded(false);
- }
-
- // create a compensating method call (reverting the effect of
- // this modification) and put it into the TX's undo list.
- if (globalTransaction != null && createUndoOps && !eviction && found)
- {
- parentFqn = parentNode.getFqn();
- transactionTable.addUndoOperation(globalTransaction, this);
- }
-
- notifyAfterEviction(ctx);
- return found;
- }
-
- private void notifyAfterEviction(InvocationContext ctx)
- {
- if (!skipSendingNodeEvents)
- {
- if (eviction)
- {
- notifier.notifyNodeEvicted(fqn, false, ctx);
- } else
- {
- notifier.notifyNodeRemoved(fqn, false, null, ctx);
- }
- }
- }
-
- private void notifyBeforeEviction(NodeSPI n, InvocationContext ctx)
- {
- if (!skipSendingNodeEvents)
- {
- if (eviction)
- {
- notifier.notifyNodeEvicted(fqn, true, ctx);
- } else
- {
- notifier.notifyNodeRemoved(fqn, true, n.getDataDirect(), ctx);
- }
- }
- }
-
- public void rollback()
- {
- String childName = (String) targetNode.getFqn().getLastElement();
- if (log.isTraceEnabled())
- {
- log.trace("rollback(\"" + parentFqn + "\", \"" + childName + "\", node=" + targetNode + ")");
- }
-
- if (parentFqn == null || childName == null || targetNode == null)
- {
- log.error("parent_fqn or childName or childNode was null");
- return;
- }
- NodeSPI parentNode = cacheData.findNode(parentFqn);
- if (parentNode == null)
- {
- log.warn("node " + parentFqn + " not found");
- return;
- }
- parentNode.addChild(childName, targetNode);
- targetNode.markAsDeleted(false, true);
- targetNode.setValid(true, true);
- }
-
- public Object accept(InvocationContext ctx, CacheCommandsVisitor handler) throws Throwable
- {
- return handler.handleRemoveFqnCommand(ctx, this);
- }
-
- public Fqn getFqn()
- {
- return fqn;
- }
-
- public DataVersion getDataVersion()
- {
- return dataVersion;
- }
-
- public void setDataVersion(DataVersion dataVersion)
- {
- this.dataVersion = dataVersion;
- }
-
- public boolean isVersioned()
- {
- return dataVersion != null;
- }
-
- public boolean isSkipSendingNodeEvents()
- {
- return skipSendingNodeEvents;
- }
-
- public boolean isCreateUndoOps()
- {
- return createUndoOps;
- }
-
- public boolean isEviction()
- {
- return eviction;
- }
-
- public GlobalTransaction getGlobalTransaction()
- {
- return globalTransaction;
- }
-
- public void setGlobalTransaction(GlobalTransaction gtx)
- {
- this.globalTransaction = gtx;
- }
-}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveKeyCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,26 +1,27 @@
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.NodeSPI;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.commands.TxCacheCommand;
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.Collections;
import java.util.Map;
/**
+ * Implements functionality defined by {@link org.jboss.cache.Cache#remove(org.jboss.cache.Fqn, Object)}
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
@@ -29,30 +30,39 @@
private static final Log log = LogFactory.getLog(RemoveKeyCommand.class);
/* dependencies */
- private GlobalTransaction globalTransaction;
private CacheData cacheData;
private Notifier notifier;
private TransactionTable transactionTable;
- private CacheSPI spi;
/* parameters */
+ private GlobalTransaction globalTransaction;
private Fqn fqn;
private Object key;
private boolean createUndoOps;
private DataVersion dataVersion;
- /** internally used for rollback */
+ /**
+ * internally used for rollback
+ */
private Object oldValue;
- public RemoveKeyCommand(Fqn fqn, Object key, boolean createUndoOps)
+ public RemoveKeyCommand(GlobalTransaction gtx, Fqn fqn, Object key, boolean createUndoOps)
{
+ this.globalTransaction = gtx;
this.fqn = fqn;
this.key = key;
this.createUndoOps = createUndoOps;
}
- public Object perform()
+ public void initialize(CacheData cacheData, Notifier notifier, TransactionTable transactionTable)
{
+ this.cacheData = cacheData;
+ this.notifier = notifier;
+ this.transactionTable = transactionTable;
+ }
+
+ public Object perform(InvocationContext ctx)
+ {
if (log.isTraceEnabled()) log.trace("perform(" + globalTransaction + ", \"" + fqn + "\", key=" + key + ")");
NodeSPI n = cacheData.findNode(fqn);
@@ -61,7 +71,6 @@
log.warn("node " + fqn + " not found");
return null;
}
- InvocationContext ctx = spi.getInvocationContext();
notifier.notifyNodeModified(fqn, true, NodeModifiedEvent.ModificationType.REMOVE_DATA, n.getDataDirect(), ctx);
this.oldValue = n.removeDirect(key);
Copied: core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveNodeCommand.java (from rev 5526, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveFqnCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveNodeCommand.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/RemoveNodeCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -0,0 +1,211 @@
+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.NodeSPI;
+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.invocation.CacheData;
+import org.jboss.cache.notifications.Notifier;
+import org.jboss.cache.optimistic.DataVersion;
+import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.cache.transaction.TransactionTable;
+
+/**
+ * Implements functionality defined by {@link org.jboss.cache.CacheSPI#removeNode(org.jboss.cache.Fqn)}
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 2.2
+ */
+public class RemoveNodeCommand implements TxCacheCommand, CacheDataCommand, DataVersionCommand, GlobalTransactionCommand
+{
+ private static final Log log = LogFactory.getLog(RemoveNodeCommand.class);
+
+ /*dependencies*/
+ private CacheData cacheData;
+ private boolean isOptimistic;
+ private TransactionTable transactionTable;
+ private Notifier notifier;
+
+ /*parameters*/
+ private GlobalTransaction globalTransaction;
+ private Fqn fqn;
+ private boolean createUndoOps;
+ private boolean skipSendingNodeEvents;
+ private boolean eviction;
+ private DataVersion dataVersion;
+
+ /*internal data for rollback */
+ private Fqn parentFqn;
+ private NodeSPI targetNode;
+
+ public RemoveNodeCommand(GlobalTransaction globalTransaction, Fqn fqn, boolean createUndoOps, boolean skipSendingNodeEvents, boolean eviction)
+ {
+ this.globalTransaction = globalTransaction;
+ this.fqn = fqn;
+ this.createUndoOps = createUndoOps;
+ this.skipSendingNodeEvents = skipSendingNodeEvents;
+ this.eviction = eviction;
+ }
+
+ public void initialize(CacheData cacheData, TransactionTable txTable, Notifier notifier, boolean isOptimisticLocking)
+ {
+ this.cacheData = cacheData;
+ this.transactionTable = txTable;
+ this.notifier = notifier;
+ this.isOptimistic = isOptimisticLocking;
+ }
+
+ public Object perform(InvocationContext ctx)
+ {
+ NodeSPI parentNode;
+ if (log.isTraceEnabled())
+ log.trace("perform(" + globalTransaction + ", \"" + fqn + "\", undo=" + createUndoOps + ")");
+
+ // Find the node. This will add the temporarily created parent nodes to the TX's node list if globalTransaction != null)
+ targetNode = cacheData.findNode(fqn, dataVersion, true);
+ if (targetNode == null)
+ {
+ if (log.isTraceEnabled()) log.trace("node " + fqn + " not found");
+ return false;
+ }
+
+ notifyBeforeEviction(targetNode, ctx);
+
+ parentNode = targetNode.getParent();
+ boolean found;
+
+ // remove subtree from parent
+ if (eviction || isOptimistic)
+ {
+ // 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
+ {
+ found = targetNode.isValid() && !targetNode.isDeleted();
+ targetNode.markAsDeleted(true, true);
+ }
+
+ if (eviction && parentNode != null)
+ {
+ parentNode.setChildrenLoaded(false);
+ }
+
+ // create a compensating method call (reverting the effect of
+ // this modification) and put it into the TX's undo list.
+ if (globalTransaction != null && createUndoOps && !eviction && found)
+ {
+ parentFqn = parentNode.getFqn();
+ transactionTable.addUndoOperation(globalTransaction, this);
+ }
+
+ notifyAfterEviction(ctx);
+ return found;
+ }
+
+ private void notifyAfterEviction(InvocationContext ctx)
+ {
+ if (!skipSendingNodeEvents)
+ {
+ if (eviction)
+ {
+ notifier.notifyNodeEvicted(fqn, false, ctx);
+ } else
+ {
+ notifier.notifyNodeRemoved(fqn, false, null, ctx);
+ }
+ }
+ }
+
+ private void notifyBeforeEviction(NodeSPI n, InvocationContext ctx)
+ {
+ if (!skipSendingNodeEvents)
+ {
+ if (eviction)
+ {
+ notifier.notifyNodeEvicted(fqn, true, ctx);
+ } else
+ {
+ notifier.notifyNodeRemoved(fqn, true, n.getDataDirect(), ctx);
+ }
+ }
+ }
+
+ public void rollback()
+ {
+ String childName = (String) targetNode.getFqn().getLastElement();
+ if (log.isTraceEnabled())
+ {
+ log.trace("rollback(\"" + parentFqn + "\", \"" + childName + "\", node=" + targetNode + ")");
+ }
+
+ if (parentFqn == null || childName == null || targetNode == null)
+ {
+ log.error("parent_fqn or childName or childNode was null");
+ return;
+ }
+ NodeSPI parentNode = cacheData.findNode(parentFqn);
+ if (parentNode == null)
+ {
+ log.warn("node " + parentFqn + " not found");
+ return;
+ }
+ parentNode.addChild(childName, targetNode);
+ targetNode.markAsDeleted(false, true);
+ targetNode.setValid(true, true);
+ }
+
+ public Object accept(InvocationContext ctx, CacheCommandsVisitor handler) throws Throwable
+ {
+ return handler.handleRemoveNodeCommand(ctx, this);
+ }
+
+ public Fqn getFqn()
+ {
+ return fqn;
+ }
+
+ public DataVersion getDataVersion()
+ {
+ return dataVersion;
+ }
+
+ public void setDataVersion(DataVersion dataVersion)
+ {
+ this.dataVersion = dataVersion;
+ }
+
+ public boolean isVersioned()
+ {
+ return dataVersion != null;
+ }
+
+ public boolean isSkipSendingNodeEvents()
+ {
+ return skipSendingNodeEvents;
+ }
+
+ public boolean isCreateUndoOps()
+ {
+ return createUndoOps;
+ }
+
+ public boolean isEviction()
+ {
+ return eviction;
+ }
+
+ public GlobalTransaction getGlobalTransaction()
+ {
+ return globalTransaction;
+ }
+
+ public void setGlobalTransaction(GlobalTransaction gtx)
+ {
+ this.globalTransaction = gtx;
+ }
+}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/channel/BlockChannelCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -13,7 +13,7 @@
*/
public class BlockChannelCommand implements CacheCommand
{
- public Object perform() throws Throwable
+ public Object perform(InvocationContext ctx) throws Throwable
{
return null;
}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/channel/UnblockChannelCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -13,7 +13,7 @@
*/
public class UnblockChannelCommand implements CacheCommand
{
- public Object perform() throws Throwable
+ public Object perform(InvocationContext ctx) throws Throwable
{
//noop
return null;
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -16,21 +16,27 @@
{
private static final Log log = LogFactory.getLog(AnnounceBuddyPoolNameCommand.class);
+ /* dependencies*/
+ private BuddyManager buddyManager;
+
/*parameters */
private Address address;
private String buddyPoolName;
- /* dependencies*/
- private BuddyManager buddyManager;
-
public AnnounceBuddyPoolNameCommand(Address address, String buddyPoolName)
{
this.address = address;
this.buddyPoolName = buddyPoolName;
}
- public Object perform() throws Throwable
+ public void initialize(BuddyManager buddyManager)
{
+ this.buddyManager = buddyManager;
+ }
+
+
+ public Object perform(InvocationContext ctx) throws Throwable
+ {
if (buddyManager != null)
buddyManager.handlePoolNameBroadcast(address, buddyPoolName);
else if (log.isWarnEnabled())
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -20,6 +20,8 @@
private static final Log log = LogFactory.getLog(AssignToBuddyGroupCommand.class);
private BuddyManager buddyManager;
+
+
private BuddyGroup group;
private Map<Fqn, byte[]> state;
@@ -29,8 +31,13 @@
this.state = state;
}
- public Object perform() throws Throwable
+ public void initialize(BuddyManager manager)
{
+ this.buddyManager = manager;
+ }
+
+ public Object perform(InvocationContext ctx) throws Throwable
+ {
if (buddyManager != null)
buddyManager.handleAssignToBuddyGroup(group, state);
else if (log.isWarnEnabled())
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -21,7 +21,6 @@
*/
public class ClusteredGetCommand implements CacheCommand
{
-
private static final Log log = LogFactory.getLog(ClusteredGetCommand.class);
private CacheDataCommand cacheDataComand;
@@ -39,8 +38,9 @@
*
* @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() throws Throwable
+ public Object perform(InvocationContext ctx) throws Throwable
{
if (log.isTraceEnabled())
log.trace("Clustered Get called with params: " + cacheDataComand + ", " + searchBackupSubtrees);
@@ -50,7 +50,7 @@
try
{
if (log.isTraceEnabled()) log.trace("Clustered get: invoking call with Fqn " + cacheDataComand.getFqn());
- callResults = cacheDataComand.perform();
+ callResults = cacheDataComand.perform(ctx);
boolean found = validResult(callResults);
if (log.isTraceEnabled()) log.trace("Got result " + callResults + ", found=" + found);
if (found && callResults == null) callResults = createEmptyResults();
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -7,7 +7,7 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.commands.*;
-import org.jboss.cache.commands.cachedata.RemoveFqnCommand;
+import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
import org.jboss.cache.invocation.CacheData;
import org.jboss.cache.invocation.CacheTransactionHelper;
import org.jboss.cache.invocation.InterceptorChain;
@@ -16,6 +16,8 @@
import java.util.Set;
/**
+ * Data gravitation cleanup handler.
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
* todo this calls other commands through the invocation chain, check wheter direct call is not okay
@@ -26,16 +28,17 @@
private static final Log log = LogFactory.getLog(DataGravitationCleanupCommand.class);
+ /* dependencies */
private BuddyManager buddyManager;
private CacheTransactionHelper transactionHelper;
- private InvocationContext invocationContext;
private InterceptorChain invoker;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
+ private CacheData cacheData;
+ /* parameters */
private GlobalTransaction globalTransaction;
private Fqn primary;
private Fqn backup;
- private CacheData cacheData;
public DataGravitationCleanupCommand(Fqn primary, Fqn backup)
@@ -44,18 +47,17 @@
this.backup = backup;
}
- public DataGravitationCleanupCommand(BuddyManager buddyManager, InterceptorChain invoker, Fqn primary,
- Fqn backup, InvocationContext invocationContext, CacheTransactionHelper transactionHelper)
+ public void initialize(BuddyManager buddyManager, InterceptorChain invoker, CacheTransactionHelper transactionHelper,
+ CommandsFactory commandsFactory, CacheData cacheData)
{
this.buddyManager = buddyManager;
this.invoker = invoker;
- this.primary = primary;
- this.backup = backup;
- this.invocationContext = invocationContext;
this.transactionHelper = transactionHelper;
+ this.commandsFactory = commandsFactory;
+ this.cacheData = cacheData;
}
- public Object perform() throws Throwable
+ public Object perform(InvocationContext invocationContext) throws Throwable
{
if (buddyManager.isDataGravitationRemoveOnFind())
{
@@ -107,7 +109,7 @@
private boolean executeRemove(GlobalTransaction gtx, Fqn toRemove) throws Throwable
{
Object result;
- RemoveFqnCommand removeBackupCommand = commandsFactory.buildRemoveFqnCommand(gtx, toRemove, true, false);
+ RemoveNodeCommand removeBackupCommand = commandsFactory.buildRemoveFqnCommand(gtx, toRemove, true, true, false);
result = invoker.invoke(removeBackupCommand);
return result != null && (Boolean) result;
}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -16,6 +16,7 @@
private static final Log log = LogFactory.getLog(RemoveFromBuddyGroupCommand.class);
private BuddyManager buddyManager;
+
private String groupName;
public RemoveFromBuddyGroupCommand(String groupName)
@@ -23,8 +24,13 @@
this.groupName = groupName;
}
- public Object perform() throws Throwable
+ public void initialize(BuddyManager buddyManager)
{
+ this.buddyManager = buddyManager;
+ }
+
+ public Object perform(InvocationContext ctx) throws Throwable
+ {
if (buddyManager != null)
buddyManager.handleRemoveFromBuddyGroup(groupName);
else if (log.isWarnEnabled())
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -2,7 +2,7 @@
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.CacheCommandsVisitor;
-import org.jboss.cache.commands.GravitateDataCacheCommand;
+import org.jboss.cache.commands.GravitateDataCommand;
import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.invocation.InterceptorChain;
@@ -11,6 +11,8 @@
import java.util.ArrayList;
/**
+ * Command that implements cluster replication logic.
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
@@ -18,6 +20,12 @@
{
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.
+ */
+ private CacheCommand singleModification;
public ReplicateCommand(CacheCommand toReplicate, InterceptorChain invoker)
{
@@ -33,13 +41,12 @@
public ReplicateCommand(CacheCommand command)
{
- modifications = new ArrayList<CacheCommand>();
- modifications.add(command);
+ this.singleModification = command;
}
- public Object perform() throws Throwable
+ public Object perform(InvocationContext ctx) throws Throwable
{
- if (modifications.size() == 1)
+ if (singleModification != null)
{
return processSingleCommand(modifications.get(0));
}
@@ -85,7 +92,7 @@
private boolean returnValueForRemoteCall(CacheCommand cacheCommand)
{
- return cacheCommand instanceof GravitateDataCacheCommand || cacheCommand instanceof ClusteredGetCommand;
+ return cacheCommand instanceof GravitateDataCommand || cacheCommand instanceof ClusteredGetCommand;
}
public Object accept(InvocationContext ctx, CacheCommandsVisitor handler) throws Throwable
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -19,7 +19,7 @@
this.globalTransaction = globalTransaction;
}
- public Object perform()
+ public Object perform(InvocationContext ctx)
{
//no op
return null;
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -17,19 +17,14 @@
{
private Map data;
- public OptimisticPrepareCommand(List<CacheCommand> modifications, Map data, Address address, boolean onePhaseCommit)
+ public OptimisticPrepareCommand(GlobalTransaction gtx, List<? extends CacheCommand> modifications, Map data, Address address, boolean onePhaseCommit)
{
- super(modifications, address, onePhaseCommit);
+ super(gtx, modifications, address, onePhaseCommit);
this.data = data;
}
- public OptimisticPrepareCommand(Address address, CacheCommand command)
+ public Object perform(InvocationContext ctx)
{
- super(null, address, false);
- }
-
- public Object perform()
- {
return null;
}
@@ -38,38 +33,8 @@
return handler.handleOptimisticPrepareCommand(ctx, this);
}
- public GlobalTransaction getGlobalTransaction()
- {
- return globalTransaction;
- }
-
- public void setGlobalTransaction(GlobalTransaction gtx)
- {
- this.globalTransaction = gtx;
- }
-
- public List<CacheCommand> getModifications()
- {
- return modifications;
- }
-
public Map getData()
{
return data;
}
-
- public Address getAddress()
- {
- return address;
- }
-
- public boolean isOnePhaseCommit()
- {
- return onePhaseCommit;
- }
-
- public int getModificationsCount()
- {
- return modifications != null ? modifications.size() : 0;
- }
}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -10,20 +10,22 @@
import java.util.List;
/**
+ * Marker for a cache command action.
+ *
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
public class PrepareCommand implements CacheCommand, GlobalTransactionCommand
{
protected GlobalTransaction globalTransaction;
- protected List<CacheCommand> modifications;
- protected Address address;
+ protected List<? extends CacheCommand> modifications;
+ protected Address localAddress;
protected boolean onePhaseCommit;
- public PrepareCommand(List<CacheCommand> modifications, Address address, boolean onePhaseCommit)
+ public PrepareCommand(GlobalTransaction gtx, List<? extends CacheCommand> modifications, Address localAddress, boolean onePhaseCommit)
{
this.modifications = modifications;
- this.address = address;
+ this.localAddress = localAddress;
this.onePhaseCommit = onePhaseCommit;
}
@@ -32,7 +34,7 @@
return handler.handlePrepareCommand(ctx, this);
}
- public Object perform()
+ public Object perform(InvocationContext ctx)
{
return null;
}
@@ -47,14 +49,14 @@
this.globalTransaction = gtx;
}
- public List<CacheCommand> getModifications()
+ public List<? extends CacheCommand> getModifications()
{
return modifications;
}
- public Address getAddress()
+ public Address getLocalAddress()
{
- return address;
+ return localAddress;
}
public boolean isOnePhaseCommit()
@@ -67,5 +69,8 @@
return modifications != null && modifications.size() > 0;
}
-
+ public int getModificationsCount()
+ {
+ return modifications != null ? modifications.size() : 0;
+ }
}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -12,14 +12,14 @@
*/
public class RollbackCommand implements CacheCommand, GlobalTransactionCommand
{
-
private GlobalTransaction globalTransaction;
- public RollbackCommand()
+ public RollbackCommand(GlobalTransaction globalTransaction)
{
+ this.globalTransaction = globalTransaction;
}
- public Object perform()
+ public Object perform(InvocationContext ctx)
{
return null;
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/visitors/AbstractCommandsVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/visitors/AbstractCommandsVisitor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/visitors/AbstractCommandsVisitor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -29,7 +29,7 @@
return handleDefault(ctx, command);
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
return handleDefault(ctx, command);
}
@@ -89,7 +89,7 @@
return handleDefault(ctx, command);
}
- public Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCacheCommand command) throws Throwable
+ public Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
{
return handleDefault(ctx, command);
}
@@ -159,7 +159,7 @@
return null;
}
- public void visitCollection(InvocationContext ctx, Collection<CacheCommand> toVisit) throws Throwable
+ public void visitCollection(InvocationContext ctx, Collection<? extends CacheCommand> toVisit) throws Throwable
{
for (CacheCommand command: toVisit)
{
Modified: core/trunk/src/main/java/org/jboss/cache/commands/visitors/DataVersionCommandsVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/visitors/DataVersionCommandsVisitor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/visitors/DataVersionCommandsVisitor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -25,7 +25,7 @@
return handleDataVersionCommand(ctx, command);
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
return handleDataVersionCommand(ctx, command);
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/visitors/GlobalTransactionCommandsVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/visitors/GlobalTransactionCommandsVisitor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/commands/visitors/GlobalTransactionCommandsVisitor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -31,7 +31,7 @@
return handleGlobalTransactionCommands(command);
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
return handleGlobalTransactionCommands(command);
}
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -4,6 +4,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.config.RuntimeConfig;
@@ -322,7 +323,7 @@
private boolean isNonBootstrapClass(Class<?> componentClass)
{
- return !(componentClass.equals(CacheSPI.class) || componentClass.equals(InterceptorChain.class) ||
+ return !(componentClass.equals(CacheSPI.class) ||
componentClass.equals(CacheLifecycleManager.class) || componentClass.equals(Cache.class) ||
componentClass.equals(CacheData.class) || componentClass.equals(ComponentRegistry.class) ||
componentClass.equals(Configuration.class));
@@ -382,25 +383,19 @@
moveComponentsToState(overallState == STARTED ? STOPPED : CONSTRUCTED);
moveComponentsToState(originalState);
// re- add a few key components - this is a hack for now
- InterceptorChain ic = getComponent(InterceptorChain.class);
- CacheData cd = getComponent(CacheData.class);
CacheLifecycleManager clm = getComponent(CacheLifecycleManager.class);
- CacheSPI rcid = getComponent("remoteDelegate", CacheInvocationDelegate.class);
CacheSPI spi = getComponent(CacheSPI.class.getName(), CacheSPI.class);
+ CommandsFactory commandsFactory = getComponent(CommandsFactory.class.getName(), CommandsFactory.class);
- unregisterComponent(InterceptorChain.class);
unregisterComponent(CacheLifecycleManager.class);
- unregisterComponent(CacheData.class);
- unregisterComponent(CacheSPI.class.getName());
- unregisterComponent("remoteDelegate");
+ unregisterComponent(CacheSPI.class);
+ unregisterComponent(CommandsFactory.class);
overallState = CONSTRUCTED;
- registerComponent(InterceptorChain.class.getName(), ic, InterceptorChain.class);
registerComponent(CacheLifecycleManager.class.getName(), clm, CacheLifecycleManager.class);
- registerComponent(CacheData.class.getName(), cd, CacheData.class);
registerComponent(CacheSPI.class.getName(), spi, CacheSPI.class);
-// registerComponent("remoteDelegate", rcid, RemoteCacheInvocationDelegate.class);
+ registerComponent(CommandsFactory.class.getName(), commandsFactory, CommandsFactory.class);
overallState = originalState;
moveComponentsToState(overallState);
Modified: core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,9 +1,14 @@
package org.jboss.cache.factories;
import org.jboss.cache.RegionManager;
+import org.jboss.cache.lock.LockManager;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.factories.annotations.DefaultFactoryFor;
import org.jboss.cache.invocation.InvocationContextContainer;
+import org.jboss.cache.invocation.CacheInvocationDelegate;
+import org.jboss.cache.invocation.CacheData;
+import org.jboss.cache.invocation.CacheTransactionHelper;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.marshall.VersionAwareMarshaller;
@@ -21,7 +26,8 @@
*/
@DefaultFactoryFor(classes = {StateTransferManager.class, TransactionTable.class, RegionManager.class, Notifier.class,
CacheMessageListener.class, CacheLoaderManager.class, Marshaller.class,
- InvocationContextContainer.class, ObjectStreamPool.class})
+ InvocationContextContainer.class, ObjectStreamPool.class, CacheInvocationDelegate.class,
+ CacheTransactionHelper.class, CacheData.class, CommandsFactory.class, LockManager.class})
public class EmptyConstructorFactory extends ComponentFactory
{
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/factories/InterceptorChainFactory.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -18,7 +18,7 @@
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
*/
-@DefaultFactoryFor(classes = ChainedInterceptor.class)
+@DefaultFactoryFor(classes = InterceptorChain.class)
public class InterceptorChainFactory extends ComponentFactory
{
/**
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -4,11 +4,10 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.Modification;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.visitors.AbstractCommandsVisitor;
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
+import org.jboss.cache.commands.visitors.AbstractCommandsVisitor;
import org.jboss.cache.invocation.CacheData;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.notifications.Notifier;
@@ -33,7 +32,6 @@
protected TransactionManager txMgr = null;
//todo - this is never queried, is this expected behavior?
- private HashMap<GlobalTransaction, Integer> txActivations = new HashMap<GlobalTransaction, Integer>();
private long activations = 0;
/**
@@ -44,7 +42,6 @@
public ActivationInterceptor()
{
- initLogger();
isActivation = true;
useCacheStore = false;
}
@@ -60,7 +57,7 @@
}
@Override
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
Object returnValue = invokeNextInterceptor(ctx, command);
if (trace)
@@ -242,17 +239,10 @@
}
List<Modification> cacheLoaderModifications = new ArrayList<Modification>();
ActivationModificationsBuilder builder = new ActivationModificationsBuilder(cacheData, loader, notifier);
- for (CacheCommand command : entry.getCacheLoaderModifications())
- {
- command.accept(ctx, builder);
- }
+ builder.visitCollection(null, entry.getCacheLoaderModifications());
if (cacheLoaderModifications.size() > 0)
{
loader.prepare(gtx, cacheLoaderModifications, false);
- if (config.getExposeManagementStatistics() && getStatisticsEnabled() && builder.txActs > 0)
- {
- txActivations.put(gtx, builder.txActs);
- }
}
}
@@ -272,9 +262,9 @@
this.notifier = notifier;
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand removeFqnCommand) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand removeNodeCommand) throws Throwable
{
- Modification mod = new Modification(Modification.ModificationType.REMOVE_NODE, removeFqnCommand.getFqn());
+ Modification mod = new Modification(Modification.ModificationType.REMOVE_NODE, removeNodeCommand.getFqn());
cacheLoaderModifications.add(mod);
return null;
}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -7,7 +7,7 @@
import org.jboss.cache.RPCManager;
import org.jboss.cache.interceptors.base.ChainedInterceptor;
import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.cluster.ReplicationQueue;
import org.jboss.cache.config.Configuration.CacheMode;
@@ -34,7 +34,7 @@
private boolean usingBuddyReplication;
private ReplicationQueue replicationQueue;
private TransactionTable txTable;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
protected RPCManager rpcManager;
protected boolean defaultSynchronous;
@@ -42,7 +42,7 @@
@Inject
public void injectComponents(RPCManager rpcManager, BuddyManager buddyManager, ReplicationQueue replicationQueue,
- Configuration config, TransactionTable txTable, CacheCommandsFactory commandsFactory)
+ Configuration config, TransactionTable txTable, CommandsFactory commandsFactory)
{
this.rpcManager = rpcManager;
this.replicationQueue = replicationQueue;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -22,6 +22,7 @@
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
+import org.apache.commons.logging.LogFactory;
import java.util.Collections;
import java.util.HashMap;
@@ -61,11 +62,6 @@
*/
protected boolean useCacheStore = true;
- public CacheLoaderInterceptor()
- {
- initLogger();
- }
-
@Inject
protected void injectDependencies(TransactionTable txTable, CacheLoaderManager clm, Configuration configuration,
CacheData cacheData, Configuration config, LockManager lockManager, Notifier notifier)
@@ -203,7 +199,7 @@
}
@Override
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
if (config.isNodeLockingOptimistic() && command.getFqn() != null)
{
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -22,12 +22,14 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.InvocationContext;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.ChainedInterceptor;
import org.jboss.cache.commands.EvictFqnCommand;
import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
import org.jboss.cache.commands.cachedata.PutDataMapCommand;
import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
import org.jboss.cache.invocation.CacheData;
+import org.apache.commons.logging.LogFactory;
import java.util.HashMap;
import java.util.Map;
@@ -52,9 +54,10 @@
private CacheData cacheData;
- public CacheMgmtInterceptor()
+ @Inject
+ public void setDependencies(CacheData cacheData)
{
- initLogger();
+ this.cacheData = cacheData;
}
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -9,7 +9,7 @@
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.RemoveFqnCommand;
+import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
@@ -25,6 +25,7 @@
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
+import org.apache.commons.logging.LogFactory;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
@@ -57,7 +58,8 @@
public CacheStoreInterceptor()
{
- initLogger();
+ log = LogFactory.getLog(getClass());
+ trace = log.isTraceEnabled();
}
@Inject
@@ -192,7 +194,7 @@
* access an element just removed, causing the CacheLoader to *load* the element before *removing* it.
*/
@Override
- public Object executeRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object executeRemoveFqnCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
if (!inTransaction())
{
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -6,7 +6,7 @@
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.RemoveFqnCommand;
+import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
@@ -88,7 +88,7 @@
Object retval;
try
{
- retval = command.perform();
+ retval = command.perform(ctx);
}
catch (Throwable t)
{
@@ -112,7 +112,7 @@
return handleAlterChacheMethod(ctx, command);
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
return handleAlterChacheMethod(ctx, command);
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -6,13 +6,16 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CacheCommandsFactory;
-import org.jboss.cache.commands.GravitateDataCacheCommand;
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.GravitateDataCommand;
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
import org.jboss.cache.commands.tx.CommitCommand;
@@ -56,23 +59,19 @@
private Map<GlobalTransaction, CacheCommand> transactionMods = new ConcurrentHashMap<GlobalTransaction, CacheCommand>();
private CacheData cacheData;
private Configuration config;
- private CacheCommandsFactory commandsFactory;
- private CacheSPI cache;
+ private CommandsFactory commandsFactory;
+ private CacheSPI cacheSPI;
@Inject
- public void injectComponents(BuddyManager buddyManager, Configuration config, CacheData cacheData, CacheCommandsFactory commandsFactory)
+ public void injectComponents(BuddyManager buddyManager, Configuration config, CacheData cacheData, CommandsFactory commandsFactory, CacheSPI cacheSPI)
{
this.buddyManager = buddyManager;
syncCommunications = config.getCacheMode() == Configuration.CacheMode.REPL_SYNC || config.getCacheMode() == Configuration.CacheMode.INVALIDATION_SYNC;
this.cacheData = cacheData;
this.commandsFactory = commandsFactory;
+ this.cacheSPI = cacheSPI;
}
- public DataGravitatorInterceptor()
- {
- initLogger();
- }
-
@Override
public Object handleGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
{
@@ -333,7 +332,7 @@
}
List<Address> mbrs = rpcManager.getMembers();
Boolean searchSubtrees = buddyManager.isDataGravitationSearchBackupTrees() ? Boolean.TRUE : Boolean.FALSE;
- GravitateDataCacheCommand command = commandsFactory.buildGravitateDataCacheCommand(fqn, searchSubtrees);
+ GravitateDataCommand command = commandsFactory.buildGravitateDataCommand(fqn, searchSubtrees);
// doing a GET_ALL is crappy but necessary since JGroups' GET_FIRST could return null results from nodes that do
// not have either the primary OR backup, and stop polling other valid nodes.
List resps = rpcManager.callRemoteMethods(mbrs, command, GroupRequest.GET_ALL, true, buddyManager.getBuddyCommunicationTimeout(), new ResponseValidityFilter(mbrs, rpcManager.getLocalAddress()), false);
@@ -394,19 +393,19 @@
}
else
{
- cache.put(data.getFqn(), data.getAttributes());
+ cacheSPI.put(data.getFqn(), data.getAttributes());
}
}
}
private TransactionEntry getTransactionEntry(GlobalTransaction gtx)
{
- return cache.getTransactionTable().get(gtx);
+ return cacheSPI.getTransactionTable().get(gtx);
}
private BackupData localBackupGet(Fqn fqn, InvocationContext ctx) throws CacheException
{
- GravitateResult result = cache.gravitateData(fqn, true);// a "local" gravitation
+ GravitateResult result = cacheSPI.gravitateData(fqn, true, ctx);// a "local" gravitation
boolean found = result.isDataFound();
BackupData data = null;
@@ -420,11 +419,11 @@
// Remove locally only; the remote call will
// be broadcast later
ctx.getOptionOverrides().setCacheModeLocal(true);
- cache.removeNode(backupFqn);
+ cacheSPI.removeNode(backupFqn);
}
else
{
- cache.evict(backupFqn, true);
+ cacheSPI.evict(backupFqn, true);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -15,6 +15,7 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.ChainedInterceptor;
import org.jboss.cache.invocation.CacheData;
+import org.apache.commons.logging.LogFactory;
/**
* Eviction Interceptor.
@@ -48,11 +49,6 @@
this.regionManager = regionManager;
}
- public EvictionInterceptor()
- {
- initLogger();
- }
-
@Override
public Object handleEvictFqnCommand(InvocationContext ctx, EvictFqnCommand command) throws Throwable
{
@@ -188,7 +184,7 @@
}
@Override
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
Object retVal = invokeNextInterceptor(ctx,command);
if (command.getFqn() != null && !canIgnoreEvent(command.getFqn(), NodeEventType.REMOVE_NODE_EVENT))
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -62,17 +62,7 @@
private boolean statsEnabled = false;
protected boolean trace;
- public Interceptor()
- {
- initLogger();
- }
- protected void initLogger()
- {
- log = LogFactory.getLog(getClass());
- trace = log.isTraceEnabled();
- }
-
public void setNext(Interceptor i)
{
next = i;
@@ -230,7 +220,7 @@
case MethodDeclarations.removeNodeMethodLocal_id:
case MethodDeclarations.removeNodeVersionedMethodLocal_id:
{
- return next.handleRemoveFqnCommand(ctx, (RemoveFqnCommand) command);
+ return next.handleRemoveNodeCommand(ctx, (RemoveNodeCommand) command);
}
case MethodDeclarations.removeDataMethodLocal_id:
case MethodDeclarations.removeDataVersionedMethodLocal_id:
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -12,15 +12,10 @@
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.cluster.ReplicationQueue;
import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.InvalidateCommand;
import org.jboss.cache.commands.TxCacheCommand;
-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.RemoveFqnCommand;
-import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
+import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
@@ -35,20 +30,11 @@
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
-import org.jboss.cache.transaction.TransactionEntry;
-import org.jboss.cache.transaction.TransactionTable;
-import org.jboss.cache.transaction.TxUtil;
+import org.jboss.cache.transaction.*;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -69,19 +55,16 @@
protected TransactionTable txTable;
protected Map<GlobalTransaction, List<TxCacheCommand>> txMods;
protected boolean optimistic;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
- public InvalidationInterceptor()
- {
- initLogger();
- }
-
@Inject
- public void injectComponents(RPCManager rpcManager, BuddyManager buddyManager, ReplicationQueue replicationQueue, Configuration config, TransactionTable txTable, CacheCommandsFactory commandsFactory)
+ public void injectComponents(RPCManager rpcManager, BuddyManager buddyManager, ReplicationQueue replicationQueue,
+ Configuration config, TransactionTable txTable, CommandsFactory commandsFactory)
{
super.injectComponents(rpcManager, buddyManager, replicationQueue, config, txTable, commandsFactory);
optimistic = config.isNodeLockingOptimistic();
if (optimistic) txMods = new ConcurrentHashMap<GlobalTransaction, List<TxCacheCommand>>();
+ this.commandsFactory = commandsFactory;
}
@Inject
@@ -113,7 +96,7 @@
return handleCrudMethod(ctx, command.getFqn(), null, command);
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
return handleCrudMethod(ctx, command.getFqn(), null, command);
}
@@ -241,7 +224,7 @@
private void broadcastInvalidate(List<TxCacheCommand> modifications, GlobalTransaction gtx, Transaction tx, InvocationContext ctx) throws Throwable
{
InvalidationFilterVisitor filterVisitor = new InvalidationFilterVisitor(modifications.size());
- filterVisitor.visitCollectionGeneric(null, modifications);
+ filterVisitor.visitCollection(null, modifications);
if (filterVisitor.containsPutForExternalRead)
{
@@ -299,7 +282,7 @@
return addFqn(command.getFqn());
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
return addFqn(command.getFqn());
}
@@ -359,7 +342,7 @@
{
// increment invalidations counter if statistics maintained
incrementInvalidations();
- InvalidateCommand call = commandsFactory.buildInvalidateCommand(fqn, getNodeVersion(workspace, fqn));
+ InvalidateCommand call = commandsFactory.buildInvalidateCommand(fqn);
if (log.isDebugEnabled()) log.debug("Cache [" + rpcManager.getLocalAddress() + "] replicating " + call);
// voila, invalidated!
replicateCall(ctx, call, synchronous, ctx.getOptionOverrides());
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -8,15 +8,16 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
-import org.jboss.cache.invocation.CacheTransactionHelper;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.remote.*;
+import org.jboss.cache.commands.cachedata.*;
+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.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.config.Option;
+import org.jboss.cache.invocation.CacheTransactionHelper;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TxUtil;
@@ -30,13 +31,14 @@
*/
public class InvocationContextInterceptor extends BaseTransactionalContextInterceptor implements InvocationContextInterceptorMBean
{
-
private CacheTransactionHelper txHelper;
private RPCManager rpcManager;
- public InvocationContextInterceptor()
+ @Inject
+ public void setDependencies(CacheTransactionHelper cth, RPCManager rpcManager)
{
- initLogger();
+ this.txHelper = cth;
+ this.rpcManager = rpcManager;
}
public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
@@ -49,7 +51,7 @@
return handleAll(ctx, command, command.getGlobalTransaction());
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
return handleAll(ctx, command, command.getGlobalTransaction());
}
Deleted: core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MethodDispacherInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,388 +0,0 @@
-package org.jboss.cache.interceptors;
-
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Node;
-import org.jboss.cache.marshall.MethodCall;
-import org.jboss.cache.marshall.MethodDeclarations;
-import org.jboss.cache.optimistic.DataVersion;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.util.BitEncodedIntegerSet;
-import org.jgroups.Address;
-
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-
-/**
- * The purpose of this interceptor is to supply a nicer way of handling the interception of desired methods:
- * <pre>
- * - one can regiter to be notified on an particular method call by extending handle<i>CalledMethod</i> method.
- * This would result in removal of switch statemenets in invoke
- * - the parameters of the hendler methods are passes in strongly typed, rather than as an array of Objects
- * </pre>
- * This interceptor acts as a switch that delegates method calls to handlers/methods.
- * <p/>
- * Implementation notes:
- * Current implementation checks to see the methods that are overwritten and does only perform calls to those methods.
- * This is for avoiding the casts needed to build parameter list. If a non-overridden method is invoked,
- * then next interceptor will be called.
- *
- * @author Mircea.Markus(a)jboss.com
- * @version 2.1.0
- * todo - Refactor stuff in txint
- */
-public abstract class MethodDispacherInterceptor extends Interceptor
-{
- /**
- * Methods that have been overridden.
- */
- private BitEncodedIntegerSet overriddenMethods = new BitEncodedIntegerSet();
-
- protected MethodDispacherInterceptor()
- {
- findOverriddenMethods();
- }
-
- /**
- * Acts like a 'switch case' that delegates the call to the appropriate method.
- */
- public Object invoke(InvocationContext ctx) throws Throwable
- {
- if (trace) log.trace("Invoked with method call " + ctx.getMethodCall());
-
- MethodCall m = ctx.getMethodCall();
- if (!overriddenMethods.contains(m.getMethodId()) || skipMethodCall(ctx))
- {
- if (trace) log.trace("Not registered for any handlers, or instructed to skip call. Passing up the chain.");
- return nextInterceptor(ctx);
- }
- long start = System.currentTimeMillis();
- Object[] args = m.getArgs();
- Object result;
- switch (m.getMethodId())
- {
- case MethodDeclarations.putDataEraseMethodLocal_id:
- result = handlePutDataMapCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Map) args[2], (Boolean) args[3], (Boolean) args[4]);
- break;
- case MethodDeclarations.putDataMethodLocal_id:
- result = handlePutDataMapCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Map) args[2], (Boolean) args[3]);
- break;
- case MethodDeclarations.putForExternalReadMethodLocal_id:
- result = handlePutKeyValueCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], args[3]);
- break;
- case MethodDeclarations.putKeyValMethodLocal_id:
- result = handlePutKeyValueCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], args[3], (Boolean) args[4]);
- break;
- case MethodDeclarations.moveMethodLocal_id:
- result = handleMoveCommand(ctx, (Fqn) args[0], (Fqn) args[1]);
- break;
- case MethodDeclarations.getKeyValueMethodLocal_id:
- result = handleGetKeyValueCommand(ctx, (Fqn) args[0], args[1], (Boolean) args[2]);
- break;
- case MethodDeclarations.getNodeMethodLocal_id:
- result = handleGetNodeCacheCommand(ctx, (Fqn) args[0]);
- break;
- case MethodDeclarations.getChildrenNamesMethodLocal_id:
- result = handleGetChildrenNamesCommand(ctx, (Fqn) args[0]);
- break;
- case MethodDeclarations.getKeysMethodLocal_id:
- result = handleGetKeysCommand(ctx, (Fqn) args[0]);
- break;
- case MethodDeclarations.getDataMapMethodLocal_id:
- result = handleGetDataCommand(ctx, (Fqn) args[0]);
- break;
- case MethodDeclarations.rollbackMethod_id:
- result = handleRollbackCommand(ctx, (GlobalTransaction) args[0]);
- break;
- case MethodDeclarations.removeNodeMethodLocal_id:
- result = handleRemoveFqnCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Boolean) args[2]);
- break;
- case MethodDeclarations.removeKeyMethodLocal_id:
- result = handleRemoveKeyCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], (Boolean) args[3]);
- break;
- case MethodDeclarations.removeDataMethodLocal_id:
- result = handleRemoveDataCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Boolean) args[2]);
- break;
- case MethodDeclarations.commitMethod_id:
- result = handleCommitCommand(ctx, (GlobalTransaction) args[0]);
- break;
- case MethodDeclarations.optimisticPrepareMethod_id:
- result = handleOptimisticPrepareCommand(ctx, (GlobalTransaction) args[0], (List) args[1], (Map) args[2], (Address) args[3], (Boolean) args[4]);
- break;
- case MethodDeclarations.prepareMethod_id:
- result = handlePrepareCommand(ctx, (GlobalTransaction) args[0], (List) args[1], (Address) args[2], (Boolean) args[3]);
- break;
- case MethodDeclarations.evictNodeMethodLocal_id:
- result = handleEvictFqnCommand(ctx, (Fqn) args[0]);
- break;
- case MethodDeclarations.evictVersionedNodeMethodLocal_id:
- result = handleEvictFqnCommand(ctx, (Fqn) args[0], (DataVersion) args[1]);
- break;
- case MethodDeclarations.existsMethod_id:
- result = handleExistsNodeCommand(ctx, (Fqn) args[0]);
- break;
- case MethodDeclarations.putDataEraseVersionedMethodLocal_id:
- result = handlePutDataMapCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Map) args[2], (Boolean) args[3], (Boolean) args[4], (DataVersion) args[5]);
- break;
- case MethodDeclarations.putDataVersionedMethodLocal_id:
- result = handlePutDataMapCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Map) args[2], (Boolean) args[3], (DataVersion) args[4]);
- break;
- case MethodDeclarations.putKeyValVersionedMethodLocal_id:
- result = handlePutKeyValueCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], args[3], (Boolean) args[4], (DataVersion) args[5]);
- break;
- case MethodDeclarations.putForExternalReadVersionedMethodLocal_id:
- result = handlePutKeyValueCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], args[3], (DataVersion) args[5]);
- break;
- case MethodDeclarations.dataGravitationCleanupMethod_id:
- result = handleDataGravitationCleanupCommand(ctx, (Fqn) args[0], (Fqn) args[1]);
- break;
- case MethodDeclarations.removeNodeVersionedMethodLocal_id:
- result = handleRemoveFqnCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Boolean) args[2], (DataVersion) args[3]);
- break;
- case MethodDeclarations.removeKeyVersionedMethodLocal_id:
- result = handleRemoveKeyCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], args[2], (Boolean) args[3], (DataVersion) args[4]);
- break;
- case MethodDeclarations.removeDataVersionedMethodLocal_id:
- result = handleRemoveDataCommand(ctx, (GlobalTransaction) args[0], (Fqn) args[1], (Boolean) args[2], (DataVersion) args[3]);
- break;
- default:
- return nextInterceptor(ctx);
- }
- return result;
- }
-
- public boolean isTheOne()
- {
- return Thread.currentThread().getName().equalsIgnoreCase("THEONE");
- }
-
- protected Object handleRemoveDataCommand(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, boolean createUndoOps, DataVersion dv) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleRemoveKeyCommand(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Object key, boolean createUndoOps, DataVersion dv) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleRemoveFqnCommand(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, boolean createUndoOps, DataVersion dv) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleDataGravitationCleanupCommand(InvocationContext ctx, Fqn primary, Fqn backup) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handlePutKeyValueCommand(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Object key, Object value, DataVersion dv) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handlePutKeyValueCommand(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps, DataVersion dv) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handlePutDataMapCommand(InvocationContext ctx, GlobalTransaction globalTransaction, Fqn fqn, Map map, Boolean createUndoOps, DataVersion dataVersion) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handlePutDataMapCommand(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Map data, boolean createUndoOps, boolean eraseContent, DataVersion dv) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleExistsNodeCommand(InvocationContext ctx, Fqn fqn) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- /**
- * Each interceptor should extend this if it does not need any processing for current call.
- * An sample usage would be: this interceptor is only interested if thre is one transaction going on. If so all
- * handleXYZ would know that we have a transaction going and would not check its state.
- */
- protected boolean skipMethodCall(InvocationContext ctx)
- {
- return false;
- }
-
- protected Object handleEvictFqnCommand(InvocationContext ctx, Fqn fqn, DataVersion dataVersion) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- /**
- * Handles evict()
- */
- protected Object handleEvictFqnCommand(InvocationContext ctx, Fqn fqn) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handlePrepareCommand(InvocationContext ctx, GlobalTransaction gtx, List modification, Address coordinator, boolean onePhaseCommit) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleOptimisticPrepareCommand(InvocationContext ctx, GlobalTransaction gtx, List modifications, Map data, Address address, boolean onePhaseCommit) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleCommitCommand(InvocationContext ctx, GlobalTransaction globalTransaction) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleRemoveDataCommand(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, boolean createUndoOps) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleRemoveKeyCommand(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, Object key, boolean createUndoOps) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleRemoveFqnCommand(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, boolean createUndoOps) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
-
- protected Object handleRollbackCommand(InvocationContext ctx, GlobalTransaction globalTransaction) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleGetDataCommand(InvocationContext ctx, Fqn fqn) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- /**
- * Handles {@link org.jboss.cache.Cache#getKeys(Fqn)}
- */
- protected Object handleGetKeysCommand(InvocationContext ctx, Fqn fqn) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleGetChildrenNamesCommand(InvocationContext ctx, Fqn fqn) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleGetNodeCacheCommand(InvocationContext ctx, Fqn fqn) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleGetKeyValueCommand(InvocationContext ctx, Fqn fqn, Object key, boolean sendNodeEvent) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handleAddChildMethod(InvocationContext ctx, GlobalTransaction tx, Fqn parentFqn, Object childName, Node cn, boolean createUndoOps) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
-
- protected Object handleMoveCommand(InvocationContext ctx, Fqn from, Fqn to) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handlePutKeyValueCommand(InvocationContext ctx, GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handlePutKeyValueCommand(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, Object key, Object value) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handlePutDataMapCommand(InvocationContext ctx, GlobalTransaction tx, Fqn fqn, Map data, boolean createUndoOps) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- protected Object handlePutDataMapCommand(InvocationContext ctx, GlobalTransaction gt, Fqn fqn, Map newData, boolean createUndoOps, boolean eraseContents) throws Throwable
- {
- return defaultHandlersBehavior();
- }
-
- /**
- * Handlers defined here should not be called directlly. There are two scenarios in which a handler might be called:
- * 1 - DerivedInterceptor.super - pointless call
- * 2 - if the logic that determines that an handler is overwritten fails. Throwing an exception by default is for
- * guarding against this scenario
- */
- private Object defaultHandlersBehavior()
- {
- throw new IllegalStateException("this is either called from a derived class or not overridden and accidentally called. Either way, is not correct.");
- }
-
- /**
- * Builds the list of methods that are overwiritten.
- */
- private void findOverriddenMethods()
- {
- checkIfOverridden(MethodDeclarations.putDataEraseMethodLocal_id, "handlePutDataMapCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, Map.class, boolean.class, boolean.class);
- checkIfOverridden(MethodDeclarations.putDataMethodLocal_id, "handlePutDataMapCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, Map.class, boolean.class);
- checkIfOverridden(MethodDeclarations.putForExternalReadMethodLocal_id, "handlePutKeyValueCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Object.class);
- checkIfOverridden(MethodDeclarations.putKeyValMethodLocal_id, "handlePutKeyValueCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Object.class, boolean.class);
- checkIfOverridden(MethodDeclarations.moveMethodLocal_id, "handleMoveCommand", InvocationContext.class, Fqn.class, Fqn.class);
- checkIfOverridden(MethodDeclarations.getKeyValueMethodLocal_id, "handleGetKeyValueCommand", InvocationContext.class, Fqn.class, Object.class, boolean.class);
- checkIfOverridden(MethodDeclarations.getNodeMethodLocal_id, "handleGetNodeCommand", InvocationContext.class, Fqn.class);
- checkIfOverridden(MethodDeclarations.getChildrenNamesMethodLocal_id, "handleGetChildrenNamesCommand", InvocationContext.class, Fqn.class);
- checkIfOverridden(MethodDeclarations.getKeysMethodLocal_id, "handleGetKeysCommand", InvocationContext.class, Fqn.class);
- checkIfOverridden(MethodDeclarations.getDataMapMethodLocal_id, "handleGetDataMapCommand", InvocationContext.class, Fqn.class);
- checkIfOverridden(MethodDeclarations.rollbackMethod_id, "handleRollbackCommand", InvocationContext.class, GlobalTransaction.class);
- checkIfOverridden(MethodDeclarations.removeNodeMethodLocal_id, "handleRemoveFqnCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, boolean.class);
- checkIfOverridden(MethodDeclarations.removeKeyMethodLocal_id, "handleRemoveKeyCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, boolean.class);
- checkIfOverridden(MethodDeclarations.removeDataMethodLocal_id, "handleRemoveDataCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, boolean.class);
- checkIfOverridden(MethodDeclarations.commitMethod_id, "handleCommitCommand", InvocationContext.class, GlobalTransaction.class);
- checkIfOverridden(MethodDeclarations.optimisticPrepareMethod_id, "handleOptimisticPrepareCommand", InvocationContext.class, GlobalTransaction.class, List.class, Map.class, Address.class, boolean.class);
- checkIfOverridden(MethodDeclarations.prepareMethod_id, "handlePrepareCommand", InvocationContext.class, GlobalTransaction.class, List.class, Address.class, boolean.class);
- checkIfOverridden(MethodDeclarations.evictNodeMethodLocal_id, "handleEvictFqnCommand", InvocationContext.class, Fqn.class);
- checkIfOverridden(MethodDeclarations.evictVersionedNodeMethodLocal_id, "handleEvictFqnCommand", InvocationContext.class, Fqn.class, DataVersion.class);
- checkIfOverridden(MethodDeclarations.existsMethod_id, "handleExistsNodeCommand", InvocationContext.class, Fqn.class);
- checkIfOverridden(MethodDeclarations.putDataEraseVersionedMethodLocal_id, "handlePutDataMapCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, Map.class, boolean.class, boolean.class, DataVersion.class);
- checkIfOverridden(MethodDeclarations.putDataVersionedMethodLocal_id, "handlePutDataMapCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, Map.class, Boolean.class, DataVersion.class);
- checkIfOverridden(MethodDeclarations.putKeyValVersionedMethodLocal_id, "handlePutKeyValueCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Object.class, boolean.class, DataVersion.class);
- checkIfOverridden(MethodDeclarations.putForExternalReadVersionedMethodLocal_id, "handlePutKeyValueCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, Object.class, DataVersion.class);
- checkIfOverridden(MethodDeclarations.dataGravitationCleanupMethod_id, "handleDataGravitationCleanupCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, Fqn.class);
- checkIfOverridden(MethodDeclarations.removeNodeVersionedMethodLocal_id, "handleRemoveFqnCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, boolean.class, DataVersion.class);
- checkIfOverridden(MethodDeclarations.removeKeyVersionedMethodLocal_id, "handleRemoveKeyCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, Object.class, boolean.class, DataVersion.class);
- checkIfOverridden(MethodDeclarations.removeDataVersionedMethodLocal_id, "handleRemoveDataCommand", InvocationContext.class, GlobalTransaction.class, Fqn.class, boolean.class, DataVersion.class);
- checkIfOverridden(MethodDeclarations.unblockChannelMethodLocal_id, "handleUnblockChannelMethod", InvocationContext.class);
- }
-
- private void checkIfOverridden(int methodId, String methodName, Class... args)
- {
- Class currentClass = getClass();
- //if this is a > 1 inheritace deepth and the method was overwritten in the parent. We also have to look into parents
- while (currentClass != MethodDispacherInterceptor.class)
- {
- try
- {
- currentClass.getDeclaredMethod(methodName, args);
- overriddenMethods.add(methodId);
- }
- catch (NoSuchMethodException e)
- {
- //ignore
- }
- currentClass = (Class) currentClass.getGenericSuperclass();
- }
- }
-}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -16,25 +16,30 @@
*/
public class NotificationInterceptor extends BaseTransactionalContextInterceptor
{
-
private Notifier notifier;
- private CacheSPI cache;
+ private CacheSPI cacheSPI;
+ public void setDependencies(Notifier notifier, CacheSPI cacheSPI)
+ {
+ this.notifier = notifier;
+ this.cacheSPI = cacheSPI;
+ }
+
@Override
public Object handleBlockChannelCommand(InvocationContext ctx, BlockChannelCommand command) throws Throwable
{
- notifier.notifyCacheBlocked(cache, true);
+ notifier.notifyCacheBlocked(cacheSPI, true);
Object retVal = invokeNextInterceptor(ctx, command);
- notifier.notifyCacheBlocked(cache, false);
+ notifier.notifyCacheBlocked(cacheSPI, false);
return retVal;
}
@Override
public Object handleUnblockChannelCommand(InvocationContext ctx, UnblockChannelCommand command) throws Throwable
{
- notifier.notifyCacheUnblocked(cache, true);
+ notifier.notifyCacheUnblocked(cacheSPI, true);
Object retval = invokeNextInterceptor(ctx, command);
- notifier.notifyCacheUnblocked(cache, false);
+ notifier.notifyCacheUnblocked(cacheSPI, false);
return retval;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -50,11 +50,6 @@
private long lockAcquisitionTimeout;
- public OptimisticCreateIfNotExistsInterceptor()
- {
- initLogger();
- }
-
@Inject
private void injectDependencies(NodeFactory nodeFactory, CacheData cacheData, CacheSPI cacheSPI)
{
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -31,8 +31,8 @@
*/
public abstract class OptimisticInterceptor extends ChainedInterceptor
{
- protected TransactionManager txManager = null;
- protected TransactionTable txTable = null;
+ protected TransactionManager txManager;
+ protected TransactionTable txTable;
@Inject
private void injectDependencies(TransactionManager txManager, TransactionTable txTable)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -7,7 +7,6 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.*;
-import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.TxCacheCommand;
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
@@ -23,6 +22,7 @@
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.apache.commons.logging.LogFactory;
import java.util.Collections;
import java.util.HashMap;
@@ -60,7 +60,8 @@
public OptimisticNodeInterceptor()
{
- initLogger();
+ log = LogFactory.getLog(getClass());
+ trace = log.isTraceEnabled();
}
public Object handleDataGravitationCleanupCommand(InvocationContext ctx, DataGravitationCleanupCommand command) throws Throwable
@@ -77,7 +78,7 @@
return result;
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
GlobalTransaction gtx = getGlobalTransaction(ctx);
TransactionWorkspace workspace = getTransactionWorkspace(gtx);
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -27,6 +27,7 @@
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;
@@ -44,25 +45,20 @@
*/
public class OptimisticReplicationInterceptor extends BaseRpcInterceptor
{
-
- // record of local broacasts - so we do not broadcast rollbacks/commits that resuted from
- // local prepare failures
- // we really just need a set here, but concurrent CopyOnWriteArraySet has poor performance when writing.
+ /**
+ * record of local broacasts - so we do not broadcast rollbacks/commits that resuted from local prepare failures we
+ * really just need a set here, but concurrent CopyOnWriteArraySet has poor performance when writing.
+ */
private final Set<GlobalTransaction> broadcastTxs = new ConcurrentHashSet<GlobalTransaction>();
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
private TransactionTable transactionTable;
private Configuration configuration;
- public OptimisticReplicationInterceptor()
- {
- initLogger();
- }
-
@Inject
- public void initialize(CacheCommandsFactory commandsFactory, TransactionTable transactionTable)
+ public void initialize(CommandsFactory commandsFactory, TransactionTable transactionTable)
{
this.commandsFactory = commandsFactory;
this.transactionTable = transactionTable;
@@ -195,6 +191,7 @@
{
// Map method calls to data versioned equivalents.
// See JBCACHE-843 and docs/design/DataVersioning.txt
+ //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())
@@ -202,7 +199,7 @@
CacheCommand clone = (CacheCommand) command1.accept(null, populator);
clonedModifications.add(clone);
}
- CacheCommand toBroadcast = commandsFactory.buildOptimisticPrepareCommand(clonedModifications, command.getData(), command.getAddress(), command.isOnePhaseCommit());
+ CacheCommand toBroadcast = commandsFactory.buildOptimisticPrepareCommand(gtx, clonedModifications, command.getData(), command.getLocalAddress(), command.isOnePhaseCommit());
//record the things we have possibly sent
broadcastTxs.add(gtx);
@@ -258,7 +255,7 @@
try
{
broadcastTxs.remove(gtx);
- RollbackCommand rollbackCommand = commandsFactory.buildRollbackCommand();
+ RollbackCommand rollbackCommand = commandsFactory.buildRollbackCommand(null);
if (log.isDebugEnabled())
log.debug("running remote rollback for " + gtx + " and coord=" + rpcManager.getLocalAddress());
@@ -286,7 +283,7 @@
return command;
}
- public Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCacheCommand command) throws Throwable
+ public Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
{
return command;
}
@@ -306,33 +303,33 @@
public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
- PutDataMapCommand clone = commandsFactory.buildPutDataMapCommand(command.getFqn(), command.getData(), command.isCreateUndoOps(), command.isEraseContents());
+ PutDataMapCommand clone = commandsFactory.buildPutDataMapCommand(null, command.getFqn(), command.getData(), command.isCreateUndoOps(), command.isEraseContents());
return setDataVersion(clone, clone.getFqn());
}
public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
- PutKeyValueCommand clone = commandsFactory.buildPutKeyValueCommand(command.getFqn(), command.getKey(), command.getValue(), command.isCreateUndoOps(), command.isPutForExternalRead());
+ PutKeyValueCommand clone = commandsFactory.buildPutKeyValueCommand(null, command.getFqn(), command.getKey(), command.getValue(), command.isCreateUndoOps(), command.isPutForExternalRead());
return setDataVersion(clone, command.getFqn());
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
- RemoveFqnCommand clone = commandsFactory.buildRemoveFqnCommand(command.getFqn(), command.isEviction(),
- command.isSkipSendingNodeEvents(), command.isCreateUndoOps(), command.getDataVersion());
+ RemoveNodeCommand clone = commandsFactory.buildRemoveFqnCommand(command.getGlobalTransaction(), command.getFqn(), command.isEviction(),
+ command.isSkipSendingNodeEvents(), command.isCreateUndoOps());
return setDataVersion(clone, command.getFqn());
}
public Object handleRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
{
- RemoveKeyCommand clone = commandsFactory.buildRemoveKeyCommand(command.getFqn(), command.getKey(), command.isCreateUndoOps());
+ RemoveKeyCommand clone = commandsFactory.buildRemoveKeyCommand(null, command.getFqn(), command.getKey(), command.isCreateUndoOps());
return setDataVersion(clone, command.getFqn());
}
public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
- RemoveDataCommand clone = commandsFactory.buildRemoveDataCommand(command.getFqn(), command.isCreateUndoops(),
- command.isSendNodeEvent(), command.isEviction(), command.getDataVersion());
+ RemoveDataCommand clone = commandsFactory.buildRemoveDataCommand(command.getGlobalTransaction(), command.getFqn(), command.isCreateUndoops(),
+ command.isSendNodeEvent(), command.isEviction());
return setDataVersion(clone, command.getFqn());
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -11,6 +11,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
@@ -53,6 +54,7 @@
private CacheData cacheData;
+ @Inject
public void initialize(CacheSPI cache, CacheData cacheData)
{
this.cacheData = cacheData;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OrderedSynchronizationHandler.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -21,12 +21,11 @@
*/
public class OrderedSynchronizationHandler implements Synchronization
{
+ static Log log = LogFactory.getLog(OrderedSynchronizationHandler.class);
+
private Transaction tx = null;
private LinkedList<Synchronization> handlers = new LinkedList<Synchronization>();
- static Log log = LogFactory.getLog(OrderedSynchronizationHandler.class);
-
-
public OrderedSynchronizationHandler(Transaction tx) throws SystemException, RollbackException
{
this.tx = tx;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -3,6 +3,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.invocation.CacheData;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.notifications.Notifier;
@@ -25,12 +26,21 @@
public class PassivationInterceptor extends ChainedInterceptor implements PassivationInterceptorMBean
{
+ private AtomicLong passivations = new AtomicLong(0);
+
protected CacheLoader loader = null;
- private AtomicLong passivations = new AtomicLong(0);
private Notifier notifier;
private Configuration configuration;
private CacheData cacheData;
+ @Inject
+ public void setDependencies(Notifier notifier, Configuration configuration, CacheData cacheData)
+ {
+ this.notifier = notifier;
+ this.configuration = configuration;
+ this.cacheData = cacheData;
+ }
+
/**
* Notifies the cache instance listeners that the evicted node is about to
* be passivated and stores the evicted node and its attributes back to the
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -67,6 +67,7 @@
this.cacheData = cacheImpl;
this.txTable = txTable;
this.lockManager = lockManager;
+ this.configuration = configuration;
}
@Override
@@ -198,7 +199,7 @@
return retValue;
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
if (supressLocking(ctx)) return invokeNextInterceptor(ctx, command);
// need to make a note of ALL nodes created here!!
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -24,6 +24,11 @@
{
private TransactionTable transactionTable;
+ public void setDependencies(TransactionTable txTable)
+ {
+ this.transactionTable = txTable;
+ }
+
protected boolean skipReplication(InvocationContext ctx)
{
Option optionOverride = ctx.getOptionOverrides();
@@ -87,7 +92,7 @@
return handleCrudMethod(ctx, command, false);
}
- public Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
return handleCrudMethod(ctx, command, false);
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -11,7 +11,7 @@
import org.jboss.cache.RPCManager;
import org.jboss.cache.ReplicationException;
import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.DataVersionCommand;
import org.jboss.cache.commands.GlobalTransactionCommand;
import org.jboss.cache.commands.tx.CommitCommand;
@@ -30,6 +30,7 @@
import org.jboss.cache.transaction.OptimisticTransactionEntry;
import org.jboss.cache.transaction.TransactionEntry;
import org.jboss.cache.transaction.TxUtil;
+import org.apache.commons.logging.LogFactory;
import javax.transaction.*;
import java.util.HashMap;
@@ -51,7 +52,7 @@
private final static Object NULL = new Object();
private Configuration configuration;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
private RPCManager rpcManager;
private CacheTransactionHelper transactionHelper;
private Notifier notifier;
@@ -70,10 +71,12 @@
private long commits = 0;
private long rollbacks = 0;
+ private GlobalTransactionCommandsVisitor globalTransactionCommandsVisitor;
public TxInterceptor()
{
- initLogger();
+ log = LogFactory.getLog(getClass());
+ trace = log.isTraceEnabled();
}
@SuppressWarnings("unchecked")
@@ -920,7 +923,7 @@
*/
private CacheCommand replaceGtx(CacheCommand m, final GlobalTransaction gtx) throws Throwable
{
- GlobalTransactionCommandsVisitor visitor = new GlobalTransactionCommandsVisitor()
+ globalTransactionCommandsVisitor = new GlobalTransactionCommandsVisitor()
{
public Object handleGlobalTransactionCommands(GlobalTransactionCommand command)
{
@@ -928,7 +931,7 @@
return null;
}
};
- m.accept(null, visitor);
+ m.accept(null, globalTransactionCommandsVisitor);
return m;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/UnlockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/UnlockInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/UnlockInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -20,15 +20,8 @@
@Deprecated
public class UnlockInterceptor extends Interceptor
{
-
Map<Thread, List<NodeLock>> lockTable = null;
-// ThreadLocal<List<NodeLock>> lockTable;
- public UnlockInterceptor()
- {
- initLogger();
- }
-
@Inject
private void injectDependencies(@ComponentName("LockTable")Map<Thread, List<NodeLock>> lockTable)
// private void init(@ComponentName("LockTable")ThreadLocal<List<NodeLock>> lockTable)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/ChainedInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/ChainedInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/ChainedInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -27,11 +27,6 @@
public ChainedInterceptor()
{
- initLogger();
- }
-
- protected void initLogger()
- {
log = LogFactory.getLog(getClass());
trace = log.isTraceEnabled();
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -4,7 +4,7 @@
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.EvictFqnCommand;
import org.jboss.cache.commands.InvalidateCommand;
-import org.jboss.cache.commands.GravitateDataCacheCommand;
+import org.jboss.cache.commands.GravitateDataCommand;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.channel.BlockChannelCommand;
import org.jboss.cache.commands.channel.UnblockChannelCommand;
@@ -52,7 +52,7 @@
return executeAll(ctx, command);
}
- public final Object handleRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public final Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
if (skipInterception(ctx))
{
@@ -61,7 +61,7 @@
return executeRemoveFqnCommand(ctx, command);
}
- public Object executeRemoveFqnCommand(InvocationContext ctx, RemoveFqnCommand command) throws Throwable
+ public Object executeRemoveFqnCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
return executeAll(ctx, command);
}
@@ -220,7 +220,7 @@
return executeAll(ctx, command);
}
- public final Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCacheCommand command) throws Throwable
+ public final Object handleGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
{
if (skipInterception(ctx))
{
@@ -229,7 +229,7 @@
return executeGravitateDataCommand(ctx, command);
}
- public Object executeGravitateDataCommand(InvocationContext ctx, GravitateDataCacheCommand command) throws Throwable
+ public Object executeGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
{
return executeAll(ctx, command);
}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -24,29 +24,26 @@
*/
public abstract class AbstractInvocationDelegate
{
- protected Log log = LogFactory.getLog(AbstractInvocationDelegate.class);
+ protected Log log = LogFactory.getLog(getClass());
- protected InterceptorChain cacheCommand;
protected Configuration configuration;
- protected boolean originLocal = true;
protected InvocationContextContainer invocationContextContainer;
protected CacheLifecycleManager lifecycleManager;
-
protected InterceptorChain invoker;
+ protected boolean originLocal = true;
+
/**
* Used by the interceptor chain factory to inject dependencies.
- *
- * @param interceptorChain interceptor chain to pass calls up
- * @param cache cache instance
- * @param configuration configuration for the cache
*/
@Inject
- public void initialise(Configuration configuration, InvocationContextContainer invocationContextContainer)
+ public void initialise(Configuration configuration, InvocationContextContainer invocationContextContainer,
+ CacheLifecycleManager lifecycleManager, InterceptorChain interceptorChain)
{
this.configuration = configuration;
this.invocationContextContainer = invocationContextContainer;
- invoker = new InterceptorChain();
+ this.invoker = interceptorChain;
+ this.lifecycleManager = lifecycleManager;
}
/**
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,11 +1,10 @@
package org.jboss.cache.invocation;
-import org.apache.commons.logging.LogFactory;
import org.jboss.cache.*;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.commands.CacheCommandsFactory;
-import org.jboss.cache.commands.GravitateDataCacheCommand;
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.GravitateDataCommand;
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.channel.BlockChannelCommand;
import org.jboss.cache.commands.channel.UnblockChannelCommand;
@@ -39,7 +38,6 @@
@SuppressWarnings("unchecked")
public class CacheInvocationDelegate<K, V> extends AbstractInvocationDelegate implements CacheSPI<K, V>
{
-
// this stuff is needed since the SPI has methods to retrieve these.
private StateTransferManager stateTransferManager;
private CacheLoaderManager cacheLoaderManager;
@@ -51,18 +49,18 @@
private RegionManager regionManager;
private Marshaller marshaller;
private CacheData cacheData;
- private CacheCommandsFactory commandsFactory;// tu be built here and imjected within any CacheCommand instance. Also pass this to the interceptor chain
+ private CommandsFactory commandsFactory;// tu be built here and imjected within any CacheCommand instance. Also pass this to the interceptor chain
private CacheTransactionHelper transactionHelper;
public CacheInvocationDelegate()
{
- log = LogFactory.getLog(CacheInvocationDelegate.class);
}
@Inject
- private void injectDependencies(StateTransferManager stateTransferManager, CacheLoaderManager cacheLoaderManager, Notifier notifier,
+ public void initialize(StateTransferManager stateTransferManager, CacheLoaderManager cacheLoaderManager, Notifier notifier,
TransactionManager transactionManager, BuddyManager buddyManager, TransactionTable transactionTable,
- RPCManager rpcManager, RegionManager regionManager, Marshaller marshaller)
+ RPCManager rpcManager, RegionManager regionManager, Marshaller marshaller,
+ CacheTransactionHelper transactionHelper, CommandsFactory commandsFactory)
{
this.stateTransferManager = stateTransferManager;
this.cacheLoaderManager = cacheLoaderManager;
@@ -74,7 +72,8 @@
this.regionManager = regionManager;
this.marshaller = marshaller;
this.cacheData = new CacheData();
- this.commandsFactory = new CacheCommandsFactory(notifier, transactionTable, cacheData, this);
+ this.commandsFactory = commandsFactory;
+ this.transactionHelper = transactionHelper;
}
private void reset()
@@ -225,10 +224,10 @@
return marshaller;
}
- public GravitateResult gravitateData(Fqn fqn, boolean searchBuddyBackupSubtrees)
+ public GravitateResult gravitateData(Fqn fqn, boolean searchBuddyBackupSubtrees, InvocationContext ctx)
{
- GravitateDataCacheCommand command = commandsFactory.buildGravitateDataCacheCommand(fqn, searchBuddyBackupSubtrees);
- return (GravitateResult) command.perform();
+ GravitateDataCommand command = commandsFactory.buildGravitateDataCacheCommand(fqn, searchBuddyBackupSubtrees);
+ return (GravitateResult) command.perform(null);
}
public NodeSPI<K, V> peek(Fqn fqn, boolean includeDeletedNodes, boolean includeInvalidNodes)
@@ -383,7 +382,7 @@
else
{
GlobalTransaction tx = transactionHelper.getCurrentTransaction();
- RemoveFqnCommand command = commandsFactory.buildRemoveFqnCommand(tx, fqn, true, false);
+ RemoveNodeCommand command = commandsFactory.buildRemoveFqnCommand(tx, fqn, true, true, false);
Object retval = invoke(command);
return retval != null && (Boolean) retval;
}
@@ -419,8 +418,7 @@
public void put(Fqn<?> fqn, Map<K, V> data)
{
-// MethodCall m = MethodCallFactory.create(MethodDeclarations.putDataMethodLocal_id, tx, fqn, data, true);
- PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(fqn, data, true, false);
+ PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(null, fqn, data, true, false);
invoke(command);
}
@@ -436,7 +434,7 @@
{
getInvocationContext().getOptionOverrides().setFailSilently(true);
getInvocationContext().getOptionOverrides().setForceAsynchronous(true);
- PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, fqn, key, value);
+ PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, fqn, key, value, false, false);
invoke(command);
}
else
@@ -449,7 +447,7 @@
public V put(Fqn<?> fqn, K key, V value)
{
GlobalTransaction tx = transactionHelper.getCurrentTransaction();
- PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(tx, fqn, key, value, true);
+ PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(tx, fqn, key, value, false, true);
return (V) invoke(command);
}
@@ -525,7 +523,7 @@
public void clearData(Fqn fqn)
{
GlobalTransaction tx = getCurrentTransaction();
- invoke(commandsFactory.buildRemoveDataCommand(tx, fqn, true));
+ invoke(commandsFactory.buildRemoveDataCommand(tx, fqn, true, false, false));
}
/**
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheLifecycleManager.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -3,10 +3,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.*;
-import org.jboss.cache.interceptors.base.ChainedInterceptor;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.interceptors.base.ChainedInterceptor;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.lock.LockStrategyFactory;
import org.jboss.cache.marshall.Marshaller;
@@ -24,20 +25,35 @@
{
private static Log log = LogFactory.getLog(CacheLifecycleManager.class);
- private Configuration configuration;
- private ComponentRegistry componentRegistry;
private NodeSPI root;
- private CacheLoaderManager cacheLoaderManager;
- private RegionManager regionManager = null;
private CacheStatus cacheStatus;
+
+ /* dependencies*/
+ private Configuration configuration;
private Notifier notifier;
- private CacheSPI spi;
- private RPCManager rpcManager;
- private TransactionManager transactionManager;
+ private RegionManager regionManager;
private NodeFactory nodeFactory;
+ private CacheData cacheData;
private BuddyManager buddyManager;
- private CacheData cacheData;
+ private RPCManager rpcManager;
+ private ComponentRegistry componentRegistry;
+
+ @Inject
+ public void initialize(Configuration configuration, Notifier notifier, RegionManager regionManager, NodeFactory nodeFactory,
+ CacheData cacheData, BuddyManager buddyManager, RPCManager rpcManager,
+ ComponentRegistry componentRegistry)
+ {
+ this.configuration = configuration;
+ this.notifier = notifier;
+ this.regionManager = regionManager;
+ this.nodeFactory = nodeFactory;
+ this.buddyManager = buddyManager;
+ this.rpcManager = rpcManager;
+ this.cacheData = cacheData;
+ this.componentRegistry = componentRegistry;
+ }
+
/**
* Hook to shut down the cache when the JVM exits.
*/
@@ -170,9 +186,6 @@
/**
* The actual start implementation.
- *
- * @throws CacheException
- * @throws IllegalArgumentException
*/
private void internalStart() throws CacheException, IllegalArgumentException
{
@@ -182,6 +195,8 @@
removeConfigurationDependentComponents();
// 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
componentRegistry.updateDependencies();
componentRegistry.wireDependencies(root);
@@ -219,19 +234,13 @@
startManualComponents();
- //now attempt to preload the cache from the loader - Manik
- if (cacheLoaderManager != null)
- {
- cacheLoaderManager.preloadCache();
- }
-
// start any eviction threads.
if (regionManager.isUsingEvictions())
{
regionManager.startEvictionThread();
}
- notifier.notifyCacheStarted(spi, spi.getInvocationContext());
+ notifier.notifyCacheStarted();
addShutdownHook();
@@ -322,14 +331,9 @@
private void internalDestroy()
{
cacheStatus = CacheStatus.DESTROYING;
- cacheLoaderManager = null;
-
// The rest of these should have already been taken care of in stop,
// but we do it here as well in case stop failed.
rpcManager.stop();
-
- transactionManager = null;
-
componentRegistry.reset();
}
@@ -339,28 +343,24 @@
private void internalStop()
{
cacheStatus = CacheStatus.STOPPING;
-
// if this is called from a source other than the shutdown hook, deregister the shutdown hook.
if (!invokedFromShutdownHook && shutdownHook != null) Runtime.getRuntime().removeShutdownHook(shutdownHook);
-
componentRegistry.stop();
-
if (notifier != null)
{
- notifier.notifyCacheStopped(spi, spi.getInvocationContext());
+ notifier.notifyCacheStopped();
notifier.removeAllCacheListeners();
}
-
// unset transaction manager reference
- transactionManager = null;
-
cacheStatus = CacheStatus.STOPPED;
-
// empty in-memory state
root.clearDataDirect();
root.removeChildrenDirect();
}
+ //todo - this should reather be implemented as follows:
+ // List<Component>comps = registry.detComponentsDependingOn(a component)
+ // registry.unregsiterComponents(comps);
private void removeConfigurationDependentComponents()
{
// remove the Interceptor.class component though, since it may pertain to an old config
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheTransactionHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheTransactionHelper.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheTransactionHelper.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,18 +1,20 @@
package org.jboss.cache.invocation;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.RPCManager;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.cache.transaction.OptimisticTransactionEntry;
import org.jboss.cache.transaction.TransactionEntry;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.RPCManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.jgroups.Address;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
import javax.transaction.Transaction;
-import javax.transaction.SystemException;
-import javax.transaction.Status;
import javax.transaction.TransactionManager;
/**
@@ -34,17 +36,18 @@
*/
private TransactionManager transactionManager = null;
- //todo - remove dependecy from this one. Basically the only thing we need is the local address, guess this might be passed in
private RPCManager rpcManager;
private boolean isOptimisticLocking;
- public CacheTransactionHelper(TransactionTable transactionTable, TransactionManager transactionManager, RPCManager rpcManager, boolean optimisticLocking)
+ @Inject
+ public void initialize(TransactionTable transactionTable, TransactionManager transactionManager,
+ RPCManager rpcManager, Configuration configuration)
{
this.transactionTable = transactionTable;
this.transactionManager = transactionManager;
this.rpcManager = rpcManager;
- isOptimisticLocking = optimisticLocking;
+ isOptimisticLocking = configuration.isNodeLockingOptimistic();
}
/**
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/InterceptorChain.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -2,6 +2,7 @@
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.InterceptorChainFactory;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.ChainedInterceptor;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.CacheCommand;
@@ -24,13 +25,16 @@
private InvocationContextContainer invocationContextContainer;
- public InterceptorChain()
+ public InterceptorChain(ChainedInterceptor first)
{
+ this.firstInChain = first;
}
- public InterceptorChain(ChainedInterceptor first)
+ @Inject
+ public void initialize(InvocationContextContainer invocationContextContainer, ComponentRegistry componentRegistry)
{
- this.firstInChain = first;
+ this.invocationContextContainer = invocationContextContainer;
+ this.componentRegistry = componentRegistry;
}
public synchronized void addInterceptor(ChainedInterceptor i, int position)
@@ -74,8 +78,6 @@
// now set the 'last' pointer.
ChainedInterceptor i = setLastInterceptorPointer(last);
- // re-register this interceptor
- componentRegistry.registerComponent(ChainedInterceptor.class.getName(), i, ChainedInterceptor.class);
return i;
}
@@ -119,12 +121,11 @@
private void setFirstInChain(ChainedInterceptor startOfNewChain)
{
- componentRegistry.registerComponent(ChainedInterceptor.class.getName(), startOfNewChain, ChainedInterceptor.class);
+ firstInChain = startOfNewChain;
}
public synchronized void removeInterceptor(Class<? extends ChainedInterceptor> interceptorType)
{
- InterceptorChainFactory factory = componentRegistry.getComponent(InterceptorChainFactory.class);
List<ChainedInterceptor> interceptors = getInterceptorsList();
int position = -1;
boolean found = false;
@@ -146,7 +147,6 @@
public synchronized boolean addInterceptor(ChainedInterceptor i, Class<? extends ChainedInterceptor> afterInterceptor)
{
- InterceptorChainFactory factory = componentRegistry.getComponent(InterceptorChainFactory.class);
List<ChainedInterceptor> interceptors = getInterceptorsList();
int position = -1;
boolean found = false;
@@ -162,10 +162,8 @@
if (found)
{
- componentRegistry.registerComponent(i, ChainedInterceptor.class);
interceptors.add(++position, i);
setFirstInChain(correctInterceptorChaining(interceptors));
- componentRegistry.start();
// make sure I start the last 2 "manually startable" components
}
return found;
Modified: core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -73,7 +73,7 @@
private RegionManager regionManager;
@Inject
- private void injectDependencies(CacheSPI cache, Configuration configuration, RegionManager regionManager)
+ public void injectDependencies(CacheSPI cache, Configuration configuration, RegionManager regionManager)
{
this.regionManager = regionManager;
this.config = configuration.getCacheLoaderConfig();
Modified: core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -9,35 +9,19 @@
import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheStatus;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.RegionManager;
+import org.jboss.cache.*;
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.commands.CacheCommandsFactory;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.cachedata.ExistsNodeCommand;
-import org.jboss.cache.commands.cachedata.GetDataMapCommand;
-import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
-import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.lock.StripedLock;
-import org.jboss.cache.marshall.MethodCall;
-import org.jboss.cache.marshall.MethodCallFactory;
-import org.jboss.cache.marshall.MethodDeclarations;
import org.jgroups.Address;
import org.jgroups.blocks.GroupRequest;
import org.jgroups.blocks.RspFilter;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* A cache loader that consults other members in the cluster for values. Does
@@ -54,7 +38,7 @@
private static Log log = LogFactory.getLog(ClusteredCacheLoader.class);
private StripedLock lock = new StripedLock();
private ClusteredCacheLoaderConfig config;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
/**
* A test to check whether the cache is in it's started state. If not, calls should not be made as the channel may
@@ -104,18 +88,18 @@
}
}
- private Object callRemote(CacheCommand call) throws Exception
+ private Object callRemote(CacheDataCommand dataCommand) throws Exception
{
- if (log.isTraceEnabled()) log.trace("cache=" + cache.getLocalAddress() + "; calling with " + call);
+ if (log.isTraceEnabled()) log.trace("cache=" + cache.getLocalAddress() + "; calling with " + dataCommand);
List<Address> mbrs = cache.getMembers();
- ClusteredGetCommand clusteredGet = commandsFactory.buildClusteredGetCommand(call, false);
+ ClusteredGetCommand clusteredGet = commandsFactory.buildClusteredGetCommand(false, dataCommand);
List resps = null;
// JBCACHE-1186
resps = cache.getRPCManager().callRemoteMethods(mbrs, clusteredGet, GroupRequest.GET_ALL, true, config.getTimeout(), new ResponseValidityFilter(mbrs, cache.getLocalAddress()), false);
if (resps == null)
{
- if (log.isInfoEnabled()) log.info("No replies to call " + call + ". Perhaps we're alone in the cluster?");
+ if (log.isInfoEnabled()) log.info("No replies to call " + dataCommand + ". Perhaps we're alone in the cluster?");
return null;
}
else
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -5,7 +5,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.cachedata.PutDataMapCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.invocation.CacheData;
@@ -25,7 +26,6 @@
*/
public class LockManager
{
-
private static Log log = LogFactory.getLog(LockManager.class);
private Configuration configuration;
@@ -33,10 +33,11 @@
private CacheData cacheData;
private NodeSPI rootNode;
private TransactionTable txTable;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
+ @Inject
public void inject(Configuration configuration, CacheData cacheData, TransactionTable txTable,
- CacheCommandsFactory commandsFactory)
+ CommandsFactory commandsFactory)
{
this.configuration = configuration;
lockAcquisitionTimeout = configuration.getLockAcquisitionTimeout();
@@ -261,7 +262,7 @@
childNode.markAsDeleted(false);
//if we'll rollback the tx data should be added to the node again
Map oldData = new HashMap(childNode.getDataDirect());
- PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(gtx, fqn, oldData, false);
+ PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(gtx, fqn, oldData, false, false);
txTable.get(gtx).addUndoOperation(command);
//we're prepared for rollback, now reset the node
childNode.clearDataDirect();
Modified: core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -13,6 +13,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
+import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.factories.annotations.Destroy;
import org.jboss.cache.factories.annotations.Inject;
@@ -42,11 +43,10 @@
*/
public class Notifier
{
- private Cache cache;
-
private static final Log log = LogFactory.getLog(Notifier.class);
private static Class emptyMap = Collections.emptyMap().getClass();
+
private static Class singletonMap = Collections.singletonMap(null, null).getClass();
private static final Class[] allowedMethodAnnotations =
{
@@ -58,7 +58,10 @@
CacheStartedEvent.class, CacheStoppedEvent.class, CacheBlockedEvent.class, CacheUnblockedEvent.class, NodeCreatedEvent.class, NodeRemovedEvent.class, NodeVisitedEvent.class, NodeModifiedEvent.class, NodeMovedEvent.class,
NodeActivatedEvent.class, NodePassivatedEvent.class, NodeLoadedEvent.class, NodeEvictedEvent.class, TransactionRegisteredEvent.class, TransactionCompletedEvent.class, ViewChangedEvent.class, BuddyGroupChangedEvent.class
};
+
+
final Map<Class, List<ListenerInvocation>> listenerInvocations = new ConcurrentHashMap<Class, List<ListenerInvocation>>();
+ private Cache cache;
public Notifier()
{
@@ -476,43 +479,33 @@
/**
* Notifies all registered listeners of a cacheStarted event.
- *
- * @param cache cache instance to notify
- * @param ctx context of invocation
*/
- public void notifyCacheStarted(final CacheSPI cache, InvocationContext ctx)
+ public void notifyCacheStarted()
{
List<ListenerInvocation> listeners = listenerInvocations.get(CacheStarted.class);
if (listeners != null && !listeners.isEmpty())
{
- InvocationContext backup = resetInvocationContext(ctx);
EventImpl e = new EventImpl();
e.setCache(cache);
e.setType(CACHE_STARTED);
for (ListenerInvocation listener : listeners) listener.invoke(e);
- restoreInvocationContext(backup);
}
}
/**
* Notifies all registered listeners of a cacheStopped event.
- *
- * @param cache cache instance to notify
- * @param ctx context of invocation
*/
- public void notifyCacheStopped(final CacheSPI cache, InvocationContext ctx)
+ public void notifyCacheStopped()
{
List<ListenerInvocation> listeners = listenerInvocations.get(CacheStopped.class);
if (listeners != null && !listeners.isEmpty())
{
- InvocationContext backup = resetInvocationContext(ctx);
EventImpl e = new EventImpl();
e.setCache(cache);
e.setType(CACHE_STOPPED);
for (ListenerInvocation listener : listeners) listener.invoke(e);
- restoreInvocationContext(backup);
}
}
@@ -552,14 +545,12 @@
if (listeners != null && !listeners.isEmpty())
{
-// InvocationContext backup = resetInvocationContext(ctx);
EventImpl e = new EventImpl();
e.setCache(cache);
e.setBuddyGroup(buddyGroup);
e.setPre(pre);
e.setType(BUDDY_GROUP_CHANGED);
for (ListenerInvocation listener : listeners) listener.invoke(e);
-// restoreInvocationContext(backup);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -13,7 +13,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Modification;
import org.jboss.cache.commands.TxCacheCommand;
-import org.jboss.cache.commands.cachedata.RemoveFqnCommand;
+import org.jboss.cache.commands.cachedata.RemoveNodeCommand;
import org.jboss.cache.config.Option;
import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
import org.jboss.cache.lock.IdentityLock;
@@ -417,7 +417,7 @@
for (TxCacheCommand txCacheCommand : getCacheLoaderModifications())
{
//todo - revisit this as it is ugly. phps add an isRemovred(fqn) somwhere on command hierarchy?
- if (txCacheCommand instanceof RemoveFqnCommand && fqn.isChildOrEquals(((RemoveFqnCommand )txCacheCommand).getFqn()))
+ if (txCacheCommand instanceof RemoveNodeCommand && fqn.isChildOrEquals(((RemoveNodeCommand)txCacheCommand).getFqn()))
{
return true;
}
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -7,15 +7,12 @@
package org.jboss.cache.buddyreplication;
import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.factories.XmlConfigurationParser;
-import org.jboss.cache.marshall.MethodCall;
-import org.jboss.cache.marshall.MethodCallFactory;
-import org.jboss.cache.marshall.MethodDeclarations;
import org.jboss.cache.xml.XmlHelper;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
@@ -33,7 +30,7 @@
public class BuddyManagerTest
{
- CacheCommandsFactory commandsFactory = new CacheCommandsFactory();
+ CommandsFactory commandsFactory = new CommandsFactory();
/**
* Constructs a buddy manager using the default buddy locator but with some specific properties.
*
@@ -138,7 +135,7 @@
{
Fqn fqn1 = Fqn.fromString("/hello/world");
- PutKeyValueCommand call1 = commandsFactory.buildPutKeyValueCommand(fqn1, "key", "value");
+ PutKeyValueCommand call1 = commandsFactory.buildPutKeyValueCommand(null, fqn1, "key", "value", false, false);
ReplicateCommand call2 = commandsFactory.buildReplicateCommand(call1);
BuddyManager bm = createBasicBuddyManager();
@@ -156,7 +153,7 @@
{
Fqn fqn1 = Fqn.ROOT;
- CacheCommand call1 = commandsFactory.buildPutKeyValueCommand(fqn1, "key", "value");
+ CacheCommand call1 = commandsFactory.buildPutKeyValueCommand(null, fqn1, "key", "value", false, false);
ReplicateCommand call2 = commandsFactory.buildReplicateCommand(call1);
BuddyManager bm = createBasicBuddyManager();
@@ -176,10 +173,10 @@
Fqn fqn3 = Fqn.fromString("/hello/again");
Fqn fqn4 = Fqn.fromString("/buddy/replication");
- PutKeyValueCommand call1 = commandsFactory.buildPutKeyValueCommand(fqn1, "key", "value");
- PutKeyValueCommand call2 = commandsFactory.buildPutKeyValueCommand(fqn2, "key", "value");
- PutKeyValueCommand call3 = commandsFactory.buildPutKeyValueCommand(fqn3, "key", "value");
- PutKeyValueCommand call4 = commandsFactory.buildPutKeyValueCommand(fqn4, "key", "value");
+ PutKeyValueCommand call1 = commandsFactory.buildPutKeyValueCommand(null, fqn1, "key", "value", false, false);
+ 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.add(call1);
list.add(call2);
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-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -8,7 +8,7 @@
import org.jboss.cache.*;
import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.config.EvictionConfig;
import org.jboss.cache.config.EvictionRegionConfig;
@@ -43,7 +43,7 @@
private CacheSPI<Object, Object> cache;
private InterceptorChain invoker;
private RegionManager regionManager;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -291,7 +291,7 @@
// this region is node granularity
Fqn fqn = Fqn.fromString("/a/b/c");
- PutDataMapCommand putDataMapCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data, false);
+ PutDataMapCommand putDataMapCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data, false, false);
invoker.invoke(putDataMapCommand);
Region region = regionManager.getRegion(fqn.toString(), false);
@@ -312,7 +312,7 @@
for (int i = 0; i < 100; i++)
{
- PutKeyValueCommand pkvCommand = commandsFactory.buildPutKeyValueCommand(null, fqn, data, false);
+ PutKeyValueCommand pkvCommand = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, data, false, false, false);
invoker.invoke(pkvCommand);
assertEquals("value", cache.peek(fqn, false, false).getDirect(i));
@@ -329,7 +329,7 @@
assertNull(region.takeLastEventNode());
fqn = Fqn.fromString("/a/b");
- PutDataMapCommand putCommand = commandsFactory.buildPutDataMapCommand(fqn, data, false, false);
+ PutDataMapCommand putCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data, false, false);
invoker.invoke(putCommand);
event = regionManager.getRegion(fqn.toString(), false).takeLastEventNode();
assertFalse(event.isResetElementCount());
@@ -348,7 +348,7 @@
assertEquals(i, node.getDirect(i));
}
- PutDataMapCommand putDataMap = commandsFactory.buildPutDataMapCommand( fqn, data, false, true);
+ PutDataMapCommand putDataMap = commandsFactory.buildPutDataMapCommand(null, fqn, data, false, true);
invoker.invoke(putDataMap);
event = regionManager.getRegion(fqn.toString(), false).takeLastEventNode();
assertEquals(NodeEventType.ADD_NODE_EVENT, event.getEventType());
@@ -377,7 +377,7 @@
Object key = "key";
Object value = "value";
- PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, fqn, key, value, false);
+ PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value, false, false);
invoker.invoke(command);
assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
EvictedEventNode event = region.takeLastEventNode();
@@ -387,7 +387,7 @@
assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
assertNull(region.takeLastEventNode());
- command = commandsFactory.buildPutKeyValueCommand(null, fqn, key, value, false);
+ command = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value, false, false);
invoker.invoke(command);
assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
event = region.takeLastEventNode();
@@ -405,7 +405,7 @@
putQuietly(fqn, "a", "b");
putQuietly(fqn, "b", "c");
- RemoveDataCommand removeDataCommand = new RemoveDataCommand(fqn, false, false, false, null);
+ RemoveDataCommand removeDataCommand = new RemoveDataCommand(null, fqn, false, false, false);
invoker.invoke(removeDataCommand);
assertEquals(0, cache.peek(fqn, false, false).getDataDirect().size());
@@ -415,8 +415,8 @@
assertEquals(fqn, event.getFqn());
assertNull(region.takeLastEventNode());
- RemoveFqnCommand removeFqnCommand = commandsFactory.buildRemoveFqnCommand(null, fqn, false, false);
- invoker.invoke(removeFqnCommand);
+ RemoveNodeCommand removeNodeCommand = commandsFactory.buildRemoveFqnCommand(null, fqn, false, false, false);
+ invoker.invoke(removeNodeCommand);
assertNull(cache.peek(fqn, false, false));
event = region.takeLastEventNode();
@@ -470,7 +470,7 @@
// this region is node granularity
Fqn fqn = Fqn.fromString("/a/b/c");
- PutDataMapCommand putDataCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data, false);
+ PutDataMapCommand putDataCommand = commandsFactory.buildPutDataMapCommand(null, fqn, data, false, false);
invoker.invoke(putDataCommand);
Region region = regionManager.getRegion(fqn.toString(), false);
@@ -488,8 +488,8 @@
assertEquals(fqn, event.getFqn());
assertNull(region.takeLastEventNode());
- RemoveFqnCommand removeFqnCommand = new RemoveFqnCommand(fqn, false, false);
- invoker.invoke(removeFqnCommand);
+ RemoveNodeCommand removeNodeCommand = new RemoveNodeCommand(null, fqn, false, false, false);
+ invoker.invoke(removeNodeCommand);
assertNull(cache.getNode(fqn));
event = region.takeLastEventNode();
assertEquals(NodeEventType.REMOVE_NODE_EVENT, event.getEventType());
@@ -498,7 +498,7 @@
Object key = "key";
Object value = "value";
- PutKeyValueCommand putKeyValueCommand = commandsFactory.buildPutKeyValueCommand(null, fqn, key, value, false);
+ PutKeyValueCommand putKeyValueCommand = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value, false, false);
invoker.invoke(putKeyValueCommand);
assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
event = region.takeLastEventNode();
@@ -516,7 +516,7 @@
assertEquals(fqn, event.getFqn());
assertNull(region.takeLastEventNode());
- RemoveKeyCommand removeKeyCommand = commandsFactory.buildRemoveKeyCommand(fqn, key, false);
+ RemoveKeyCommand removeKeyCommand = commandsFactory.buildRemoveKeyCommand(null, fqn, key, false);
invoker.invoke(removeKeyCommand);
assertNull(cache.get(fqn, key));
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -12,7 +12,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
import org.jboss.cache.config.Configuration;
@@ -33,7 +33,7 @@
@Test(groups = "functional")
public class ActiveInactiveTest extends AbstractVersionAwareMarshallerTest
{
- CacheCommandsFactory commandsFactory = new CacheCommandsFactory();
+ CommandsFactory commandsFactory = new CommandsFactory();
RegionManager rman;
CacheSPI cache;
Configuration c;
@@ -155,7 +155,7 @@
public void testObjectFromByteBuffer() throws Exception
{
- PutKeyValueCommand put = commandsFactory.buildPutKeyValueCommand(null, A_B, "name", "Joe", false);
+ PutKeyValueCommand put = commandsFactory.buildPutKeyValueCommand(null, A_B, "name", "Joe", false, false);
ReplicateCommand replicate = commandsFactory.buildReplicateCommand(put);
rman.setDefaultInactive(true);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -29,7 +29,7 @@
Map map = createMap(size);
Fqn fqn = Fqn.fromString("/my/stuff");
String key = "key";
- PutKeyValueCommand putCommand = commandsFactory.buildPutKeyValueCommand(fqn, key, map);
+ PutKeyValueCommand putCommand = commandsFactory.buildPutKeyValueCommand(null, fqn, key, map, false, false);
ReplicateCommand replicateCommand = commandsFactory.buildReplicateCommand(putCommand);
byte[] buf = marshaller.objectToByteBuffer(replicateCommand);
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -8,7 +8,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.RegionManager;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
@@ -29,7 +29,7 @@
protected VersionAwareMarshaller marshaller;
protected RegionManager regionManager;
protected Configuration c;
- protected CacheCommandsFactory commandsFactory = new CacheCommandsFactory();
+ protected CommandsFactory commandsFactory = new CommandsFactory();
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MethodIdPreservationTest.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -1,7 +1,7 @@
package org.jboss.cache.marshall;
import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import static org.testng.AssertJUnit.assertEquals;
@@ -29,19 +29,19 @@
private CacheCommand command2;
private List<CacheCommand> list = new ArrayList<CacheCommand>(2);
private PrepareCommand prepareComand;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
byteStream = new ByteArrayOutputStream();
stream = new ObjectOutputStream(byteStream);
- command1 = commandsFactory.buildPutDataMapCommand(Fqn.ROOT, null, false, true);
- command2 = commandsFactory.buildPutDataMapCommand(Fqn.ROOT, null, false, true);
+ command1 = commandsFactory.buildPutDataMapCommand(null, Fqn.ROOT, null, false, true);
+ command2 = commandsFactory.buildPutDataMapCommand(null, Fqn.ROOT, null, false, true);
list.clear();
list.add(command1);
list.add(command2);
- prepareComand = commandsFactory.buildPrepareCommand(list, null, true);
+ prepareComand = commandsFactory.buildPrepareCommand(null, list, null, true);
}
public void testSingleMethodCall() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ReturnValueMarshallingTest.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -4,11 +4,11 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
-import org.jboss.cache.commands.CacheCommandsFactory;
-import org.jboss.cache.commands.CacheCommand;
-import org.jboss.cache.commands.GravitateDataCacheCommand;
+import org.jboss.cache.buddyreplication.GravitateResult;
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.GravitateDataCommand;
+import org.jboss.cache.commands.cachedata.CacheDataCommand;
import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.misc.TestingUtil;
import static org.testng.AssertJUnit.*;
@@ -34,7 +34,7 @@
private Object key = "key", value;
private String className = "org.jboss.cache.marshall.MyList";
private Class listClass;
- private CacheCommandsFactory commandsFactory = new CacheCommandsFactory();
+ private CommandsFactory commandsFactory = new CommandsFactory();
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -98,8 +98,8 @@
assertSame(listClass, cache2.get(fqn, key).getClass());
- CacheCommand command = commandsFactory.buildGetKeyValueCommand(fqn, key, false);
- ClusteredGetCommand clusteredGet = commandsFactory.buildClusteredGetCommand(command, false);
+ CacheDataCommand command = commandsFactory.buildGetKeyValueCommand(fqn, key, false);
+ ClusteredGetCommand clusteredGet = commandsFactory.buildClusteredGetCommand(false, command);
List responses = cache1.getRPCManager().callRemoteMethods(null, clusteredGet, true, true, 15000, false);
List response1 = (List) responses.get(0);// response from the first (and only) node
@@ -127,7 +127,7 @@
assertNotSame(MyList.class, cache2.get(fqn, key).getClass());
assertSame(listClass, cache2.get(fqn, key).getClass());
- GravitateDataCacheCommand cdCc = commandsFactory.buildGravitateDataCacheCommand(fqn, false);
+ GravitateDataCommand cdCc = commandsFactory.buildGravitateDataCacheCommand(fqn, false);
List responses = cache1.getRPCManager().callRemoteMethods(null, cdCc, true, true, 15000, false);
GravitateResult data = (GravitateResult) responses.get(0);// response from the first (and only) node
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -10,8 +10,9 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.VersionedNode;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.GlobalTransactionCommand;
+import org.jboss.cache.commands.TxCacheCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.invocation.NodeInvocationDelegate;
@@ -24,11 +25,13 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import org.jgroups.Address;
import javax.transaction.RollbackException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.CountDownLatch;
@@ -38,7 +41,7 @@
Log log = LogFactory.getLog(CacheTest.class);
private CacheSPI<Object, Object> c;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -220,10 +223,10 @@
command.setGlobalTransaction(remoteGtx);
- commandsFactory = new CacheCommandsFactory();
+ commandsFactory = new CommandsFactory();
//call our remote method
- OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null,
- remoteGtx.getAddress(), Boolean.FALSE);
+ List<TxCacheCommand> cacheCommands = injectDataVersion(entry.getModifications());
+ OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, cacheCommands, (Map)null, (Address)remoteGtx.getAddress(), false);
TestingUtil.replicateCommand(c, prepareCommand);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -9,7 +9,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.GlobalTransactionCommand;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.marshall.MethodDeclarations;
@@ -33,6 +33,7 @@
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.List;
+import java.util.Map;
/**
* @author xenephon
@@ -42,7 +43,7 @@
public class OptimisticReplicationInterceptorTest extends AbstractOptimisticTestCase
{
private CacheSPI cache;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -146,8 +147,8 @@
command.setGlobalTransaction(remoteGtx);
//call our remote method
- commandsFactory = new CacheCommandsFactory();
- CacheCommand prepcareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, (Address) remoteGtx.getAddress());
+ commandsFactory = new CommandsFactory();
+ CacheCommand prepcareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, null, (Map) null, (Address) remoteGtx.getAddress(), false);
try
{
TestingUtil.replicateCommand(cache, prepcareCommand); //getInvocationDelegate(cache)._replicate(prepareMethod);
@@ -211,7 +212,7 @@
GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
//call our remote method
- CacheCommand prepcareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, (Address) remoteGtx.getAddress());
+ CacheCommand prepcareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, null, (Map) null, (Address) remoteGtx.getAddress(), false);
try
{
TestingUtil.replicateCommand(cache, prepcareCommand);
@@ -240,7 +241,7 @@
assertEquals(1, cache.getTransactionTable().getNumLocalTransactions());
// call our remote method
- CacheCommand cacheCommand = commandsFactory.buildRollbackCommand();
+ CacheCommand cacheCommand = commandsFactory.buildRollbackCommand(null);
try
{
TestingUtil.replicateCommand(cache, cacheCommand);
@@ -400,7 +401,7 @@
//hack the method call to make it have the remote globalTransaction
GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
- CacheCommand prepcareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, (Address) remoteGtx.getAddress());
+ CacheCommand prepcareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, null, (Map) null, (Address) remoteGtx.getAddress(), false);
try
{
TestingUtil.replicateCommand(cache, prepcareCommand);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -7,7 +7,7 @@
package org.jboss.cache.optimistic;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.GlobalTransactionCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
@@ -21,15 +21,17 @@
import org.jboss.cache.transaction.TransactionTable;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
+import org.jgroups.Address;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.util.List;
+import java.util.Map;
@Test(groups = {"functional", "transaction"})
public class TxInterceptorTest extends AbstractOptimisticTestCase
{
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
@Override
protected CacheSPI<Object, Object> createCacheUnstarted(boolean optimistic) throws Exception
@@ -308,11 +310,11 @@
remoteGtx.setAddress(new DummyAddress());
//hack the method call to make it have the remote globalTransaction
- commandsFactory = new CacheCommandsFactory();
+ commandsFactory = new CommandsFactory();
GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map)null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -371,7 +373,7 @@
GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map)null, (Address)remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -454,7 +456,7 @@
GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address)remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -542,7 +544,7 @@
GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map)null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -640,7 +642,7 @@
GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map)null, (Address)remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -724,7 +726,7 @@
GlobalTransactionCommand command = (GlobalTransactionCommand) entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null, remoteGtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map)null, (Address)remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, command);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java 2008-04-10 04:27:48 UTC (rev 5527)
@@ -10,7 +10,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.CommitCommand;
@@ -33,6 +33,7 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import org.jgroups.Address;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
@@ -49,7 +50,7 @@
private CacheSPI<Object, Object> cache;
private TransactionManager mgr;
private MockInterceptor dummy;
- private CacheCommandsFactory commandsFactory;
+ private CommandsFactory commandsFactory;
@BeforeMethod
public void setUp() throws Exception
@@ -112,8 +113,8 @@
assertTrue(!cache.exists("/one/two"));
assertEquals(null, dummy.getCalledCommand());
- commandsFactory = new CacheCommandsFactory();
- OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), null, gtx.getAddress(), Boolean.FALSE);
+ commandsFactory = new CommandsFactory();
+ OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), (Map)null, (Address) gtx.getAddress(), Boolean.FALSE);
//now let us do a prepare
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -166,7 +167,7 @@
//lets change one of the underlying version numbers
workspace.getNode(Fqn.fromString("/one/two")).getNode().setVersion(new DefaultDataVersion(2));
//now let us do a prepare
- OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), null, gtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), (Map)null, (Address) gtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -213,7 +214,7 @@
//lets change one of the underlying version numbers
//now let us do a prepare
- OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), null, gtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), (Map)null, (Address) gtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -291,7 +292,7 @@
//lets change one of the underlying version numbers
//now let us do a prepare
- OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), null, gtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), (Map)null, (Address)gtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -370,7 +371,7 @@
//lets change one of the underlying version numbers
//now let us do a prepare
- OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), null, gtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = commandsFactory.buildOptimisticPrepareCommand(gtx, entry.getModifications(), (Map)null, (Address)gtx.getAddress(), Boolean.FALSE);
try
{
@@ -383,7 +384,7 @@
}
MethodCall rollbackMethod = MethodCallFactory.create(MethodDeclarations.rollbackMethod_id, gtx);
- RollbackCommand rollbackCommand = commandsFactory.buildRollbackCommand();
+ RollbackCommand rollbackCommand = commandsFactory.buildRollbackCommand(null);
TestingUtil.replicateCommand(cache, rollbackCommand);
Modified: core/trunk/src/test/resources/log4j.xml
===================================================================
--- core/trunk/src/test/resources/log4j.xml 2008-04-09 16:29:33 UTC (rev 5526)
+++ core/trunk/src/test/resources/log4j.xml 2008-04-10 04:27:48 UTC (rev 5527)
@@ -22,8 +22,8 @@
<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
- <param name="File" value="jbosscache.log"/>
- <param name="Append" value="true"/>
+ <param name="File" value="../jbosscache.log"/>
+ <param name="Append" value="false"/>
<!-- Rollover at midnight each day -->
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
@@ -31,7 +31,7 @@
<!-- Rollover at the top of each hour
<param name="DatePattern" value="'.'yyyy-MM-dd-HH"/>
-->
- <param name="Threshold" value="TRACE"/>
+ <param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
@@ -63,13 +63,9 @@
<!-- ================ -->
<category name="org.jboss.cache">
- <priority value="WARN"/>
+ <priority value="TRACE"/>
</category>
- <category name="org.jboss.cache.factories">
- <priority value="ERROR"/>
- </category>
-
<category name="org.jboss.tm">
<priority value="WARN"/>
</category>
@@ -83,7 +79,7 @@
<!-- ======================= -->
<root>
- <!--<appender-ref ref="CONSOLE"/>-->
+ <appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
16 years, 9 months
JBoss Cache SVN: r5526 - in core/branches/2.1.X/src: test/java/org/jboss/cache/eviction and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2008-04-09 12:29:33 -0400 (Wed, 09 Apr 2008)
New Revision: 5526
Added:
core/branches/2.1.X/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java
Modified:
core/branches/2.1.X/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
Log:
[JBCACHE-1316] offer() is called instead of put() on the recycle queue to avoid blocking forever. Added unit test that forces recycle queue to fill up completely.
Modified: core/branches/2.1.X/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
===================================================================
--- core/branches/2.1.X/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java 2008-04-09 16:16:53 UTC (rev 5525)
+++ core/branches/2.1.X/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java 2008-04-09 16:29:33 UTC (rev 5526)
@@ -24,6 +24,7 @@
* abstract methods and a policy.
*
* @author Daniel Huang - dhuang(a)jboss.org 10/2005
+ * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
* @version $Revision$
*/
public abstract class BaseEvictionAlgorithm implements EvictionAlgorithm
@@ -193,7 +194,14 @@
{
try
{
- recycleQueue.put(ne.getFqn());
+ boolean result = recycleQueue.offer(ne.getFqn(), 5, TimeUnit.SECONDS);
+ if (!result)
+ {
+ log.warn("Unable to add Fqn[" + ne.getFqn() + "] to recycle " +
+ "queue because it's full. This is often sign that " +
+ "evictions are not occurring and nodes that should be " +
+ "evicted are piling up waiting to be evicted.");
+ }
}
catch (InterruptedException e)
{
Added: core/branches/2.1.X/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java
===================================================================
--- core/branches/2.1.X/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java (rev 0)
+++ core/branches/2.1.X/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java 2008-04-09 16:29:33 UTC (rev 5526)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache.eviction;
+
+import static org.testng.AssertJUnit.fail;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Region;
+import org.jboss.cache.RegionManager;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionPolicyConfig;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Tests BaseEvictionAlgorithm class.
+ *
+ * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
+ */
+@Test(groups = "functional")
+public class BaseEvictionAlgorithmTest
+{
+ private static final Log log = LogFactory.getLog(BaseEvictionAlgorithmTest.class);
+
+ private RegionManager regionManager;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ regionManager = new RegionManager();
+ }
+
+ public void testFillUpRecycleQueue() throws Exception
+ {
+ final int recycleQueueCapacity = 10;
+
+ /* override recycle queue capacity to make the test shorter */
+ BaseEvictionAlgorithm algorithm = new MockEvictionAlgorithm(recycleQueueCapacity);
+
+ Region region = regionManager.getRegion("/a/b/c", true);
+ region.setEvictionPolicy(new MockEvictionPolicyConfig());
+
+ for (int i = 0; i < (recycleQueueCapacity + 1); i ++)
+ {
+ Fqn<String> fqn = Fqn.fromString("/a/b/c/" + Integer.toString(i + 1));
+ region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
+ }
+
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ Future<Void> future = executor.submit(new ProcessEvictionRegion(region, algorithm));
+
+ try
+ {
+ future.get(20, TimeUnit.SECONDS);
+ }
+ catch(TimeoutException te)
+ {
+ log.error("Region eviction processing did not finish on time", te);
+ fail("Region eviction processing should have finished by now, something is wrong. Recycle queue may have filled up.");
+ }
+ finally
+ {
+ log.info("recycle queue size: " + algorithm.recycleQueue.size());
+ }
+ }
+
+ /** Classes **/
+
+ public static class MockEvictionAlgorithm extends BaseEvictionAlgorithm
+ {
+ public MockEvictionAlgorithm(int recycleQueueCapacity)
+ {
+ recycleQueue = new LinkedBlockingQueue<Fqn>(recycleQueueCapacity);
+ }
+
+ @Override
+ protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException
+ {
+ return new LRUQueue();
+ }
+
+ @Override
+ protected boolean shouldEvictNode(NodeEntry ne)
+ {
+ /* all node entries need evicting */
+ return true;
+ }
+
+ }
+
+ public static class MockEvictionPolicy extends BaseEvictionPolicy
+ {
+
+ @Override
+ public void evict(Fqn fqn) throws Exception
+ {
+ throw new Exception("Unable to evict");
+ }
+
+ @Override
+ public void setCache(CacheSPI cache)
+ {
+ /* no op */
+ }
+
+ public EvictionAlgorithm getEvictionAlgorithm()
+ {
+ return null;
+ }
+
+ public Class<? extends EvictionPolicyConfig> getEvictionConfigurationClass()
+ {
+ return MockEvictionPolicyConfig.class;
+ }
+ }
+
+ public static class MockEvictionPolicyConfig implements EvictionPolicyConfig
+ {
+
+ public String getEvictionPolicyClass()
+ {
+ return MockEvictionPolicy.class.getName();
+ }
+
+ public void reset()
+ {
+ /* no op */
+ }
+
+ public void validate() throws ConfigurationException
+ {
+ /* no op */
+ }
+ }
+
+ public class ProcessEvictionRegion implements Callable<Void>
+ {
+ private Region region;
+
+ private EvictionAlgorithm algorithm;
+
+ public ProcessEvictionRegion(Region region, EvictionAlgorithm algorithm)
+ {
+ this.region = region;
+ this.algorithm = algorithm;
+ }
+
+ public Void call() throws Exception
+ {
+ try
+ {
+ algorithm.process(region);
+ }
+ catch(EvictionException e)
+ {
+ log.error("Eviction exception reported", e);
+ fail("Eviction exception reported" + e);
+ }
+
+ return null;
+ }
+ }
+}
16 years, 9 months
JBoss Cache SVN: r5525 - in core/trunk/src: test/java/org/jboss/cache/eviction and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2008-04-09 12:16:53 -0400 (Wed, 09 Apr 2008)
New Revision: 5525
Added:
core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
Log:
[JBCACHE-1316] offer() is called instead of put() on the recycle queue to avoid blocking forever. Added unit test that forces recycle queue to fill up completely.
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java 2008-04-09 15:59:33 UTC (rev 5524)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/BaseEvictionAlgorithm.java 2008-04-09 16:16:53 UTC (rev 5525)
@@ -24,6 +24,7 @@
* abstract methods and a policy.
*
* @author Daniel Huang - dhuang(a)jboss.org 10/2005
+ * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
* @version $Revision$
*/
public abstract class BaseEvictionAlgorithm implements EvictionAlgorithm
@@ -193,7 +194,14 @@
{
try
{
- recycleQueue.put(ne.getFqn());
+ boolean result = recycleQueue.offer(ne.getFqn(), 5, TimeUnit.SECONDS);
+ if (!result)
+ {
+ log.warn("Unable to add Fqn[" + ne.getFqn() + "] to recycle " +
+ "queue because it's full. This is often sign that " +
+ "evictions are not occurring and nodes that should be " +
+ "evicted are piling up waiting to be evicted.");
+ }
}
catch (InterruptedException e)
{
Added: core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/BaseEvictionAlgorithmTest.java 2008-04-09 16:16:53 UTC (rev 5525)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache.eviction;
+
+import static org.testng.AssertJUnit.fail;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Region;
+import org.jboss.cache.RegionManager;
+import org.jboss.cache.config.ConfigurationException;
+import org.jboss.cache.config.EvictionPolicyConfig;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Tests BaseEvictionAlgorithm class.
+ *
+ * @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
+ */
+@Test(groups = "functional")
+public class BaseEvictionAlgorithmTest
+{
+ private static final Log log = LogFactory.getLog(BaseEvictionAlgorithmTest.class);
+
+ private RegionManager regionManager;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ regionManager = new RegionManager();
+ }
+
+ public void testFillUpRecycleQueue() throws Exception
+ {
+ final int recycleQueueCapacity = 10;
+
+ /* override recycle queue capacity to make the test shorter */
+ BaseEvictionAlgorithm algorithm = new MockEvictionAlgorithm(recycleQueueCapacity);
+
+ Region region = regionManager.getRegion("/a/b/c", true);
+ region.setEvictionPolicy(new MockEvictionPolicyConfig());
+
+ for (int i = 0; i < (recycleQueueCapacity + 1); i ++)
+ {
+ Fqn<String> fqn = Fqn.fromString("/a/b/c/" + Integer.toString(i + 1));
+ region.putNodeEvent(new EvictedEventNode(fqn, NodeEventType.ADD_NODE_EVENT));
+ }
+
+ ExecutorService executor = Executors.newSingleThreadExecutor();
+ Future<Void> future = executor.submit(new ProcessEvictionRegion(region, algorithm));
+
+ try
+ {
+ future.get(20, TimeUnit.SECONDS);
+ }
+ catch(TimeoutException te)
+ {
+ log.error("Region eviction processing did not finish on time", te);
+ fail("Region eviction processing should have finished by now, something is wrong. Recycle queue may have filled up.");
+ }
+ finally
+ {
+ log.info("recycle queue size: " + algorithm.recycleQueue.size());
+ }
+ }
+
+ /** Classes **/
+
+ public static class MockEvictionAlgorithm extends BaseEvictionAlgorithm
+ {
+ public MockEvictionAlgorithm(int recycleQueueCapacity)
+ {
+ recycleQueue = new LinkedBlockingQueue<Fqn>(recycleQueueCapacity);
+ }
+
+ @Override
+ protected EvictionQueue setupEvictionQueue(Region region) throws EvictionException
+ {
+ return new LRUQueue();
+ }
+
+ @Override
+ protected boolean shouldEvictNode(NodeEntry ne)
+ {
+ /* all node entries need evicting */
+ return true;
+ }
+
+ }
+
+ public static class MockEvictionPolicy extends BaseEvictionPolicy
+ {
+
+ @Override
+ public void evict(Fqn fqn) throws Exception
+ {
+ throw new Exception("Unable to evict");
+ }
+
+ @Override
+ public void setCache(CacheSPI cache)
+ {
+ /* no op */
+ }
+
+ public EvictionAlgorithm getEvictionAlgorithm()
+ {
+ return null;
+ }
+
+ public Class<? extends EvictionPolicyConfig> getEvictionConfigurationClass()
+ {
+ return MockEvictionPolicyConfig.class;
+ }
+ }
+
+ public static class MockEvictionPolicyConfig implements EvictionPolicyConfig
+ {
+
+ public String getEvictionPolicyClass()
+ {
+ return MockEvictionPolicy.class.getName();
+ }
+
+ public void reset()
+ {
+ /* no op */
+ }
+
+ public void validate() throws ConfigurationException
+ {
+ /* no op */
+ }
+ }
+
+ public class ProcessEvictionRegion implements Callable<Void>
+ {
+ private Region region;
+
+ private EvictionAlgorithm algorithm;
+
+ public ProcessEvictionRegion(Region region, EvictionAlgorithm algorithm)
+ {
+ this.region = region;
+ this.algorithm = algorithm;
+ }
+
+ public Void call() throws Exception
+ {
+ try
+ {
+ algorithm.process(region);
+ }
+ catch(EvictionException e)
+ {
+ log.error("Eviction exception reported", e);
+ fail("Eviction exception reported" + e);
+ }
+
+ return null;
+ }
+ }
+}
16 years, 9 months
JBoss Cache SVN: r5524 - in core/branches/2.1.X/src: main/java/org/jboss/cache/marshall and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-04-09 11:59:33 -0400 (Wed, 09 Apr 2008)
New Revision: 5524
Modified:
core/branches/2.1.X/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java
core/branches/2.1.X/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
core/branches/2.1.X/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
Log:
JBCACHE-1325: ClassLoader and probable memory leak in ReusableObjectInputStream
Modified: core/branches/2.1.X/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java
===================================================================
--- core/branches/2.1.X/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java 2008-04-09 14:33:24 UTC (rev 5523)
+++ core/branches/2.1.X/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java 2008-04-09 15:59:33 UTC (rev 5524)
@@ -8,7 +8,6 @@
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.marshall.VersionAwareMarshaller;
-import org.jboss.cache.marshall.io.ObjectStreamPool;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.remoting.jgroups.CacheMessageListener;
import org.jboss.cache.statetransfer.StateTransferManager;
@@ -22,7 +21,7 @@
*/
@DefaultFactoryFor(classes = {StateTransferManager.class, TransactionTable.class, RegionManager.class, Notifier.class,
CacheMessageListener.class, CacheLoaderManager.class, RemoteCacheInvocationDelegate.class, Marshaller.class,
- InvocationContextContainer.class, ObjectStreamPool.class})
+ InvocationContextContainer.class})
public class EmptyConstructorFactory extends ComponentFactory
{
@Override
Modified: core/branches/2.1.X/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java
===================================================================
--- core/branches/2.1.X/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-04-09 14:33:24 UTC (rev 5523)
+++ core/branches/2.1.X/src/main/java/org/jboss/cache/marshall/VersionAwareMarshaller.java 2008-04-09 15:59:33 UTC (rev 5524)
@@ -12,8 +12,6 @@
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.marshall.io.ObjectStreamPool;
-import org.jboss.cache.marshall.io.ReusableObjectOutputStream;
import org.jboss.cache.util.Util;
import org.jboss.util.stream.MarshalledValueInputStream;
@@ -47,13 +45,11 @@
Marshaller defaultMarshaller;
Map<Integer, Marshaller> marshallers = new HashMap<Integer, Marshaller>();
private int versionInt;
- ObjectStreamPool pool;
@Inject
- void injectComponents(ComponentRegistry componentRegistry, ObjectStreamPool pool)
+ void injectComponents(ComponentRegistry componentRegistry)
{
this.componentRegistry = componentRegistry;
- this.pool = pool;
}
@Start
@@ -152,7 +148,8 @@
}
}
- private byte[] useNonPooledStream(Object obj) throws Exception
+ @Override
+ public byte[] objectToByteBuffer(Object obj, boolean writeHeader) throws Exception
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(baos);
@@ -169,57 +166,26 @@
}
@Override
- public byte[] objectToByteBuffer(Object obj, boolean writeHeader) throws Exception
- {
- if (writeHeader) return useNonPooledStream(obj);
-
- ReusableObjectOutputStream out = pool.getOutputStream();
-
- try
- {
- out.writeShort(versionInt);
- if (trace) log.trace("Wrote version " + versionInt);
-
- //now marshall the contents of the object
- defaultMarshaller.objectToObjectStream(obj, out);
-
- // and return bytes.
- return out.getBytes();
- }
- finally
- {
- pool.returnStreamToPool(out);
- }
- }
-
- @Override
public Object objectFromByteBuffer(byte[] buf) throws Exception
{
Marshaller marshaller;
int versionId;
- ObjectInputStream in = pool.getInputStream(buf);
+ ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(buf));
try
{
- try
- {
- versionId = in.readShort();
- if (trace) log.trace("Read version " + versionId);
- }
- catch (Exception e)
- {
- log.error("Unable to read version id from first two bytes of stream, barfing.");
- throw e;
- }
-
- marshaller = getMarshaller(versionId);
-
- return marshaller.objectFromObjectStream(in);
+ versionId = in.readShort();
+ if (trace) log.trace("Read version " + versionId);
}
- finally
+ catch (Exception e)
{
- pool.returnStreamToPool(in);
+ log.error("Unable to read version id from first two bytes of stream, barfing.");
+ throw e;
}
+
+ marshaller = getMarshaller(versionId);
+
+ return marshaller.objectFromObjectStream(in);
}
@Override
@@ -227,29 +193,22 @@
{
Marshaller marshaller;
int versionId;
- ObjectInputStream in = pool.getInputStream(buf);
+ ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(buf));
try
{
- try
- {
- versionId = in.readShort();
- if (trace) log.trace("Read version " + versionId);
- }
- catch (Exception e)
- {
- log.error("Unable to read version id from first two bytes of stream, barfing.");
- throw e;
- }
-
- marshaller = getMarshaller(versionId);
-
- return marshaller.regionalizedMethodCallFromObjectStream(in);
+ versionId = in.readShort();
+ if (trace) log.trace("Read version " + versionId);
}
- finally
+ catch (Exception e)
{
- pool.returnStreamToPool(in);
+ log.error("Unable to read version id from first two bytes of stream, barfing.");
+ throw e;
}
+
+ marshaller = getMarshaller(versionId);
+
+ return marshaller.regionalizedMethodCallFromObjectStream(in);
}
@Override
Modified: core/branches/2.1.X/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java
===================================================================
--- core/branches/2.1.X/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-04-09 14:33:24 UTC (rev 5523)
+++ core/branches/2.1.X/src/test/java/org/jboss/cache/marshall/VersionAwareMarshallerTest.java 2008-04-09 15:59:33 UTC (rev 5524)
@@ -9,13 +9,13 @@
import org.jboss.cache.Version;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.marshall.io.ObjectStreamPool;
-import org.jboss.cache.misc.TestingUtil;
+import org.jboss.util.stream.MarshalledValueInputStream;
import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.io.ByteArrayInputStream;
import java.io.ObjectInputStream;
/**
@@ -73,8 +73,7 @@
VersionAwareMarshaller marshaller = createVAMandRestartCache(Version.getVersionString(Version.getVersionShort()));
byte[] bytes = marshaller.objectToByteBuffer("Hello");
- ObjectStreamPool pool = (ObjectStreamPool) TestingUtil.extractField(marshaller, "pool");
- ObjectInputStream in = pool.getInputStream(bytes);
+ ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(bytes));
assertEquals("Version header short should be '21'", 21, in.readShort());
}
@@ -83,8 +82,7 @@
VersionAwareMarshaller marshaller = createVAMandRestartCache("2.0.0.GA");
byte[] bytes = marshaller.objectToByteBuffer("Hello");
- ObjectStreamPool pool = (ObjectStreamPool) TestingUtil.extractField(marshaller, "pool");
- ObjectInputStream in = pool.getInputStream(bytes);
+ ObjectInputStream in = new MarshalledValueInputStream(new ByteArrayInputStream(bytes));
assertEquals("Version header short should be '20'", 20, in.readShort());
}
16 years, 9 months