Author: manik.surtani(a)jboss.com
Date: 2008-07-31 14:07:54 -0400 (Thu, 31 Jul 2008)
New Revision: 6475
Added:
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/CreateNodeCommand.java
Removed:
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessCreateNodeCommand.java
Modified:
core/trunk/src/main/java/org/jboss/cache/AbstractNode.java
core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java
core/trunk/src/main/java/org/jboss/cache/InternalNode.java
core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java
core/trunk/src/main/java/org/jboss/cache/commands/PessimisticCommandsFactoryImpl.java
core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java
core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java
core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/CreateNodeCommandTest.java
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
Log:
Removed CreateNodeCommand frm MVCC codepaths
Modified: core/trunk/src/main/java/org/jboss/cache/AbstractNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/AbstractNode.java 2008-07-31 16:50:36 UTC
(rev 6474)
+++ core/trunk/src/main/java/org/jboss/cache/AbstractNode.java 2008-07-31 18:07:54 UTC
(rev 6475)
@@ -5,7 +5,6 @@
import static org.jboss.cache.AbstractNode.NodeFlags.REMOVED;
import static org.jboss.cache.AbstractNode.NodeFlags.RESIDENT;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.IdentityLock;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -228,31 +227,11 @@
throw new UnsupportedOperationException("Not supported in " +
getClass().getSimpleName());
}
- public InternalNode<K, V> addChild(Fqn f)
- {
- throw new UnsupportedOperationException("Not supported in " +
getClass().getSimpleName());
- }
-
- public InternalNode<K, V> addChild(Fqn f, boolean notify)
- {
- throw new UnsupportedOperationException("Not supported in " +
getClass().getSimpleName());
- }
-
- public InternalNode<K, V> addChild(Object o, boolean notify)
- {
- throw new UnsupportedOperationException("Not supported in " +
getClass().getSimpleName());
- }
-
public void setChildrenMap(ConcurrentMap<Object, InternalNode<K, V>>
children)
{
throw new UnsupportedOperationException("Not supported in " +
getClass().getSimpleName());
}
- public InternalNode<K, V> getOrCreateChild(Object childName, InvocationContext
ctx)
- {
- throw new UnsupportedOperationException("Not supported in " +
getClass().getSimpleName());
- }
-
public NodeSPI<K, V> getChildDirect(Fqn fqn)
{
throw new UnsupportedOperationException("Not supported in " +
getClass().getSimpleName());
Modified: core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-07-31 16:50:36
UTC (rev 6474)
+++ core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-07-31 18:07:54
UTC (rev 6475)
@@ -126,7 +126,7 @@
return nid;
}
- public InternalNode<K, V> createAndRegister(Fqn fqn, InternalNode<K, V>
parent, InvocationContext ctx, boolean attachToParent)
+ public InternalNode<K, V> createChildNode(Fqn fqn, InternalNode<K, V>
parent, InvocationContext ctx, boolean attachToParent)
{
throw new UnsupportedOperationException("Unsupported in this implementation
(" + getClass().getSimpleName() + ")!");
}
Modified: core/trunk/src/main/java/org/jboss/cache/InternalNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InternalNode.java 2008-07-31 16:50:36 UTC
(rev 6474)
+++ core/trunk/src/main/java/org/jboss/cache/InternalNode.java 2008-07-31 18:07:54 UTC
(rev 6475)
@@ -1,6 +1,5 @@
package org.jboss.cache;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -118,14 +117,6 @@
void addChild(InternalNode<K, V> child);
- InternalNode<K, V> addChild(Fqn f);
-
- InternalNode<K, V> addChild(Fqn f, boolean notify);
-
- InternalNode<K, V> addChild(Object o, boolean notify);
-
- InternalNode<K, V> getOrCreateChild(Object childName, InvocationContext ctx);
-
// *****************End new methods *****************
Modified: core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-31 16:50:36 UTC (rev
6474)
+++ core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-31 18:07:54 UTC (rev
6475)
@@ -65,7 +65,7 @@
NodeSPI<K, V> createNode(Object childName, NodeSPI<K, V> parent);
/**
- * Creates a new node, registers an undo operation in the context, and optionally
attaches the node to its parent.
+ * Creates a new node, and optionally attaches the node to its parent.
* <p/>
* The assumption here is that any locks are acquired to prevent concurrent creation
of the same node. Implementations
* of the NodeFactory should not attempt to synchronize or guard against concurrent
creation.
@@ -77,7 +77,7 @@
* @param attachToParent if true, the node is registered in the parent's child
map. If false, it is not.
* @return a new node, or the existing node if one existed.
*/
- InternalNode<K, V> createAndRegister(Fqn fqn, InternalNode<K, V> parent,
InvocationContext ctx, boolean attachToParent);
+ InternalNode<K, V> createChildNode(Fqn fqn, InternalNode<K, V> parent,
InvocationContext ctx, boolean attachToParent);
NodeSPI<K, V> createRootNode();
Modified: core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java 2008-07-31
16:50:36 UTC (rev 6474)
+++ core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -1,7 +1,8 @@
package org.jboss.cache;
import static org.jboss.cache.AbstractNode.NodeFlags.VALID;
-import org.jboss.cache.commands.write.CreateNodeCommand;
+import org.jboss.cache.commands.CommandsFactory;
+import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.IdentityLock;
import org.jboss.cache.lock.LockStrategyFactory;
@@ -33,6 +34,9 @@
*/
protected transient IdentityLock lock = null;
protected LockStrategyFactory lockStrategyFactory;
+ CommandsFactory commandsFactory;
+ protected NodeFactory<K, V> nodeFactory;
+ protected CacheSPI<K, V> cache;
public PessimisticUnversionedNode(Object name, Fqn fqn, Map<K, V> data,
CacheSPI<K, V> cache)
{
@@ -67,6 +71,14 @@
this.lockStrategyFactory = lockStrategyFactory;
}
+ public void injectDependencies(CacheSPI<K, V> spi, CommandsFactory
commandsFactory, NodeFactory<K, V> nodeFactory)
+ {
+ this.cache = spi;
+ this.commandsFactory = commandsFactory;
+ this.nodeFactory = nodeFactory;
+ }
+
+
protected synchronized void initLock()
{
if (lock == null)
@@ -108,6 +120,8 @@
copyInternals(n);
n.children = children;
n.lockStrategyFactory = lockStrategyFactory;
+ n.commandsFactory = commandsFactory;
+ n.nodeFactory = nodeFactory;
return n;
}
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-31 16:50:36 UTC
(rev 6474)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-31 18:07:54 UTC
(rev 6475)
@@ -9,9 +9,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.jboss.cache.AbstractNode.NodeFlags.*;
-import org.jboss.cache.commands.CommandsFactory;
-import org.jboss.cache.commands.write.CreateNodeCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.marshall.MarshalledValue;
import org.jboss.cache.util.FastCopyHashMap;
import org.jboss.cache.util.ImmutableSetCopy;
@@ -45,8 +42,6 @@
*/
protected FastCopyHashMap<K, V> data;
protected NodeSPI<K, V> delegate;
- CommandsFactory commandsFactory;
- protected NodeFactory<K, V> nodeFactory;
protected CacheSPI<K, V> cache;
/**
@@ -114,13 +109,6 @@
this.delegate = delegate;
}
- public void injectDependencies(CacheSPI<K, V> spi, CommandsFactory
commandsFactory, NodeFactory<K, V> nodeFactory)
- {
- this.cache = spi;
- this.commandsFactory = commandsFactory;
- this.nodeFactory = nodeFactory;
- }
-
/**
* Returns a parent by checking the TreeMap by name.
*/
@@ -172,12 +160,6 @@
}
@Override
- public InternalNode<K, V> getOrCreateChild(Object childName, InvocationContext
ctx)
- {
- return getOrCreateChild(childName, ctx, true, true);
- }
-
- @Override
public InternalNode<K, V> getChild(Fqn f)
{
if (fqn.size() == 1)
@@ -274,68 +256,6 @@
}
}
- public InternalNode<K, V> addChild(Fqn f)
- {
- return addChild(f, true);
- }
-
- @Override
- public InternalNode<K, V> addChild(Fqn f, boolean notify)
- {
- if (f.size() == 1)
- {
- return getOrCreateChild(f.getLastElement(), cache.getInvocationContext(), true,
notify);
- }
- else
- {
- throw new UnsupportedOperationException("Cannot directly create children
which aren't directly under the current node.");
- }
- }
-
- @Override
- public InternalNode<K, V> addChild(Object o, boolean notify)
- {
- return getOrCreateChild(o, cache.getInvocationContext(), true, notify);
- }
-
- private InternalNode<K, V> getOrCreateChild(Object childName, InvocationContext
ctx, boolean createIfNotExists, boolean notify)
- {
- InternalNode<K, V> child;
- if (childName == null) throw new IllegalArgumentException("null child
name");
-
- child = children().get(childName);
-
- if (createIfNotExists && child == null)
- {
- Fqn childFqn = Fqn.fromRelativeElements(fqn, childName);
- InternalNode<K, V> newChild = nodeFactory.createInternalNode(childFqn);
-
- child = children().putIfAbsent(childName, newChild);
-
- if (child == null)
- {
- // addChild actually succeeded!
- child = newChild;
-
- if (trace) log.trace("created child: fqn=" + childFqn);
-
- if (ctx.getTransactionContext() != null)
- {
- CreateNodeCommand createNodeCommand =
commandsFactory.buildCreateNodeCommand(childFqn);
- ctx.getTransactionContext().addLocalModification(createNodeCommand);
- }
-
- // notify if we actually created a new child
- if (notify)
- {
- cache.getNotifier().notifyNodeCreated(childFqn, true, ctx);
- cache.getNotifier().notifyNodeCreated(childFqn, false, ctx);
- }
- }
- }
- return child;
- }
-
public V remove(K key)
{
if (data == null) return null;
@@ -623,9 +543,7 @@
{
// direct reference to child map
n.children = children;
- n.commandsFactory = commandsFactory;
n.delegate = delegate;
- n.nodeFactory = nodeFactory;
n.flags = flags;
}
Modified:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-07-31
16:50:36 UTC (rev 6474)
+++
core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -4,6 +4,7 @@
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.WriteCommand;
+import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -16,7 +17,6 @@
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
-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;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java 2008-07-31
16:50:36 UTC (rev 6474)
+++ core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -1,5 +1,6 @@
package org.jboss.cache.commands;
+import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -11,7 +12,15 @@
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.*;
+import org.jboss.cache.commands.write.ClearDataCommand;
+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.PutForExternalReadCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.invocation.InvocationContext;
import java.util.Collection;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-07-31
16:50:36 UTC (rev 6474)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactory.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -2,6 +2,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.buddyreplication.BuddyGroup;
+import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -20,7 +21,6 @@
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
-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;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java 2008-07-31
16:50:36 UTC (rev 6474)
+++ core/trunk/src/main/java/org/jboss/cache/commands/CommandsFactoryImpl.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -8,6 +8,7 @@
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -26,7 +27,6 @@
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
-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;
@@ -269,9 +269,7 @@
public CreateNodeCommand buildCreateNodeCommand(Fqn fqn)
{
- CreateNodeCommand command = new CreateNodeCommand(fqn);
- command.initialize(dataContainer);
- return command;
+ throw new UnsupportedOperationException("Not supported in MVCC!");
}
public ReplicableCommand fromStream(int id, Object[] parameters)
@@ -381,10 +379,7 @@
}
case CreateNodeCommand.METHOD_ID:
{
- CreateNodeCommand returnValue = new CreateNodeCommand(null);
- returnValue.initialize(dataContainer);
- command = returnValue;
- break;
+ throw new UnsupportedOperationException("CreateNodeCommand is not
supported in MVCC!");
}
// --- transactional method calls
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/PessimisticCommandsFactoryImpl.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/PessimisticCommandsFactoryImpl.java 2008-07-31
16:50:36 UTC (rev 6474)
+++
core/trunk/src/main/java/org/jboss/cache/commands/PessimisticCommandsFactoryImpl.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -2,8 +2,8 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.commands.legacy.read.PessGetChildrenNamesCommand;
+import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.legacy.write.PessClearDataCommand;
-import org.jboss.cache.commands.legacy.write.PessCreateNodeCommand;
import org.jboss.cache.commands.legacy.write.PessMoveCommand;
import org.jboss.cache.commands.legacy.write.PessPutDataMapCommand;
import org.jboss.cache.commands.legacy.write.PessPutForExternalReadCommand;
@@ -12,7 +12,6 @@
import org.jboss.cache.commands.legacy.write.PessRemoveNodeCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.CreateNodeCommand;
import org.jboss.cache.commands.write.InvalidateCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
@@ -101,7 +100,7 @@
@Override
public CreateNodeCommand buildCreateNodeCommand(Fqn fqn)
{
- CreateNodeCommand command = new PessCreateNodeCommand(fqn);
+ CreateNodeCommand command = new CreateNodeCommand(fqn);
command.initialize(dataContainer);
return command;
}
@@ -188,7 +187,7 @@
}
case CreateNodeCommand.METHOD_ID:
{
- CreateNodeCommand returnValue = new PessCreateNodeCommand(null);
+ CreateNodeCommand returnValue = new CreateNodeCommand(null);
returnValue.initialize(dataContainer);
command = returnValue;
break;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-07-31 16:50:36 UTC
(rev 6474)
+++ core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-07-31 18:07:54 UTC
(rev 6475)
@@ -1,5 +1,6 @@
package org.jboss.cache.commands;
+import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -11,7 +12,15 @@
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.*;
+import org.jboss.cache.commands.write.ClearDataCommand;
+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.PutForExternalReadCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
+import org.jboss.cache.commands.write.RemoveKeyCommand;
+import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.invocation.InvocationContext;
/**
Copied:
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/CreateNodeCommand.java
(from rev 6455,
core/trunk/src/main/java/org/jboss/cache/commands/write/CreateNodeCommand.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/CreateNodeCommand.java
(rev 0)
+++
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/CreateNodeCommand.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -0,0 +1,101 @@
+package org.jboss.cache.commands.legacy.write;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.Visitor;
+import org.jboss.cache.commands.WriteCommand;
+import org.jboss.cache.commands.legacy.ReversibleCommand;
+import org.jboss.cache.commands.read.AbstractDataCommand;
+import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Command that creates a node. Primarily to be used as an undo command for removing
nodes.
+ *
+ * @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
+ * @since 2.2.0
+ * @deprecated will be removed when pessimistic locking is removed.
+ */
+@Deprecated
+public class CreateNodeCommand extends AbstractDataCommand implements WriteCommand,
ReversibleCommand
+{
+ public static final int METHOD_ID = 48;
+ protected final List<Fqn> newlyCreated = new LinkedList<Fqn>();
+
+ public CreateNodeCommand(Fqn fqn)
+ {
+ this.fqn = fqn;
+ newlyCreated.add(fqn);
+ }
+
+ public CreateNodeCommand()
+ {
+ }
+
+ public int getCommandId()
+ {
+ return METHOD_ID;
+ }
+
+ public void setGlobalTransaction(GlobalTransaction gtx)
+ {
+ // no op
+ }
+
+ public GlobalTransaction getGlobalTransaction()
+ {
+ return null;
+ }
+
+ /**
+ * Creates a node in the cache, specified by the given Fqn.
+ */
+ public Object perform(InvocationContext ctx)
+ {
+ Object[] results = dataContainer.createNodes(fqn);
+ List<NodeSPI> created = (List<NodeSPI>) results[0];
+
+ boolean foundFqn = false;
+ if (!created.isEmpty())
+ {
+ for (NodeSPI n : created)
+ {
+ if (fqn.equals(n.getFqn())) foundFqn = true;
+ newlyCreated.add(n.getFqn());
+ }
+ }
+ if (newlyCreated != null && !foundFqn) newlyCreated.remove(fqn);
+
+ return results[1];
+ }
+
+ public void rollback()
+ {
+ if (newlyCreated != null)
+ {
+ for (Fqn f : newlyCreated) dataContainer.removeFromDataStructure(f, true);
+ }
+ }
+
+ List<Fqn> getNewlyCreated()
+ {
+ return newlyCreated;
+ }
+
+ public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
+ {
+ return visitor.visitCreateNodeCommand(ctx, this);
+ }
+
+ @Override
+ public String toString()
+ {
+ return "CreateNodeCommand{" +
+ "fqn=" + fqn +
+ ", newlyCreated=" + newlyCreated +
+ '}';
+ }
+}
Deleted:
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessCreateNodeCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessCreateNodeCommand.java 2008-07-31
16:50:36 UTC (rev 6474)
+++
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessCreateNodeCommand.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -1,41 +0,0 @@
-package org.jboss.cache.commands.legacy.write;
-
-import org.jboss.cache.Fqn;
-import org.jboss.cache.commands.legacy.ReversibleCommand;
-import org.jboss.cache.commands.write.CreateNodeCommand;
-
-import java.util.List;
-
-/**
- * A version of {@link org.jboss.cache.commands.write.CreateNodeCommand} which can be
rolled back, for use with
- * pessimistic locking where changes are made directly on the data structures and may
need to be reversed.
- *
- * @author Manik Surtani (<a
href="mailto:manik@jboss.org">manik@jboss.org</a>)
- * @since 3.0
- * @deprecated will be removed along with optimistic and pessimistic locking.
- */
-@Deprecated
-public class PessCreateNodeCommand extends CreateNodeCommand implements
ReversibleCommand
-{
- public PessCreateNodeCommand(Fqn fqn)
- {
- super(fqn);
- }
-
- public PessCreateNodeCommand()
- {
- }
-
- public void rollback()
- {
- if (newlyCreated != null)
- {
- for (Fqn f : newlyCreated) dataContainer.removeFromDataStructure(f, true);
- }
- }
-
- List<Fqn> getNewlyCreated()
- {
- return newlyCreated;
- }
-}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-07-31
16:50:36 UTC (rev 6474)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -5,6 +5,7 @@
import org.jboss.cache.InternalNode;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -16,7 +17,6 @@
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
-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;
@@ -267,8 +267,7 @@
@Override
public Object handleCreateNodeCommand(InvocationContext ctx, CreateNodeCommand
command) throws Throwable
{
- helper.wrapNodeForWriting(ctx, command.getFqn(), true, true, false, false, false);
// get the node and stick it in the context.
- return invokeNextInterceptor(ctx, command);
+ throw new UnsupportedOperationException("Unsupported in MVCC!");
}
@Override
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-07-31
16:50:36 UTC (rev 6474)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -14,12 +14,12 @@
import org.jboss.cache.commands.VersionedDataCommand;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.WriteCommand;
+import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
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.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.commands.write.CreateNodeCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java 2008-07-31
16:50:36 UTC (rev 6474)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -1,6 +1,7 @@
package org.jboss.cache.interceptors.base;
import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -13,7 +14,6 @@
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
-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;
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java 2008-07-31 16:50:36
UTC (rev 6474)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java 2008-07-31 18:07:54
UTC (rev 6475)
@@ -7,11 +7,9 @@
import org.jboss.cache.InternalNode;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.UnversionedNode;
-import org.jboss.cache.commands.write.CreateNodeCommand;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.transaction.TransactionContext;
import java.util.Map;
@@ -99,7 +97,7 @@
@Override
@SuppressWarnings("unchecked")
- public InternalNode<K, V> createAndRegister(Fqn fqn, InternalNode<K, V>
parent, InvocationContext ctx, boolean attachToParent)
+ public InternalNode<K, V> createChildNode(Fqn fqn, InternalNode<K, V>
parent, InvocationContext ctx, boolean attachToParent)
{
InternalNode<K, V> child;
if (fqn == null) throw new IllegalArgumentException("null child fqn");
@@ -116,13 +114,6 @@
if (trace) log.trace("Created new child with fqn [" + fqn +
"]");
- TransactionContext tctx;
- if ((tctx = ctx.getTransactionContext()) != null)
- {
- CreateNodeCommand createNodeCommand =
commandsFactory.buildCreateNodeCommand(fqn);
- tctx.addLocalModification(createNodeCommand);
- }
-
// notify if we actually created a new child
cache.getNotifier().notifyNodeCreated(fqn, false, ctx);
}
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-07-31 16:50:36
UTC (rev 6474)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-07-31 18:07:54
UTC (rev 6475)
@@ -223,7 +223,7 @@
// now to lock and create the node. Lock first to prevent concurrent
creation!
acquireLock(context, fqn);
- in = nodeFactory.createAndRegister(fqn, null, context, false);
+ in = nodeFactory.createChildNode(fqn, null, context, false);
n = nodeFactory.createWrappedNode(in);
n.setCreated(true);
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-07-31 16:50:36
UTC (rev 6474)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/NodeReference.java 2008-07-31 18:07:54
UTC (rev 6475)
@@ -6,7 +6,6 @@
import org.jboss.cache.InternalNode;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -137,26 +136,6 @@
delegate.addChild(child);
}
- public final InternalNode<K, V> addChild(Fqn f)
- {
- return delegate.addChild(f);
- }
-
- public final InternalNode<K, V> addChild(Fqn f, boolean notify)
- {
- return delegate.addChild(f, notify);
- }
-
- public final InternalNode<K, V> addChild(Object o, boolean notify)
- {
- return delegate.addChild(o, notify);
- }
-
- public final InternalNode<K, V> getOrCreateChild(Object childName,
InvocationContext ctx)
- {
- return delegate.getOrCreateChild(childName, ctx);
- }
-
public final V remove(K key)
{
return delegate.remove(key);
Modified:
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/CreateNodeCommandTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/CreateNodeCommandTest.java 2008-07-31
16:50:36 UTC (rev 6474)
+++
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/CreateNodeCommandTest.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -8,7 +8,7 @@
import java.util.ArrayList;
/**
- * Tester class for {@link org.jboss.cache.commands.write.CreateNodeCommand}
+ * Tester class for {@link CreateNodeCommand}
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
@@ -16,13 +16,13 @@
@Test(groups = "unit")
public class CreateNodeCommandTest extends AbstractDataCommandTest
{
- PessCreateNodeCommand command;
+ CreateNodeCommand command;
private Object[] result;
private ArrayList createdNodes;
protected void moreSetup()
{
- command = new PessCreateNodeCommand(testFqn);
+ command = new CreateNodeCommand(testFqn);
command.initialize(container);
createdNodes = new ArrayList();
result = new Object[2];
Modified:
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-07-31
16:50:36 UTC (rev 6474)
+++
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-07-31
18:07:54 UTC (rev 6475)
@@ -67,7 +67,6 @@
protected NodeSPI createNode(Fqn fqn)
{
UnversionedNode un = new UnversionedNode(fqn);
- un.injectDependencies(null, null, null);
return new NodeInvocationDelegate(un);
}
}