JBoss Cache SVN: r6148 - searchable/trunk/src/test/java/org/jboss/cache/search/blackbox.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-07-02 06:52:43 -0400 (Wed, 02 Jul 2008)
New Revision: 6148
Modified:
searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java
Log:
Created iterator test within LocalCacheTest
Modified: searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java
===================================================================
--- searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java 2008-07-01 17:21:11 UTC (rev 6147)
+++ searchable/trunk/src/test/java/org/jboss/cache/search/blackbox/LocalCacheTest.java 2008-07-02 10:52:43 UTC (rev 6148)
@@ -3,6 +3,7 @@
import org.jboss.cache.search.SearchableCache;
import org.jboss.cache.search.SearchableCacheFactory;
import org.jboss.cache.search.CacheQuery;
+import org.jboss.cache.search.QueryResultIterator;
import org.jboss.cache.search.test.Person;
import org.jboss.cache.Cache;
import org.jboss.cache.DefaultCacheFactory;
@@ -16,6 +17,7 @@
import org.apache.lucene.search.Query;
import java.util.List;
+import java.util.Iterator;
/**
* @author Navin Surtani - navin(a)surtani.org
@@ -78,6 +80,19 @@
assert found.get(0).equals(person1);
}
+ public void testSimpleIterator() throws ParseException
+ {
+ queryParser = new QueryParser("blurb", new StandardAnalyzer());
+ luceneQuery = queryParser.parse("playing");
+ cacheQuery = searchableCache.createQuery(luceneQuery);
+
+ QueryResultIterator found = cacheQuery.iterator();
+
+ assert found.equals(person1);
+ }
+
+
+
public void testMultipleResults() throws ParseException
{
queryParser = new QueryParser("name", new StandardAnalyzer());
16 years, 6 months
JBoss Cache SVN: r6147 - in core/trunk/src: main/java/org/jboss/cache/commands/write and 7 other directories.
by jbosscache-commits@lists.jboss.org
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";
+ }
}
16 years, 6 months
JBoss Cache SVN: r6146 - searchable/trunk/src/main/java/org/jboss/cache/search.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-07-01 13:09:30 -0400 (Tue, 01 Jul 2008)
New Revision: 6146
Modified:
searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.java
searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java
Log:
Still testing - and failing
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.java 2008-07-01 15:24:27 UTC (rev 6145)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheEntityId.java 2008-07-01 17:09:30 UTC (rev 6146)
@@ -16,11 +16,14 @@
public CacheEntityId(String documentId)
{
+ if(documentId == null) throw new NullPointerException("documentId is null");
this.documentId = documentId;
}
public CacheEntityId(Fqn fqn, String key)
{
+ if(fqn == null) throw new NullPointerException("Fqn is null");
+ if(key == null) throw new NullPointerException("Key is null");
this.fqn = fqn;
this.key = key;
}
@@ -39,7 +42,11 @@
fqn = Transformer.getFqn(documentId);
return fqn;
}
- throw new IllegalArgumentException("At least fqn or documentId must be set to call this method");
+
+ if(documentId == null)
+ throw new IllegalArgumentException("docId is null");
+
+ throw new IllegalArgumentException("Fqn is null");
}
/**
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java 2008-07-01 15:24:27 UTC (rev 6145)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/CacheQueryImpl.java 2008-07-01 17:09:30 UTC (rev 6146)
@@ -258,6 +258,7 @@
for (int index = first; index <= max; index++)
{
String documentId = (String) extractor.extract(hits, index).id;
+ if (documentId == null) throw new NullPointerException("The document id extracted is null");
CacheEntityId id = new CacheEntityId(documentId);
ids.add(id);
}
16 years, 6 months
JBoss Cache SVN: r6145 - core/trunk/src/main/resources.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-07-01 11:24:27 -0400 (Tue, 01 Jul 2008)
New Revision: 6145
Added:
core/trunk/src/main/resources/jbosscache-config.xsd
Modified:
core/trunk/src/main/resources/all-elements-file-3.x.xml
Log:
first versio of XSD schema
Modified: core/trunk/src/main/resources/all-elements-file-3.x.xml
===================================================================
--- core/trunk/src/main/resources/all-elements-file-3.x.xml 2008-07-01 14:27:02 UTC (rev 6144)
+++ core/trunk/src/main/resources/all-elements-file-3.x.xml 2008-07-01 15:24:27 UTC (rev 6145)
@@ -3,7 +3,7 @@
<jbosscache>
<locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="true" lockAcquisitionTimeout="10234"
- nodeLockingScheme="mvcc"allowWriteSkew="true" concurrencyLevel="21"/>
+ nodeLockingScheme="mvcc" allowWriteSkew="true" concurrencyLevel="21"/>
<transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup"
syncRollbackPhase="true" syncCommitPhase="true"/>
Added: core/trunk/src/main/resources/jbosscache-config.xsd
===================================================================
--- core/trunk/src/main/resources/jbosscache-config.xsd (rev 0)
+++ core/trunk/src/main/resources/jbosscache-config.xsd 2008-07-01 15:24:27 UTC (rev 6145)
@@ -0,0 +1,362 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="jbosscache" type="jbosscacheType"/>
+ <xs:complexType name="FRAG2Type">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="frag_size"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="dataGravitationType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="auto"/>
+ <xs:attribute type="xs:string" name="removeOnFind"/>
+ <xs:attribute type="xs:string" name="searchBackupTrees"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="pbcast.STREAMING_STATE_TRANSFERType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="use_reading_thread"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="positionType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="first" use="optional"/>
+ <xs:attribute type="xs:string" name="last" use="optional"/>
+ <xs:attribute type="xs:string" name="index" use="optional"/>
+ <xs:attribute type="xs:string" name="before" use="optional"/>
+ <xs:attribute type="xs:string" name="after" use="optional"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="rootType">
+ <xs:sequence>
+ <xs:element type="attributeType" name="attribute" maxOccurs="unbounded" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="evictionType">
+ <xs:sequence>
+ <xs:element type="defaultsType" name="defaults"/>
+ <xs:element type="rootType" name="root"/>
+ <xs:element type="regionType" name="region" maxOccurs="unbounded" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="wakeUpInterval"/>
+ </xs:complexType>
+ <xs:complexType name="lockingType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="isolationLevel"/>
+ <xs:attribute type="xs:string" name="lockParentForChildInsertRemove"/>
+ <xs:attribute type="xs:string" name="lockAcquisitionTimeout"/>
+ <xs:attribute type="xs:string" name="nodeLockingScheme"/>
+ <xs:attribute type="xs:string" name="allowWriteSkew"/>
+ <xs:attribute type="xs:string" name="concurrencyLevel"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="jmxStatisticsType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="enabled"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="defaultsType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="policyClass"/>
+ <xs:attribute type="xs:string" name="eventQueueSize"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="transactionType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="transactionManagerLookupClass"/>
+ <xs:attribute type="xs:string" name="syncRollbackPhase"/>
+ <xs:attribute type="xs:string" name="syncCommitPhase"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="pbcast.FLUSHType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="timeout"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="pbcast.STABLEType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="stability_delay"/>
+ <xs:attribute type="xs:string" name="desired_avg_gossip"/>
+ <xs:attribute type="xs:string" name="max_bytes"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="transportType">
+ <xs:sequence>
+ <xs:element type="jgroupsConfigType" name="jgroupsConfig"/>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="clusterName"/>
+ <xs:attribute type="xs:string" name="multiplexerStack"/>
+ </xs:complexType>
+ <xs:complexType name="regionType">
+ <xs:sequence>
+ <xs:element type="attributeType" name="attribute" maxOccurs="unbounded" minOccurs="0"/>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="name" use="optional"/>
+ <xs:attribute type="xs:string" name="policyClass" use="optional"/>
+ <xs:attribute type="xs:string" name="eventQueueSize" use="optional"/>
+ </xs:complexType>
+ <xs:complexType name="jgroupsConfigType">
+ <xs:sequence>
+ <xs:element type="PINGType" name="PING"/>
+ <xs:element type="MERGE2Type" name="MERGE2"/>
+ <xs:element type="xs:string" name="FD_SOCK"/>
+ <xs:element type="FDType" name="FD"/>
+ <xs:element type="VERIFY_SUSPECTType" name="VERIFY_SUSPECT"/>
+ <xs:element type="pbcast.NAKACKType" name="pbcast.NAKACK"/>
+ <xs:element type="UNICASTType" name="UNICAST"/>
+ <xs:element type="pbcast.STABLEType" name="pbcast.STABLE"/>
+ <xs:element type="pbcast.GMSType" name="pbcast.GMS"/>
+ <xs:element type="FRAG2Type" name="FRAG2"/>
+ <xs:element type="pbcast.STREAMING_STATE_TRANSFERType" name="pbcast.STREAMING_STATE_TRANSFER"/>
+ <xs:element type="pbcast.FLUSHType" name="pbcast.FLUSH"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="shutdownType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="hookBehavior"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="asyncType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="useReplQueue"/>
+ <xs:attribute type="xs:string" name="replQueueInterval"/>
+ <xs:attribute type="xs:string" name="replQueueMaxElements"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="serializationType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="objectInputStreamPoolSize"/>
+ <xs:attribute type="xs:string" name="objectOutputStreamPoolSize"/>
+ <xs:attribute type="xs:string" name="version"/>
+ <xs:attribute type="xs:string" name="marshallerClass"/>
+ <xs:attribute type="xs:string" name="useLazyDeserialization"/>
+ <xs:attribute type="xs:string" name="useRegionBasedMarshalling"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="customInterceptorsType">
+ <xs:sequence>
+ <xs:element type="interceptorType" name="interceptor" maxOccurs="unbounded" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="startupType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="fetchInMemoryState"/>
+ <xs:attribute type="xs:string" name="stateRetrievalTimeout"/>
+ <xs:attribute type="xs:string" name="inactiveOnStartup"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="pbcast.GMSType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="print_local_addr"/>
+ <xs:attribute type="xs:string" name="join_timeout"/>
+ <xs:attribute type="xs:string" name="shun"/>
+ <xs:attribute type="xs:string" name="view_bundling"/>
+ <xs:attribute type="xs:string" name="view_ack_collection_timeout"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="UNICASTType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="timeout"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="jbosscacheType">
+ <xs:sequence>
+ <xs:element type="lockingType" name="locking"/>
+ <xs:element type="transactionType" name="transaction"/>
+ <xs:element type="serializationType" name="serialization">
+ <xs:annotation>
+ <xs:documentation>serialization related configuration, used for replication and cache loading</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element type="replicationType" name="replication">
+ <xs:annotation>
+ <xs:documentation>either replication or invalidation tags will be present, not both</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element type="invalidationType" name="invalidation">
+ <xs:annotation>
+ <xs:documentation>either replication or invalidation tags will be present, not both</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element type="startupType" name="startup"/>
+ <xs:element type="shutdownType" name="shutdown"/>
+ <xs:element type="jmxStatisticsType" name="jmxStatistics"/>
+ <xs:element type="transportType" name="transport"/>
+ <xs:element type="evictionType" name="eviction"/>
+ <xs:element type="loadersType" name="loaders"/>
+ <xs:element type="customInterceptorsType" name="customInterceptors">
+ <xs:annotation>
+ <xs:documentation>this is new behavior added within 3.x only. it support configuring custom interceptors through configurations</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="attributeType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="name" use="optional"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="PINGType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="timeout"/>
+ <xs:attribute type="xs:string" name="num_initial_members"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="nodeType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="fqn" use="optional"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="invalidationType">
+ <xs:sequence>
+ <xs:element type="asyncType" name="async">
+ <xs:annotation>
+ <xs:documentation>either sync or async will be present, not both</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ <xs:element type="syncType" name="sync"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="loaderType">
+ <xs:sequence>
+ <xs:element type="xs:string" name="properties"/>
+ <xs:element type="singletonStoreType" name="singletonStore"/>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="class"/>
+ <xs:attribute type="xs:string" name="async"/>
+ <xs:attribute type="xs:string" name="fetchPersistentState"/>
+ <xs:attribute type="xs:string" name="ignoreModifications"/>
+ <xs:attribute type="xs:string" name="purgeOnStartup"/>
+ </xs:complexType>
+ <xs:complexType name="replicationType">
+ <xs:sequence>
+ <xs:element type="syncType" name="sync"/>
+ <xs:element type="buddyType" name="buddy"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="interceptorType">
+ <xs:sequence>
+ <xs:element type="xs:string" name="properties" minOccurs="0"/>
+ <xs:element type="positionType" name="position"/>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="class" use="optional"/>
+ </xs:complexType>
+ <xs:complexType name="buddyType">
+ <xs:sequence>
+ <xs:element type="dataGravitationType" name="dataGravitation"/>
+ <xs:element type="locatorType" name="locator"/>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="enabled"/>
+ <xs:attribute type="xs:string" name="poolName"/>
+ <xs:attribute type="xs:string" name="communicationTimeout"/>
+ </xs:complexType>
+ <xs:complexType name="locatorType">
+ <xs:sequence>
+ <xs:element type="xs:string" name="properties"/>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="class"/>
+ </xs:complexType>
+ <xs:complexType name="pbcast.NAKACKType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="use_mcast_xmit"/>
+ <xs:attribute type="xs:string" name="gc_lag"/>
+ <xs:attribute type="xs:string" name="retransmit_timeout"/>
+ <xs:attribute type="xs:string" name="discard_delivered_msgs"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="preloadType">
+ <xs:sequence>
+ <xs:element type="nodeType" name="node" maxOccurs="unbounded" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="MERGE2Type">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="max_interval"/>
+ <xs:attribute type="xs:string" name="min_interval"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="VERIFY_SUSPECTType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="timeout"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="syncType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="replTimeout" use="optional"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="FDType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string">
+ <xs:attribute type="xs:string" name="timeout"/>
+ <xs:attribute type="xs:string" name="max_tries"/>
+ <xs:attribute type="xs:string" name="shun"/>
+ </xs:extension>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:complexType name="singletonStoreType">
+ <xs:sequence>
+ <xs:element type="xs:string" name="properties"/>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="enabled"/>
+ <xs:attribute type="xs:string" name="class"/>
+ </xs:complexType>
+ <xs:complexType name="loadersType">
+ <xs:sequence>
+ <xs:element type="preloadType" name="preload"/>
+ <xs:element type="loaderType" name="loader">
+ <xs:annotation>
+ <xs:documentation>we can now have multiple cache loaders, which get chained</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute type="xs:string" name="passivation"/>
+ <xs:attribute type="xs:string" name="shared"/>
+ </xs:complexType>
+</xs:schema>
\ No newline at end of file
16 years, 6 months
JBoss Cache SVN: r6144 - in core/trunk/src: test/java/org/jboss/cache/api and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-01 10:27:02 -0400 (Tue, 01 Jul 2008)
New Revision: 6144
Added:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheAPIMVCCTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/DeletedChildResurrectionMvccTest.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/read_committed/NodeMoveMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeReplicatedMoveMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/SyncReplMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/SyncReplTxMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheAPIMVCCTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/DeletedChildResurrectionMvccTest.java
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/NodeMoveMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeReplicatedMoveMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/SyncReplMvccTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/SyncReplTxMvccTest.java
Removed:
core/trunk/src/test/java/org/jboss/cache/api/mvcc/CacheAPIMVCCTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/DeletedChildResurrectionMvccTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java
core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java
Log:
Added more MVCC tests
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-01 13:58:17 UTC (rev 6143)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -1,7 +1,9 @@
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;
import org.jboss.cache.invocation.NodeInvocationDelegate;
import org.jboss.cache.optimistic.DataVersion;
@@ -50,13 +52,22 @@
protected void updateNode(DataContainer container, NodeFactory nf)
{
- // TODO: Deal with removes and moves
// TODO: Deal with creating - what if children is null?
- log.error("Backup is of type " + backup.getClass().getSimpleName());
- log.error("Node is of type " + node.getClass().getSimpleName());
- ((NodeReference) backup).setDelegate(((NodeReference) node).getDelegate());
- node = backup;
+ if (isDeleted())
+ {
+ Fqn fqn = getFqn();
+ NodeSPI parent = container.peek(fqn);
+ if (parent != null)
+ {
+ parent.removeChildDirect(fqn.getLastElement());
+ }
+ }
+ else
+ {
+ ((NodeReference) backup).setDelegate(((NodeReference) node).getDelegate());
+ node = backup;
+ }
}
public void rollbackUpdate()
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 13:58:17 UTC (rev 6143)
+++ core/trunk/src/test/java/org/jboss/cache/api/CacheAPITest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -6,6 +6,7 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.Region;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
@@ -15,6 +16,7 @@
import org.jboss.cache.notifications.event.Event;
import org.jboss.cache.transaction.GenericTransactionManagerLookup;
import org.jboss.cache.util.CachePrinter;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -35,7 +37,7 @@
@Test(groups = {"functional", "pessimistic"})
public class CacheAPITest
{
- private Cache<String, String> cache;
+ private CacheSPI<String, String> cache;
final List<String> events = new ArrayList<String>();
@BeforeMethod(alwaysRun = true)
@@ -43,16 +45,22 @@
{
// start a single cache instance
CacheFactory<String, String> cf = new DefaultCacheFactory<String, String>();
- cache = cf.createCache("configs/local-tx.xml", false);
- cache.getConfiguration().setNodeLockingScheme(getNodeLockingScheme());
+ cache = (CacheSPI<String, String>) cf.createCache("configs/local-tx.xml", false);
+ configure(cache.getConfiguration());
cache.start();
events.clear();
}
+ protected void configure(Configuration c)
+ {
+ c.setNodeLockingScheme(getNodeLockingScheme());
+ }
+
+
@AfterMethod(alwaysRun = true)
public void tearDown()
{
- if (cache != null) cache.stop();
+ TestingUtil.killCaches(cache);
}
protected NodeLockingScheme getNodeLockingScheme()
@@ -160,6 +168,10 @@
assertFalse(cache.getRoot().hasChild(fqn));
assertEquals(false, cache.removeNode(fqn));
+ // remove should REALLY remove though and not just mark as deleted/invalid.
+ NodeSPI n = cache.peek(fqn, true, true);
+ assert n == null;
+
System.out.println("Cache: " + CachePrinter.printCacheDetails(cache));
// Check that it's removed if it has a child
Modified: core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java 2008-07-01 13:58:17 UTC (rev 6143)
+++ core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -42,6 +42,7 @@
cache = new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true), false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
cache.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
+ configure(cache.getConfiguration());
cache.start();
}
@@ -51,6 +52,11 @@
TestingUtil.killCaches(cache);
}
+ protected void configure(Configuration c)
+ {
+ // to be overridden
+ }
+
public void testDeletedChildResurrection1() throws Exception
{
CacheSPI spi = (CacheSPI) cache;
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 13:58:17 UTC (rev 6143)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -4,6 +4,7 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import static org.jboss.cache.config.Configuration.NodeLockingScheme.OPTIMISTIC;
import org.jboss.cache.interceptors.MVCCLockingInterceptor;
@@ -48,11 +49,17 @@
// start a single cache instance
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory().createCache("configs/local-tx.xml", false);
cache.getConfiguration().setNodeLockingScheme(getNodeLockingScheme());
+ configure(cache.getConfiguration());
cache.start();
rootNode = cache.getRoot();
tm = cache.getTransactionManager();
}
+ protected void configure(Configuration c)
+ {
+ // to be overridden
+ }
+
@AfterMethod(alwaysRun = true)
public void tearDown()
{
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-07-01 13:58:17 UTC (rev 6143)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -8,6 +8,7 @@
import org.jboss.cache.Node;
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.config.parsing.XmlConfigHelper;
import org.jboss.cache.config.parsing.element.LoadersElementParser;
@@ -49,6 +50,7 @@
// start a single cache instance
cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache("configs/local-tx.xml", false);
cache.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
+ configure(cache.getConfiguration());
cache.start();
rootNode = cache.getRoot();
tm = cache.getTransactionManager();
@@ -60,6 +62,11 @@
TestingUtil.killCaches(cache);
}
+ protected void configure(Configuration c)
+ {
+ // to be overridden
+ }
+
@Test(groups = {"functional"})
public void testBasicMove()
{
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java 2008-07-01 13:58:17 UTC (rev 6143)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeReplicatedMoveTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -45,6 +45,7 @@
cache1.getConfiguration().setSyncCommitPhase(true);
cache1.getConfiguration().setSyncRollbackPhase(true);
cache1.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
+ configure(cache1.getConfiguration());
cache1.start();
rootNode = cache1.getRoot();
tm = cache1.getTransactionManager();
@@ -54,6 +55,7 @@
cache2.getConfiguration().setSyncCommitPhase(true);
cache2.getConfiguration().setSyncRollbackPhase(true);
cache2.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
+ configure(cache2.getConfiguration());
cache2.start();
}
@@ -65,6 +67,11 @@
if (rootNode != null) rootNode = null;
}
+ protected void configure(Configuration c)
+ {
+ // to be overridden
+ }
+
public void testReplicatability()
{
nodeA = rootNode.addChild(A);
Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-07-01 13:58:17 UTC (rev 6143)
+++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -12,6 +12,7 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -44,6 +45,9 @@
cache1.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
cache2.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
+ configure(cache1.getConfiguration());
+ configure(cache2.getConfiguration());
+
cache1.start();
cache2.start();
@@ -58,6 +62,11 @@
if (cache2 != null) cache2.stop();
}
+ protected void configure(Configuration c)
+ {
+ // to be overridden
+ }
+
public void testBasicOperation()
{
assertClusterSize("Should only be 2 caches in the cluster!!!", 2);
Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java 2008-07-01 13:58:17 UTC (rev 6143)
+++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -12,6 +12,7 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.Node;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -53,6 +54,9 @@
cache1.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
cache2.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
+ configure(cache1.getConfiguration());
+ configure(cache2.getConfiguration());
+
cache1.start();
cache2.start();
@@ -102,6 +106,11 @@
System.out.println("*** Finished tearDown()");
}
+ protected void configure(Configuration c)
+ {
+ // to be overridden
+ }
+
private TransactionManager beginTransaction(Cache<Object, Object> cache) throws NotSupportedException, SystemException
{
TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
Deleted: core/trunk/src/test/java/org/jboss/cache/api/mvcc/CacheAPIMVCCTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/CacheAPIMVCCTest.java 2008-07-01 13:58:17 UTC (rev 6143)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/CacheAPIMVCCTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -1,20 +0,0 @@
-package org.jboss.cache.api.mvcc;
-
-import org.jboss.cache.api.CacheAPITest;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.testng.annotations.Test;
-
-
-/**
- * MVCC version of {@link org.jboss.cache.api.CacheAPITest}
- */
-@Test(groups = {"functional", "mvcc"})
-public class CacheAPIMVCCTest extends CacheAPITest
-{
- @Override
- protected NodeLockingScheme getNodeLockingScheme()
- {
- return NodeLockingScheme.MVCC;
- }
-
-}
\ No newline at end of file
Deleted: core/trunk/src/test/java/org/jboss/cache/api/mvcc/DeletedChildResurrectionMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/DeletedChildResurrectionMvccTest.java 2008-07-01 13:58:17 UTC (rev 6143)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/DeletedChildResurrectionMvccTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -1,14 +0,0 @@
-package org.jboss.cache.api.mvcc;
-
-import org.jboss.cache.api.DeletedChildResurrectionTest;
-import org.jboss.cache.config.Configuration.NodeLockingScheme;
-import org.testng.annotations.Test;
-
-@Test(groups = {"functional", "mvcc"})
-public class DeletedChildResurrectionMvccTest extends DeletedChildResurrectionTest
-{
- public DeletedChildResurrectionMvccTest()
- {
- nodeLockingScheme = NodeLockingScheme.MVCC;
- }
-}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheAPIMVCCTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheAPIMVCCTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/CacheAPIMVCCTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,29 @@
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.jboss.cache.api.CacheAPITest;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+
+/**
+ * MVCC version of {@link org.jboss.cache.api.CacheAPITest}
+ */
+@Test(groups = {"functional", "mvcc"})
+public class CacheAPIMVCCTest extends CacheAPITest
+{
+ @Override
+ protected void configure(Configuration c)
+ {
+ super.configure(c);
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
+
+ @Override
+ protected NodeLockingScheme getNodeLockingScheme()
+ {
+ return NodeLockingScheme.MVCC;
+ }
+
+}
\ No newline at end of file
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/DeletedChildResurrectionMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/DeletedChildResurrectionMvccTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/DeletedChildResurrectionMvccTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,22 @@
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.jboss.cache.api.DeletedChildResurrectionTest;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class DeletedChildResurrectionMvccTest extends DeletedChildResurrectionTest
+{
+ public DeletedChildResurrectionMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+
+ @Override
+ protected void configure(Configuration c)
+ {
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeAPIMVCCTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,45 @@
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.jboss.cache.api.NodeAPITest;
+import org.jboss.cache.config.Configuration;
+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.jboss.cache.lock.IsolationLevel;
+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;
+ }
+
+ @Override
+ protected void configure(Configuration c)
+ {
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
+
+ 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
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeMoveMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeMoveMvccTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeMoveMvccTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.jboss.cache.api.NodeMoveAPITest;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class NodeMoveMvccTest extends NodeMoveAPITest
+{
+ public NodeMoveMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+
+ @Override
+ protected void configure(Configuration c)
+ {
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
+}
\ No newline at end of file
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeReplicatedMoveMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeReplicatedMoveMvccTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/NodeReplicatedMoveMvccTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.jboss.cache.api.NodeReplicatedMoveTest;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class NodeReplicatedMoveMvccTest extends NodeReplicatedMoveTest
+{
+ public NodeReplicatedMoveMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+
+ @Override
+ protected void configure(Configuration c)
+ {
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
+}
\ No newline at end of file
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/SyncReplMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/SyncReplMvccTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/SyncReplMvccTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,22 @@
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.jboss.cache.api.SyncReplTest;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "jgroups", "mvcc"})
+public class SyncReplMvccTest extends SyncReplTest
+{
+ public SyncReplMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+
+ @Override
+ protected void configure(Configuration c)
+ {
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
+}
\ No newline at end of file
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/SyncReplTxMvccTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/SyncReplTxMvccTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/SyncReplTxMvccTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,22 @@
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.jboss.cache.api.SyncReplTxTest;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "jgroups", "transaction", "mvcc"})
+public class SyncReplTxMvccTest extends SyncReplTxTest
+{
+ public SyncReplTxMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+
+ @Override
+ protected void configure(Configuration c)
+ {
+ c.setIsolationLevel(IsolationLevel.READ_COMMITTED);
+ }
+}
\ No newline at end of file
Copied: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheAPIMVCCTest.java (from rev 6142, core/trunk/src/test/java/org/jboss/cache/api/mvcc/CacheAPIMVCCTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheAPIMVCCTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheAPIMVCCTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,29 @@
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.jboss.cache.api.CacheAPITest;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+
+/**
+ * MVCC version of {@link org.jboss.cache.api.CacheAPITest}
+ */
+@Test(groups = {"functional", "mvcc"})
+public class CacheAPIMVCCTest extends CacheAPITest
+{
+ @Override
+ protected void configure(Configuration c)
+ {
+ super.configure(c);
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ }
+
+ @Override
+ protected NodeLockingScheme getNodeLockingScheme()
+ {
+ return NodeLockingScheme.MVCC;
+ }
+
+}
\ No newline at end of file
Property changes on: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/CacheAPIMVCCTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/DeletedChildResurrectionMvccTest.java (from rev 6142, core/trunk/src/test/java/org/jboss/cache/api/mvcc/DeletedChildResurrectionMvccTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/DeletedChildResurrectionMvccTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/DeletedChildResurrectionMvccTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,22 @@
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.jboss.cache.api.DeletedChildResurrectionTest;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class DeletedChildResurrectionMvccTest extends DeletedChildResurrectionTest
+{
+ public DeletedChildResurrectionMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+
+ @Override
+ protected void configure(Configuration c)
+ {
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ }
+}
Copied: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java (from rev 6142, core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeAPIMVCCTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,45 @@
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.jboss.cache.api.NodeAPITest;
+import org.jboss.cache.config.Configuration;
+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.jboss.cache.lock.IsolationLevel;
+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;
+ }
+
+ @Override
+ protected void configure(Configuration c)
+ {
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ }
+
+ 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
Property changes on: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeAPIMVCCTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeMoveMvccTest.java (from rev 6142, core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeMoveMvccTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeMoveMvccTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeMoveMvccTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.jboss.cache.api.NodeMoveAPITest;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class NodeMoveMvccTest extends NodeMoveAPITest
+{
+ public NodeMoveMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+
+ @Override
+ protected void configure(Configuration c)
+ {
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ }
+}
Copied: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeReplicatedMoveMvccTest.java (from rev 6142, core/trunk/src/test/java/org/jboss/cache/api/mvcc/NodeReplicatedMoveMvccTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeReplicatedMoveMvccTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/NodeReplicatedMoveMvccTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.jboss.cache.api.NodeReplicatedMoveTest;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class NodeReplicatedMoveMvccTest extends NodeReplicatedMoveTest
+{
+ public NodeReplicatedMoveMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+
+ @Override
+ protected void configure(Configuration c)
+ {
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ }
+}
Copied: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/SyncReplMvccTest.java (from rev 6142, core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplMvccTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/SyncReplMvccTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/SyncReplMvccTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,22 @@
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.jboss.cache.api.SyncReplTest;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "jgroups", "mvcc"})
+public class SyncReplMvccTest extends SyncReplTest
+{
+ public SyncReplMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+
+ @Override
+ protected void configure(Configuration c)
+ {
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ }
+}
Copied: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/SyncReplTxMvccTest.java (from rev 6142, core/trunk/src/test/java/org/jboss/cache/api/mvcc/SyncReplTxMvccTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/SyncReplTxMvccTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/SyncReplTxMvccTest.java 2008-07-01 14:27:02 UTC (rev 6144)
@@ -0,0 +1,22 @@
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.jboss.cache.api.SyncReplTxTest;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.lock.IsolationLevel;
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "jgroups", "transaction", "mvcc"})
+public class SyncReplTxMvccTest extends SyncReplTxTest
+{
+ public SyncReplTxMvccTest()
+ {
+ nodeLockingScheme = NodeLockingScheme.MVCC;
+ }
+
+ @Override
+ protected void configure(Configuration c)
+ {
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ }
+}
16 years, 6 months
JBoss Cache SVN: r6143 - in core/trunk/src/main/java/org/jboss/cache: interceptors and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-01 09:58:17 -0400 (Tue, 01 Jul 2008)
New Revision: 6143
Modified:
core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
Log:
MVCC-RC
Modified: core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-01 13:42:59 UTC (rev 6142)
+++ core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-01 13:58:17 UTC (rev 6143)
@@ -18,6 +18,7 @@
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockStrategyFactory;
import org.jboss.cache.mvcc.InternalNode;
+import org.jboss.cache.mvcc.NodeReference;
import org.jboss.cache.mvcc.NullMarkerNode;
import org.jboss.cache.mvcc.ReadCommittedNode;
import org.jboss.cache.mvcc.RepeatableReadNode;
@@ -126,9 +127,17 @@
public NodeSPI<K, V> createDataNode(Object childName, Fqn fqn, NodeSPI<K, V> parent, Map<K, V> data, boolean mapSafe)
{
UnversionedNode un = useVersionedNode ? new VersionedNode<K, V>(fqn, parent, data, cache) : new UnversionedNode<K, V>(childName, fqn, data, cache);
+
+ // it is internal nodes that are wrapped in NIDs.
+ InternalNode in = un;
+ if (useVersionedNode && !useRepeatableRead)
+ {
+ // this is MVCC with READ_COMMITTED. Make sure we use node references.
+ in = new NodeReference(un);
+ }
// always assume that new nodes do not have data loaded
un.setDataLoaded(false);
- NodeInvocationDelegate<K, V> nid = new NodeInvocationDelegate(un);
+ NodeInvocationDelegate<K, V> nid = new NodeInvocationDelegate(in);
// Too slow to have these autowired for now. Look at manually wiring them.
nid.initialize(configuration, invocationContextContainer, componentRegistry, interceptorChain);
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-01 13:42:59 UTC (rev 6142)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-07-01 13:58:17 UTC (rev 6143)
@@ -141,7 +141,7 @@
ctx.putLookedUpNode(fqn, node);
}
- if (needToCopyNode && !node.isChanged())
+ if (needToCopyNode && node != null && !node.isChanged()) // node could be null if using read-committed
{
node.copyNodeForUpdate(dataContainer, allowWriteSkew, ctx, nodeFactory, lockParentForChildInsertRemove);
}
@@ -366,16 +366,18 @@
for (int i = fqnsToUnlock.length - 1; i > -1; i--)
{
ReadCommittedNode rcn = (ReadCommittedNode) ctx.lookUpNode(fqnsToUnlock[i]);
- if (commit)
+ if (rcn != null) // could be null with read-committed
{
- // for each of these, swap refs
-// rcn.copyNodeForUpdate(dataContainer, allowWriteSkew);
- rcn.commitUpdate(dataContainer, nodeFactory);
+ if (commit)
+ {
+ // for each of these, swap refs
+ rcn.commitUpdate(dataContainer, nodeFactory);
+ }
+ else
+ {
+ rcn.rollbackUpdate();
+ }
}
- else
- {
- rcn.rollbackUpdate();
- }
// and then unlock
lockManager.unlock(fqnsToUnlock[i], owner);
}
16 years, 6 months
JBoss Cache SVN: r6142 - in core/trunk/src: main/java/org/jboss/cache/commands/read and 4 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-01 09:42:59 -0400 (Tue, 01 Jul 2008)
New Revision: 6142
Added:
core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java
Modified:
core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java
Log:
MVCC-RR
Modified: core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-01 13:42:35 UTC (rev 6141)
+++ core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -18,6 +18,7 @@
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockStrategyFactory;
import org.jboss.cache.mvcc.InternalNode;
+import org.jboss.cache.mvcc.NullMarkerNode;
import org.jboss.cache.mvcc.ReadCommittedNode;
import org.jboss.cache.mvcc.RepeatableReadNode;
import org.jboss.cache.optimistic.TransactionWorkspace;
@@ -41,6 +42,7 @@
private CommandsFactory commandsFactory;
private LockStrategyFactory lockStrategyFactory;
private boolean useRepeatableRead;
+ private static final NullMarkerNode NULL_MARKER = new NullMarkerNode(null);
@Override
protected <T> T construct(Class<T> componentType)
@@ -50,13 +52,16 @@
/**
* Creates an MVCC wrapped node - either a {@link org.jboss.cache.mvcc.ReadCommittedNode} or it's subclass, a
- * {@link org.jboss.cache.mvcc.RepeatableReadNode} based on cache configuration.
+ * {@link org.jboss.cache.mvcc.RepeatableReadNode} based on cache configuration. If a null is passed in as the InternalNode,
+ * this method will return a special {@link org.jboss.cache.mvcc.NullMarkerNode} instance if using repeatable read,
+ * or a null if read committed.
*
* @param node internal node to wrap.
* @return a ReadCommittedNode
*/
public ReadCommittedNode createMvccNode(InternalNode node)
{
+ if (node == null) return useRepeatableRead ? NULL_MARKER : null;
ReadCommittedNode rcn = useRepeatableRead ? new RepeatableReadNode(node) : new ReadCommittedNode(node);
rcn.initialize(configuration, invocationContextContainer, componentRegistry, interceptorChain);
rcn.injectDependencies(cache);
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java 2008-07-01 13:42:35 UTC (rev 6141)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -42,7 +42,7 @@
public Object perform(InvocationContext ctx)
{
NodeSPI n = fqn == null ? null : ctx.lookUpNode(fqn);
- if (n == null) return null;
+ if (n == null || n.isDeleted()) return null;
Map childrenMap = n.getChildrenMapDirect();
if (childrenMap == null || childrenMap.isEmpty()) return Collections.emptySet();
Set childNames = new HashSet();
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java 2008-07-01 13:42:35 UTC (rev 6141)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -36,7 +36,7 @@
public Object perform(InvocationContext ctx)
{
NodeSPI n = ctx.lookUpNode(fqn);
- if (n == null) return null;
+ if (n == null || n.isDeleted()) return null;
return new MapCopy(n.getDataDirect());
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-07-01 13:42:35 UTC (rev 6141)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -60,9 +60,14 @@
NodeSPI n = ctx.lookUpNode(fqn);
if (n == null)
{
- log.trace("node not found");
+ if (trace) log.trace("Node not found");
return null;
}
+ if (n.isDeleted())
+ {
+ if (trace) log.trace("Node has been deleted!");
+ return null;
+ }
if (sendNodeEvent) notifier.notifyNodeVisited(fqn, true, ctx);
Object result = n.getDirect(key);
if (sendNodeEvent) notifier.notifyNodeVisited(fqn, false, ctx);
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java 2008-07-01 13:42:35 UTC (rev 6141)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -37,7 +37,7 @@
public Object perform(InvocationContext ctx)
{
NodeSPI n = ctx.lookUpNode(fqn);
- if (n == null) return null;
+ if (n == null || n.isDeleted()) return null;
return n.getKeysDirect();
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java 2008-07-01 13:42:35 UTC (rev 6141)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -1,6 +1,7 @@
package org.jboss.cache.commands.read;
import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.invocation.InvocationContext;
@@ -34,7 +35,9 @@
*/
public Object perform(InvocationContext ctx)
{
- return ctx.lookUpNode(fqn);
+ NodeSPI node = ctx.lookUpNode(fqn);
+ if (node != null && node.isDeleted()) return null;
+ return node;
}
public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-07-01 13:42:35 UTC (rev 6141)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -134,6 +134,7 @@
parentNode.setChildrenLoaded(false);
}
node.setValid(false, false);
+ node.markAsDeleted(true, false);
return true;
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-07-01 13:42:35 UTC (rev 6141)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -87,7 +87,7 @@
// the actual move algorithm.
// ctx *could* be null if this is a rollback!!! Sucks big time.
NodeSPI newParent = ctx == null ? dataContainer.peek(newParentFqn) : ctx.lookUpNode(newParentFqn);
- if (newParent == null)
+ if (newParent == null || newParent.isDeleted())
{
throw new NodeNotExistsException("New parent node " + newParentFqn + " does not exist when attempting to move node!!");
}
@@ -95,7 +95,7 @@
// ctx *could* be null if this is a rollback!!! Sucks big time.
NodeSPI node = ctx == null ? dataContainer.peek(toMoveFqn) : ctx.lookUpNode(toMoveFqn);
- if (node == null)
+ if (node == null || node.isDeleted())
{
throw new NodeNotExistsException("Node " + toMoveFqn + " does not exist when attempting to move node!!");
}
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 13:42:35 UTC (rev 6141)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -46,7 +46,7 @@
// Find the node
targetNode = peekVersioned(ctx);
- if (targetNode == null)
+ if (targetNode == null || targetNode.isDeleted())
{
if (trace) log.trace("node " + fqn + " not found");
return false;
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-01 13:42:35 UTC (rev 6141)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -31,6 +31,7 @@
import org.jboss.cache.invocation.NodeInvocationDelegate;
import org.jboss.cache.lock.LockManager;
import static org.jboss.cache.lock.LockType.WRITE;
+import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.mvcc.InternalNode;
import org.jboss.cache.mvcc.ReadCommittedNode;
@@ -61,6 +62,7 @@
LockManager lockManager;
DataContainer dataContainer;
NodeFactory nodeFactory;
+ private long defaultLockAcquisitionTimeout;
@Inject
public void setDependencies(LockManager lockManager, DataContainer dataContainer, NodeFactory nodeFactory)
@@ -75,6 +77,7 @@
{
allowWriteSkew = configuration.isAllowWriteSkew();
lockParentForChildInsertRemove = configuration.isLockParentForChildInsertRemove();
+ defaultLockAcquisitionTimeout = configuration.getLockAcquisitionTimeout();
}
@Override
@@ -112,23 +115,38 @@
{
if (lockParentForChildInsertRemove || (parent != null && parent.isLockForChildInsertRemove()))
{
- // lock parent
- lockManager.lockAndRecord(parentFqn, WRITE, ctx);
+ boolean needToCopyNode = lock(ctx, parentFqn);
- // retrieve again from the dataContainer in case we have a race, and add to the context
- getWrappedNode(ctx, parentFqn, true, false, false);
+ // Ensure the node is in the context.
+ putNodeInContext(ctx, parentFqn, needToCopyNode);
}
}
}
- lockManager.lockAndRecord(nodeFqn, WRITE, ctx); // lock node.
+ boolean needToCopyNode = lock(ctx, nodeFqn);
- // now wrap and add to the context
- getWrappedNode(ctx, nodeFqn, true, false, false);
+ // Ensure the node is in the context.
+ putNodeInContext(ctx, nodeFqn, needToCopyNode);
return invokeNextInterceptor(ctx, command);
}
+ private void putNodeInContext(InvocationContext ctx, Fqn fqn, boolean needToCopyNode)
+ {
+ ReadCommittedNode node = (ReadCommittedNode) ctx.lookUpNode(fqn);
+ if (node == null)
+ {
+ InternalNode in = dataContainer.peekInternalNode(fqn, false);
+ node = nodeFactory.createMvccNode(in);
+ ctx.putLookedUpNode(fqn, node);
+ }
+
+ if (needToCopyNode && !node.isChanged())
+ {
+ node.copyNodeForUpdate(dataContainer, allowWriteSkew, ctx, nodeFactory, lockParentForChildInsertRemove);
+ }
+ }
+
@Override
public Object handleClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
{
@@ -158,7 +176,8 @@
// retrieve again from the dataContainer in case we have a race, and add to the context
ReadCommittedNode rcn = (ReadCommittedNode) getWrappedNode(ctx, parentFqn, true, false, false);
- if (rcn != null) rcn.copyNodeForUpdate(dataContainer, allowWriteSkew);
+ if (rcn != null)
+ rcn.copyNodeForUpdate(dataContainer, allowWriteSkew, ctx, nodeFactory, lockParentForChildInsertRemove);
}
}
}
@@ -184,7 +203,7 @@
ReadCommittedNode rcn = (ReadCommittedNode) getWrappedNode(ctx, fqn, true, false, true);
if (rcn != null)
{
- rcn.copyNodeForUpdate(dataContainer, allowWriteSkew);
+ rcn.copyNodeForUpdate(dataContainer, allowWriteSkew, ctx, nodeFactory, lockParentForChildInsertRemove);
if (isRecursive)
{
@@ -376,11 +395,8 @@
{
// simple implementation. Peek the node, wrap it, put wrapped node in the context.
InternalNode node = dataContainer.peekInternalNode(f, false);
- if (node != null)
- {
- NodeSPI wrapped = nodeFactory.createMvccNode(node);
- ctx.putLookedUpNode(f, wrapped);
- }
+ NodeSPI wrapped = nodeFactory.createMvccNode(node);
+ if (wrapped != null) ctx.putLookedUpNode(f, wrapped);
}
}
return invokeNextInterceptor(ctx, command);
@@ -437,15 +453,14 @@
protected NodeSPI getWrappedNode(InvocationContext context, Fqn fqn, boolean lockForWriting, boolean createIfAbsent, boolean includeInvalidNodes) throws InterruptedException
{
ReadCommittedNode n = (ReadCommittedNode) context.lookUpNode(fqn);
+ if (createIfAbsent && n != null && n.isNullNode()) n = null;
if (n != null)
{
// acquire lock if needed
- if (lockForWriting && !isLocked(context, fqn))
+ if (lockForWriting && lock(context, fqn))
{
- lockManager.lockAndRecord(fqn, WRITE, context);
// create a copy of the underlying node
-
- n.copyNodeForUpdate(dataContainer, allowWriteSkew);
+ n.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory, lockParentForChildInsertRemove);
}
if (trace) log.trace("Retrieving wrapped node " + fqn);
return n;
@@ -457,14 +472,14 @@
{
// do we need a lock?
boolean needToCopy = false;
- if (lockForWriting && !isLocked(context, fqn))
+ if (lockForWriting && lock(context, fqn))
{
- lockManager.lockAndRecord(fqn, WRITE, context);
needToCopy = true;
}
ReadCommittedNode wrapped = nodeFactory.createMvccNode(in);
context.putLookedUpNode(fqn, wrapped);
- if (needToCopy) wrapped.copyNodeForUpdate(dataContainer, allowWriteSkew);
+ if (needToCopy)
+ wrapped.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory, lockParentForChildInsertRemove);
return wrapped;
}
@@ -477,33 +492,48 @@
if (lockParentForChildInsertRemove || parent.isLockForChildInsertRemove())
{
// get a lock on the parent.
- if (!isLocked(context, parentFqn))
+ if (lock(context, parentFqn))
{
- lockManager.lockAndRecord(parentFqn, WRITE, context);
ReadCommittedNode parentRCN = (ReadCommittedNode) context.lookUpNode(parentFqn);
- parentRCN.copyNodeForUpdate(dataContainer, allowWriteSkew);
+ parentRCN.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory, lockParentForChildInsertRemove);
}
}
// now to lock and create the node.
- if (!isLocked(context, fqn)) lockManager.lockAndRecord(fqn, WRITE, context);
+ lock(context, fqn);
+
NodeSPI temp = parent.getOrCreateChild(fqn.getLastElement(), context.getGlobalTransaction());
in = (InternalNode) ((NodeInvocationDelegate) temp).getDelegationTarget();
ReadCommittedNode wrapped = nodeFactory.createMvccNode(in);
context.putLookedUpNode(fqn, wrapped);
- wrapped.copyNodeForUpdate(dataContainer, allowWriteSkew);
+ wrapped.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory, lockParentForChildInsertRemove);
return wrapped;
}
return null;
}
- protected boolean isLocked(InvocationContext ctx, Fqn fqn)
+ /**
+ * Attempts to lock a node if the lock isn't already held in the current scope.
+ *
+ * @param ctx context
+ * @param fqn Fqn to lock
+ * @return true if a lock was needed and acquired, false if it didn't need to acquire the lock (i.e., lock was already held)
+ * @throws InterruptedException
+ * @throws TimeoutException if we are unable to acquire the lock after a specified timeout.
+ */
+ protected boolean lock(InvocationContext ctx, Fqn fqn) throws InterruptedException
{
// don't EVER use lockManager.isLocked() since with lock striping it may be the case that we hold the relevant
// lock which may be shared with another Fqn that we have a lock for already.
// nothing wrong, just means that we fail to record the lock. And that is a problem.
// Better to check our records and lock again if necessary.
- return ctx.getLocks().contains(fqn);
+ if (!ctx.getLocks().contains(fqn))
+ {
+ if (!lockManager.lockAndRecord(fqn, WRITE, ctx))
+ throw new TimeoutException("Unable to acquire lock on Fqn [" + fqn + "] after [" + ctx.getLockAcquisitionTimeout(defaultLockAcquisitionTimeout) + "] milliseconds!");
+ return true;
+ }
+ return false;
}
}
Added: core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/NullMarkerNode.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -0,0 +1,43 @@
+package org.jboss.cache.mvcc;
+
+import org.jboss.cache.DataContainer;
+import org.jboss.cache.NodeFactory;
+import org.jboss.cache.invocation.InvocationContext;
+
+/**
+ * A marker node to represent a null node for repeatable read
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public class NullMarkerNode extends RepeatableReadNode
+{
+ public NullMarkerNode(InternalNode node)
+ {
+ super(node);
+ }
+
+ @Override
+ public boolean isNullNode()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isDeleted()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isValid()
+ {
+ return false;
+ }
+
+ @Override
+ public void copyNodeForUpdate(DataContainer d, boolean b, InvocationContext ctx, NodeFactory nodeFactory, boolean lockParent)
+ {
+ // no op
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-01 13:42:35 UTC (rev 6141)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -2,6 +2,7 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.NodeFactory;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.NodeInvocationDelegate;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DefaultDataVersion;
@@ -22,8 +23,13 @@
super(node);
}
- public void copyNodeForUpdate(DataContainer container, boolean ignoreWriteSkew)
+ public boolean isNullNode()
{
+ return false;
+ }
+
+ public void copyNodeForUpdate(DataContainer container, boolean allowWriteSkew, InvocationContext ctx, NodeFactory nodeFactory, boolean lockParent)
+ {
changed = true;
backup = node;
node = backup.copy();
@@ -59,4 +65,14 @@
backup = null;
changed = false;
}
+
+ public boolean isChanged()
+ {
+ return changed;
+ }
+
+ public void setChanged(boolean changed)
+ {
+ this.changed = changed;
+ }
}
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 13:42:35 UTC (rev 6141)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -3,6 +3,7 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeSPI;
+import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DataVersioningException;
import org.jboss.cache.optimistic.DefaultDataVersion;
@@ -21,7 +22,7 @@
}
@Override
- public void copyNodeForUpdate(DataContainer container, boolean ignoreWriteSkew)
+ public void copyNodeForUpdate(DataContainer container, boolean allowWriteSkew, InvocationContext ctx, NodeFactory nodeFactory, boolean lockParent)
{
// mark node as changed.
changed = true;
@@ -29,9 +30,11 @@
// check for write skew.
NodeSPI underlyingNode = container.peek(getFqn(), false, true); // even check for invalid nodes. we should check tombstones too.
DataVersion underlyingNodeVersion = underlyingNode == null ? null : underlyingNode.getVersion();
- if (!ignoreWriteSkew && underlyingNode != null && !node.getVersion().equals(underlyingNodeVersion))
+ if (!allowWriteSkew && underlyingNode != null && !node.getVersion().equals(underlyingNodeVersion))
{
- throw new DataVersioningException("Detected write skew. Attempting to overwrite version " + node.getVersion() + " but current version has progressed to " + 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();
+ if (log.isWarnEnabled()) log.warn(errormsg + ". Unable to copy node for update.");
+ throw new DataVersioningException(errormsg);
}
// make a backup copy
@@ -43,17 +46,12 @@
DataVersion newVersion = ((DefaultDataVersion) node.getVersion()).increment();
node.setVersion(newVersion);
- // update parent nodes references - May not be necessary, we could just make sure we don't overwrite child maps when
- // updateNode() runs.
-
-// if (!getFqn().isRoot())
-// {
-// RepeatableReadNode parent = (RepeatableReadNode) ctx.lookUpNode(getFqn().getParent());
-// if (parent.changed)
-// {
-// parent.addChildDirect();
-// }
-// }
+ // if the parent is in the context make sure the parent has a ref to the copy now.
+ if (!getFqn().isRoot() && lockParent)
+ {
+ NodeSPI parent = ctx.lookUpNode(getFqn().getParent());
+ if (parent != null) parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(node));
+ }
}
@Override
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java 2008-07-01 13:42:35 UTC (rev 6141)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java 2008-07-01 13:42:59 UTC (rev 6142)
@@ -17,8 +17,10 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -51,6 +53,9 @@
cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.getConfiguration().setLockParentForChildInsertRemove(lockParentForInsertRemove);
cache.getConfiguration().setIsolationLevel(repeatableRead ? IsolationLevel.REPEATABLE_READ : IsolationLevel.READ_COMMITTED);
+ cache.getConfiguration().setAllowWriteSkew(allowWriteSkew);
+ // reduce lock acquisition timeout so this doesn't take forever to run
+ cache.getConfiguration().setLockAcquisitionTimeout(200); // 200 ms
cache.start();
lockManager = TestingUtil.extractComponentRegistry(cache).getComponent(LockManager.class);
icc = TestingUtil.extractComponentRegistry(cache).getComponent(InvocationContextContainer.class);
@@ -79,7 +84,7 @@
protected void assertNoLocks()
{
LockContainer lc = (LockContainer) TestingUtil.extractField(lockManager, "lockContainer");
- assert lc.getNumLocksHeld() == 0 : "Stale locks exist!" + lockManager.printLockInfo();
+ assert lc.getNumLocksHeld() == 0 : "Stale locks exist! NumLocksHeld is " + lc.getNumLocksHeld() + " and lock info is " + lockManager.printLockInfo();
assert icc.get().getLocks().isEmpty() : "Stale (?) locks recorded! " + icc.get().getLocks();
}
@@ -133,12 +138,13 @@
assertLocked(A);
assertLocked(AB);
assertNotLocked(ABC);
+ assert "v".equals(cache.get(AB, "k"));
tm.commit();
-
+ assert "v".equals(cache.get(AB, "k"));
assertNoLocks();
tm.begin();
- assert cache.get(AB, "k").equals("v");
+ assert "v".equals(cache.get(AB, "k"));
assertNotLocked(Fqn.ROOT);
assertNotLocked(A);
assertNotLocked(AB);
@@ -435,7 +441,7 @@
}
catch (TimeoutException expected)
{
-
+// expected.printStackTrace(); // for debugging
}
tm.commit();
tm.resume(t1);
@@ -496,15 +502,19 @@
final Set<Exception> w2exceptions = new HashSet<Exception>();
final CountDownLatch w1Signal = new CountDownLatch(1);
final CountDownLatch w2Signal = new CountDownLatch(1);
+ final CountDownLatch threadSignal = new CountDownLatch(2);
- Thread w1 = new Thread()
+ Thread w1 = new Thread("Writer-1")
{
public void run()
{
+ boolean didCoundDown = false;
try
{
tm.begin();
assert "v".equals(cache.get(AB, "k"));
+ threadSignal.countDown();
+ didCoundDown = true;
w1Signal.await();
cache.put(AB, "k", "v2");
tm.commit();
@@ -513,17 +523,24 @@
{
w1exceptions.add(e);
}
+ finally
+ {
+ if (!didCoundDown) threadSignal.countDown();
+ }
}
};
- Thread w2 = new Thread()
+ Thread w2 = new Thread("Writer-2")
{
public void run()
{
+ boolean didCoundDown = false;
try
{
tm.begin();
assert "v".equals(cache.get(AB, "k"));
+ threadSignal.countDown();
+ didCoundDown = true;
w2Signal.await();
cache.put(AB, "k", "v3");
tm.commit();
@@ -531,13 +548,30 @@
catch (Exception e)
{
w2exceptions.add(e);
+ // the exception will be thrown when doing a cache.put(). We should make sure we roll back the tx to release locks.
+ if (!allowWriteSkew)
+ {
+ try
+ {
+ tm.rollback();
+ }
+ catch (SystemException e1)
+ {
+ // do nothing.
+ }
+ }
}
+ finally
+ {
+ if (!didCoundDown) threadSignal.countDown();
+ }
}
};
w1.start();
w2.start();
+ threadSignal.await();
// now. both txs have read.
// let tx1 start writing
w1Signal.countDown();
@@ -548,20 +582,30 @@
if (allowWriteSkew)
{
- assert "v3".equals(cache.get(AB, "k")) : "W2 should have overwritten W1's work!";
// should have no exceptions!!
+ throwExceptions(w1exceptions, w2exceptions);
assert w2exceptions.size() == 0;
assert w1exceptions.size() == 0;
+ assert "v3".equals(cache.get(AB, "k")) : "W2 should have overwritten W1's work!";
}
else
{
- assert "v2".equals(cache.get(AB, "k")) : "W2 should NOT have overwritten W1's work!";
// there should be a single exception from w2.
assert w2exceptions.size() == 1;
+ throwExceptions(w1exceptions);
assert w1exceptions.size() == 0;
+ assert "v2".equals(cache.get(AB, "k")) : "W2 should NOT have overwritten W1's work!";
}
assertNoLocks();
}
}
+
+ protected void throwExceptions(Collection<Exception>... exceptions) throws Exception
+ {
+ for (Collection<Exception> ce : exceptions)
+ {
+ for (Exception e : ce) throw e;
+ }
+ }
}
16 years, 6 months
JBoss Cache SVN: r6141 - core/trunk/src/main/java/org/jboss/cache/invocation.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-01 09:42:35 -0400 (Tue, 01 Jul 2008)
New Revision: 6141
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
Log:
temp solution to clean ctx
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-07-01 13:39:03 UTC (rev 6140)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-07-01 13:42:35 UTC (rev 6141)
@@ -65,10 +65,11 @@
*/
public void clearLookedUpNodes()
{
- if (mvccTCtx != null)
- mvccTCtx.clearLookedUpNodes();
- else
- lookedUpNodes.clear();
+ // TODO: see if we can reinstate common behaviour once we have the ICI calling ctx.reset() instead of ctx.clearLookedUpNodes()
+// if (mvccTCtx != null)
+// mvccTCtx.clearLookedUpNodes();
+// else
+ lookedUpNodes.clear();
}
/**
16 years, 6 months
JBoss Cache SVN: r6140 - in core/trunk/src: main/java/org/jboss/cache/invocation and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-01 09:39:03 -0400 (Tue, 01 Jul 2008)
New Revision: 6140
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java
Log:
Fixed wiping of context
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-07-01 13:33:42 UTC (rev 6139)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-07-01 13:39:03 UTC (rev 6140)
@@ -206,8 +206,10 @@
ctx.setCommand(null);
ctx.setMethodCall(null);
-
- ctx.reset();
+ // TODO: Calling ctx.reset() here breaks stuff. Check whether this is just becuse UTs expect stuff in the ctx or whether this really breaks functionality.
+// ctx.reset();
+ // instead, for now, just wipe contents of the looked up node map
+ ctx.clearLookedUpNodes();
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java 2008-07-01 13:33:42 UTC (rev 6139)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java 2008-07-01 13:39:03 UTC (rev 6140)
@@ -33,7 +33,7 @@
public void clearLookedUpNodes()
{
- throw new UnsupportedOperationException("Should not be called on legacy locking schemes!");
+ // no-op
}
public Map<Fqn, NodeSPI> getLookedUpNodes()
Modified: core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java 2008-07-01 13:33:42 UTC (rev 6139)
+++ core/trunk/src/test/java/org/jboss/cache/options/ForceWriteLockTest.java 2008-07-01 13:39:03 UTC (rev 6140)
@@ -6,8 +6,10 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.lock.LockType;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.AfterMethod;
@@ -22,7 +24,7 @@
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.0.0
*/
-@Test(groups = {"functional"})
+@Test(groups = {"functional", "pessimistic"})
public class ForceWriteLockTest
{
private CacheSPI<String, String> cache;
@@ -33,7 +35,8 @@
public void setUp()
{
Configuration c = new Configuration();
- c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ c.setNodeLockingScheme(NodeLockingScheme.PESSIMISTIC);
CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
cache = (CacheSPI<String, String>) instance.createCache(c);
tm = cache.getTransactionManager();
16 years, 6 months
JBoss Cache SVN: r6139 - core/trunk/src/test/java/org/jboss/cache/replicated.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-01 09:33:42 -0400 (Tue, 01 Jul 2008)
New Revision: 6139
Modified:
core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java
Log:
Should not set a new Option when resetting context
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2008-07-01 13:31:16 UTC (rev 6138)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2008-07-01 13:33:42 UTC (rev 6139)
@@ -12,7 +12,6 @@
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration.CacheMode;
-import org.jboss.cache.config.Option;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.invocation.CacheInvocationDelegate;
import org.jboss.cache.invocation.InvocationContext;
@@ -145,7 +144,6 @@
control = ctx.copy();
control.reset();
- control.setOptionOverrides(new Option());
assertEquals("Should be equal", control, ctx);
}
16 years, 6 months