Author: bstansberry(a)jboss.com
Date: 2007-12-10 14:37:16 -0500 (Mon, 10 Dec 2007)
New Revision: 4822
Modified:
core/branches/1.4.X/src/org/jboss/cache/TreeCache.java
core/branches/1.4.X/src/org/jboss/cache/buddyreplication/BuddyManager.java
core/branches/1.4.X/tests/functional/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
Log:
[JBCACHE-1234] Region activation requests partial state transfer from wrong nodes
Modified: core/branches/1.4.X/src/org/jboss/cache/TreeCache.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/TreeCache.java 2007-12-07 16:29:18 UTC (rev
4821)
+++ core/branches/1.4.X/src/org/jboss/cache/TreeCache.java 2007-12-10 19:37:16 UTC (rev
4822)
@@ -1989,7 +1989,7 @@
{
// Get the state from each DataOwner and integrate in their
// respective buddy backup tree
- List buddies = buddyManager.getBuddyAddresses();
+ List buddies = buddyManager.getBackupDataOwners();
for (Iterator it = buddies.iterator(); it.hasNext();)
{
Address buddy = (Address) it.next();
Modified: core/branches/1.4.X/src/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/branches/1.4.X/src/org/jboss/cache/buddyreplication/BuddyManager.java 2007-12-07
16:29:18 UTC (rev 4821)
+++ core/branches/1.4.X/src/org/jboss/cache/buddyreplication/BuddyManager.java 2007-12-10
19:37:16 UTC (rev 4822)
@@ -475,6 +475,21 @@
}
}
}
+
+ /**
+ * Returns a List<IpAddress> identifying the DataOwner for each buddy
+ * group for which this node serves as a backup node.
+ */
+ public List getBackupDataOwners()
+ {
+ List owners = new ArrayList();
+ for (Iterator it = buddyGroupsIParticipateIn.values().iterator(); it.hasNext();)
+ {
+ BuddyGroup group = (BuddyGroup) it.next();
+ owners.add(group.getDataOwner());
+ }
+ return owners;
+ }
// -------------- static util methods ------------------
Modified:
core/branches/1.4.X/tests/functional/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
===================================================================
---
core/branches/1.4.X/tests/functional/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java 2007-12-07
16:29:18 UTC (rev 4821)
+++
core/branches/1.4.X/tests/functional/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java 2007-12-10
19:37:16 UTC (rev 4822)
@@ -73,22 +73,29 @@
public void testRegionBasedStateTransfer() throws Exception
{
- TreeCache[] caches = new TreeCache[3];
+ TreeCache[] caches = new TreeCache[4];
try
{
caches[0] = createCache(1, "TEST", false, false);
caches[1] = createCache(1, "TEST", false, false);
caches[2] = createCache(1, "TEST", false, false);
+ // JBCACHE-1234 -- add a 4th cache so when we kill caches[1]
+ // caches[0] is not the backup node for caches[2] (although
+ // caches[2] *is* the backup node for caches[0]
+ caches[3] = createCache(1, "TEST", false, false);
caches[0].setInactiveOnStartup(true);
caches[1].setInactiveOnStartup(true);
caches[2].setInactiveOnStartup(true);
+ caches[3].setInactiveOnStartup(true);
caches[0].setUseRegionBasedMarshalling(true);
caches[1].setUseRegionBasedMarshalling(true);
caches[2].setUseRegionBasedMarshalling(true);
+ caches[3].setUseRegionBasedMarshalling(true);
caches[0].startService();
caches[1].startService();
caches[2].startService();
+ caches[3].startService();
TestingUtil.blockUntilViewsReceived(caches, VIEW_BLOCK_TIMEOUT);
TestingUtil.sleepThread(getSleepTimeout());
@@ -96,6 +103,7 @@
caches[0].activateRegion("/a");
caches[1].activateRegion("/a");
caches[2].activateRegion("/a");
+ caches[3].activateRegion("/a");
caches[0].activateRegion("/d");
caches[1].activateRegion("/d");
@@ -116,7 +124,7 @@
assertEquals("/d replicated", "Joe", caches[1].get(testD,
"name"));
assertNull("No backup of /d", caches[2].get(testD,
"name"));
- // Make 2 the buddy of 0
+ // Make 2 the buddy of 0 -- this should cause a push from 0 to 2
caches[1].stopService();
caches[1] = null;
@@ -124,6 +132,13 @@
assertEquals("/a state transferred", "Joe",
caches[2].get(testA, "name"));
assertNull("/d state not transferred", caches[2].get(testD,
"name"));
+
+ // JBCACHE-1234 -- Activate region on 2 and 3. This should cause
+ // a pull from 0 by and from 2 by 3.
+ caches[2].activateRegion("/d");
+ caches[3].activateRegion("/d");
+ assertEquals("/d transferred to cache 2", "Joe",
caches[2].get(testD, "name"));
+ assertNull("/d state not transferred to cache 3",
caches[3].get(testD, "name"));
}
finally
{
Show replies by date