[jbosscache-commits] JBoss Cache SVN: r5578 - in core/trunk/src/main/java/org/jboss/cache: commands and 9 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Wed Apr 16 10:33:06 EDT 2008
Author: mircea.markus
Date: 2008-04-16 10:33:06 -0400 (Wed, 16 Apr 2008)
New Revision: 5578
Added:
core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoteExistsNodeCommand.java
Removed:
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/ExistsNodeCommand.java
Modified:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
core/trunk/src/main/java/org/jboss/cache/commands/CacheCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/visitors/AbstractCommandsVisitor.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/Interceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
Log:
JBCACHE-1222 - bug fixing - optimistic locking
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -7,13 +7,7 @@
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.functional.MarshallableCommand;
-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.GravitateDataCommand;
-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;
@@ -120,7 +114,7 @@
return factory.buildGetDataMapCommand(transformed);
}
- public Object handleExistsNodeCommand(InvocationContext ctx, ExistsNodeCommand command) throws Throwable
+ public Object handleExistsNodeCommand(InvocationContext ctx, RemoteExistsNodeCommand command) throws Throwable
{
Fqn transformed = getBackupFqn(command.getFqn());
return factory.buildEvictFqnCommand(transformed);
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CacheCommand.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -6,6 +6,7 @@
* @author Mircea.Markus at jboss.com
* @since 2.2
* todo - reduce dependencies from CacheSPI many commands depend on CacheSPI only for invoceation ctxt. inject ctxt rather than entire CacheSPI
+ * todo - add toString to all commands
*/
public interface CacheCommand extends Cloneable
{
Modified: core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-04-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -8,13 +8,7 @@
import org.jboss.cache.commands.channel.BlockChannelCommand;
import org.jboss.cache.commands.channel.UnblockChannelCommand;
import org.jboss.cache.commands.functional.MarshallableCommand;
-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.GravitateDataCommand;
-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;
@@ -165,9 +159,9 @@
return command;
}
- public ExistsNodeCommand buildExistsNodeCommand(Fqn fqn)
+ public RemoteExistsNodeCommand buildExistsNodeCommand(Fqn fqn)
{
- ExistsNodeCommand command = new ExistsNodeCommand(fqn);
+ RemoteExistsNodeCommand command = new RemoteExistsNodeCommand(fqn);
registry.wireDependencies(command);
return command;
}
@@ -231,7 +225,8 @@
public OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, CacheCommand command)
{
- return buildOptimisticPrepareCommand(gtx, Collections.singletonList(command), null, null, false);
+ List<CacheCommand> list = command == null ? Collections.EMPTY_LIST : Collections.singletonList(command);
+ return buildOptimisticPrepareCommand(gtx, list, null, null, false);
}
public AnnounceBuddyPoolNameCommand buildAnnounceBuddyPoolNameCommand(Address address, String buddyPoolName)
@@ -296,8 +291,8 @@
MarshallableCommand returnValue;
switch (id)
{
- case ExistsNodeCommand.METHOD_ID:
- returnValue = new ExistsNodeCommand();
+ case RemoteExistsNodeCommand.METHOD_ID:
+ returnValue = new RemoteExistsNodeCommand();
break;
case GetChildrenNamesCommand.METHOD_ID:
Modified: core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java 2008-04-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsVisitor.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -4,13 +4,7 @@
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.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.GravitateDataCommand;
-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;
@@ -106,7 +100,7 @@
equiv of old:
1 - existsMethod_id
*/
- public Object handleExistsNodeCommand(InvocationContext ctx, ExistsNodeCommand existsNodeCommand) throws Throwable;
+ public Object handleExistsNodeCommand(InvocationContext ctx, RemoteExistsNodeCommand existsNodeCommand) throws Throwable;
/*
equiv of old:
Deleted: 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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/commands/cachedata/ExistsNodeCommand.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -1,46 +0,0 @@
-package org.jboss.cache.commands.cachedata;
-
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.Node;
-import org.jboss.cache.commands.CommandsVisitor;
-import org.jboss.cache.commands.state.BaseCacheDataCommand;
-
-/**
- * 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
- * node has been evicted).
- *
- * @author Mircea.Markus at jboss.com
- * @since 2.2
- */
-public class ExistsNodeCommand extends BaseCacheDataCommand
-{
- public static final int METHOD_ID = 16;
-
- public ExistsNodeCommand()
- {
- }
-
- public ExistsNodeCommand(Fqn fqn)
- {
- this.fqn = fqn;
- }
-
- public Object perform(InvocationContext ctx)
- {
- Node n = cacheData.peek(fqn, false);
- return n != null;
- }
-
- public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
- {
- return handler.handleExistsNodeCommand(ctx, this);
- }
-
- public int getCommandId()
- {
- return METHOD_ID;
- }
-}
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -3,7 +3,7 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.CommandsVisitor;
import org.jboss.cache.commands.cachedata.CacheDataCommand;
-import org.jboss.cache.commands.cachedata.ExistsNodeCommand;
+import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
import org.jboss.cache.commands.cachedata.GetDataMapCommand;
import org.jboss.cache.factories.annotations.Inject;
@@ -102,7 +102,7 @@
{
return callResults != null || cacheData.exists(cacheDataComand.getFqn());
}
- return cacheDataComand instanceof ExistsNodeCommand && (Boolean) callResults;
+ return cacheDataComand instanceof RemoteExistsNodeCommand && (Boolean) callResults;
}
/**
Copied: core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoteExistsNodeCommand.java (from rev 5572, core/trunk/src/main/java/org/jboss/cache/commands/cachedata/ExistsNodeCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoteExistsNodeCommand.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoteExistsNodeCommand.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -0,0 +1,47 @@
+package org.jboss.cache.commands.remote;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
+import org.jboss.cache.commands.CommandsVisitor;
+import org.jboss.cache.commands.state.BaseCacheDataCommand;
+
+/**
+ * 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
+ * node has been evicted).
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 2.2
+ * todo - this is only used when remote cache calls exists, nut sure it is necessary to have it as a command
+ */
+public class RemoteExistsNodeCommand extends BaseCacheDataCommand
+{
+ public static final int METHOD_ID = 16;
+
+ public RemoteExistsNodeCommand()
+ {
+ }
+
+ public RemoteExistsNodeCommand(Fqn fqn)
+ {
+ this.fqn = fqn;
+ }
+
+ public Object perform(InvocationContext ctx)
+ {
+ Node n = cacheData.peek(fqn, false);
+ return n != null;
+ }
+
+ public Object accept(InvocationContext ctx, CommandsVisitor handler) throws Throwable
+ {
+ return handler.handleExistsNodeCommand(ctx, this);
+ }
+
+ public int getCommandId()
+ {
+ return METHOD_ID;
+ }
+}
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -8,6 +8,7 @@
import java.util.List;
import java.util.Map;
+import java.util.Collections;
/**
* @author Mircea.Markus at jboss.com
@@ -25,6 +26,10 @@
public OptimisticPrepareCommand(GlobalTransaction gtx, List<? extends CacheCommand> modifications, Map data, Address address, boolean onePhaseCommit)
{
super(gtx, modifications, address, onePhaseCommit);
+ if (log.isTraceEnabled())
+ {
+ log.trace("Building optimistic prepare command with modification list: " + modifications);
+ }
this.data = data;
}
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/commands/visitors/AbstractCommandsVisitor.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -6,13 +6,7 @@
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.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.GravitateDataCommand;
-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;
@@ -66,7 +60,7 @@
return handleDefault(ctx, command);
}
- public Object handleExistsNodeCommand(InvocationContext ctx, ExistsNodeCommand command) throws Throwable
+ public Object handleExistsNodeCommand(InvocationContext ctx, RemoteExistsNodeCommand command) throws Throwable
{
return handleDefault(ctx, command);
}
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -184,7 +184,7 @@
if (inTransaction())
{
if (trace) log.trace("transactional so don't put stuff in the cloader yet.");
- prepareCacheLoader(command.getGlobalTransaction(), ctx.getMethodCall().isOnePhaseCommitPrepareMehod());
+ prepareCacheLoader(command.getGlobalTransaction(), command.isOnePhaseCommit());
}
return invokeNextInterceptor(ctx, command);
}
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -2,10 +2,7 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.CacheCommand;
-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.RemoveNodeCommand;
+import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.functional.TxCacheCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
@@ -56,30 +53,35 @@
configuration.getCacheLoaderConfig().getFirstCacheLoaderConfig() != null;
}
+ @Override
public Object handlePrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
{
if (trace) log.trace("Suppressing invocation of method handlePrepareCommand.");
return null;
}
+ @Override
public Object handleOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
{
if (trace) log.trace("Suppressing invocation of method handleOptimisticPrepareCommand.");
return null;
}
+ @Override
public Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
{
if (trace) log.trace("Suppressing invocation of method handleCommitCommand.");
return null;
}
+ @Override
public Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
{
if (trace) log.trace("Suppressing invocation of method handleRollbackCommand.");
return null;
}
+ @Override
public Object handleDefault(InvocationContext ctx, CacheCommand command) throws Throwable
{
if (trace) log.trace("Executing command: " + command.getClass().getSimpleName() + " .");
@@ -106,26 +108,36 @@
return retval;
}
+ @Override
public Object handlePutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
return handleAlterCacheMethod(ctx, command);
}
+ @Override
public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
return handleAlterCacheMethod(ctx, command);
}
+ @Override
public Object handleRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
return handleAlterCacheMethod(ctx, command);
}
+ @Override
public Object handleRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
return handleAlterCacheMethod(ctx, command);
}
+ @Override
+ public Object handleMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+ {
+ return handleAlterCacheMethod(ctx, command);
+ }
+
/**
* only add the modification to the modification list if we are using pessimistic locking.
* Optimistic locking calls *should* not make it this far down the interceptor chain, but just
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -18,6 +18,7 @@
import org.jboss.cache.commands.remote.GravitateDataCommand;
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
@@ -85,7 +86,7 @@
}
@Override
- public Object handleExistsNodeCommand(InvocationContext ctx, ExistsNodeCommand command) throws Throwable
+ public Object handleExistsNodeCommand(InvocationContext ctx, RemoteExistsNodeCommand command) throws Throwable
{
return handleGetMethod(ctx, command);
}
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -31,12 +31,7 @@
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.AnnounceBuddyPoolNameCommand;
-import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.GravitateDataCommand;
-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;
@@ -228,8 +223,8 @@
case GetDataMapCommand.METHOD_ID:
return next.handleGetDataMapCommand(ctx, (GetDataMapCommand) command);
- case ExistsNodeCommand.METHOD_ID:
- return next.handleExistsNodeCommand(ctx, (ExistsNodeCommand) command);
+ case RemoteExistsNodeCommand.METHOD_ID:
+ return next.handleExistsNodeCommand(ctx, (RemoteExistsNodeCommand) command);
case GetKeyValueCommand.METHOD_ID:
return next.handleGetKeyValueCommand(ctx, (GetKeyValueCommand) command);
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -65,10 +65,11 @@
private Configuration configuration;
@Inject
- public void initialize(CommandsFactory commandsFactory, TransactionTable transactionTable)
+ public void initialize(CommandsFactory commandsFactory, TransactionTable transactionTable, Configuration configuration)
{
this.commandsFactory = commandsFactory;
this.transactionTable = transactionTable;
+ this.configuration = configuration;
}
private boolean isLocalOptionOverrides(InvocationContext ctx)
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -6,7 +6,6 @@
import org.jboss.cache.commands.cachedata.EvictNodeCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.ChainedInterceptor;
import org.jboss.cache.invocation.CacheData;
import org.jboss.cache.loader.CacheLoader;
@@ -30,27 +29,20 @@
private AtomicLong passivations = new AtomicLong(0);
- private CacheLoader loader;
+ protected CacheLoader loader;
private Notifier notifier;
private Configuration configuration;
private CacheData cacheData;
- private CacheLoaderManager cacheLoaderManager;
@Inject
- public void setDependencies(Notifier notifier, Configuration configuration, CacheData cacheData, CacheLoaderManager cacheLoaderManager)
+ public void setDependencies(Notifier notifier, Configuration configuration, CacheData cacheData, CacheLoaderManager loaderManager)
{
this.notifier = notifier;
this.configuration = configuration;
this.cacheData = cacheData;
- this.cacheLoaderManager = cacheLoaderManager;
+ this.loader = loaderManager.getCacheLoader();
}
- @Start
- public void startInterceptor()
- {
- loader = cacheLoaderManager.getCacheLoader();
- }
-
/**
* 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/base/SkipCheckChainedInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-04-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -5,13 +5,7 @@
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.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.GravitateDataCommand;
-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;
@@ -139,7 +133,7 @@
return executeAll(ctx, command);
}
- public final Object handleExistsNodeCommand(InvocationContext ctx, ExistsNodeCommand command) throws Throwable
+ public final Object handleExistsNodeCommand(InvocationContext ctx, RemoteExistsNodeCommand command) throws Throwable
{
if (skipInterception(ctx))
{
@@ -148,7 +142,7 @@
return executeExistsNodeCommand(ctx, command);
}
- public Object executeExistsNodeCommand(InvocationContext ctx, ExistsNodeCommand command) throws Throwable
+ public Object executeExistsNodeCommand(InvocationContext ctx, RemoteExistsNodeCommand command) throws Throwable
{
return executeAll(ctx, command);
}
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -333,6 +333,7 @@
public void move(Fqn<?> nodeToMove, Fqn<?> newParent) throws NodeNotExistsException
{
+ checkState();
MoveCommand command = commandsFactory.buildMoveCommand(nodeToMove, newParent);
invoke(command);
}
@@ -354,7 +355,7 @@
public void evict(Fqn<?> fqn, boolean recursive)
{
- if (!getCacheStatus().allowInvocations()) throw new IllegalStateException("Cache is not in STARTED state");
+ checkState();
List<Fqn> nodesToEvict = cacheData.getNodesForEviction(fqn, recursive);
for (Fqn aFqn : nodesToEvict)
{
@@ -369,6 +370,7 @@
public V get(Fqn<?> fqn, K key)
{
+ checkState();
GetKeyValueCommand command = commandsFactory.buildGetKeyValueCommand(fqn, key, true);
return (V) invoke(command);
}
@@ -380,6 +382,7 @@
public boolean removeNode(Fqn<?> fqn)
{
+ checkState();
// special case if we are removing the root. Remove all children instead.
if (fqn.isRoot())
{
@@ -407,6 +410,11 @@
}
}
+ private void checkState()
+ {
+ if (!getCacheStatus().allowInvocations()) throw new IllegalStateException("Cache is not in STARTED state");
+ }
+
public boolean removeNode(String fqn)
{
return removeNode(Fqn.fromString(fqn));
@@ -414,6 +422,7 @@
public NodeSPI<K, V> getNode(Fqn<?> fqn)
{
+ checkState();
GetNodeCommand command = commandsFactory.buildGetNodeCommand(fqn);
return (NodeSPI) invoke(command);
}
@@ -425,6 +434,7 @@
public V remove(Fqn<?> fqn, K key) throws CacheException
{
+ checkState();
GlobalTransaction tx = transactionHelper.getCurrentTransaction();
RemoveKeyCommand command = commandsFactory.buildRemoveKeyCommand(tx, fqn, key, true);
return (V) invoke(command);
@@ -437,6 +447,7 @@
public void put(Fqn<?> fqn, Map<K, V> data)
{
+ checkState();
PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(null, fqn, data, true, false);
invoke(command);
}
@@ -448,6 +459,7 @@
public void putForExternalRead(Fqn<?> fqn, K key, V value)
{
+ checkState();
// if the node exists then this should be a no-op.
if (peek(fqn, false, false) == null)
{
@@ -465,6 +477,7 @@
public V put(Fqn<?> fqn, K key, V value)
{
+ checkState();
GlobalTransaction tx = transactionHelper.getCurrentTransaction();
PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(tx, fqn, key, value, false, false);
return (V) invoke(command);
@@ -499,6 +512,7 @@
*/
public Map<K, V> getData(Fqn<?> fqn)
{
+ checkState();
GetDataMapCommand command = commandsFactory.buildGetDataMapCommand(fqn);
return (Map<K, V>) invoke(command);
}
@@ -524,6 +538,7 @@
*/
public Set<K> getKeys(Fqn<?> fqn)
{
+ checkState();
GetKeysCommand command = commandsFactory.buildGetKeysCommand(fqn);
return (Set<K>) invoke(command);
}
@@ -541,6 +556,7 @@
*/
public void clearData(Fqn fqn)
{
+ checkState();
GlobalTransaction tx = getCurrentTransaction();
invoke(commandsFactory.buildRemoveDataCommand(tx, fqn, true, false, false));
}
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-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/loader/ClusteredCacheLoader.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -9,18 +9,14 @@
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.CacheDataCommand;
-import org.jboss.cache.commands.cachedata.ExistsNodeCommand;
import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
import org.jboss.cache.commands.cachedata.GetDataMapCommand;
import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
import org.jboss.cache.commands.remote.ClusteredGetCommand;
+import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.lock.StripedLock;
@@ -30,12 +26,7 @@
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
@@ -190,7 +181,7 @@
lock.acquireLock(name, false);
try
{
- ExistsNodeCommand command = commandsFactory.buildExistsNodeCommand(name);
+ RemoteExistsNodeCommand command = commandsFactory.buildExistsNodeCommand(name);
Object resp = callRemote(command);
return resp != null && (Boolean) resp;
}
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-04-16 14:24:20 UTC (rev 5577)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-04-16 14:33:06 UTC (rev 5578)
@@ -12,14 +12,8 @@
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
-import org.jboss.cache.commands.cachedata.CacheDataCommand;
-import org.jboss.cache.commands.cachedata.EvictNodeCommand;
-import org.jboss.cache.commands.cachedata.ExistsNodeCommand;
-import org.jboss.cache.commands.cachedata.GetChildrenNamesCommand;
-import org.jboss.cache.commands.cachedata.GetDataMapCommand;
-import org.jboss.cache.commands.cachedata.GetKeyValueCommand;
-import org.jboss.cache.commands.cachedata.GetKeysCommand;
-import org.jboss.cache.commands.cachedata.InvalidateCommand;
+import org.jboss.cache.commands.remote.RemoteExistsNodeCommand;
+import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.functional.MarshallableCommand;
import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
@@ -154,7 +148,7 @@
case GetDataMapCommand.METHOD_ID:
case GetKeyValueCommand.METHOD_ID:
case GetKeysCommand.METHOD_ID:
- case ExistsNodeCommand.METHOD_ID:
+ case RemoteExistsNodeCommand.METHOD_ID:
fqn = ((CacheDataCommand) cmd).getFqn();
break;
More information about the jbosscache-commits
mailing list