JBoss Cache SVN: r5870 - in core/trunk/src: main/java/org/jboss/cache/commands and 9 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-19 07:26:40 -0400 (Mon, 19 May 2008)
New Revision: 5870
Added:
core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java
Modified:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.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/base/PostProcessingCommandInterceptor.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/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
Log:
Refactored commands and visitors
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -16,15 +16,7 @@
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.write.CreateNodeCommand;
-import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.commands.write.InvalidateCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveDataCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.commands.write.*;
import org.jboss.cache.factories.CommandsFactory;
import org.jgroups.Address;
@@ -80,10 +72,18 @@
{
Fqn transformed = getBackupFqn(command.getFqn());
return factory.buildPutKeyValueCommand(null, transformed, command.getKey(),
- command.getValue(), command.isCreateUndoOps(), command.isPutForExternalRead());
+ command.getValue(), command.isCreateUndoOps());
}
@Override
+ public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildPutForExternalReadCommand(null, transformed, command.getKey(),
+ command.getValue(), command.isCreateUndoOps());
+ }
+
+ @Override
public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
Fqn transformed = getBackupFqn(command.getFqn());
Modified: core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java 2008-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -1,7 +1,13 @@
package org.jboss.cache.commands;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.read.*;
+import org.jboss.cache.commands.read.ExistsCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
@@ -29,6 +35,11 @@
return handleDefault(ctx, command);
}
+ public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
return handleDefault(ctx, command);
Modified: core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -1,7 +1,13 @@
package org.jboss.cache.commands;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.read.*;
+import org.jboss.cache.commands.read.ExistsCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
@@ -40,6 +46,16 @@
Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable;
/**
+ * Visits a PutForExternalReadCommand.
+ *
+ * @param ctx invocation context
+ * @param command command to visit
+ * @return response from the visit
+ * @throws Throwable in the event of problems.
+ */
+ Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable;
+
+ /**
* Visits a RemoveNodeCommand.
*
* @param ctx invocation context
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-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -6,7 +6,7 @@
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.read.GravitateDataCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.interceptors.InterceptorChain;
import java.util.List;
@@ -118,21 +118,24 @@
if (returnValueForRemoteCall(cacheCommand))
{
result = retVal;
- } else
+ }
+ else
{
result = null;
}
- } else
+ }
+ else
{
result = cacheCommand.perform(null);
}
}
catch (Throwable ex)
{
- if (!isPutForExternalRead(cacheCommand))
+ if (!(cacheCommand instanceof PutForExternalReadCommand))
{
throw ex;
- } else
+ }
+ else
{
if (trace)
log.trace("Caught an exception, but since this is a putForExternalRead() call, suppressing the exception. Exception is:", ex);
@@ -142,13 +145,6 @@
return result;
}
- private boolean isPutForExternalRead(ReplicableCommand cacheCommand)
- {
- if (!(cacheCommand instanceof PutKeyValueCommand)) return false;
- PutKeyValueCommand pkvCommand = (PutKeyValueCommand) cacheCommand;
- return pkvCommand.isPutForExternalRead();
- }
-
private boolean returnValueForRemoteCall(ReplicableCommand cacheCommand)
{
return cacheCommand instanceof GravitateDataCommand || cacheCommand instanceof ClusteredGetCommand;
@@ -183,7 +179,8 @@
if (commandId == SINGLE_METHOD_ID)
{
singleModification = (ReplicableCommand) args[0];
- } else
+ }
+ else
{
modifications = (List<ReplicableCommand>) args[0];
}
Added: core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -0,0 +1,45 @@
+package org.jboss.cache.commands.write;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+/**
+ * Represents the {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn, Object, Object)} method call.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 2.2.0
+ */
+public class PutForExternalReadCommand extends PutKeyValueCommand
+{
+ public static final int METHOD_ID = 45;
+ public static final int VERSIONED_METHOD_ID = 46;
+
+ public PutForExternalReadCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps)
+ {
+ super(gtx, fqn, key, value, createUndoOps);
+ }
+
+ public PutForExternalReadCommand()
+ {
+ super();
+ }
+
+ @Override
+ public int getCommandId()
+ {
+ if (isVersioned())
+ {
+ return VERSIONED_METHOD_ID;
+ }
+ else
+ {
+ return METHOD_ID;
+ }
+ }
+
+ @Override
+ protected boolean isVersionedId(int commandId)
+ {
+ return commandId == VERSIONED_METHOD_ID;
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -15,8 +15,7 @@
import java.util.Map;
/**
- * Implements functionality defined by {@link org.jboss.cache.Cache#put(org.jboss.cache.Fqn, Object, Object)}. Also implements
- * {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn, Object, Object)} if {@link #isPutForExternalRead()} is true.
+ * Implements functionality defined by {@link org.jboss.cache.Cache#put(org.jboss.cache.Fqn, Object, Object)}.
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
@@ -25,27 +24,23 @@
{
public static final int METHOD_ID = 3;
public static final int VERSIONED_METHOD_ID = 39;
- public static final int PUT_FOR_EXT_READ_METHOD_ID = 45;
- public static final int PUT_FOR_EXT_READ_VERSIONED_METHOD_ID = 46;
private static final Log log = LogFactory.getLog(PutKeyValueCommand.class);
private static boolean trace = log.isTraceEnabled();
/* parametres */
- private Object key;
- private Object value;
- private boolean createUndoOps;
- private boolean putForExternalRead;
- private Object oldValue;
+ protected Object key;
+ protected Object value;
+ protected boolean createUndoOps;
+ protected Object oldValue;
- public PutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps, boolean putForExternalRead)
+ public PutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps)
{
this.globalTransaction = gtx;
this.fqn = fqn;
this.key = key;
this.value = value;
this.createUndoOps = createUndoOps;
- this.putForExternalRead = putForExternalRead;
}
public PutKeyValueCommand()
@@ -99,11 +94,6 @@
return visitor.visitPutKeyValueCommand(ctx, this);
}
- public boolean isPutForExternalRead()
- {
- return putForExternalRead;
- }
-
public Object getKey()
{
return key;
@@ -133,11 +123,11 @@
{
if (isVersioned())
{
- return putForExternalRead ? PUT_FOR_EXT_READ_VERSIONED_METHOD_ID : VERSIONED_METHOD_ID;
+ return VERSIONED_METHOD_ID;
}
else
{
- return putForExternalRead ? PUT_FOR_EXT_READ_METHOD_ID : METHOD_ID;
+ return METHOD_ID;
}
}
@@ -158,7 +148,6 @@
key = args[2];
value = args[3];
createUndoOps = (Boolean) args[4];
- putForExternalRead = (commandId == PUT_FOR_EXT_READ_METHOD_ID || commandId == PUT_FOR_EXT_READ_VERSIONED_METHOD_ID);
if (isVersionedId(commandId)) dataVersion = (DataVersion) args[5];
}
@@ -172,7 +161,6 @@
PutKeyValueCommand that = (PutKeyValueCommand) o;
if (createUndoOps != that.createUndoOps) return false;
- if (putForExternalRead != that.putForExternalRead) return false;
if (globalTransaction != null ? !globalTransaction.equals(that.globalTransaction) : that.globalTransaction != null)
return false;
if (key != null ? !key.equals(that.key) : that.key != null) return false;
@@ -189,27 +177,25 @@
result = 31 * result + (key != null ? key.hashCode() : 0);
result = 31 * result + (value != null ? value.hashCode() : 0);
result = 31 * result + (createUndoOps ? 1 : 0);
- result = 31 * result + (putForExternalRead ? 1 : 0);
return result;
}
@Override
protected boolean isVersionedId(int commandId)
{
- return commandId == PUT_FOR_EXT_READ_VERSIONED_METHOD_ID || commandId == VERSIONED_METHOD_ID;
+ return commandId == VERSIONED_METHOD_ID;
}
@Override
public String toString()
{
- return "PutKeyValueCommand{" +
+ return getClass().getSimpleName() + "{" +
"fqn=" + fqn +
", dataVersion=" + dataVersion +
", globalTransaction=" + globalTransaction +
", key=" + key +
", value=" + value +
", createUndoOps=" + createUndoOps +
- ", isPutForExternalRead=" + putForExternalRead +
", oldValue=" + oldValue +
'}';
}
Modified: core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java 2008-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -27,15 +27,7 @@
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.write.CreateNodeCommand;
-import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.commands.write.InvalidateCommand;
-import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.RemoveDataCommand;
-import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.commands.write.RemoveNodeCommand;
+import org.jboss.cache.commands.write.*;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.NonVolatile;
@@ -102,13 +94,20 @@
return cmd;
}
- public PutKeyValueCommand buildPutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps, boolean putForExternalRead)
+ public PutKeyValueCommand buildPutKeyValueCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps)
{
- PutKeyValueCommand command = new PutKeyValueCommand(gtx, fqn, key, value, createUndoOps, putForExternalRead);
+ PutKeyValueCommand command = new PutKeyValueCommand(gtx, fqn, key, value, createUndoOps);
command.initialize(notifier, dataContainer);
return command;
}
+ public PutForExternalReadCommand buildPutForExternalReadCommand(GlobalTransaction gtx, Fqn fqn, Object key, Object value, boolean createUndoOps)
+ {
+ PutForExternalReadCommand command = new PutForExternalReadCommand(gtx, fqn, key, value, createUndoOps);
+ command.initialize(notifier, dataContainer);
+ return command;
+ }
+
public ReplicateCommand buildReplicateCommand(ReplicableCommand command)
{
ReplicateCommand cmd = new ReplicateCommand(command);
@@ -362,14 +361,20 @@
}
case PutKeyValueCommand.METHOD_ID:
case PutKeyValueCommand.VERSIONED_METHOD_ID:
- case PutKeyValueCommand.PUT_FOR_EXT_READ_METHOD_ID:
- case PutKeyValueCommand.PUT_FOR_EXT_READ_VERSIONED_METHOD_ID:
{
PutKeyValueCommand returnValue = new PutKeyValueCommand();
returnValue.initialize(notifier, dataContainer);
command = returnValue;
break;
}
+ case PutForExternalReadCommand.METHOD_ID:
+ case PutForExternalReadCommand.VERSIONED_METHOD_ID:
+ {
+ PutForExternalReadCommand returnValue = new PutForExternalReadCommand();
+ returnValue.initialize(notifier, dataContainer);
+ command = returnValue;
+ break;
+ }
case RemoveDataCommand.METHOD_ID:
case RemoveDataCommand.VERSIONED_METHOD_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-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -18,6 +18,7 @@
import org.jboss.cache.commands.write.InvalidateCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveDataCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
@@ -84,14 +85,16 @@
}
@Override
+ public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+ {
+ // these are always local more, as far as invalidation is concerned
+ if (ctx.getTransaction() != null) ctx.getTransactionEntry().addLocalModification(command);
+ return invokeNextInterceptor(ctx, command);
+ }
+
+ @Override
public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
- if (command.isPutForExternalRead())
- {
- // these are always local more, as far as invalidation is concerned
- if (ctx.getTransaction() != null) ctx.getTransactionEntry().addLocalModification(command);
- return invokeNextInterceptor(ctx, command);
- }
return handleWriteMethod(ctx, command.getFqn(), null, command);
}
@@ -291,43 +294,48 @@
@Override
public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
- if (command.isPutForExternalRead())
- {
- containsPutForExternalRead = true;
- return null;
- }
result.add(command.getFqn());
return null;
}
@Override
+ public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+ {
+ containsPutForExternalRead = true;
+ return null;
+ }
+
+ @Override
public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
- return addFqn(command.getFqn());
+ result.add(command.getFqn());
+ return null;
}
@Override
public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
- return addFqn(command.getFqn());
+ result.add(command.getFqn());
+ return null;
}
@Override
public Object visitRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
- return addFqn(command.getFqn());
+ result.add(command.getFqn());
+ return null;
}
@Override
public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
{
- return addFqn(command.getFqn());
+ result.add(command.getFqn());
+ return null;
}
@Override
public Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
{
- if (containsPutForExternalRead) return null;
result.add(command.getFqn());
// now if this is a "move" operation, then we also have another Fqn -
Object le = command.getFqn().getLastElement();
@@ -335,12 +343,6 @@
result.add(Fqn.fromRelativeElements(parent, le));
return null;
}
-
- private Object addFqn(Fqn fqn)
- {
- result.add(fqn);
- return null;
- }
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -22,6 +22,7 @@
import org.jboss.cache.commands.write.EvictCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveDataCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
@@ -145,11 +146,10 @@
}
@Override
- public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
{
- if (command.isPutForExternalRead()) ctx.getTransactionEntry().setForceAsyncReplication(true);
- if (isLocalModeForced(ctx)) ctx.getTransactionEntry().addLocalModification(command);
- return invokeNextInterceptor(ctx, command);
+ ctx.getTransactionEntry().setForceAsyncReplication(true);
+ return handleDefault(ctx, command);
}
public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
@@ -178,16 +178,13 @@
{
// Map method calls to data versioned equivalents.
// See JBCACHE-843 and docs/design/DataVersioning.txt
- //TODO: 2.2.0: make the visitor a field
- DataVersionPopulator populator = new DataVersionPopulator(getTransactionWorkspace(ctx));
- List<ReversibleCommand> clonedModifications = new ArrayList<ReversibleCommand>(command.getModifications().size());
- for (ReversibleCommand command1 : command.getModifications())
- {
- ReversibleCommand clone = (ReversibleCommand) command1.acceptVisitor(null, populator);
- clonedModifications.add(clone);
- }
- ReplicableCommand toBroadcast = commandsFactory.buildOptimisticPrepareCommand(gtx, clonedModifications, command.getData(), command.getLocalAddress(), command.isOnePhaseCommit());
+ DataVersionPopulator populator = new DataVersionPopulator(getTransactionWorkspace(ctx), command.getModifications().size());
+ // visit all elements in the collection and apply the DataVersionPopulator to ensure all commands have data versions set.
+ populator.visitCollection(null, command.getModifications());
+
+ ReplicableCommand toBroadcast = commandsFactory.buildOptimisticPrepareCommand(gtx, populator.versionedCommands, command.getData(), command.getLocalAddress(), command.isOnePhaseCommit());
+
//record the things we have possibly sent
broadcastTxs.add(gtx);
if (log.isDebugEnabled())
@@ -260,12 +257,21 @@
public class DataVersionPopulator extends AbstractVisitor
{
final TransactionWorkspace workspace;
+ final List<ReversibleCommand> versionedCommands;
- public DataVersionPopulator(TransactionWorkspace workspace)
+ public DataVersionPopulator(TransactionWorkspace workspace, int numCommands)
{
this.workspace = workspace;
+ versionedCommands = new ArrayList<ReversibleCommand>(numCommands);
}
+ private void setDataVersion(VersionedDataCommand clone, Fqn fqn)
+ {
+ DataVersion versionToBroadcast = getVersionToBroadcast(workspace, fqn);
+ clone.setDataVersion(versionToBroadcast);
+ versionedCommands.add(clone);
+ }
+
@Override
public Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
{
@@ -275,63 +281,72 @@
@Override
public Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
{
- EvictCommand clone = commandsFactory.buildEvictFqnCommand(command.getFqn());
- return setDataVersion(clone, command.getFqn());
+ VersionedDataCommand clone = commandsFactory.buildEvictFqnCommand(command.getFqn());
+ setDataVersion(clone, command.getFqn());
+ return null;
}
- private Object setDataVersion(VersionedDataCommand clone, Fqn fqn)
+ @Override
+ public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
- DataVersion versionToBroadcast = getVersionToBroadcast(workspace, fqn);
- clone.setDataVersion(versionToBroadcast);
- return clone;
+ VersionedDataCommand clone = commandsFactory.buildPutDataMapCommand(null, command.getFqn(), command.getData(), command.isCreateUndoOps(), command.isEraseContents());
+ setDataVersion(clone, command.getFqn());
+ return null;
}
@Override
- public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+ public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
- PutDataMapCommand clone = commandsFactory.buildPutDataMapCommand(null, command.getFqn(), command.getData(), command.isCreateUndoOps(), command.isEraseContents());
- return setDataVersion(clone, clone.getFqn());
+ VersionedDataCommand clone = commandsFactory.buildPutKeyValueCommand(null, command.getFqn(), command.getKey(), command.getValue(), command.isCreateUndoOps());
+ setDataVersion(clone, command.getFqn());
+ return null;
}
@Override
- public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
{
- PutKeyValueCommand clone = commandsFactory.buildPutKeyValueCommand(null, command.getFqn(), command.getKey(), command.getValue(), command.isCreateUndoOps(), command.isPutForExternalRead());
- return setDataVersion(clone, command.getFqn());
+ VersionedDataCommand clone = commandsFactory.buildPutForExternalReadCommand(null, command.getFqn(), command.getKey(), command.getValue(), command.isCreateUndoOps());
+ setDataVersion(clone, command.getFqn());
+ return null;
}
@Override
public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
- RemoveNodeCommand clone = commandsFactory.buildRemoveNodeCommand(command.getGlobalTransaction(), command.getFqn(), command.isEviction(),
+ VersionedDataCommand clone = commandsFactory.buildRemoveNodeCommand(command.getGlobalTransaction(), command.getFqn(), command.isEviction(),
command.isSkipSendingNodeEvents(), command.isCreateUndoOps());
- return setDataVersion(clone, command.getFqn());
+ setDataVersion(clone, command.getFqn());
+ return null;
}
@Override
public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
{
- RemoveKeyCommand clone = commandsFactory.buildRemoveKeyCommand(null, command.getFqn(), command.getKey(), command.isCreateUndoOps());
- return setDataVersion(clone, command.getFqn());
+ VersionedDataCommand clone = commandsFactory.buildRemoveKeyCommand(null, command.getFqn(), command.getKey(), command.isCreateUndoOps());
+ setDataVersion(clone, command.getFqn());
+ return null;
}
@Override
public Object visitRemoveDataCommand(InvocationContext ctx, RemoveDataCommand command) throws Throwable
{
- RemoveDataCommand clone = commandsFactory.buildRemoveDataCommand(command.getGlobalTransaction(), command.getFqn(), command.isCreateUndoops(),
+ VersionedDataCommand clone = commandsFactory.buildRemoveDataCommand(command.getGlobalTransaction(), command.getFqn(), command.isCreateUndoops(),
command.isSendNodeEvent(), command.isEviction());
- return setDataVersion(clone, command.getFqn());
+ setDataVersion(clone, command.getFqn());
+ return null;
}
@Override
public Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
{
+ versionedCommands.add(command);
return command;
}
@Override
public Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
{
+ versionedCommands.add(command);
return command;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -22,6 +22,7 @@
import org.jboss.cache.commands.write.EvictCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveDataCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
@@ -86,9 +87,15 @@
@Override
public Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
- return handlePutCommand(ctx, command, command.isPutForExternalRead());
+ return handlePutCommand(ctx, command, false);
}
+ @Override
+ public Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+ {
+ return handlePutCommand(ctx, command, true);
+ }
+
private Object handlePutCommand(InvocationContext ctx, DataCommand command, boolean zeroAcquisitionTimeout)
throws Throwable
{
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -8,6 +8,7 @@
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveDataCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
@@ -62,17 +63,14 @@
}
@Override
- public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
{
boolean local = isLocalModeForced(ctx);
if (local && ctx.getTransaction() == null) return invokeNextInterceptor(ctx, command);
if (isTransactionalAndLocal(ctx))
{
Object returnValue = invokeNextInterceptor(ctx, command);
- if (command.isPutForExternalRead())
- {
- ctx.getTransactionEntry().setForceAsyncReplication(true);
- }
+ ctx.getTransactionEntry().setForceAsyncReplication(true);
if (local) ctx.getTransactionEntry().addLocalModification(command);
@@ -80,11 +78,17 @@
}
else
{
- return handleCrudMethod(ctx, command, command.isPutForExternalRead());
+ return handleCrudMethod(ctx, command, true);
}
}
@Override
+ public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ {
+ return handleCrudMethod(ctx, command, false);
+ }
+
+ @Override
public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
{
return handleCrudMethod(ctx, command, false);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java 2008-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/PostProcessingCommandInterceptor.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -17,6 +17,7 @@
import org.jboss.cache.commands.write.InvalidateCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveDataCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
@@ -68,11 +69,31 @@
}
}
+ @Override
+ public final Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+ {
+ try
+ {
+ return handlePutForExternalReadCommand(ctx, command);
+ }
+ finally
+ {
+ doAfterCall(ctx, command);
+ }
+ }
+
+
protected Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
return handleDefault(ctx, command);
}
+ protected Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+ {
+ return handleDefault(ctx, command);
+ }
+
+
@Override
public final Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
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-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -17,6 +17,7 @@
import org.jboss.cache.commands.write.InvalidateCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveDataCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
@@ -63,11 +64,26 @@
return handlePutKeyValueCommand(ctx, command);
}
+ @Override
+ public final Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+ {
+ if (skipInterception(ctx, command))
+ {
+ return invokeNextInterceptor(ctx, command);
+ }
+ return handlePutForExternalReadCommand(ctx, command);
+ }
+
protected Object handlePutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
{
return handleAll(ctx, command);
}
+ protected Object handlePutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+ {
+ return handleAll(ctx, command);
+ }
+
@Override
public final Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
{
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -12,6 +12,7 @@
import org.jboss.cache.commands.write.EvictCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
@@ -449,7 +450,7 @@
{
getInvocationContext().getOptionOverrides().setFailSilently(true);
getInvocationContext().getOptionOverrides().setForceAsynchronous(true);
- PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, fqn, key, value, false, true);
+ PutForExternalReadCommand command = commandsFactory.buildPutForExternalReadCommand(null, fqn, key, value, false);
invoker.invoke(ctx, command);
}
else
@@ -464,7 +465,7 @@
InvocationContext ctx = invocationContextContainer.get();
cacheStatusCheck(ctx);
GlobalTransaction tx = transactionTable.getCurrentTransaction();
- PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(tx, fqn, key, value, false, false);
+ PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(tx, fqn, key, value, false);
return (V) invoker.invoke(ctx, command);
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -139,7 +139,7 @@
{
Fqn fqn1 = Fqn.fromString("/hello/world");
- PutKeyValueCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value", false, false);
+ PutKeyValueCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value", false);
ReplicateCommand call2 = new ReplicateCommand(call1);
BuddyManager bm = createBasicBuddyManager();
@@ -157,7 +157,7 @@
{
Fqn fqn1 = Fqn.ROOT;
- ReplicableCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value", false, false);
+ ReplicableCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value", false);
ReplicateCommand call2 = new ReplicateCommand(call1);
BuddyManager bm = createBasicBuddyManager();
@@ -177,10 +177,10 @@
Fqn fqn3 = Fqn.fromString("/hello/again");
Fqn fqn4 = Fqn.fromString("/buddy/replication");
- PutKeyValueCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value", false, false);
- PutKeyValueCommand call2 = new PutKeyValueCommand(null, fqn2, "key", "value", false, false);
- PutKeyValueCommand call3 = new PutKeyValueCommand(null, fqn3, "key", "value", false, false);
- PutKeyValueCommand call4 = new PutKeyValueCommand(null, fqn4, "key", "value", false, false);
+ PutKeyValueCommand call1 = new PutKeyValueCommand(null, fqn1, "key", "value", false);
+ PutKeyValueCommand call2 = new PutKeyValueCommand(null, fqn2, "key", "value", false);
+ PutKeyValueCommand call3 = new PutKeyValueCommand(null, fqn3, "key", "value", false);
+ PutKeyValueCommand call4 = new PutKeyValueCommand(null, fqn4, "key", "value", false);
List<ReplicableCommand> list = new ArrayList<ReplicableCommand>();
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-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/test/java/org/jboss/cache/interceptors/EvictionInterceptorTest.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -324,7 +324,7 @@
for (int i = 0; i < 100; i++)
{
- PutKeyValueCommand pkvCommand = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, i, "value", false, false);
+ PutKeyValueCommand pkvCommand = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, i, "value", false);
invoker.invoke(pkvCommand);
assertEquals("value", cache.peek(fqn, false, false).getDirect(i));
@@ -389,7 +389,7 @@
Object key = "key";
Object value = "value";
- PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value, false, false);
+ PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value, false);
invoker.invoke(command);
assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
EvictedEventNode event = region.takeLastEventNode();
@@ -399,7 +399,7 @@
assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
assertNull(region.takeLastEventNode());
- command = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value, false, false);
+ command = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value, false);
invoker.invoke(command);
assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
event = region.takeLastEventNode();
@@ -510,7 +510,7 @@
Object key = "key";
Object value = "value";
- PutKeyValueCommand putKeyValueCommand = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value, false, false);
+ PutKeyValueCommand putKeyValueCommand = commandsFactory.buildPutKeyValueCommand(null, (Fqn<?>) fqn, key, value, false);
invoker.invoke(putKeyValueCommand);
assertEquals("value", cache.peek(fqn, false, false).getDirect(key));
event = region.takeLastEventNode();
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/ActiveInactiveTest.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -152,7 +152,7 @@
public void testObjectFromByteBuffer() throws Exception
{
- PutKeyValueCommand put = new PutKeyValueCommand(null, A_B, "name", "Joe", false, false);
+ PutKeyValueCommand put = new PutKeyValueCommand(null, A_B, "name", "Joe", false);
ReplicateCommand replicate = new ReplicateCommand(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-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller210Test.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -29,7 +29,7 @@
Map map = createMap(size);
Fqn fqn = Fqn.fromString("/my/stuff");
String key = "key";
- PutKeyValueCommand putCommand = new PutKeyValueCommand(null, fqn, key, map, false, false);
+ PutKeyValueCommand putCommand = new PutKeyValueCommand(null, fqn, key, map, false);
ReplicateCommand replicateCommand = new ReplicateCommand(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-05-17 10:52:37 UTC (rev 5869)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshallerTestBase.java 2008-05-19 11:26:40 UTC (rev 5870)
@@ -112,7 +112,7 @@
public void testMethodCall() throws Exception
{
Fqn fqn = Fqn.fromElements(3, false);
- ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value", false, false);
+ ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value", false);
byte[] asBytes = marshaller.objectToByteBuffer(cmd);
Object o2 = marshaller.objectFromByteBuffer(asBytes);
@@ -125,7 +125,7 @@
public void testNestedMethodCall() throws Exception
{
Fqn fqn = Fqn.fromElements(3, false);
- ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value", false, false);
+ ReplicableCommand cmd = new PutKeyValueCommand(null, fqn, "key", "value", false);
ReplicableCommand replicateCmd = new ReplicateCommand(cmd);
byte[] asBytes = marshaller.objectToByteBuffer(replicateCmd);
Object o2 = marshaller.objectFromByteBuffer(asBytes);
@@ -215,12 +215,12 @@
Fqn f = Fqn.fromElements("BlahBlah", 3, false);
String k = "key", v = "value";
- ReplicableCommand cmd = new PutKeyValueCommand(null, f, k, v, true, false);
+ ReplicableCommand cmd = new PutKeyValueCommand(null, f, k, v, true);
ReplicableCommand replCmd = new ReplicateCommand(cmd);
calls.add(replCmd);
- cmd = new PutKeyValueCommand(null, f, k, v, true, false);
+ cmd = new PutKeyValueCommand(null, f, k, v, true);
replCmd = new ReplicateCommand(cmd);
calls.add(replCmd);
16 years, 7 months
JBoss Cache SVN: r5869 - in core/trunk/src: test/java/org/jboss/cache/loader and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-17 06:52:37 -0400 (Sat, 17 May 2008)
New Revision: 5869
Modified:
core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java
Log:
Fixed broken test
Modified: core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-05-16 14:46:15 UTC (rev 5868)
+++ core/trunk/src/main/java/org/jboss/cache/loader/CacheLoaderManager.java 2008-05-17 10:52:37 UTC (rev 5869)
@@ -16,6 +16,7 @@
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
@@ -161,12 +162,9 @@
{
throw new Exception("Invalid cache loader configuration!! Only ONE cache loader may have fetchPersistentState set to true. Cache will not start!");
}
- SingletonStoreConfig ssc = cfg.getSingletonStoreConfig();
- if (ssc != null && ssc.isSingletonStoreEnabled() && config.isShared())
- {
- throw new Exception("Invalid cache loader configuration!! If a cache loader is configured as a singleton, the cache loader cannot be shared in a cluster!");
- }
+ assertNotSingletonAndShared(cfg);
+
CacheLoader l = createCacheLoader(cfg, cache);
cfg = l.getConfig();
finalConfigs.add(cfg);
@@ -182,6 +180,7 @@
tmpLoader = createCacheLoader(cfg, cache);
finalConfigs.add(tmpLoader.getConfig() == null ? cfg : tmpLoader.getConfig());
fetchPersistentState = cfg.isFetchPersistentState();
+ assertNotSingletonAndShared(cfg);
}
// Update the config with those actually used by the loaders
@@ -191,6 +190,13 @@
return tmpLoader;
}
+ private void assertNotSingletonAndShared(IndividualCacheLoaderConfig cfg)
+ {
+ SingletonStoreConfig ssc = cfg.getSingletonStoreConfig();
+ if (ssc != null && ssc.isSingletonStoreEnabled() && config.isShared())
+ throw new ConfigurationException("Invalid cache loader configuration!! If a cache loader is configured as a singleton, the cache loader cannot be shared in a cluster!");
+ }
+
/**
* Creates the cache loader based on the configuration.
*
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java 2008-05-16 14:46:15 UTC (rev 5868)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderManagerTest.java 2008-05-17 10:52:37 UTC (rev 5869)
@@ -11,6 +11,7 @@
import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.xml.XmlHelper;
import static org.testng.AssertJUnit.*;
+import org.testng.annotations.Test;
import org.w3c.dom.Element;
import java.util.List;
@@ -22,6 +23,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
*/
+@Test(groups = "functional")
public class CacheLoaderManagerTest extends AbstractCacheLoaderTestBase
{
private CacheLoaderConfig createCacheLoaderCfg(boolean passivation)
16 years, 7 months
JBoss Cache SVN: r5868 - core/trunk/src/test/java/org/jboss/cache/commands/read.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-16 10:46:15 -0400 (Fri, 16 May 2008)
New Revision: 5868
Modified:
core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataCommandTest.java
Log:
Need to annotate abstract superclasses so that @BeforeMethod methods will be called. This is only a bug when executing from Maven.
Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataCommandTest.java 2008-05-16 14:42:33 UTC (rev 5867)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataCommandTest.java 2008-05-16 14:46:15 UTC (rev 5868)
@@ -1,10 +1,10 @@
package org.jboss.cache.commands.read;
+import static org.easymock.EasyMock.createMock;
+import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
-import org.jboss.cache.DataContainer;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import static org.easymock.EasyMock.createMock;
/**
* Class that has convinience fixture for all tests that operated on {@link AbstractDataCommand}
@@ -12,6 +12,7 @@
* @author Mircea.Markus(a)jboss.com
* @since 2.2
*/
+@Test(groups = "unit")
public abstract class AbstractDataCommandTest
{
protected Fqn testFqn = Fqn.fromString("/testfqn");
16 years, 7 months
JBoss Cache SVN: r5867 - core/trunk/src/main/java/org/jboss/cache/factories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-16 10:42:33 -0400 (Fri, 16 May 2008)
New Revision: 5867
Modified:
core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
Log:
Proper setting of FAILED status
Modified: core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-05-16 13:29:52 UTC (rev 5866)
+++ core/trunk/src/main/java/org/jboss/cache/factories/ComponentRegistry.java 2008-05-16 14:42:33 UTC (rev 5867)
@@ -613,6 +613,7 @@
{
log.warn("Attempted to stop() from FAILED state, but caught exception; try calling destroy()", t);
}
+ failed = true;
handleLifecycleTransitionFailure(t);
}
finally
16 years, 7 months
JBoss Cache SVN: r5866 - core/trunk/src/test/java/org/jboss/cache/statetransfer.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-16 09:29:52 -0400 (Fri, 16 May 2008)
New Revision: 5866
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
Log:
Fixed broken test
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2008-05-16 13:11:23 UTC (rev 5865)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/FailedStateTransferTest.java 2008-05-16 13:29:52 UTC (rev 5866)
@@ -29,6 +29,7 @@
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.misc.TestingUtil;
import org.jboss.cache.remoting.jgroups.ChannelMessageListener;
@@ -80,9 +81,7 @@
// inject our own message listener and re-wire deps
cr = TestingUtil.extractComponentRegistry(recipient);
- //cr.unregisterComponent(ChannelMessageListener.class);
cr.registerComponent(new SecretiveStateCacheMessageListener(), ChannelMessageListener.class);
- //cr.updateDependencies();
try
{
@@ -100,6 +99,7 @@
return Version.version;
}
+ @NonVolatile
private static class SecretiveStateCacheMessageListener extends ChannelMessageListener
{
@Override
16 years, 7 months
JBoss Cache SVN: r5865 - in core/branches/2.1.X/src: test/java/org/jboss/cache/invocationcontext and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-16 09:11:23 -0400 (Fri, 16 May 2008)
New Revision: 5865
Modified:
core/branches/2.1.X/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
core/branches/2.1.X/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
Log:
JBCACHE-1348: Use of replication queue and transactions may cause modifications not to be applied on remote nodes
Modified: core/branches/2.1.X/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
===================================================================
--- core/branches/2.1.X/src/main/java/org/jboss/cache/transaction/TransactionEntry.java 2008-05-16 11:33:45 UTC (rev 5864)
+++ core/branches/2.1.X/src/main/java/org/jboss/cache/transaction/TransactionEntry.java 2008-05-16 13:11:23 UTC (rev 5865)
@@ -132,6 +132,7 @@
public List<MethodCall> getCacheLoaderModifications()
{
// make sure this isn't modified externally
+ if (cl_mod_list == null) return null;
return Collections.unmodifiableList(cl_mod_list);
}
Modified: core/branches/2.1.X/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
===================================================================
--- core/branches/2.1.X/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java 2008-05-16 11:33:45 UTC (rev 5864)
+++ core/branches/2.1.X/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java 2008-05-16 13:11:23 UTC (rev 5865)
@@ -137,8 +137,8 @@
assertEquals("MethodCall should have been scrubbed", null, cache.getInvocationContext().getMethodCall());
// check that the transaction entry hasn't leaked stuff.
- assert entry.getModifications().isEmpty() : "Should have scrubbed modifications in transaction entry";
- assert entry.getCacheLoaderModifications().isEmpty() : "Should have scrubbed modifications in transaction entry";
+ assert entry.getModifications() == null : "Should have scrubbed modifications in transaction entry";
+ assert entry.getCacheLoaderModifications() == null : "Should have scrubbed modifications in transaction entry";
assert entry.getOrderedSynchronizationHandler() == null : "Should have removed the ordered sync handler";
}
Modified: core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
--- core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-05-16 11:33:45 UTC (rev 5864)
+++ core/branches/2.1.X/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-05-16 13:11:23 UTC (rev 5865)
@@ -290,6 +290,7 @@
protected List<MethodCall> injectDataVersion(List<MethodCall> modifications)
{
List<MethodCall> newList = new LinkedList<MethodCall>();
+ if (modifications == null) return newList;
for (MethodCall c : modifications)
{
Object[] oa = c.getArgs();
16 years, 7 months
JBoss Cache SVN: r5864 - core/trunk/src/main/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2008-05-16 07:33:45 -0400 (Fri, 16 May 2008)
New Revision: 5864
Modified:
core/trunk/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java
Log:
[JBCACHE-1346] Cache listener now added in the create step rather than in the configuration phase.
Modified: core/trunk/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java 2008-05-16 07:36:32 UTC (rev 5863)
+++ core/trunk/src/main/java/org/jboss/cache/loader/SingletonStoreCacheLoader.java 2008-05-16 11:33:45 UTC (rev 5864)
@@ -140,9 +140,15 @@
public void setCache(CacheSPI c)
{
super.setCache(c);
-
- c.addCacheListener(new SingletonStoreListener());
}
+
+ @Override
+ public void create() throws Exception
+ {
+ super.create();
+
+ cache.addCacheListener(new SingletonStoreListener());
+ }
/**
* Protected constructor which should only be used from unit tests. Production code should set
16 years, 7 months
JBoss Cache SVN: r5863 - core/trunk/src/main/java/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: galder.zamarreno(a)jboss.com
Date: 2008-05-16 03:36:32 -0400 (Fri, 16 May 2008)
New Revision: 5863
Modified:
core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
Log:
[JBCACHE-1342] Default values now work for both setProperties() and individual property setting paths.
Modified: core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java 2008-05-15 23:03:49 UTC (rev 5862)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AdjListJDBCCacheLoaderConfig.java 2008-05-16 07:36:32 UTC (rev 5863)
@@ -18,13 +18,23 @@
* The serialVersionUID
*/
private static final long serialVersionUID = -8371846151643130281L;
-
- private boolean createTable;
+
+ private static final boolean CREATE_TABLE_DEFAULT = true;
+ private static final boolean DROP_TABLE_DEFAULT = false;
+ private static final String PARENT_COLUMN_DEFAULT = "parent";
+ private static final String NODE_TYPE_DEFAULT = "blob";
+ private static final String NODE_COLUMN_DEFAULT = "node";
+ private static final String FQN_TYPE_DEFAULT = "varchar(255)";
+ private static final String FQN_COLUMN_DEFAULT = "fqn";
+ private static final String PRIMARY_KEY_DEFAULT = "jbosscache_pk";
+ private static final String TABLE_DEFAULT = "jbosscache";
+
+ private boolean createTable = CREATE_TABLE_DEFAULT;
private String createTableDDL;
private String datasourceName;
private String deleteAllSql;
private String deleteNodeSql;
- private boolean dropTable;
+ private boolean dropTable = DROP_TABLE_DEFAULT;
private String dropTableDDL;
private String driverClass;
private String insertNodeSql;
@@ -37,13 +47,13 @@
private String updateNodeSql;
private String updateTableSql;
private String connectionFactoryClass;
- private String primaryKey;
- private String fqnType;
- private String nodeType;
- private String parentColumn;
- protected String table;
- protected String nodeColumn;
- protected String fqnColumn;
+ private String primaryKey = PRIMARY_KEY_DEFAULT;
+ private String fqnType = FQN_TYPE_DEFAULT;
+ private String nodeType = NODE_TYPE_DEFAULT;
+ private String parentColumn = PARENT_COLUMN_DEFAULT;
+ protected String table = TABLE_DEFAULT;
+ protected String nodeColumn = NODE_COLUMN_DEFAULT;
+ protected String fqnColumn = FQN_COLUMN_DEFAULT;
public AdjListJDBCCacheLoaderConfig()
{
@@ -398,17 +408,17 @@
}
String prop = props.getProperty("cache.jdbc.table.create");
- this.createTable = (prop == null || Boolean.valueOf(prop));
+ this.createTable = prop == null ? CREATE_TABLE_DEFAULT : Boolean.valueOf(prop);
prop = props.getProperty("cache.jdbc.table.drop");
- this.dropTable = prop == null ? false : Boolean.valueOf(prop);
+ this.dropTable = prop == null ? DROP_TABLE_DEFAULT : Boolean.valueOf(prop);
- this.table = props.getProperty("cache.jdbc.table.name", "jbosscache");
- primaryKey = props.getProperty("cache.jdbc.table.primarykey", "jbosscache_pk");
- fqnColumn = props.getProperty("cache.jdbc.fqn.column", "fqn");
- fqnType = props.getProperty("cache.jdbc.fqn.type", "varchar(255)");
- nodeColumn = props.getProperty("cache.jdbc.node.column", "node");
- nodeType = props.getProperty("cache.jdbc.node.type", "blob");
- parentColumn = props.getProperty("cache.jdbc.parent.column", "parent");
+ this.table = props.getProperty("cache.jdbc.table.name", TABLE_DEFAULT);
+ primaryKey = props.getProperty("cache.jdbc.table.primarykey", PRIMARY_KEY_DEFAULT);
+ fqnColumn = props.getProperty("cache.jdbc.fqn.column", FQN_COLUMN_DEFAULT);
+ fqnType = props.getProperty("cache.jdbc.fqn.type", FQN_TYPE_DEFAULT);
+ nodeColumn = props.getProperty("cache.jdbc.node.column", NODE_COLUMN_DEFAULT);
+ nodeType = props.getProperty("cache.jdbc.node.type", NODE_TYPE_DEFAULT);
+ parentColumn = props.getProperty("cache.jdbc.parent.column", PARENT_COLUMN_DEFAULT);
selectChildNamesSql = constructSelectChildNamesSql();
deleteNodeSql = constructDeleteNodeSql();
16 years, 7 months
JBoss Cache SVN: r5862 - core/trunk.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-15 19:03:49 -0400 (Thu, 15 May 2008)
New Revision: 5862
Modified:
core/trunk/pom.xml
Log:
Updated to 1.1.0.GA of jdocbookstyle
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-05-15 23:01:14 UTC (rev 5861)
+++ core/trunk/pom.xml 2008-05-15 23:03:49 UTC (rev 5862)
@@ -220,12 +220,12 @@
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jbossorg-docbook-xslt</artifactId>
- <version>1.1.0.GA</version>
+ <version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jbossorg-jdocbook-style</artifactId>
- <version>1.1.0.GA</version>
+ <version>1.1.0</version>
<type>jdocbook-style</type>
</dependency>
</dependencies>
16 years, 7 months
JBoss Cache SVN: r5861 - core/trunk.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-05-15 19:01:14 -0400 (Thu, 15 May 2008)
New Revision: 5861
Modified:
core/trunk/pom.xml
Log:
Updated to 1.1.0.GA of jdocbookstyle
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-05-15 22:54:22 UTC (rev 5860)
+++ core/trunk/pom.xml 2008-05-15 23:01:14 UTC (rev 5861)
@@ -220,12 +220,12 @@
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jbossorg-docbook-xslt</artifactId>
- <version>1.1.0.Beta1</version>
+ <version>1.1.0.GA</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jbossorg-jdocbook-style</artifactId>
- <version>1.1.0.Beta1</version>
+ <version>1.1.0.GA</version>
<type>jdocbook-style</type>
</dependency>
</dependencies>
16 years, 7 months