Author: manik.surtani(a)jboss.com
Date: 2008-07-01 13:21:11 -0400 (Tue, 01 Jul 2008)
New Revision: 6147
Removed:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeAPIMVCCTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeReplicatedMoveMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplTxMvccTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/VersionedNode.java
core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeAPIMVCCTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeAPIOptimisticTest.java
Log:
Added more MVCC fixes
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-01 17:09:30 UTC
(rev 6146)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-07-01 17:21:11 UTC
(rev 6147)
@@ -741,13 +741,25 @@
public InternalNode copy()
{
UnversionedNode n = new UnversionedNode(fqn.getLastElement(), fqn, data, cache);
- n.children = children;
+ copyInternals(n);
+ return n;
+ }
+
+ protected void copyInternals(UnversionedNode n)
+ {
+ if (children == null || children.isEmpty())
+ {
+ n.children = null;
+ }
+ else
+ {
+ n.children().putAll(children);
+ }
n.commandsFactory = commandsFactory;
n.delegate = delegate;
n.flags.clear();
n.flags.addAll(flags);
n.lockStrategyFactory = lockStrategyFactory;
- return n;
}
public void setInternalState(Map state)
Modified: core/trunk/src/main/java/org/jboss/cache/VersionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/VersionedNode.java 2008-07-01 17:09:30 UTC
(rev 6146)
+++ core/trunk/src/main/java/org/jboss/cache/VersionedNode.java 2008-07-01 17:21:11 UTC
(rev 6147)
@@ -112,12 +112,7 @@
public VersionedNode copy()
{
VersionedNode n = new VersionedNode(fqn, getParent(), data, cache);
- n.children = children;
- n.commandsFactory = commandsFactory;
- n.delegate = delegate;
- n.flags.clear();
- n.flags.addAll(flags);
- n.lockStrategyFactory = lockStrategyFactory;
+ copyInternals(n);
n.version = version;
return n;
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-07-01
17:09:30 UTC (rev 6146)
+++
core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -42,7 +42,7 @@
*/
public Object perform(InvocationContext ctx)
{
- if (trace) log.trace("perform(" + globalTransaction + ",
\"" + fqn + ")");
+ if (trace) log.trace("perform(" + globalTransaction + ", " +
fqn + ")");
// Find the node
targetNode = peekVersioned(ctx);
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-07-01
17:09:30 UTC (rev 6146)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -19,8 +19,8 @@
*/
public abstract class AbstractInvocationDelegate
{
- protected Log log = LogFactory.getLog(getClass());
-
+ protected final Log log = LogFactory.getLog(getClass());
+ protected final boolean trace = log.isTraceEnabled();
protected Configuration configuration;
protected InvocationContextContainer invocationContextContainer;
protected ComponentRegistry componentRegistry;
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-07-01
17:09:30 UTC (rev 6146)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -1,6 +1,16 @@
package org.jboss.cache.invocation;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.DataContainer;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeNotExistsException;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.RPCManager;
+import org.jboss.cache.Region;
+import org.jboss.cache.RegionManager;
+import org.jboss.cache.Version;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
@@ -107,7 +117,7 @@
public NodeSPI<K, V> getRoot()
{
- return (NodeSPI<K, V>) dataContainer.getRoot();
+ return getNode(Fqn.ROOT);
}
public TransactionManager getTransactionManager()
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-07-01
17:09:30 UTC (rev 6146)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -27,7 +27,7 @@
@SuppressWarnings("unchecked")
public class NodeInvocationDelegate<K, V> extends AbstractInvocationDelegate
implements NodeSPI<K, V>
{
- protected InternalNode node;
+ protected volatile InternalNode node;
private CacheSPI<K, V> spi;
public NodeInvocationDelegate(InternalNode node)
@@ -232,7 +232,9 @@
public NodeSPI<K, V> getParent()
{
- return node.getParent();
+ Fqn f = getFqn();
+ if (f.isRoot()) return this;
+ return spi.getNode(f.getParent());
}
public Set<Node<K, V>> getChildren()
@@ -482,4 +484,21 @@
{
return node == null ? "null" : node.toString();
}
+
+ public boolean equals(Object o)
+ {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ NodeInvocationDelegate that = (NodeInvocationDelegate) o;
+
+ if (node != null ? !node.equals(that.node) : that.node != null) return false;
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return (node != null ? node.hashCode() : 0);
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-01
17:09:30 UTC (rev 6146)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -1,6 +1,7 @@
package org.jboss.cache.mvcc;
import org.jboss.cache.DataContainer;
+import org.jboss.cache.Fqn;
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.invocation.InvocationContext;
@@ -24,15 +25,17 @@
@Override
public void copyNodeForUpdate(DataContainer container, boolean allowWriteSkew,
InvocationContext ctx, NodeFactory nodeFactory, boolean lockParent)
{
+ Fqn fqn = getFqn();
+
// mark node as changed.
changed = true;
// check for write skew.
- NodeSPI underlyingNode = container.peek(getFqn(), false, true); // even check for
invalid nodes. we should check tombstones too.
+ NodeSPI underlyingNode = container.peek(fqn, false, true); // even check for
invalid nodes. we should check tombstones too.
DataVersion underlyingNodeVersion = underlyingNode == null ? null :
underlyingNode.getVersion();
if (!allowWriteSkew && underlyingNode != null &&
!node.getVersion().equals(underlyingNodeVersion))
{
- String errormsg = new StringBuilder().append("Detected write skew.
Attempting to overwrite version ").append(node.getVersion()).append(" but
current version has progressed to ").append(underlyingNodeVersion).toString();
+ String errormsg = new StringBuilder().append("Detected write skew on Fqn
[").append(fqn).append("]. Attempting to overwrite version
").append(node.getVersion()).append(" but current version has progressed to
").append(underlyingNodeVersion).toString();
if (log.isWarnEnabled()) log.warn(errormsg + ". Unable to copy node for
update.");
throw new DataVersioningException(errormsg);
}
@@ -47,9 +50,10 @@
node.setVersion(newVersion);
// if the parent is in the context make sure the parent has a ref to the copy now.
- if (!getFqn().isRoot() && lockParent)
+ Fqn parentFqn = getFqn().getParent();
+ if (!getFqn().isRoot() && (lockParent || container.peek(parentFqn) ==
null))
{
- NodeSPI parent = ctx.lookUpNode(getFqn().getParent());
+ NodeSPI parent = ctx.lookUpNode(parentFqn);
if (parent != null)
parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(node));
}
}
@@ -57,22 +61,32 @@
@Override
protected void updateNode(DataContainer dataContainer, NodeFactory nf)
{
- // TODO: Deal with removes and moves
+ if (trace)
+ log.trace("Updating RepeatableReadNode. IsDeleted? " + isDeleted() +
" isValid? " + isValid() + " isChanged? " + isChanged());
if (getFqn().isRoot())
{
dataContainer.setRoot(nf.createNodeInvocationDelegate(node));
}
else
{
- NodeSPI parent = dataContainer.peek(getFqn().getParent());
+ Fqn fqn = getFqn();
+ NodeSPI parent = dataContainer.peek(fqn.getParent());
if (parent != null)
{
- NodeSPI oldChild = parent.getChildDirect(getFqn().getLastElement());
- if (oldChild != null)
+ Object name = fqn.getLastElement();
+ NodeSPI oldChild = parent.getChildDirect(name);
+ if (isDeleted())
{
- node.setChildrenMapDirect(oldChild.getChildrenMapDirect());
+ parent.removeChildDirect(name);
}
- parent.addChildDirect(nf.createNodeInvocationDelegate(node));
+ else
+ {
+ if (oldChild != null)
+ {
+ node.setChildrenMapDirect(oldChild.getChildrenMapDirect());
+ }
+ parent.addChildDirect(nf.createNodeInvocationDelegate(node));
+ }
}
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java 2008-07-01 17:09:30 UTC
(rev 6146)
+++ core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java 2008-07-01 17:21:11 UTC
(rev 6147)
@@ -46,6 +46,7 @@
// start a single cache instance
CacheFactory<String, String> cf = new DefaultCacheFactory<String,
String>();
cache = (CacheSPI<String, String>)
cf.createCache("configs/local-tx.xml", false);
+ cache.getConfiguration().setEvictionConfig(null);
configure(cache.getConfiguration());
cache.start();
events.clear();
@@ -312,9 +313,8 @@
assertSame(myRegion, cache.getRegion(Fqn.fromString("/myregion"),
false));
Region otherRegion = cache.getRegion(Fqn.fromString("/other/region"),
false);
- // should return the default region
- assertNotNull(otherRegion);
- assertEquals(Fqn.ROOT, otherRegion.getFqn());
+ // should return null since no eviction is in use.
+ assert otherRegion == null;
}
public void testStopClearsData() throws Exception
@@ -341,25 +341,23 @@
public void testPhantomStructuralNodesOnRemove()
{
- CacheSPI spi = (CacheSPI) cache;
- assert spi.peek(Fqn.fromString("/a/b/c"), true, true) == null;
- assert !spi.removeNode("/a/b/c");
- assert spi.peek(Fqn.fromString("/a/b/c"), true, true) == null;
- assert spi.peek(Fqn.fromString("/a/b"), true, true) == null;
- assert spi.peek(Fqn.fromString("/a"), true, true) == null;
+ assert cache.peek(Fqn.fromString("/a/b/c"), true, true) == null;
+ assert !cache.removeNode("/a/b/c");
+ assert cache.peek(Fqn.fromString("/a/b/c"), true, true) == null;
+ assert cache.peek(Fqn.fromString("/a/b"), true, true) == null;
+ assert cache.peek(Fqn.fromString("/a"), true, true) == null;
}
public void testPhantomStructuralNodesOnRemoveTransactional() throws Exception
{
- CacheSPI spi = (CacheSPI) cache;
- TransactionManager tm = spi.getTransactionManager();
- assert spi.peek(Fqn.fromString("/a/b/c"), true, true) == null;
+ TransactionManager tm = cache.getTransactionManager();
+ assert cache.peek(Fqn.fromString("/a/b/c"), true, true) == null;
tm.begin();
- assert !spi.removeNode("/a/b/c");
+ assert !cache.removeNode("/a/b/c");
tm.commit();
- assert spi.peek(Fqn.fromString("/a/b/c"), true, true) == null;
- assert spi.peek(Fqn.fromString("/a/b"), true, true) == null;
- assert spi.peek(Fqn.fromString("/a"), true, true) == null;
+ assert cache.peek(Fqn.fromString("/a/b/c"), true, true) == null;
+ assert cache.peek(Fqn.fromString("/a/b"), true, true) == null;
+ assert cache.peek(Fqn.fromString("/a"), true, true) == null;
}
public void testRpcManagerElements()
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-07-01 17:09:30 UTC
(rev 6146)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-07-01 17:21:11 UTC
(rev 6147)
@@ -7,6 +7,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import static org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC;
+import static org.jboss.cache.config.Configuration.NodeLockingScheme.PESSIMISTIC;
import org.jboss.cache.interceptors.MVCCLockingInterceptor;
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.PessimisticLockInterceptor;
@@ -21,7 +22,6 @@
import javax.transaction.TransactionManager;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -40,8 +40,10 @@
private TransactionManager tm;
- private static final Fqn<String> A = Fqn.fromString("/a"), B =
Fqn.fromString("/b"), C = Fqn.fromString("/c"), D = Fqn
+ protected static final Fqn<String> A = Fqn.fromString("/a"), B =
Fqn.fromString("/b"), C = Fqn.fromString("/c"), D = Fqn
.fromString("/d");
+ protected Fqn<Object> A_B = Fqn.fromRelativeFqn(A, B);
+ protected Fqn A_C = Fqn.fromRelativeFqn(A, C);
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -86,12 +88,12 @@
protected NodeLockingScheme getNodeLockingScheme()
{
- return NodeLockingScheme.PESSIMISTIC;
+ return PESSIMISTIC;
}
protected void assertNodeLockingScheme()
{
- assert cache.getConfiguration().getNodeLockingScheme() ==
NodeLockingScheme.PESSIMISTIC;
+ assert cache.getConfiguration().getNodeLockingScheme() == PESSIMISTIC;
boolean interceptorChainOK = false;
for (CommandInterceptor i : cache.getInterceptorChain())
@@ -294,47 +296,25 @@
}
}
+ protected void childrenUnderTxCheck() throws Exception
+ {
+ assertEquals(3, cache.getNumberOfNodes());
+ assertEquals(4, cache.getNumberOfLocksHeld());
+ }
+
public void testGetChildrenUnderTx() throws Exception
{
- Fqn<Object> A_B = Fqn.fromRelativeFqn(A, B);
- Fqn A_C = Fqn.fromRelativeFqn(A, C);
tm.begin();
cache.put(A_B, "1", "1");
cache.put(A_C, "2", "2");
- if (getNodeLockingScheme() != OPTIMISTIC)
- {
- assertEquals(3, cache.getNumberOfNodes());
- assertEquals(4, cache.getNumberOfLocksHeld());
- }
- else
- {
- TransactionWorkspace<Object, Object> w = getTransactionWorkspace();
- assert w.getNodes().size() == 4 : "Should be 4 nodes in the workspace, not
" + w.getNodes().size();
- // test deltas
- List<Set<Fqn>> deltas =
w.getNodes().get(Fqn.ROOT).getMergedChildren();
- assert deltas.get(0).size() == 1 : "/ should have 1 child added";
- assert deltas.get(1).size() == 0 : "/ should have 0 children
removed";
-
- deltas = w.getNodes().get(A).getMergedChildren();
- assert deltas.get(0).size() == 2 : "/ should have 2 children added";
- assert deltas.get(1).size() == 0 : "/ should have 0 children
removed";
-
- deltas = w.getNodes().get(A_B).getMergedChildren();
- assert deltas.get(0).size() == 0 : "/a/b should have 0 children
added";
- assert deltas.get(1).size() == 0 : "/a/b should have 0 children
removed";
-
- deltas = w.getNodes().get(A_C).getMergedChildren();
- assert deltas.get(0).size() == 0 : "/a/c should have 0 children
added";
- assert deltas.get(1).size() == 0 : "/a/c should have 0 children
removed";
- }
-
+ childrenUnderTxCheck();
assertEquals("Number of child", 2,
cache.getRoot().getChild(A).getChildren().size());
tm.commit();
}
@SuppressWarnings("unchecked")
- private TransactionWorkspace<Object, Object> getTransactionWorkspace() throws
Exception
+ protected TransactionWorkspace<Object, Object> getTransactionWorkspace() throws
Exception
{
return ((OptimisticTransactionContext)
cache.getTransactionTable().get(cache.getTransactionTable().get(tm.getTransaction()))).getTransactionWorkSpace();
}
@@ -436,8 +416,9 @@
public void testDoubleRemovalOfData() throws Exception
{
cache.put("/foo/1/2/3", "item", 1);
+ assert 1 == (Integer) cache.get("/foo/1/2/3", "item");
tm.begin();
- assertEquals(cache.get("/foo/1/2/3", "item"), 1);
+ assert 1 == (Integer) cache.get("/foo/1/2/3", "item");
cache.removeNode("/foo/1");
assertNull(cache.getNode("/foo/1"));
assertNull(cache.get("/foo/1", "item"));
Deleted: core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeAPIMVCCTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeAPIMVCCTest.java 2008-07-01
17:09:30 UTC (rev 6146)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeAPIMVCCTest.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -1,37 +0,0 @@
-package org.jboss.cache.api.mvcc;
-
-import org.jboss.cache.api.NodeAPITest;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.jboss.cache.interceptors.MVCCLockingInterceptor;
-import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
-import org.jboss.cache.interceptors.PessimisticLockInterceptor;
-import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.testng.annotations.Test;
-
-/**
- * An MVCC version of {@link org.jboss.cache.api.NodeAPITest}
- */
-@Test(groups = {"functional", "mvcc"})
-public class NodeAPIMVCCTest extends NodeAPITest
-{
- protected NodeLockingScheme getNodeLockingScheme()
- {
- return NodeLockingScheme.MVCC;
- }
-
- protected void assertNodeLockingScheme()
- {
- assert cache.getConfiguration().getNodeLockingScheme() == NodeLockingScheme.MVCC;
- boolean interceptorChainOK = false;
-
- for (CommandInterceptor i : cache.getInterceptorChain())
- {
- if (i instanceof PessimisticLockInterceptor) assert false : "Not an MVCC
locking chain!!";
- if (i instanceof OptimisticNodeInterceptor) assert false : "Not an MVCC
locking chain!!";
- if (i instanceof MVCCLockingInterceptor) interceptorChainOK = true;
-
- }
-
- assert interceptorChainOK : "Not an MVCC locking chain!!";
- }
-}
\ No newline at end of file
Deleted: core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTest.java 2008-07-01
17:09:30 UTC (rev 6146)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTest.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -1,20 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at
gnu.org.
- */
-package org.jboss.cache.api.mvcc;
-
-import org.jboss.cache.api.NodeMoveAPITest;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.testng.annotations.Test;
-
-@Test(groups = {"functional", "mvcc"})
-public class NodeMoveMvccTest extends NodeMoveAPITest
-{
- public NodeMoveMvccTest()
- {
- nodeLockingScheme = NodeLockingScheme.MVCC;
- }
-}
Deleted:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeReplicatedMoveMvccTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeReplicatedMoveMvccTest.java 2008-07-01
17:09:30 UTC (rev 6146)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeReplicatedMoveMvccTest.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -1,20 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at
gnu.org.
- */
-package org.jboss.cache.api.mvcc;
-
-import org.jboss.cache.api.NodeReplicatedMoveTest;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.testng.annotations.Test;
-
-@Test(groups = {"functional", "mvcc"})
-public class NodeReplicatedMoveMvccTest extends NodeReplicatedMoveTest
-{
- public NodeReplicatedMoveMvccTest()
- {
- nodeLockingScheme = NodeLockingScheme.MVCC;
- }
-}
Deleted: core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplMvccTest.java 2008-07-01
17:09:30 UTC (rev 6146)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplMvccTest.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -1,14 +0,0 @@
-package org.jboss.cache.api.mvcc;
-
-import org.jboss.cache.api.SyncReplTest;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.testng.annotations.Test;
-
-@Test(groups = {"functional", "jgroups", "mvcc"})
-public class SyncReplMvccTest extends SyncReplTest
-{
- public SyncReplMvccTest()
- {
- nodeLockingScheme = NodeLockingScheme.MVCC;
- }
-}
Deleted: core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplTxMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplTxMvccTest.java 2008-07-01
17:09:30 UTC (rev 6146)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplTxMvccTest.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -1,14 +0,0 @@
-package org.jboss.cache.api.mvcc;
-
-import org.jboss.cache.api.SyncReplTxTest;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.testng.annotations.Test;
-
-@Test(groups = {"functional", "jgroups", "transaction",
"mvcc"})
-public class SyncReplTxMvccTest extends SyncReplTxTest
-{
- public SyncReplTxMvccTest()
- {
- nodeLockingScheme = NodeLockingScheme.MVCC;
- }
-}
Modified:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeAPIMVCCTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeAPIMVCCTest.java 2008-07-01
17:09:30 UTC (rev 6146)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeAPIMVCCTest.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -42,4 +42,21 @@
assert interceptorChainOK : "Not an MVCC locking chain!!";
}
+
+ @Override
+ public void testLocking()
+ {
+ // no op - this is tested separately
+ }
+
+ @Override
+ protected void childrenUnderTxCheck() throws Exception
+ {
+ assert cache.getNode(A_B) != null;
+ assert cache.getNode(A_C) != null;
+
+ assert cache.getInvocationContext().getLocks().contains(A);
+ assert cache.getInvocationContext().getLocks().contains(A_B);
+ assert cache.getInvocationContext().getLocks().contains(A_C);
+ }
}
\ No newline at end of file
Modified:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java 2008-07-01
17:09:30 UTC (rev 6146)
+++
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -42,4 +42,21 @@
assert interceptorChainOK : "Not an MVCC locking chain!!";
}
+
+ @Override
+ public void testLocking()
+ {
+ // no op - this is tested separately
+ }
+
+ @Override
+ protected void childrenUnderTxCheck() throws Exception
+ {
+ assert cache.getNode(A_B) != null;
+ assert cache.getNode(A_C) != null;
+
+ assert cache.getInvocationContext().getLocks().contains(A);
+ assert cache.getInvocationContext().getLocks().contains(A_B);
+ assert cache.getInvocationContext().getLocks().contains(A_C);
+ }
}
\ No newline at end of file
Modified:
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeAPIOptimisticTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeAPIOptimisticTest.java 2008-07-01
17:09:30 UTC (rev 6146)
+++
core/trunk/src/test/java/org/jboss/cache/api/optimistic/NodeAPIOptimisticTest.java 2008-07-01
17:21:11 UTC (rev 6147)
@@ -1,12 +1,17 @@
package org.jboss.cache.api.optimistic;
+import org.jboss.cache.Fqn;
import org.jboss.cache.api.NodeAPITest;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.PessimisticLockInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
+import org.jboss.cache.optimistic.TransactionWorkspace;
import org.testng.annotations.Test;
+import java.util.List;
+import java.util.Set;
+
/**
* An optimistic version of {@link org.jboss.cache.api.NodeAPITest}
*/
@@ -31,4 +36,27 @@
assert interceptorChainOK : "Not an optimistic locking chain!!";
}
+
+ @Override
+ protected void childrenUnderTxCheck() throws Exception
+ {
+ TransactionWorkspace<Object, Object> w = getTransactionWorkspace();
+ assert w.getNodes().size() == 4 : "Should be 4 nodes in the workspace, not
" + w.getNodes().size();
+ // test deltas
+ List<Set<Fqn>> deltas =
w.getNodes().get(Fqn.ROOT).getMergedChildren();
+ assert deltas.get(0).size() == 1 : "/ should have 1 child added";
+ assert deltas.get(1).size() == 0 : "/ should have 0 children removed";
+
+ deltas = w.getNodes().get(A).getMergedChildren();
+ assert deltas.get(0).size() == 2 : "/ should have 2 children added";
+ assert deltas.get(1).size() == 0 : "/ should have 0 children removed";
+
+ deltas = w.getNodes().get(A_B).getMergedChildren();
+ assert deltas.get(0).size() == 0 : "/a/b should have 0 children added";
+ assert deltas.get(1).size() == 0 : "/a/b should have 0 children
removed";
+
+ deltas = w.getNodes().get(A_C).getMergedChildren();
+ assert deltas.get(0).size() == 0 : "/a/c should have 0 children added";
+ assert deltas.get(1).size() == 0 : "/a/c should have 0 children
removed";
+ }
}