[jbosscache-commits] JBoss Cache SVN: r7568 - core/trunk/src/test/java/org/jboss/cache/buddyreplication.

jbosscache-commits at lists.jboss.org jbosscache-commits at lists.jboss.org
Thu Jan 22 05:31:05 EST 2009


Author: mircea.markus
Date: 2009-01-22 05:31:05 -0500 (Thu, 22 Jan 2009)
New Revision: 7568

Modified:
   core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java
Log:
more strict replication control

Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java	2009-01-22 09:26:00 UTC (rev 7567)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/Buddy3NodesWithFailoverTest.java	2009-01-22 10:31:05 UTC (rev 7568)
@@ -9,6 +9,7 @@
 import org.jboss.cache.CacheSPI;
 import org.jboss.cache.Fqn;
 import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
+import org.jboss.cache.commands.write.PutKeyValueCommand;
 import org.jboss.cache.util.TestingUtil;
 import org.jboss.cache.util.internals.replicationlisteners.ReplicationListener;
 import org.jgroups.JChannel;
@@ -103,74 +104,74 @@
 
    public void testDataGravitationKillOwner() throws Exception
    {
-      List<CacheSPI<Object, Object>> cachePool = createCaches(3, false, true);
+      List<CacheSPI<Object, Object>> caches = createCaches(3, false, true);
       Fqn fqn = Fqn.fromString("/test");
-      Fqn backupFqn = fqnTransformer.getBackupFqn(cachePool.get(0).getLocalAddress(), fqn);
+      Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
 
-      TestingUtil.dumpCacheContents(cachePool);
+      TestingUtil.dumpCacheContents(caches);
 
-      cachePool.get(0).put(fqn, key, value);
+      ReplicationListener replListener0 = ReplicationListener.getReplicationListener(caches.get(0));
 
-      TestingUtil.dumpCacheContents(cachePool);
+      replListener0.expect(PutKeyValueCommand.class);
+      caches.get(2).put(fqn, key, value);
+      replListener0.waitForReplicationToOccur();
 
-      assertEquals("Value should exist", value, cachePool.get(0).get(fqn, key));
 
-      TestingUtil.dumpCacheContents(cachePool);
+      TestingUtil.dumpCacheContents(caches);
 
+      assertEquals("Value should exist", value, caches.get(2).get(fqn, key));
+
+      TestingUtil.dumpCacheContents(caches);
+
       // use exists instead of get() to prevent going up the interceptor stack
-      assertTrue("Should be false", !cachePool.get(1).exists(fqn));
-      assertTrue("Should be false", !cachePool.get(2).exists(fqn));
+      assertTrue("Should be false", !caches.get(0).exists(fqn));
+      assertTrue("Should be false", !caches.get(1).exists(fqn));
 
-      assertFalse("Should be false", cachePool.get(0).exists(backupFqn));
-      assertTrue("Value be true", cachePool.get(1).exists(backupFqn));
-      assertFalse("Should be false", cachePool.get(2).exists(backupFqn));
+      assertTrue("Value be true", caches.get(0).exists(backupFqn));
+      assertFalse("Should be false", caches.get(1).exists(backupFqn));
+      assertFalse("Should be false", caches.get(2).exists(backupFqn));
 
-      Address cacheOAddr = cachePool.get(0).getLocalAddress();
+      Address cache2Addr = caches.get(2).getLocalAddress();
       // forcefully kill data owner.
-      cachePool.get(0).stop();
-      cachePool.get(0).destroy();
-      TestingUtil.blockUntilViewsReceived(10000, cachePool.get(1), cachePool.get(2));
-      waitForSingleBuddy(cachePool.get(1), cachePool.get(2));
+      caches.get(2).stop();
+      caches.get(2).destroy();
+      TestingUtil.blockUntilViewsReceived(10000, caches.get(0), caches.get(1));
+      waitForSingleBuddy(caches.get(0), caches.get(1));
 
 //      TestingUtil.dumpCacheContents(cachePool);
       // assert that the remaining cachePool have picked new buddies.  Cache 1 should have cache 2's backup data.
-      assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(2).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
-      assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
-      assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cacheOAddr), false) == null : "Should not have dead node as a backup root.";
-      assert cachePool.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cacheOAddr), 1), false) != null : "Should have dead node as a defunct backup root.";
+      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
+      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
+      assert caches.get(0).peek(fqnTransformer.getBackupRoot(cache2Addr), false) == null : "Should not have dead node as a backup root.";
+      assert caches.get(0).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cache2Addr), 1), false) != null : "Should have dead node as a defunct backup root.";
 
-      assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(2).getLocalAddress()), false) == null : "Should not have self as a backup root.";
-      assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
-      assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cacheOAddr), false) == null : "Should not have dead node as a backup root.";
-      assert cachePool.get(2).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cacheOAddr), 1), false) == null : "Should not have dead node as a defunct backup root.";
+      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
+      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
+      assert caches.get(1).peek(fqnTransformer.getBackupRoot(cache2Addr), false) == null : "Should not have dead node as a backup root.";
+      assert caches.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cache2Addr), 1), false) == null : "Should not have dead node as a defunct backup root.";
 
-      ReplicationListener replListener = ReplicationListener.getReplicationListener(cachePool.get(1));
-      replListener.expect(DataGravitationCleanupCommand.class);
 
+      replListener0.expect(DataGravitationCleanupCommand.class);
+
       // according to data gravitation, a call to *any* cache should retrieve the data, and move the data to the new cache.
-      assertEquals("Value should have gravitated", value, cachePool.get(2).get(fqn, key));
-      replListener.waitForReplicationToOccur();
+      assertEquals("Value should have gravitated", value, caches.get(1).get(fqn, key));
+      replListener0.waitForReplicationToOccur();
 
-//      TestingUtil.dumpCacheContents(cachePool);
-
-      // now lets test the eviction part of gravitation
-      Fqn newBackupFqn = fqnTransformer.getBackupFqn(cachePool.get(2).getLocalAddress(), fqn);
-
       // use exists instead of get() to prevent going up the interceptor stack
-      assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(2).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
-      assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cachePool.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
-      assert cachePool.get(1).peek(fqnTransformer.getBackupRoot(cacheOAddr), false) == null : "Should not have dead node as a backup root.";
-      assert cachePool.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cacheOAddr), 1), false) == null : "Should not have dead node as a defunct backup root.";
-      assert cachePool.get(1).peek(fqnTransformer.getDeadBackupRoot(cacheOAddr), false) == null : "Should not have dead node as a defunct backup root.";
+      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
+      assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have self as a backup root.";
+      assert caches.get(0).peek(fqnTransformer.getBackupRoot(cache2Addr), false) == null : "Should not have dead node as a backup root.";
+      assert caches.get(0).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cache2Addr), 1), false) == null : "Should not have dead node as a defunct backup root.";
+      assert caches.get(0).peek(fqnTransformer.getDeadBackupRoot(cache2Addr), false) == null : "Should not have dead node as a defunct backup root.";
 
-      assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(2).getLocalAddress()), false) == null : "Should not have self as a backup root.";
-      assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cachePool.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
-      assert cachePool.get(2).peek(fqnTransformer.getBackupRoot(cacheOAddr), false) == null : "Should not have dead node as a backup root.";
-      assert cachePool.get(2).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cacheOAddr), 1), false) == null : "Should not have dead node as a defunct backup root.";
-      assertTrue("Should be false", !cachePool.get(1).exists(fqn));
+      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
+      assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
+      assert caches.get(1).peek(fqnTransformer.getBackupRoot(cache2Addr), false) == null : "Should not have dead node as a backup root.";
+      assert caches.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(cache2Addr), 1), false) == null : "Should not have dead node as a defunct backup root.";
+      assertTrue("Should be false", !caches.get(0).exists(fqn));
 
       // the old backup should no longer exist
-      assertFalse("Should be null", cachePool.get(1).exists(backupFqn));
-      assertFalse("Should be null", cachePool.get(2).exists(backupFqn));
+      assertFalse("Should be null", caches.get(0).exists(backupFqn));
+      assertFalse("Should be null", caches.get(1).exists(backupFqn));
    }
 }




More information about the jbosscache-commits mailing list