JBoss Cache SVN: r6184 - in core/trunk/src/test/java/org/jboss/cache: loader and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-07 10:38:23 -0400 (Mon, 07 Jul 2008)
New Revision: 6184
Modified:
core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
Log:
Improved tests
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-07 10:53:27 UTC (rev 6183)
+++ core/trunk/src/test/java/org/jboss/cache/api/DeletedChildResurrectionTest.java 2008-07-07 14:38:23 UTC (rev 6184)
@@ -1,10 +1,9 @@
package org.jboss.cache.api;
-import org.jboss.cache.Cache;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
@@ -26,7 +25,7 @@
@Test(groups = {"functional", "pessimistic"})
public class DeletedChildResurrectionTest
{
- private Cache<Object, Object> cache;
+ private CacheSPI<Object, Object> cache;
private static final Fqn<String> A_B = Fqn.fromString("/a/b");
private static final Fqn<String> A = Fqn.fromString("/a");
private static final Fqn<String> A_C = Fqn.fromString("/a/c");
@@ -35,15 +34,20 @@
private static final String K2 = "k2";
private static final String V2 = "v2";
protected NodeLockingScheme nodeLockingScheme = NodeLockingScheme.PESSIMISTIC;
+ protected NodeSPI root;
+ protected TransactionManager txManager;
@BeforeMethod(alwaysRun = true)
public void setUp()
{
- cache = new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true), false);
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true), false);
cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+ cache.getConfiguration().setCacheLoaderConfig(null);
cache.getConfiguration().setNodeLockingScheme(nodeLockingScheme);
configure(cache.getConfiguration());
cache.start();
+ root = cache.getRoot();
+ txManager = cache.getTransactionManager();
}
@AfterMethod(alwaysRun = true)
@@ -59,11 +63,6 @@
public void testDeletedChildResurrection1() throws Exception
{
- CacheSPI spi = (CacheSPI) cache;
- Node<Object, Object> root = cache.getRoot();
-
- TransactionManager txManager = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
-
root.addChild(A_B).put(KEY, VALUE);
cache.put(A, "key", "value");
txManager.begin();
@@ -73,7 +72,7 @@
assert !root.hasChild(A_B);
assert null == cache.get(A, "key");
// do a peek to ensure the node really has been removed and not just marked for removal
- assert spi.peek(A_B, true, true) == null;
+ assert cache.peek(A_B, true, true) == null;
assert root.hasChild(A);
}
@@ -84,10 +83,6 @@
*/
public void testDeletedChildResurrection2() throws Exception
{
- Node<Object, Object> root = cache.getRoot();
-
- TransactionManager txManager = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
-
root.addChild(A_B).put(KEY, VALUE);
txManager.begin();
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-07-07 10:53:27 UTC (rev 6183)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-07-07 14:38:23 UTC (rev 6184)
@@ -13,6 +13,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.TransactionSetup;
+import org.jboss.cache.util.TestingUtil;
import org.jboss.util.stream.MarshalledValueInputStream;
import org.jboss.util.stream.MarshalledValueOutputStream;
import static org.testng.AssertJUnit.*;
@@ -87,28 +88,9 @@
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
{
- log.warn("********* Starting tearDown()");
cleanup();
- try
- {
- cache.removeNode(Fqn.ROOT);
- }
- catch (Exception e)
- {
- // do nothing
- }
-
- try
- {
- loader.remove(Fqn.ROOT);
- }
- catch (Exception e)
- {
- // do nothing
- }
-
- cache.stop();
- cache.destroy();
+ loader.remove(Fqn.ROOT);
+ TestingUtil.killCaches(cache);
}
protected void cleanup()
16 years, 5 months
JBoss Cache SVN: r6183 - in searchable/trunk: src/main/java/org/jboss/cache/search and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: navssurtani
Date: 2008-07-07 06:53:27 -0400 (Mon, 07 Jul 2008)
New Revision: 6183
Modified:
searchable/trunk/pom.xml
searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
Log:
Edited deps
Modified: searchable/trunk/pom.xml
===================================================================
--- searchable/trunk/pom.xml 2008-07-04 13:44:11 UTC (rev 6182)
+++ searchable/trunk/pom.xml 2008-07-07 10:53:27 UTC (rev 6183)
@@ -32,6 +32,7 @@
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-pojo</artifactId>
<version>2.2.0.CR5</version>
+ <scope>test</scope>
</dependency>
<dependency>
@@ -50,6 +51,7 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.4.2</version>
+ <scope>test</scope>
</dependency>
<dependency>
Modified: searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java
===================================================================
--- searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2008-07-04 13:44:11 UTC (rev 6182)
+++ searchable/trunk/src/main/java/org/jboss/cache/search/SearchableCacheFactory.java 2008-07-07 10:53:27 UTC (rev 6183)
@@ -4,7 +4,6 @@
import org.hibernate.search.cfg.Cfg;
import org.jboss.cache.Cache;
import org.jboss.cache.CacheStatus;
-import org.jboss.cache.pojo.PojoCache;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -56,7 +55,7 @@
// set classes in the cfg
SearchFactoryImpl searchFactory = new SearchFactoryImpl(cfg);
- boolean isPojoCache = c instanceof PojoCache;
+ // boolean isPojoCache = c instanceof PojoCache; keep this for later usage
// Step 2: Add cache listener to listen for events happening in the cache.
//SearchableListener listener = isPojoCache ? new SearchablePojoListener(searchFactory) : new SearchableCoreListener(searchFactory);
16 years, 5 months
JBoss Cache SVN: r6182 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 4 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-04 09:44:11 -0400 (Fri, 04 Jul 2008)
New Revision: 6182
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.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
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedLockParentTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadLockParentTest.java
Log:
pre-optimised, but correct. Very ugly with unnecessary casts and loops.
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-04 12:13:44 UTC (rev 6181)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java 2008-07-04 13:44:11 UTC (rev 6182)
@@ -1,5 +1,7 @@
package org.jboss.cache.commands.read;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
@@ -23,6 +25,8 @@
public class GetChildrenNamesCommand extends AbstractDataCommand
{
public static final int METHOD_ID = 23;
+ private static final Log log = LogFactory.getLog(GetChildrenNamesCommand.class);
+ private static final boolean trace = log.isTraceEnabled();
public GetChildrenNamesCommand()
{
@@ -65,22 +69,28 @@
{
Set<Object> childNames = fetchChildrenNames(ctx);
+ if (trace) log.trace("Got child name set as " + childNames);
// check for *new* children added.
+ boolean modified = false;
for (Map.Entry<Fqn, NodeSPI> n : ctx.getLookedUpNodes().entrySet())
{
- if (n.getKey().getParent().equals(fqn))
+ Fqn childFqn = n.getKey();
+ if (childFqn.getParent().equals(fqn))
{
- if (n.getValue().isDeleted())
+ NodeSPI childNode = n.getValue();
+ if (childNode.isDeleted())
{
- childNames.remove(n.getKey());
+ childNames.remove(childFqn.getLastElement());
+ modified = true;
}
- else if (((ReadCommittedNode) n.getValue()).isCreated())
+ else if (((ReadCommittedNode) childNode).isCreated())
{
- childNames.add(n.getKey().getLastElement());
+ childNames.add(childFqn.getLastElement());
+ modified = true;
}
}
}
-
+ if (trace && modified) log.trace("Modified child set to " + childNames);
return childNames;
}
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-04 12:13:44 UTC (rev 6181)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-07-04 13:44:11 UTC (rev 6182)
@@ -52,11 +52,6 @@
*/
public Object perform(InvocationContext ctx)
{
- if (trace)
- {
- log.trace(new StringBuilder("get(").append("\"").append(fqn).append("\", \"").append(key).append("\", \"").
- append(sendNodeEvent).append("\")"));
- }
NodeSPI n = ctx.lookUpNode(fqn);
if (n == null)
{
@@ -65,11 +60,12 @@
}
if (n.isDeleted())
{
- if (trace) log.trace("Node has been deleted!");
+ if (trace) log.trace("Node has been deleted and is of type " + n.getClass().getSimpleName());
return null;
}
if (sendNodeEvent) notifier.notifyNodeVisited(fqn, true, ctx);
Object result = n.getDirect(key);
+ if (trace) log.trace("Found value " + result);
if (sendNodeEvent) notifier.notifyNodeVisited(fqn, false, ctx);
return result;
}
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-04 12:13:44 UTC (rev 6181)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-07-04 13:44:11 UTC (rev 6182)
@@ -88,7 +88,9 @@
protected boolean doBeforeCall(InvocationContext ctx, VisitableCommand command)
{
if (ctx.getOptionOverrides().isSuppressLocking())
- throw new CacheException("Lock suppression not supported with MVCC!");
+ {
+ if (log.isWarnEnabled()) log.warn("Lock suppression not supported with MVCC!");
+ }
return true;
}
@@ -366,7 +368,6 @@
// clean up.
Fqn[] fqnsToUnlock = new Fqn[locks.size()];
fqnsToUnlock = locks.toArray(fqnsToUnlock);
- if (trace) log.trace("Releasing locks for thread " + Thread.currentThread() + " on fqns " + locks);
Object owner = Thread.currentThread();
for (int i = fqnsToUnlock.length - 1; i > -1; i--)
@@ -375,6 +376,7 @@
ReadCommittedNode rcn = (ReadCommittedNode) ctx.lookUpNode(fqnsToUnlock[i]);
if (rcn != null) rcn.commitUpdate(dataContainer, nodeFactory, ctx); // could be null with read-committed
// and then unlock
+ if (trace) log.trace("Releasing lock on [" + fqnsToUnlock[i] + "] for thread " + owner);
lockManager.unlock(fqnsToUnlock[i], owner);
}
ctx.clearLocks();
@@ -386,7 +388,6 @@
{
if (ctx.getTransaction() != null)
{
- if (trace) log.trace("Releasing locks for transaction " + ctx.getGlobalTransaction());
List<Fqn> locks;
if (!(locks = ctx.getTransactionContext().getLocks()).isEmpty())
{
@@ -411,6 +412,7 @@
}
}
// and then unlock
+ if (trace) log.trace("Releasing lock on [" + fqnsToUnlock[i] + "] for transaction " + owner);
lockManager.unlock(fqnsToUnlock[i], owner);
}
ctx.clearLocks();
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-04 12:13:44 UTC (rev 6181)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-04 13:44:11 UTC (rev 6182)
@@ -10,6 +10,10 @@
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DefaultDataVersion;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
/**
* Repeatable read would do a simple delegation to the underlying node.
*
@@ -21,6 +25,7 @@
protected volatile InternalNode backup;
protected boolean changed;
protected boolean created;
+ protected Set childrenAdded, childrenRemoved;
public ReadCommittedNode(InternalNode node)
{
@@ -63,9 +68,11 @@
protected void updateNode(DataContainer container, NodeFactory nf, InvocationContext ctx)
{
+ Fqn fqn = getFqn();
+ if (trace)
+ log.trace("Updating node [" + fqn + "]. deleted=" + isDeleted() + " valid=" + isValid() + " changed" + isChanged() + " created=" + created);
if (isDeleted())
{
- Fqn fqn = getFqn();
if (!fqn.isRoot())
{
NodeSPI parent = lookupParent(fqn, ctx, container);
@@ -78,7 +85,6 @@
}
else if (created)
{
- Fqn fqn = getFqn();
NodeSPI parent = lookupParent(fqn, ctx, container);
if (parent == null)
throw new NodeNotExistsException("Cannot add node " + fqn + " to data structure since its parent is null!");
@@ -86,6 +92,7 @@
}
else
{
+ mergeChildren(backup.getChildrenMapDirect());
((NodeReference) backup).setDelegate(((NodeReference) node).getDelegate());
node = backup;
}
@@ -127,4 +134,43 @@
{
return backup;
}
+
+ @Override
+ public void addChildDirect(NodeSPI child)
+ {
+ Object childname = child.getFqn().getLastElement();
+ if (childrenAdded == null) childrenAdded = new HashSet();
+ childrenAdded.add(childname);
+ if (childrenRemoved != null) childrenRemoved.remove(childname);
+ super.addChildDirect(child);
+ }
+
+ @Override
+ public boolean removeChildDirect(Object childname)
+ {
+ boolean rv = super.removeChildDirect(childname);
+ if (rv)
+ {
+ if (childrenRemoved == null) childrenRemoved = new HashSet();
+ childrenRemoved.add(childname);
+ if (childrenAdded != null) childrenAdded.remove(childname);
+ }
+ return rv;
+ }
+
+ protected void mergeChildren(Map oldChildren)
+ {
+ if (oldChildren == null || oldChildren.isEmpty()) return; // nothing to do.
+ Map childmap = node.getChildrenMapDirect();
+ node.setChildrenMapDirect(oldChildren);
+ if (childrenRemoved != null)
+ {
+ for (Object name : childrenRemoved) node.removeChildDirect(name);
+ }
+
+ if (childrenAdded != null)
+ {
+ for (Object name : childrenAdded) node.addChildDirect((NodeSPI) childmap.get(name));
+ }
+ }
}
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-04 12:13:44 UTC (rev 6181)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-04 13:44:11 UTC (rev 6182)
@@ -54,10 +54,10 @@
@Override
protected void updateNode(DataContainer dataContainer, NodeFactory nf, InvocationContext ctx)
{
+ Fqn fqn = getFqn();
if (trace)
- log.trace("Updating RepeatableReadNode. IsDeleted? " + isDeleted() + " isValid? " + isValid() + " isChanged? " + isChanged());
+ log.trace("Updating node [" + fqn + "]. deleted=" + isDeleted() + " valid=" + isValid() + " changed" + isChanged() + " created=" + created);
- Fqn fqn = getFqn();
if (fqn.isRoot())
{
dataContainer.setRoot(nf.createNodeInvocationDelegate(node));
@@ -75,17 +75,17 @@
if (parent != null)
{
Object name = fqn.getLastElement();
-// NodeSPI oldChild = parent.getChildDirect(name);
+ NodeSPI oldChild = parent.getChildDirect(name);
if (isDeleted())
{
parent.removeChildDirect(name);
}
else
{
-// if (oldChild != null)
-// {
-// node.setChildrenMapDirect(oldChild.getChildrenMapDirect());
-// }
+ if (oldChild != null)
+ {
+ mergeChildren(oldChild.getChildrenMapDirect());
+ }
parent.addChildDirect(nf.createNodeInvocationDelegate(node));
}
}
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-04 12:13:44 UTC (rev 6181)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java 2008-07-04 13:44:11 UTC (rev 6182)
@@ -540,4 +540,33 @@
assert cache.getNode(A).hasChild(AB.getLastElement()) == false;
assert cache.getNode(AB) == null;
}
+
+ public void testOverwritingOnInsert() throws Exception
+ {
+ cache.put(AB, "k", "v");
+
+ tm.begin();
+ cache.put(ABC, "k", "v");
+ assert "v".equals(cache.get(ABC, "k"));
+ assert "v".equals(cache.get(AB, "k"));
+ Transaction t1 = tm.suspend();
+
+ tm.begin();
+ cache.put(AB, "k", "v2");
+ assert "v2".equals(cache.get(AB, "k"));
+ assert null == cache.get(ABC, "k");
+ Transaction t2 = tm.suspend();
+
+ tm.resume(t1);
+ t1.commit();
+
+ assert "v".equals(cache.get(AB, "k"));
+ assert "v".equals(cache.get(ABC, "k"));
+
+ tm.resume(t2);
+ t2.commit();
+
+ assert "v2".equals(cache.get(AB, "k"));
+ assert "v".equals(cache.get(ABC, "k"));
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedLockParentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedLockParentTest.java 2008-07-04 12:13:44 UTC (rev 6181)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedLockParentTest.java 2008-07-04 13:44:11 UTC (rev 6182)
@@ -9,4 +9,10 @@
{
lockParentForChildInsertRemove = true;
}
+
+ @Override
+ public void testOverwritingOnInsert()
+ {
+ // no op since a locked parent makes tis test irrelevant.
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadLockParentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadLockParentTest.java 2008-07-04 12:13:44 UTC (rev 6181)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadLockParentTest.java 2008-07-04 13:44:11 UTC (rev 6182)
@@ -9,4 +9,10 @@
{
lockParentForChildInsertRemove = true;
}
+
+ @Override
+ public void testOverwritingOnInsert()
+ {
+ // no op since a locked parent makes tis test irrelevant.
+ }
}
16 years, 6 months
JBoss Cache SVN: r6181 - in core/trunk/src: main/java/org/jboss/cache/commands/legacy/read and 8 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-04 08:13:44 -0400 (Fri, 04 Jul 2008)
New Revision: 6181
Added:
core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/
core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/PessGetChildrenNamesCommand.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedLockParentTest.java
core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadLockParentTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
core/trunk/src/main/java/org/jboss/cache/factories/PessimisticCommandsFactoryImpl.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
core/trunk/src/test/java/org/jboss/cache/commands/read/GetChildrenNamesCommandTest.java
Log:
Re-added lockParentForInsertRemove tests with MVCC
Added: core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/PessGetChildrenNamesCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/PessGetChildrenNamesCommand.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/PessGetChildrenNamesCommand.java 2008-07-04 12:13:44 UTC (rev 6181)
@@ -0,0 +1,23 @@
+package org.jboss.cache.commands.legacy.read;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.invocation.InvocationContext;
+
+public class PessGetChildrenNamesCommand extends GetChildrenNamesCommand
+{
+ public PessGetChildrenNamesCommand()
+ {
+ }
+
+ public PessGetChildrenNamesCommand(Fqn fqn)
+ {
+ super(fqn);
+ }
+
+ @Override
+ public Object perform(InvocationContext ctx)
+ {
+ return fetchChildrenNames(ctx);
+ }
+}
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-04 12:13:03 UTC (rev 6180)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java 2008-07-04 12:13:44 UTC (rev 6181)
@@ -4,9 +4,9 @@
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.mvcc.ReadCommittedNode;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -33,19 +33,13 @@
this.fqn = fqn;
}
- /**
- * Retrieves the names of children for a specific Fqn.
- *
- * @param ctx invocation context
- * @return a Set<Object> of child names, for a given Fqn, or null if the Fqn refers to a node that does not exist.
- */
- public Object perform(InvocationContext ctx)
+ protected final Set<Object> fetchChildrenNames(InvocationContext ctx)
{
NodeSPI n = fqn == null ? null : ctx.lookUpNode(fqn);
if (n == null || n.isDeleted()) return null;
Map childrenMap = n.getChildrenMapDirect();
- if (childrenMap == null || childrenMap.isEmpty()) return Collections.emptySet();
- Set childNames = new HashSet();
+ if (childrenMap == null || childrenMap.isEmpty()) return new HashSet<Object>();
+ Set<Object> childNames = new HashSet<Object>();
Collection s = childrenMap.values();
// prune deleted children - JBCACHE-1136
for (Object c : s)
@@ -61,6 +55,36 @@
}
+ /**
+ * Retrieves the names of children for a specific Fqn.
+ *
+ * @param ctx invocation context
+ * @return a Set<Object> of child names, for a given Fqn, or null if the Fqn refers to a node that does not exist.
+ */
+ public Object perform(InvocationContext ctx)
+ {
+ Set<Object> childNames = fetchChildrenNames(ctx);
+
+ // check for *new* children added.
+ for (Map.Entry<Fqn, NodeSPI> n : ctx.getLookedUpNodes().entrySet())
+ {
+ if (n.getKey().getParent().equals(fqn))
+ {
+ if (n.getValue().isDeleted())
+ {
+ childNames.remove(n.getKey());
+ }
+ else if (((ReadCommittedNode) n.getValue()).isCreated())
+ {
+ childNames.add(n.getKey().getLastElement());
+ }
+ }
+ }
+
+ return childNames;
+ }
+
+
public Object acceptVisitor(InvocationContext ctx, Visitor visitor) throws Throwable
{
return visitor.visitGetChildrenNamesCommand(ctx, this);
Modified: core/trunk/src/main/java/org/jboss/cache/factories/PessimisticCommandsFactoryImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/PessimisticCommandsFactoryImpl.java 2008-07-04 12:13:03 UTC (rev 6180)
+++ core/trunk/src/main/java/org/jboss/cache/factories/PessimisticCommandsFactoryImpl.java 2008-07-04 12:13:44 UTC (rev 6181)
@@ -2,6 +2,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.commands.ReplicableCommand;
+import org.jboss.cache.commands.legacy.read.PessGetChildrenNamesCommand;
import org.jboss.cache.commands.legacy.write.PessClearDataCommand;
import org.jboss.cache.commands.legacy.write.PessCreateNodeCommand;
import org.jboss.cache.commands.legacy.write.PessMoveCommand;
@@ -10,6 +11,7 @@
import org.jboss.cache.commands.legacy.write.PessPutKeyValueCommand;
import org.jboss.cache.commands.legacy.write.PessRemoveKeyCommand;
import org.jboss.cache.commands.legacy.write.PessRemoveNodeCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.CreateNodeCommand;
import org.jboss.cache.commands.write.MoveCommand;
@@ -33,6 +35,14 @@
public class PessimisticCommandsFactoryImpl extends OptimisticCommandsFactoryImpl
{
@Override
+ public GetChildrenNamesCommand buildGetChildrenNamesCommand(Fqn fqn)
+ {
+ GetChildrenNamesCommand command = new PessGetChildrenNamesCommand(fqn);
+ command.initialize(dataContainer);
+ return command;
+ }
+
+ @Override
public PutDataMapCommand buildPutDataMapCommand(GlobalTransaction gtx, Fqn fqn, Map data)
{
PutDataMapCommand cmd = new PessPutDataMapCommand(gtx, fqn, data);
@@ -103,6 +113,13 @@
boolean skipSetParams = false;
switch (id)
{
+ case GetChildrenNamesCommand.METHOD_ID:
+ {
+ GetChildrenNamesCommand returnValue = new PessGetChildrenNamesCommand();
+ returnValue.initialize(dataContainer);
+ command = returnValue;
+ break;
+ }
case MoveCommand.METHOD_ID:
{
MoveCommand returnValue = new PessMoveCommand();
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-04 12:13:03 UTC (rev 6180)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-07-04 12:13:44 UTC (rev 6181)
@@ -56,6 +56,7 @@
DataContainer dataContainer;
NodeFactory nodeFactory;
private long defaultLockAcquisitionTimeout;
+ private boolean lockParentForChildInsertRemove;
@Inject
public void setDependencies(LockManager lockManager, DataContainer dataContainer, NodeFactory nodeFactory)
@@ -70,8 +71,19 @@
{
allowWriteSkew = configuration.isAllowWriteSkew();
defaultLockAcquisitionTimeout = configuration.getLockAcquisitionTimeout();
+ lockParentForChildInsertRemove = configuration.isLockParentForChildInsertRemove();
}
+ private boolean parentLockNeeded(NodeSPI parent)
+ {
+ return lockParentForChildInsertRemove || (parent != null && parent.isLockForChildInsertRemove());
+ }
+
+ private boolean parentLockNeeded(Fqn parent)
+ {
+ return parentLockNeeded(dataContainer.peek(parent, true, true));
+ }
+
@Override
protected boolean doBeforeCall(InvocationContext ctx, VisitableCommand command)
{
@@ -115,11 +127,15 @@
Fqn parentFqn = nodeFqn.getParent();
// inspect parent
- boolean needToCopyParent = lock(ctx, parentFqn);
+ boolean needToCopyParent = false;
+ boolean parentLockNeeded = parentLockNeeded(parentFqn);
+ if (parentLockNeeded)
+ {
+ needToCopyParent = lock(ctx, parentFqn);
+ // Ensure the node is in the context.
+ putNodeInContext(ctx, parentFqn, needToCopyParent);
+ }
- // Ensure the node is in the context.
- putNodeInContext(ctx, parentFqn, needToCopyParent);
-
boolean needToCopyNode = lock(ctx, nodeFqn);
// Ensure the node is in the context.
@@ -130,9 +146,8 @@
// update child ref on parent to point to child as this is now a copy.
if (node != null && !(node instanceof NullMarkerNode))
{
- if (needToCopyNode || needToCopyParent)
+ if (parentLockNeeded && (needToCopyNode || needToCopyParent))
{
-
ReadCommittedNode parent = (ReadCommittedNode) ctx.lookUpNode(parentFqn);
parent.addChildDirect(nodeFactory.createNodeInvocationDelegate((InternalNode) node.getDelegationTarget()));
}
@@ -345,13 +360,13 @@
// for non-transactional stuff.
if (ctx.getTransaction() == null)
{
- if (trace) log.trace("Releasing locks for thread " + Thread.currentThread());
List<Fqn> locks;
if (!(locks = ctx.getLocks()).isEmpty())
{
// clean up.
Fqn[] fqnsToUnlock = new Fqn[locks.size()];
fqnsToUnlock = locks.toArray(fqnsToUnlock);
+ if (trace) log.trace("Releasing locks for thread " + Thread.currentThread() + " on fqns " + locks);
Object owner = Thread.currentThread();
for (int i = fqnsToUnlock.length - 1; i > -1; i--)
@@ -485,8 +500,9 @@
Fqn parentFqn = fqn.getParent();
NodeSPI parent = getWrappedNode(context, parentFqn, false, createIfAbsent, false);
// do we need to lock the parent to create children?
+ boolean parentLockNeeded = parentLockNeeded(parent);
// get a lock on the parent.
- if (lock(context, parentFqn))
+ if (parentLockNeeded && lock(context, parentFqn))
{
ReadCommittedNode parentRCN = (ReadCommittedNode) context.lookUpNode(parentFqn);
parentRCN.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory);
@@ -496,12 +512,19 @@
lock(context, fqn);
NodeSPI temp = parent.getOrCreateChild(fqn.getLastElement(), context.getGlobalTransaction());
+ // TODO: warning, hack! There is a race condition here. Add a way to create nodes without attaching to a parent.
+ parent.removeChildDirect(fqn.getLastElement());
+
in = (InternalNode) ((NodeInvocationDelegate) temp).getDelegationTarget();
ReadCommittedNode wrapped = nodeFactory.createMvccNode(in);
+ wrapped.setCreated(true);
context.putLookedUpNode(fqn, wrapped);
wrapped.copyNodeForUpdate(dataContainer, allowWriteSkew, context, nodeFactory);
- // since we copied the child make sure we update the parent's ref
- parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(wrapped.getNode()));
+// if (parentLockNeeded)
+// {
+// // since we copied the child make sure we update the parent's ref
+// parent.addChildDirect(nodeFactory.createNodeInvocationDelegate(wrapped.getNode()));
+// }
return wrapped;
}
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-04 12:13:03 UTC (rev 6180)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-07-04 12:13:44 UTC (rev 6181)
@@ -3,6 +3,7 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeFactory;
+import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.NodeInvocationDelegate;
@@ -19,6 +20,7 @@
{
protected volatile InternalNode backup;
protected boolean changed;
+ protected boolean created;
public ReadCommittedNode(InternalNode node)
{
@@ -50,6 +52,15 @@
}
}
+ protected NodeSPI lookupParent(Fqn fqn, InvocationContext ctx, DataContainer container)
+ {
+ Fqn parentFqn = fqn.getParent();
+ NodeSPI parent = ctx.lookUpNode(parentFqn);
+ if (parent != null) return parent;
+ parent = container.peek(parentFqn);
+ return parent;
+ }
+
protected void updateNode(DataContainer container, NodeFactory nf, InvocationContext ctx)
{
if (isDeleted())
@@ -57,7 +68,7 @@
Fqn fqn = getFqn();
if (!fqn.isRoot())
{
- NodeSPI parent = ctx.lookUpNode(fqn.getParent()); // this will be there since parent nodes are locked when a child is removed.
+ NodeSPI parent = lookupParent(fqn, ctx, container);
parent.removeChildDirect(fqn.getLastElement());
}
else
@@ -65,6 +76,14 @@
log.warn("Attempting to remove the root node. Not doing anything!");
}
}
+ else if (created)
+ {
+ Fqn fqn = getFqn();
+ NodeSPI parent = lookupParent(fqn, ctx, container);
+ if (parent == null)
+ throw new NodeNotExistsException("Cannot add node " + fqn + " to data structure since its parent is null!");
+ parent.addChildDirect(nf.createNodeInvocationDelegate(node));
+ }
else
{
((NodeReference) backup).setDelegate(((NodeReference) node).getDelegate());
@@ -89,6 +108,16 @@
this.changed = changed;
}
+ public boolean isCreated()
+ {
+ return created;
+ }
+
+ public void setCreated(boolean created)
+ {
+ this.created = created;
+ }
+
public InternalNode getNode()
{
return node;
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-04 12:13:03 UTC (rev 6180)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-07-04 12:13:44 UTC (rev 6181)
@@ -3,6 +3,7 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeFactory;
+import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersion;
@@ -55,28 +56,36 @@
{
if (trace)
log.trace("Updating RepeatableReadNode. IsDeleted? " + isDeleted() + " isValid? " + isValid() + " isChanged? " + isChanged());
- if (getFqn().isRoot())
+
+ Fqn fqn = getFqn();
+ if (fqn.isRoot())
{
dataContainer.setRoot(nf.createNodeInvocationDelegate(node));
}
+ else if (created)
+ {
+ NodeSPI parent = lookupParent(fqn, ctx, dataContainer);
+ if (parent == null)
+ throw new NodeNotExistsException("Cannot add node " + fqn + " to data structure since its parent is null!");
+ parent.addChildDirect(nf.createNodeInvocationDelegate(node));
+ }
else
{
- Fqn fqn = getFqn();
- NodeSPI parent = dataContainer.peek(fqn.getParent());
+ NodeSPI parent = lookupParent(fqn, ctx, dataContainer);
if (parent != null)
{
Object name = fqn.getLastElement();
- NodeSPI oldChild = parent.getChildDirect(name);
+// NodeSPI oldChild = parent.getChildDirect(name);
if (isDeleted())
{
parent.removeChildDirect(name);
}
else
{
- if (oldChild != null)
- {
- node.setChildrenMapDirect(oldChild.getChildrenMapDirect());
- }
+// if (oldChild != null)
+// {
+// node.setChildrenMapDirect(oldChild.getChildrenMapDirect());
+// }
parent.addChildDirect(nf.createNodeInvocationDelegate(node));
}
}
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-04 12:13:03 UTC (rev 6180)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/LockTestBase.java 2008-07-04 12:13:44 UTC (rev 6181)
@@ -36,7 +36,9 @@
protected LockManager lockManager;
protected InvocationContextContainer icc;
protected boolean repeatableRead = true;
+ protected boolean lockParentForChildInsertRemove = false;
+
@BeforeMethod
public void setUp()
{
@@ -44,6 +46,7 @@
cache.getConfiguration().setNodeLockingScheme(NodeLockingScheme.MVCC);
cache.getConfiguration().setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
cache.getConfiguration().setIsolationLevel(repeatableRead ? IsolationLevel.REPEATABLE_READ : IsolationLevel.READ_COMMITTED);
+ cache.getConfiguration().setLockParentForChildInsertRemove(lockParentForChildInsertRemove);
// reduce lock acquisition timeout so this doesn't take forever to run
cache.getConfiguration().setLockAcquisitionTimeout(200); // 200 ms
cache.start();
@@ -77,7 +80,10 @@
{
tm.begin();
cache.put(AB, "k", "v");
- assertLocked(Fqn.ROOT);
+ if (lockParentForChildInsertRemove)
+ assertLocked(Fqn.ROOT);
+ else
+ assertNotLocked(Fqn.ROOT);
assertLocked(A);
assertLocked(AB);
assertNotLocked(ABC);
@@ -99,7 +105,10 @@
cache.put(ABC, "k", "v");
assertNotLocked(Fqn.ROOT);
assertNotLocked(A);
- assertLocked(AB);
+ if (lockParentForChildInsertRemove)
+ assertLocked(AB);
+ else
+ assertNotLocked(AB);
assertLocked(ABC);
tm.commit();
@@ -110,7 +119,10 @@
{
tm.begin();
cache.put(AB, Collections.singletonMap("k", "v"));
- assertLocked(Fqn.ROOT);
+ if (lockParentForChildInsertRemove)
+ assertLocked(Fqn.ROOT);
+ else
+ assertNotLocked(Fqn.ROOT);
assertLocked(A);
assertLocked(AB);
assertNotLocked(ABC);
@@ -133,7 +145,10 @@
cache.put(ABC, Collections.singletonMap("k", "v"));
assertNotLocked(Fqn.ROOT);
assertNotLocked(A);
- assertLocked(AB);
+ if (lockParentForChildInsertRemove)
+ assertLocked(AB);
+ else
+ assertNotLocked(AB);
assertLocked(ABC);
tm.commit();
@@ -150,7 +165,10 @@
tm.begin();
cache.removeNode(AB);
assertLocked(AB);
- assertLocked(A);
+ if (lockParentForChildInsertRemove)
+ assertLocked(A);
+ else
+ assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
tm.commit();
assert cache.getNode(AB) == null : "Should not exist";
@@ -167,7 +185,10 @@
tm.begin();
cache.evict(AB);
assertLocked(AB);
- assertLocked(A);
+ if (lockParentForChildInsertRemove)
+ assertLocked(A);
+ else
+ assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
tm.commit();
assert cache.getNode(AB) == null : "Should not exist";
@@ -190,7 +211,10 @@
assertLocked(AB);
assertLocked(ABC);
assertLocked(ABCD);
- assertLocked(A);
+ if (lockParentForChildInsertRemove)
+ assertLocked(A);
+ else
+ assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
tm.commit();
assert cache.getNode(AB) == null : "Should not exist";
@@ -204,7 +228,10 @@
tm.begin();
cache.removeNode(AB);
assertLocked(AB);
- assertLocked(A);
+ if (lockParentForChildInsertRemove)
+ assertLocked(A);
+ else
+ assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
tm.commit();
assert cache.getNode(AB) == null : "Should not exist";
@@ -218,7 +245,10 @@
tm.begin();
cache.evict(AB);
assertLocked(AB);
- assertLocked(A);
+ if (lockParentForChildInsertRemove)
+ assertLocked(A);
+ else
+ assertNotLocked(A);
assertNotLocked(Fqn.ROOT);
tm.commit();
assert cache.getNode(AB) == null : "Should not exist";
@@ -450,4 +480,64 @@
assert null == cache.getNode(AB);
assertNoLocks();
}
+
+ public void testPhantomChildren() throws Exception
+ {
+ cache.put(AB, "k", "v");
+ assert cache.getNode(AB).getChildren().size() == 0;
+ assert cache.getNode(A).getChildren().size() == 1;
+
+ tm.begin();
+ cache.put(ABC, "k", "v");
+ assert cache.getRoot().hasChild(ABC);
+ assert cache.getNode(ABC) != null;
+ assert cache.getNode(AB).getChild(ABC.getLastElement()) != null;
+ assert cache.getNode(AB).getChildren().size() == 1;
+ Transaction t = tm.suspend();
+
+
+ assert cache.getNode(ABC) == null;
+ assert cache.getNode(AB).getChild(ABC.getLastElement()) == null;
+ assert cache.getNode(AB).getChildren().size() == 0;
+
+ tm.resume(t);
+ assert cache.getRoot().hasChild(ABC);
+ assert cache.getNode(ABC) != null;
+ tm.commit();
+
+ assert cache.getNode(ABC) != null;
+ assert cache.getNode(AB).getChild(ABC.getLastElement()) != null;
+ assert cache.getNode(AB).getChildren().size() == 1;
+ }
+
+ public void testChildCount() throws Exception
+ {
+ cache.put(AB, "k", "v");
+ assert cache.getNode(AB).getChildren().size() == 0;
+ assert cache.getNode(A).getChildren().size() == 1;
+
+ tm.begin();
+ assert cache.getNode(AB).getChildren().size() == 0;
+ assert cache.getNode(A).getChildren().size() == 1;
+ cache.removeNode(AB);
+ assert cache.getNode(A).getChildren().size() == 0;
+ assert cache.getNode(A).hasChild(AB.getLastElement()) == false;
+ assert cache.getNode(AB) == null;
+ Transaction t = tm.suspend();
+
+
+ assert cache.getNode(AB) != null;
+ assert cache.getNode(A).getChild(AB.getLastElement()) != null;
+ assert cache.getNode(A).getChildren().size() == 1;
+
+ tm.resume(t);
+ assert cache.getNode(A).getChildren().size() == 0;
+ assert cache.getNode(A).hasChild(AB.getLastElement()) == false;
+ assert cache.getNode(AB) == null;
+ tm.commit();
+
+ assert cache.getNode(A).getChildren().size() == 0;
+ assert cache.getNode(A).hasChild(AB.getLastElement()) == false;
+ assert cache.getNode(AB) == null;
+ }
}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedLockParentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedLockParentTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/read_committed/ReadCommittedLockParentTest.java 2008-07-04 12:13:44 UTC (rev 6181)
@@ -0,0 +1,12 @@
+package org.jboss.cache.api.mvcc.read_committed;
+
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class ReadCommittedLockParentTest extends ReadCommittedLockTest
+{
+ public ReadCommittedLockParentTest()
+ {
+ lockParentForChildInsertRemove = true;
+ }
+}
Added: core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadLockParentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadLockParentTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/api/mvcc/repeatable_read/RepeatableReadLockParentTest.java 2008-07-04 12:13:44 UTC (rev 6181)
@@ -0,0 +1,12 @@
+package org.jboss.cache.api.mvcc.repeatable_read;
+
+import org.testng.annotations.Test;
+
+@Test(groups = {"functional", "mvcc"})
+public class RepeatableReadLockParentTest extends RepeatableReadLockTest
+{
+ public RepeatableReadLockParentTest()
+ {
+ lockParentForChildInsertRemove = true;
+ }
+}
Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/GetChildrenNamesCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/GetChildrenNamesCommandTest.java 2008-07-04 12:13:03 UTC (rev 6180)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/GetChildrenNamesCommandTest.java 2008-07-04 12:13:44 UTC (rev 6181)
@@ -2,6 +2,7 @@
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
+import org.jboss.cache.commands.legacy.read.PessGetChildrenNamesCommand;
import org.jboss.cache.mock.MockNodesFixture;
import org.jboss.cache.mock.NodeSpiMock;
import org.testng.annotations.Test;
@@ -23,7 +24,7 @@
protected void moreSetup()
{
nodes = new MockNodesFixture();
- command = new GetChildrenNamesCommand(testFqn);
+ command = new PessGetChildrenNamesCommand(testFqn);
command.initialize(container);
}
16 years, 6 months
JBoss Cache SVN: r6180 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-04 08:13:03 -0400 (Fri, 04 Jul 2008)
New Revision: 6180
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
Log:
Reverted: Always scrub txs!
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-04 11:47:53 UTC (rev 6179)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-07-04 12:13:03 UTC (rev 6180)
@@ -182,8 +182,7 @@
* basically any other call coming in on the same thread and hijacking any running tx's
* was highlighted in JBCACHE-606
*/
-// if (scrubContextOnCompletion)
- setTransactionalContext(null, null, null, ctx);
+ if (scrubContextOnCompletion) setTransactionalContext(null, null, null, ctx);
// clean up any invocation-scope options set up
if (trace) log.trace("Resetting invocation-scope options");
16 years, 6 months
JBoss Cache SVN: r6179 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-07-04 07:47:53 -0400 (Fri, 04 Jul 2008)
New Revision: 6179
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
Log:
Always scrub txs!
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-04 11:02:48 UTC (rev 6178)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-07-04 11:47:53 UTC (rev 6179)
@@ -182,7 +182,8 @@
* basically any other call coming in on the same thread and hijacking any running tx's
* was highlighted in JBCACHE-606
*/
- if (scrubContextOnCompletion) setTransactionalContext(null, null, null, ctx);
+// if (scrubContextOnCompletion)
+ setTransactionalContext(null, null, null, ctx);
// clean up any invocation-scope options set up
if (trace) log.trace("Resetting invocation-scope options");
16 years, 6 months
JBoss Cache SVN: r6178 - core/branches/1.4.X/src/org/jboss/cache/loader.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-07-04 07:02:48 -0400 (Fri, 04 Jul 2008)
New Revision: 6178
Modified:
core/branches/1.4.X/src/org/jboss/cache/loader/JDBCCacheLoader.java
Log:
http://jira.jboss.com/jira/browse/JBCACHE-1384
Modified: core/branches/1.4.X/src/org/jboss/cache/loader/JDBCCacheLoader.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/loader/JDBCCacheLoader.java 2008-07-04 10:09:25 UTC (rev 6177)
+++ core/branches/1.4.X/src/org/jboss/cache/loader/JDBCCacheLoader.java 2008-07-04 11:02:48 UTC (rev 6178)
@@ -365,7 +365,7 @@
*/
public void put(Fqn name, Map attributes) throws Exception
{
- put(name, attributes, false);
+ put(name, attributes, true);
}
public void put(List modifications) throws Exception
@@ -937,7 +937,9 @@
{
if(!override && oldNode != NULL_NODE_IN_ROW && attrs != null)
{
- attrs.putAll(oldNode);
+ Map newOne = new HashMap(oldNode);
+ if(attrs != null) newOne.putAll(attrs);
+ attrs = newOne;
}
updateNode(name, attrs);
}
16 years, 6 months