Author: manik.surtani(a)jboss.com
Date: 2008-10-28 15:22:41 -0400 (Tue, 28 Oct 2008)
New Revision: 7021
Added:
core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java
Log:
Fixed state transfer and passivation bug
Modified:
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-10-28
04:39:48 UTC (rev 7020)
+++
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-10-28
19:22:41 UTC (rev 7021)
@@ -221,6 +221,10 @@
targetNode.removeChild(childname);
}
+ // set these flags to false if we have persistent state!
+ targetNode.setDataLoaded(false);
+ targetNode.setChildrenLoaded(false);
+
List<NodeData> list = readNodesAsList(in);
if (list != null)
{
@@ -303,6 +307,8 @@
cache.clearData(fqn);
prepareContextOptions();
cache.put(fqn, attrs);
+ cache.getNode(fqn).setDataLoaded(false);
+ cache.getNode(fqn).setChildrenLoaded(false);
// Recursively call, which will walk down the tree
// and return the next NodeData that's a child of our parent
Modified:
core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java 2008-10-28
04:39:48 UTC (rev 7020)
+++
core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java 2008-10-28
19:22:41 UTC (rev 7021)
@@ -258,6 +258,11 @@
}
}
+ // set these flags to false if we have persistent state!
+ target.setDataLoaded(false);
+ target.setChildrenLoaded(false);
+
+
// read marker off stack
if (trace) log.trace("Reading marker from stream");
cache.getMarshaller().objectFromObjectStream(in);
Added:
core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java 2008-10-28
19:22:41 UTC (rev 7021)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.cache.passivation;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.config.CacheLoaderConfig;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Configuration.CacheMode;
+import org.jboss.cache.config.Configuration.NodeLockingScheme;
+import org.jboss.cache.loader.AbstractCacheLoaderTestBase;
+import org.jboss.cache.loader.DummySharedInMemoryCacheLoader;
+import org.jboss.cache.util.TestingUtil;
+import org.testng.annotations.Test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+@Test(groups = "functional")
+public class ReplAndStateTransferWithPassivationTest extends AbstractCacheLoaderTestBase
+{
+ public void testStateTransferOfPassivatedState() throws Exception
+ {
+ doTest(NodeLockingScheme.MVCC);
+ }
+
+ public void testStateTransferOfPassivatedStatePessimistic() throws Exception
+ {
+ doTest(NodeLockingScheme.PESSIMISTIC);
+ }
+
+ private void doTest(NodeLockingScheme nls) throws Exception
+ {
+ Cache cache1=null, cache2=null;
+ try
+ {
+ Set<Object> nameSet = new HashSet<Object>();
+ nameSet.add("a");
+ nameSet.add("b");
+ nameSet.add("c");
+
+ cache1 = new UnitTestCacheFactory().createCache(buildConf(nls,
"cache1"));
+
+ cache1.put("/a", "k", "v");
+ cache1.put("/b", "k", "v");
+ cache1.put("/c", "k", "v");
+ assert cache1.getRoot().getChildrenNames().equals(nameSet);
+
+ cache1.evict(Fqn.fromString("/a"));
+
+ cache2 = new UnitTestCacheFactory().createCache(buildConf(nls,
"cache2"));
+ assert cache2.getRoot().getChildrenNames().equals(nameSet) : "Expecting
" + nameSet + " but got " + cache2.getRoot().getChildrenNames();
+ }
+ finally
+ {
+ TestingUtil.killCaches(cache1, cache2);
+ }
+ }
+
+ private Configuration buildConf(NodeLockingScheme nls, String n) throws Exception
+ {
+ Configuration c = new Configuration();
+ c.setCacheMode(CacheMode.REPL_SYNC);
+ c.setNodeLockingScheme(nls);
+ CacheLoaderConfig clc = getSingleCacheLoaderConfig("",
DummySharedInMemoryCacheLoader.class.getName(), "bin="+n, false, true, false);
+ clc.setPassivation(true);
+ c.setCacheLoaderConfig(clc);
+ return c;
+ }
+
+}