[jbosscache-commits] JBoss Cache SVN: r7379 - in core/trunk/src: test/java/org/jboss/cache/loader and 1 other directory.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Mon Jan 5 12:48:27 EST 2009
Author: manik.surtani at jboss.com
Date: 2009-01-05 12:48:27 -0500 (Mon, 05 Jan 2009)
New Revision: 7379
Added:
core/trunk/src/test/java/org/jboss/cache/loader/RootChildrenLoadedTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
Log:
JBCACHE-1456 - The root node starts with "children loaded" flag
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2009-01-05 17:35:41 UTC (rev 7378)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2009-01-05 17:48:27 UTC (rev 7379)
@@ -111,9 +111,6 @@
}
if (usingMvcc && rootInternal == null) setRoot(root); // sets the "internal root"
-
- if (root != null) root.setChildrenLoaded(true);
- if (rootInternal != null) rootInternal.setChildrenLoaded(true);
}
@Stop(priority = 100)
@@ -243,9 +240,13 @@
public List<NodeData> buildNodeData(List<NodeData> list, NodeSPI node, boolean mapSafe)
{
if (usingMvcc)
+ {
return buildNodeData(list, node.getDelegationTarget(), node.getData(), mapSafe);
+ }
else
+ {
return buildNodeDataLegacy(list, node, mapSafe);
+ }
}
private List<NodeData> buildNodeData(List<NodeData> list, InternalNode<?, ?> node, Map dataInNode, boolean mapSafe)
@@ -389,7 +390,9 @@
else
{
if (root == null)
+ {
return sb.toString();
+ }
for (Object n : root.getChildrenDirect())
{
((NodeSPI) n).print(sb, indent);
@@ -467,9 +470,13 @@
{
StringBuilder sb = new StringBuilder();
if (root == null)
+ {
rootInternal.printDetails(sb, 0);
+ }
else
+ {
root.printDetails(sb, 0);
+ }
sb.append("\n");
return sb.toString();
}
@@ -632,20 +639,30 @@
if (hasChildren(fqn))
{
if (trace)
+ {
log.trace("removing DATA as node has children: evict(" + fqn + ")");
+ }
if (usingMvcc)
+ {
removeData(fqn);
+ }
else
+ {
removeDataLegacy(fqn);
+ }
return false;
}
else
{
if (trace) log.trace("removing NODE as it is a leaf: evict(" + fqn + ")");
if (usingMvcc)
+ {
removeNode(fqn);
+ }
else
+ {
removeNodeLegacy(fqn);
+ }
return true;
}
}
Added: core/trunk/src/test/java/org/jboss/cache/loader/RootChildrenLoadedTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/RootChildrenLoadedTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/loader/RootChildrenLoadedTest.java 2009-01-05 17:48:27 UTC (rev 7379)
@@ -0,0 +1,52 @@
+package org.jboss.cache.loader;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.loader.testloaders.DummyInMemoryCacheLoader;
+import org.jboss.cache.util.TestingUtil;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+ at Test(groups = "functional", enabled = true)
+public class RootChildrenLoadedTest
+{
+ Cache<String, String> cache;
+ Fqn fqn = Fqn.fromElements("a", "a");
+ String key = "key";
+
+ @BeforeTest
+ public void setUp() throws Exception
+ {
+ CacheLoaderConfig cacheLoaderConfig = UnitTestCacheConfigurationFactory.buildSingleCacheLoaderConfig(false, "", DummyInMemoryCacheLoader.class.getName(), "", false, true, false, false, false);
+ // assign the cache loader explicitly so it will stick between restarts
+ cacheLoaderConfig.getFirstCacheLoaderConfig().setCacheLoader(new DummyInMemoryCacheLoader());
+ Configuration cfg = new Configuration();
+ cfg.setCacheLoaderConfig(cacheLoaderConfig);
+ cache = new DefaultCacheFactory<String, String>().createCache(cfg);
+ cache.put(fqn, key, "value");
+
+ // flush the cache and start with totally clean state
+ cache.stop();
+ cache.start();
+ }
+
+ @AfterTest
+ public void tearDown()
+ {
+ TestingUtil.killCaches(cache);
+ }
+
+ public void doTest() throws Exception
+ {
+ // the workaround:
+ // NodeInvocationDelegate<String, String> root = (NodeInvocationDelegate<String, String>) cache.getRoot();
+ // root.setChildrenLoaded(false);
+
+ assert cache.getNode(Fqn.ROOT).getChildrenNames().size() == 1;
+ }
+}
More information about the jbosscache-commits
mailing list