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>