[jbosscache-commits] JBoss Cache SVN: r7026 - in core/trunk/src: test/java/org/jboss/cache/passivation and 1 other directory.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Wed Oct 29 09:21:40 EDT 2008


Author: manik.surtani at jboss.com
Date: 2008-10-29 09:21:40 -0400 (Wed, 29 Oct 2008)
New Revision: 7026

Modified:
   core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
   core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java
Log:
Added state tfr with BR tests

Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java	2008-10-29 05:00:16 UTC (rev 7025)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java	2008-10-29 13:21:40 UTC (rev 7026)
@@ -172,6 +172,8 @@
          {
             // make sure we LOAD data for this node!!
             actualNode.getData();
+            // and children!
+            actualNode.getChildrenNames();
          }
 
          if (backupNodeFqn == null && searchSubtrees)

Modified: core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java	2008-10-29 05:00:16 UTC (rev 7025)
+++ core/trunk/src/test/java/org/jboss/cache/passivation/ReplAndStateTransferWithPassivationTest.java	2008-10-29 13:21:40 UTC (rev 7026)
@@ -27,6 +27,8 @@
 import org.jboss.cache.Node;
 import org.jboss.cache.Region;
 import org.jboss.cache.UnitTestCacheFactory;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
+import org.jboss.cache.config.BuddyReplicationConfig;
 import org.jboss.cache.config.CacheLoaderConfig;
 import org.jboss.cache.config.Configuration;
 import org.jboss.cache.config.Configuration.CacheMode;
@@ -44,12 +46,12 @@
 {
    public void testStateTransferOfPassivatedState() throws Exception
    {
-      doTest(NodeLockingScheme.MVCC);
+      doTest(NodeLockingScheme.MVCC, false);
    }
 
    public void testStateTransferOfPassivatedStatePessimistic() throws Exception
    {
-      doTest(NodeLockingScheme.PESSIMISTIC);
+      doTest(NodeLockingScheme.PESSIMISTIC, false);
    }
 
    public void testStateTransferOfPassivatedPartialState() throws Exception
@@ -62,7 +64,16 @@
       doPartialStateTransferTest(NodeLockingScheme.PESSIMISTIC);
    }
 
+   public void testStateTransferOfPassivatedPartialStateBR() throws Exception
+   {
+      doTest(NodeLockingScheme.MVCC, true);
+   }
 
+   public void testStateTransferOfPassivatedPartialStateBRPessimistic() throws Exception
+   {
+      doTest(NodeLockingScheme.PESSIMISTIC, true);
+   }
+
    private void doPartialStateTransferTest(NodeLockingScheme nls) throws Exception
    {
       CacheSPI cache1=null, cache2=null;
@@ -74,8 +85,8 @@
          nameSet.add("b");
          nameSet.add("c");
 
-         cache1 = (CacheSPI) new UnitTestCacheFactory().createCache(buildConf(nls, "cache1", true));
-         cache2 = (CacheSPI) new UnitTestCacheFactory().createCache(buildConf(nls, "cache2", true));
+         cache1 = (CacheSPI) new UnitTestCacheFactory().createCache(buildConf(nls, "cache1", true, false));
+         cache2 = (CacheSPI) new UnitTestCacheFactory().createCache(buildConf(nls, "cache2", true, false));
 
          Region r1 = cache1.getRegionManager().getRegion(subtree, true);
          Region r2 = cache2.getRegionManager().getRegion(subtree, true);
@@ -103,27 +114,40 @@
       }
    }
 
-   private void doTest(NodeLockingScheme nls) throws Exception
+   private void doTest(NodeLockingScheme nls, boolean useBR) throws Exception
    {
       Cache cache1=null, cache2=null;
+      Fqn fqn = useBR ? Fqn.fromString("/someFqn") : Fqn.ROOT;
+      Fqn A = Fqn.fromRelativeElements(fqn, "a"), B = Fqn.fromRelativeElements(fqn, "b"), C = Fqn.fromRelativeElements(fqn, "c");
       try
       {
          Set<Object> nameSet = new HashSet<Object>();
-         nameSet.add("a");
-         nameSet.add("b");
-         nameSet.add("c");
+         nameSet.add(A.getLastElement());
+         nameSet.add(B.getLastElement());
+         nameSet.add(C.getLastElement());
+         
+         cache1 = new UnitTestCacheFactory().createCache(buildConf(nls, "cache1", false, useBR));
 
-         cache1 = new UnitTestCacheFactory().createCache(buildConf(nls, "cache1", false));
+         cache1.put(A, "k", "v");
+         cache1.put(B, "k", "v");
+         cache1.put(C, "k", "v");
+         assert cache1.getNode(fqn).getChildrenNames().equals(nameSet);
 
-         cache1.put("/a", "k", "v");
-         cache1.put("/b", "k", "v");
-         cache1.put("/c", "k", "v");
-         assert cache1.getRoot().getChildrenNames().equals(nameSet);
+         cache1.evict(A);
 
-         cache1.evict(Fqn.fromString("/a"));
-
-         cache2 = new UnitTestCacheFactory().createCache(buildConf(nls, "cache2", false));
-         assert cache2.getRoot().getChildrenNames().equals(nameSet) : "Expecting " + nameSet + " but got " + cache2.getRoot().getChildrenNames();
+         cache2 = new UnitTestCacheFactory().createCache(buildConf(nls, "cache2", false, useBR));
+         if (useBR)
+         {
+            Set backupNameSet = new HashSet(nameSet);
+            backupNameSet.remove(BuddyFqnTransformer.BUDDY_BACKUP_SUBTREE);
+            cache2.getInvocationContext().getOptionOverrides().setForceDataGravitation(true);
+            Node backupNode = cache2.getNode(fqn);
+            assert backupNode.getChildrenNames().equals(backupNameSet) : "Expecting " + backupNameSet + " but got " + backupNode.getChildrenNames();
+         }
+         else
+         {
+            assert cache2.getRoot().getChildrenNames().equals(nameSet) : "Expecting " + nameSet + " but got " + cache2.getRoot().getChildrenNames();
+         }
       }
       finally
       {
@@ -131,7 +155,7 @@
       }
    }
 
-   private Configuration buildConf(NodeLockingScheme nls, String n, boolean regionbased) throws Exception
+   private Configuration buildConf(NodeLockingScheme nls, String n, boolean regionbased, boolean useBR) throws Exception
    {
       Configuration c = new Configuration();
       if (regionbased)
@@ -144,6 +168,15 @@
       CacheLoaderConfig clc = getSingleCacheLoaderConfig("", DummySharedInMemoryCacheLoader.class.getName(), "bin="+n, false, true, false);
       clc.setPassivation(true);
       c.setCacheLoaderConfig(clc);
+      if (useBR)
+      {
+         BuddyReplicationConfig brc = new BuddyReplicationConfig();
+         brc.setEnabled(true);
+         brc.setAutoDataGravitation(false);
+         brc.setDataGravitationSearchBackupTrees(true);
+         brc.setDataGravitationRemoveOnFind(true);
+         c.setBuddyReplicationConfig(brc);
+      }
       return c;
    }
 




More information about the jbosscache-commits mailing list