JBoss Cache SVN: r5985 - in core/trunk: src/main/java/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-12 12:31:07 -0400 (Thu, 12 Jun 2008)
New Revision: 5985
Modified:
core/trunk/pom.xml
core/trunk/src/main/java/org/jboss/cache/Version.java
Log:
Versioning info
Modified: core/trunk/pom.xml
===================================================================
--- core/trunk/pom.xml 2008-06-12 16:29:23 UTC (rev 5984)
+++ core/trunk/pom.xml 2008-06-12 16:31:07 UTC (rev 5985)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-core-version>2.2.0-SNAPSHOT</jbosscache-core-version>
+ <jbosscache-core-version>3.0.0-SNAPSHOT</jbosscache-core-version>
<!-- By default only run tests in the "unit" group -->
<defaultTestGroup>unit</defaultTestGroup>
<!-- By default only generate Javadocs when we install the module. -->
@@ -410,7 +410,7 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
- <jbosscache-core-version>2.2.0-SNAPSHOT-JBossAS</jbosscache-core-version>
+ <jbosscache-core-version>3.0.0-SNAPSHOT-JBossAS</jbosscache-core-version>
</properties>
<dependencies>
<dependency>
Modified: core/trunk/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Version.java 2008-06-12 16:29:23 UTC (rev 5984)
+++ core/trunk/src/main/java/org/jboss/cache/Version.java 2008-06-12 16:31:07 UTC (rev 5985)
@@ -11,10 +11,10 @@
@Immutable
public class Version
{
- public static final String version = "2.2.0-SNAPSHOT";
- public static final String codename = "Poblano";
+ public static final String version = "3.0.0-SNAPSHOT";
+ public static final String codename = "Naga";
//public static final String cvs = "$Id: Version.java 4592 2007-10-10 16:44:36Z manik.surtani(a)jboss.com $";
- static final byte[] version_id = {'0', '2', '2', '0', 'S'};
+ static final byte[] version_id = {'0', '3', '0', '0', 'S'};
private static final int MAJOR_SHIFT = 11;
private static final int MINOR_SHIFT = 6;
16 years, 6 months
JBoss Cache SVN: r5984 - core/branches.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-12 12:29:23 -0400 (Thu, 12 Jun 2008)
New Revision: 5984
Added:
core/branches/2.2.X/
Log:
Copied: core/branches/2.2.X (from rev 5983, core/trunk)
16 years, 6 months
JBoss Cache SVN: r5983 - in core/tags/2.2.0.CR4: src/main/java/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-12 12:27:42 -0400 (Thu, 12 Jun 2008)
New Revision: 5983
Modified:
core/tags/2.2.0.CR4/pom.xml
core/tags/2.2.0.CR4/src/main/java/org/jboss/cache/Version.java
Log:
Yet another CR
Modified: core/tags/2.2.0.CR4/pom.xml
===================================================================
--- core/tags/2.2.0.CR4/pom.xml 2008-06-12 16:25:23 UTC (rev 5982)
+++ core/tags/2.2.0.CR4/pom.xml 2008-06-12 16:27:42 UTC (rev 5983)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
- <jbosscache-core-version>2.2.0-SNAPSHOT</jbosscache-core-version>
+ <jbosscache-core-version>2.2.0.CR4</jbosscache-core-version>
<!-- By default only run tests in the "unit" group -->
<defaultTestGroup>unit</defaultTestGroup>
<!-- By default only generate Javadocs when we install the module. -->
@@ -410,7 +410,7 @@
<activeByDefault>false</activeByDefault>
</activation>
<properties>
- <jbosscache-core-version>2.2.0-SNAPSHOT-JBossAS</jbosscache-core-version>
+ <jbosscache-core-version>2.2.0.CR4-JBossAS</jbosscache-core-version>
</properties>
<dependencies>
<dependency>
Modified: core/tags/2.2.0.CR4/src/main/java/org/jboss/cache/Version.java
===================================================================
--- core/tags/2.2.0.CR4/src/main/java/org/jboss/cache/Version.java 2008-06-12 16:25:23 UTC (rev 5982)
+++ core/tags/2.2.0.CR4/src/main/java/org/jboss/cache/Version.java 2008-06-12 16:27:42 UTC (rev 5983)
@@ -11,10 +11,10 @@
@Immutable
public class Version
{
- public static final String version = "2.2.0-SNAPSHOT";
+ public static final String version = "2.2.0.CR4";
public static final String codename = "Poblano";
//public static final String cvs = "$Id: Version.java 4592 2007-10-10 16:44:36Z manik.surtani(a)jboss.com $";
- static final byte[] version_id = {'0', '2', '2', '0', 'S'};
+ static final byte[] version_id = {'0', '2', '2', '0', 'C', '4'};
private static final int MAJOR_SHIFT = 11;
private static final int MINOR_SHIFT = 6;
16 years, 6 months
JBoss Cache SVN: r5982 - core/tags.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-12 12:25:23 -0400 (Thu, 12 Jun 2008)
New Revision: 5982
Added:
core/tags/2.2.0.CR4/
Removed:
core/tags/2.1.1.CR4/
Log:
Copied: core/tags/2.2.0.CR4 (from rev 5981, core/tags/2.1.1.CR4)
16 years, 6 months
JBoss Cache SVN: r5981 - core/tags.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-12 12:24:03 -0400 (Thu, 12 Jun 2008)
New Revision: 5981
Added:
core/tags/2.1.1.CR4/
Log:
Copied: core/tags/2.1.1.CR4 (from rev 5980, core/trunk)
16 years, 6 months
JBoss Cache SVN: r5980 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-06-12 12:18:44 -0400 (Thu, 12 Jun 2008)
New Revision: 5980
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/trunk/src/test/java/org/jboss/cache/DataContainerTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
Log:
find bugs fixes
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-06-12 15:03:39 UTC (rev 5979)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-06-12 16:18:44 UTC (rev 5980)
@@ -529,4 +529,9 @@
}
return new Object[]{result, n};
}
+
+ public void setBuddyFqnTransformer(BuddyFqnTransformer buddyFqnTransformer)
+ {
+ this.buddyFqnTransformer = buddyFqnTransformer;
+ }
}
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-06-12 15:03:39 UTC (rev 5979)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-06-12 16:18:44 UTC (rev 5980)
@@ -685,7 +685,6 @@
{
try
{
-
VisitableCommand transformed = (VisitableCommand) call.acceptVisitor(null, fqnVisitorFqn2);
if (trace) log.trace("Transformed " + call + " to " + transformed);
return transformed;
Modified: core/trunk/src/test/java/org/jboss/cache/DataContainerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/DataContainerTest.java 2008-06-12 15:03:39 UTC (rev 5979)
+++ core/trunk/src/test/java/org/jboss/cache/DataContainerTest.java 2008-06-12 16:18:44 UTC (rev 5980)
@@ -5,6 +5,7 @@
import org.jboss.cache.mock.MockNodesFixture;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DefaultDataVersion;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -31,6 +32,7 @@
nodes = new MockNodesFixture();
container = new DataContainerImpl();
container.setRoot(nodes.root);
+ container.setBuddyFqnTransformer(new BuddyFqnTransformer());
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-06-12 15:03:39 UTC (rev 5979)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-06-12 16:18:44 UTC (rev 5980)
@@ -125,6 +125,7 @@
Element element = XmlHelper.stringToElement("<config><buddyReplicationEnabled>true</buddyReplicationEnabled></config>");
BuddyReplicationConfig cfg = XmlConfigurationParser.parseBuddyReplicationConfig(element);
bm = new BuddyManager(cfg);
+ bm.injectDependencies(null, null, null, null, null, null, null, null, new BuddyFqnTransformer());
CommandsFactory commandsFactory = new CommandsFactory();
commandsFactory.initialize(null, null, null, null, null, null, null, new Configuration(), null, new BuddyFqnTransformer());
bm.initFqnTransformer(DUMMY_LOCAL_ADDRESS, commandsFactory);
16 years, 6 months
JBoss Cache SVN: r5979 - in core/trunk/src: test/java/org/jboss/cache and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-12 11:03:39 -0400 (Thu, 12 Jun 2008)
New Revision: 5979
Modified:
core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java
core/trunk/src/main/java/org/jboss/cache/eviction/FIFOQueue.java
core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java
core/trunk/src/main/java/org/jboss/cache/eviction/LRUQueue.java
core/trunk/src/main/java/org/jboss/cache/eviction/MRUQueue.java
core/trunk/src/test/java/org/jboss/cache/CallbackTest.java
Log:
JBCACHE-1169
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java 2008-06-12 12:03:09 UTC (rev 5978)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/ElementSizeQueue.java 2008-06-12 15:03:39 UTC (rev 5979)
@@ -23,7 +23,7 @@
private Set<NodeEntry> removalQueue;
private int numElements = 0;
- ElementSizeQueue()
+ protected ElementSizeQueue()
{
nodeMap = new HashMap<Fqn, NodeEntry>();
evictionList = new LinkedList<NodeEntry>();
@@ -132,17 +132,17 @@
this.numElements = 0;
}
- final List<NodeEntry> getEvictionList()
+ protected final List<NodeEntry> getEvictionList()
{
return evictionList;
}
- final Set<NodeEntry> getRemovalQueue()
+ protected final Set<NodeEntry> getRemovalQueue()
{
return removalQueue;
}
- final void prune()
+ protected final void prune()
{
Iterator<NodeEntry> it = evictionList.iterator();
while (it.hasNext() && removalQueue.size() > 0)
@@ -170,7 +170,7 @@
* Note: this class has a natural ordering that is inconsistent with equals as defined by the java.lang.Comparator
* contract.
*/
- static class MaxElementComparator implements Comparator<NodeEntry>
+ protected static class MaxElementComparator implements Comparator<NodeEntry>
{
public int compare(NodeEntry ne1, NodeEntry ne2)
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/FIFOQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/FIFOQueue.java 2008-06-12 12:03:09 UTC (rev 5978)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/FIFOQueue.java 2008-06-12 15:03:39 UTC (rev 5979)
@@ -23,7 +23,7 @@
private Map<Fqn, NodeEntry> nodeMap;
private int numElements = 0;
- FIFOQueue()
+ protected FIFOQueue()
{
nodeMap = new LinkedHashMap<Fqn, NodeEntry>();
// We use a LinkedHashMap here because we want to maintain FIFO ordering and still get the benefits of
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java 2008-06-12 12:03:09 UTC (rev 5978)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LFUQueue.java 2008-06-12 15:03:39 UTC (rev 5979)
@@ -27,7 +27,7 @@
private Set<NodeEntry> removalQueue;
private int numElements = 0;
- LFUQueue()
+ protected LFUQueue()
{
nodeMap = new HashMap<Fqn, NodeEntry>();
comparator = new LFUComparator();
@@ -141,7 +141,7 @@
this.numElements += difference;
}
- void prune()
+ protected void prune()
{
Iterator<NodeEntry> it = this.iterate();
while (it.hasNext() && removalQueue.size() > 0)
@@ -153,14 +153,12 @@
}
}
- // provided as friend access for unit testing only.
- final List<NodeEntry> getEvictionList()
+ protected final List<NodeEntry> getEvictionList()
{
return this.evictionList;
}
- // provided as friend access for unit testing only.
- final Set<NodeEntry> getRemovalQueue()
+ protected final Set<NodeEntry> getRemovalQueue()
{
return this.removalQueue;
}
@@ -181,7 +179,7 @@
* Note: this class has a natural ordering that is inconsistent with equals as defined by the java.lang.Comparator
* contract.
*/
- static class LFUComparator implements Comparator<NodeEntry>
+ protected static class LFUComparator implements Comparator<NodeEntry>
{
public int compare(NodeEntry ne1, NodeEntry ne2)
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/LRUQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/LRUQueue.java 2008-06-12 12:03:09 UTC (rev 5978)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/LRUQueue.java 2008-06-12 15:03:39 UTC (rev 5979)
@@ -28,13 +28,13 @@
private long alternatingCount = 0;
private int numElements = 0;
- LRUQueue()
+ protected LRUQueue()
{
maxAgeQueue = new LinkedHashMap<Fqn, NodeEntry>();
lruQueue = new LinkedHashMap<Fqn, NodeEntry>(16, 0.75f, true);
}
- void reorderByLRU(Fqn fqn)
+ protected void reorderByLRU(Fqn fqn)
{
// leave the max age queue alone - it is like a fifo.
@@ -105,13 +105,13 @@
return this.maxAgeQueue.containsKey(entry.getFqn());
}
- void removeNodeEntryFromLRU(NodeEntry entry)
+ protected void removeNodeEntryFromLRU(NodeEntry entry)
{
Fqn fqn = entry.getFqn();
lruQueue.remove(fqn);
}
- void removeNodeEntryFromMaxAge(NodeEntry entry)
+ protected void removeNodeEntryFromMaxAge(NodeEntry entry)
{
Fqn fqn = entry.getFqn();
maxAgeQueue.remove(fqn);
@@ -175,12 +175,12 @@
return lruQueue.values().iterator();
}
- final Iterator<NodeEntry> iterateMaxAgeQueue()
+ protected final Iterator<NodeEntry> iterateMaxAgeQueue()
{
return maxAgeQueue.values().iterator();
}
- final Iterator<NodeEntry> iterateLRUQueue()
+ protected final Iterator<NodeEntry> iterateLRUQueue()
{
return lruQueue.values().iterator();
}
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/MRUQueue.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/MRUQueue.java 2008-06-12 12:03:09 UTC (rev 5978)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/MRUQueue.java 2008-06-12 15:03:39 UTC (rev 5979)
@@ -33,7 +33,7 @@
EvictionQueueList list;
private int numElements = 0;
- MRUQueue()
+ protected MRUQueue()
{
nodeMap = new HashMap<Fqn, EvictionListEntry>();
list = new EvictionQueueList();
@@ -46,7 +46,7 @@
*
* @param fqn Fqn of the nodeEntry to move to the top of the stack.
*/
- void moveToTopOfStack(Fqn fqn)
+ protected void moveToTopOfStack(Fqn fqn)
{
EvictionListEntry le = nodeMap.remove(fqn);
if (le != null)
Modified: core/trunk/src/test/java/org/jboss/cache/CallbackTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/CallbackTest.java 2008-06-12 12:03:09 UTC (rev 5978)
+++ core/trunk/src/test/java/org/jboss/cache/CallbackTest.java 2008-06-12 15:03:39 UTC (rev 5979)
@@ -18,6 +18,7 @@
* @author Bela Ban
* @version $Id$
*/
+@Test(groups = "functional")
public class CallbackTest
{
CacheSPI<Object, Object> cache = null, cache2;
@@ -37,7 +38,6 @@
}
}
- @Test(groups = {"functional"})
public void testLocalPutCallbackWithoutTransaction() throws Exception
{
cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
@@ -46,12 +46,10 @@
cache.put(FQN_A, null);
assertTrue(cache.exists(FQN_A));
assertTrue(cache.exists(FQN_B));//created by callback
- //assertEquals(cache.getLockTable().size(), 0);
System.out.println("cache locks:\n" + CachePrinter.printCacheLockingInfo(cache));
assertEquals(0, cache.getNumberOfLocksHeld());
}
- @Test(groups = {"functional"})
public void testLocalGetCallbackSameFqnWithoutTransaction() throws Exception
{
cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
@@ -59,12 +57,10 @@
cache.put(FQN_A, null);
assertTrue(cache.exists(FQN_A));
-// assertEquals(cache.getLockTable().size(), 0);
System.out.println("cache locks:\n" + CachePrinter.printCacheLockingInfo(cache));
assertEquals(0, cache.getNumberOfLocksHeld());
}
- @Test(groups = {"functional"})
public void testLocalGetCallbackDifferentFqnWithoutTransaction() throws Exception
{
cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
@@ -74,12 +70,10 @@
cache.put("/a", null);
assertTrue(cache.exists(FQN_A));
assertTrue(cache.exists(FQN_B));
-// assertEquals(cache.getLockTable().size(), 0);
System.out.println("cache locks:\n" + CachePrinter.printCacheLockingInfo(cache));
assertEquals(0, cache.getNumberOfLocksHeld());
}
- @Test(groups = {"functional"})
public void testLocalCallbackWithTransaction() throws Exception
{
cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
@@ -92,7 +86,6 @@
assertEquals(0, cache.getNumberOfLocksHeld());
}
- @Test(groups = {"functional"})
public void testLocalCallbackWithException() throws Exception
{
cache = createCache(Configuration.CacheMode.LOCAL, IsolationLevel.SERIALIZABLE);
16 years, 6 months
JBoss Cache SVN: r5978 - core/trunk/src/main/java/org/jboss/cache/buddyreplication.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-12 08:03:09 -0400 (Thu, 12 Jun 2008)
New Revision: 5978
Modified:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
Log:
removed unused fields
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-06-12 11:53:27 UTC (rev 5977)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-06-12 12:03:09 UTC (rev 5978)
@@ -4,7 +4,13 @@
import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.ReversibleCommand;
-import org.jboss.cache.commands.read.*;
+import org.jboss.cache.commands.read.ExistsCommand;
+import org.jboss.cache.commands.read.GetChildrenNamesCommand;
+import org.jboss.cache.commands.read.GetDataMapCommand;
+import org.jboss.cache.commands.read.GetKeyValueCommand;
+import org.jboss.cache.commands.read.GetKeysCommand;
+import org.jboss.cache.commands.read.GetNodeCommand;
+import org.jboss.cache.commands.read.GravitateDataCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
@@ -24,9 +30,6 @@
*/
public class Fqn2BuddyFqnVisitor extends AbstractVisitor
{
- public static final String BUDDY_BACKUP_SUBTREE = "_BUDDY_BACKUP_";
- public static final Fqn<String> BUDDY_BACKUP_SUBTREE_FQN = Fqn.fromString(BUDDY_BACKUP_SUBTREE);
-
private BuddyFqnTransformer buddyFqnTransformer;
private final String buddyGroupName;
16 years, 6 months
JBoss Cache SVN: r5977 - in core/trunk/src: main/java/org/jboss/cache/transaction and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-06-12 07:53:27 -0400 (Thu, 12 Jun 2008)
New Revision: 5977
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java
Log:
http://jira.jboss.com/jira/browse/JBCACHE-1363 - rollback: runtime excpetion propagation to the user was rolledback, as it needs ample changes, and not sure if I woun't break compatibility (users and API)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-06-12 11:36:26 UTC (rev 5976)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-06-12 11:53:27 UTC (rev 5977)
@@ -624,8 +624,7 @@
}
catch (Throwable e)
{
- log.error("Rollback had a problem", e);
- throw new CacheException("A failure occured durring rollback!", e);
+ log.warn("Rollback had a problem", e);
}
finally
{
@@ -969,17 +968,11 @@
switch (status)
{
case Status.STATUS_COMMITTED:
- try
- {
- boolean onePhaseCommit = isOnePhaseCommit();
- if (log.isDebugEnabled()) log.debug("Running commit phase. One phase? " + onePhaseCommit);
- runCommitPhase(ctx, gtx, modifications, onePhaseCommit);
- log.debug("Finished commit phase");
- break;
- } catch (Exception e)
- {
- log.trace("Caught exception on After completion", e);
- }
+ boolean onePhaseCommit = isOnePhaseCommit();
+ if (log.isDebugEnabled()) log.debug("Running commit phase. One phase? " + onePhaseCommit);
+ runCommitPhase(ctx, gtx, modifications, onePhaseCommit);
+ log.debug("Finished commit phase");
+ break;
case Status.STATUS_UNKNOWN:
log.warn("Received JTA STATUS_UNKNOWN in afterCompletion()! XA resources may not be in sync. The app should manually clean up resources at this point.");
case Status.STATUS_MARKED_ROLLBACK:
@@ -993,6 +986,11 @@
throw new IllegalStateException("illegal status: " + status);
}
}
+ catch (Exception th)
+ {
+ log.trace("Caught exception ", th);
+
+ }
finally
{
// clean up the tx table
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2008-06-12 11:36:26 UTC (rev 5976)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2008-06-12 11:53:27 UTC (rev 5977)
@@ -95,17 +95,13 @@
{
try
{
- // JBCACHE-360 -- to match JBossTM (and presumable the spec) a
- // rollback transaction should have status ROLLEDBACK before
+ // JBCACHE-360 -- to match JBossTM (and presumable the spec) a
+ // rollback transaction should have status ROLLEDBACK before
// calling afterCompletion().
//status=Status.STATUS_ROLLING_BACK;
status = Status.STATUS_ROLLEDBACK;
notifyAfterCompletion(Status.STATUS_ROLLEDBACK);
}
- catch (RuntimeException re)
- {
- throw re;
- }
catch (Throwable t)
{
}
@@ -285,15 +281,10 @@
{
s.afterCompletion(status);
}
- catch (RuntimeException t)
+ catch (Throwable t)
{
log.error("afterCompletion() failed for " + s, t);
- throw t;
}
- catch (Exception t)
- {
- log.error("afterCompletion() failed for " + s, t);
- }
}
participants.clear();
}
Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java 2008-06-12 11:36:26 UTC (rev 5976)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java 2008-06-12 11:53:27 UTC (rev 5977)
@@ -30,7 +30,7 @@
IMocksControl control;
Fqn fqn = Fqn.fromString("/dummy");
InvocationContext ctx;
- BuddyFqnTransformer fqnTransformer;
+ BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
@BeforeMethod
public void setUp()
16 years, 6 months
JBoss Cache SVN: r5976 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 11 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-06-12 07:36:26 -0400 (Thu, 12 Jun 2008)
New Revision: 5976
Added:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
Removed:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
core/trunk/src/main/java/org/jboss/cache/RegionManager.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyFqnTransformerTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithOptimisticLockingTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/EmptyRegionTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
Log:
http://jira.jboss.com/jira/browse/JBCACHE-1362
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -14,12 +14,7 @@
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* A container for the root node in the cache, which also provides helpers for efficiently accessing nodes, walking trees, etc.
@@ -47,9 +42,10 @@
private final Set<Fqn> internalFqns = new HashSet<Fqn>();
private NodeFactory nodeFactory;
private LockManager lockManager;
+ private BuddyFqnTransformer buddyFqnTransformer;
@Inject
- public void injectDependencies(Configuration configuration, NodeFactory nodeFactory, LockManager lockManager)
+ public void injectDependencies(Configuration configuration, NodeFactory nodeFactory, LockManager lockManager, BuddyFqnTransformer transformer)
{
setDependencies(configuration, nodeFactory, lockManager);
@@ -58,6 +54,7 @@
// TODO: Investigate which components rely on this being available before start(), and why!
//TODO - remove setDependencies method at this point
createRootNode();
+ this.buddyFqnTransformer = transformer;
}
public void setDependencies(Configuration configuration, NodeFactory nodeFactory, LockManager lockManager)
@@ -224,7 +221,7 @@
public List<NodeData> buildNodeData(List<NodeData> list, NodeSPI node)
{
- NodeData data = new NodeData(BuddyFqnTransformer.getActualFqn(node.getFqn()), node.getDataDirect());
+ NodeData data = new NodeData(buddyFqnTransformer.getActualFqn(node.getFqn()), node.getDataDirect());
list.add(data);
for (Object childNode : node.getChildrenDirect())
{
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -6,28 +6,15 @@
import static org.jboss.cache.Region.Type.*;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.ConfigurationException;
-import org.jboss.cache.config.EvictionConfig;
-import org.jboss.cache.config.EvictionPolicyConfig;
-import org.jboss.cache.config.EvictionRegionConfig;
+import org.jboss.cache.config.*;
import org.jboss.cache.eviction.EvictionTimerTask;
import org.jboss.cache.eviction.RegionNameConflictException;
-import org.jboss.cache.factories.annotations.Destroy;
-import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.factories.annotations.NonVolatile;
-import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.factories.annotations.Stop;
+import org.jboss.cache.factories.annotations.*;
import org.jboss.cache.lock.LockManager;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jgroups.Address;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -62,14 +49,17 @@
protected Configuration configuration;
protected RPCManager rpcManager;
private LockManager lockManager;
+ private BuddyFqnTransformer buddyFqnTransformer;
@Inject
- void injectDependencies(CacheSPI cache, Configuration configuration, RPCManager rpcManager, LockManager lockManager)
+ void injectDependencies(CacheSPI cache, Configuration configuration, RPCManager rpcManager, LockManager lockManager,
+ BuddyFqnTransformer transformer)
{
this.cache = cache;
this.rpcManager = rpcManager;
this.configuration = configuration;
this.lockManager = lockManager;
+ this.buddyFqnTransformer = transformer;
}
@Start
@@ -440,7 +430,7 @@
if (members != null && !members.isEmpty())
rpcManager.fetchPartialState(members, subtreeRoot.getFqn());
}
- else if (!BuddyFqnTransformer.isBackupFqn(fqn))
+ else if (!buddyFqnTransformer.isBackupFqn(fqn))
{
// Get the state from each DataOwner and integrate in their
// respective buddy backup cache
@@ -451,7 +441,7 @@
if (!cache.getMembers().contains(buddy))
continue;
sources.add(buddy);
- Fqn buddyRoot = BuddyFqnTransformer.getBackupFqn(buddy, fqn);
+ Fqn buddyRoot = buddyFqnTransformer.getBackupFqn(buddy, fqn);
subtreeRoot = cache.peek(buddyRoot, false, false);
if (subtreeRoot == null)
{
@@ -572,7 +562,7 @@
{
for (Object buddy : buddies)
{
- list.add(BuddyFqnTransformer.getBackupFqn((String) buddy, fqn));
+ list.add(buddyFqnTransformer.getBackupFqn((String) buddy, fqn));
}
}
}
Deleted: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -1,356 +0,0 @@
-package org.jboss.cache.buddyreplication;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.AbstractVisitor;
-import org.jboss.cache.commands.ReversibleCommand;
-import org.jboss.cache.commands.read.ExistsCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.read.GravitateDataCommand;
-import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.*;
-import org.jboss.cache.factories.CommandsFactory;
-import org.jgroups.Address;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * For each command the fqns are chnaged such that they are under the current buddy group's backup subtree
- * (e.g., /_buddy_backup_/my_host:7890/) rather than the root (/).
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 2.2
- */
-public class BuddyFqnTransformer extends AbstractVisitor
-{
-
-
- public static final String BUDDY_BACKUP_SUBTREE = "_BUDDY_BACKUP_";
- public static final Fqn<String> BUDDY_BACKUP_SUBTREE_FQN = Fqn.fromString(BUDDY_BACKUP_SUBTREE);
-
-
- private final String buddyGroupName;
-
- CommandsFactory factory;
-
- public BuddyFqnTransformer(String buddyGroupName)
- {
- this.buddyGroupName = buddyGroupName == null ? "null" : buddyGroupName;
- }
-
- public BuddyFqnTransformer(String buddyGroupName, CommandsFactory cf)
- {
- this.buddyGroupName = buddyGroupName == null ? "null" : buddyGroupName;
- this.factory = cf;
- }
-
- @Override
- public Object visitCommitCommand(InvocationContext ctx, CommitCommand commitCommand) throws Throwable
- {
- return commitCommand;
- }
-
- @Override
- public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildPutDataMapCommand(null, transformed, command.getData());
- }
-
- @Override
- public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildPutKeyValueCommand(null, transformed, command.getKey(), command.getValue());
- }
-
- @Override
- public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildPutForExternalReadCommand(null, transformed, command.getKey(), command.getValue());
- }
-
- @Override
- public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildRemoveNodeCommand(command.getGlobalTransaction(), transformed);
- }
-
- @Override
- public Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildClearDataCommand(command.getGlobalTransaction(), transformed);
- }
-
- @Override
- public Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
- {
- Fqn fqn = getBackupFqn(command.getFqn());
- return factory.buildEvictFqnCommand(fqn);
- }
-
- @Override
- public Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildInvalidateCommand(transformed);
- }
-
- @Override
- public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildRemoveKeyCommand(null, transformed, command.getKey());
- }
-
- @Override
- public Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildGetDataMapCommand(transformed);
- }
-
- @Override
- public Object visitExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildEvictFqnCommand(transformed);
- }
-
- @Override
- public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildGetKeyValueCommand(transformed, command.getKey(), command.isSendNodeEvent());
- }
-
- @Override
- public Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildGetNodeCommand(transformed);
- }
-
- @Override
- public Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildGetKeysCommand(transformed);
- }
-
- @Override
- public Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildGetChildrenNamesCommand(transformed);
- }
-
- @Override
- public Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
- {
- Fqn transformedFrom = getBackupFqn(command.getFqn());
- Fqn transformedTo = getBackupFqn(command.getTo());
- return factory.buildMoveCommand(transformedFrom, transformedTo);
- }
-
- @Override
- public Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
- {
- Fqn transformed = getBackupFqn(command.getFqn());
- return factory.buildGravitateDataCacheCommand(transformed, command.isSearchSubtrees());
- }
-
- @Override
- public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
- {
- List<ReversibleCommand> toTransform = command.getModifications();
- List<ReversibleCommand> transformedCommands = transformBatch(toTransform);
- return factory.buildPrepareCommand(command.getGlobalTransaction(), transformedCommands, command.getLocalAddress(), command.isOnePhaseCommit());
- }
-
- @Override
- public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
- {
- return factory.buildRollbackCommand(null);
- }
-
- @Override
- public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
- {
- List<ReversibleCommand> transformed = transformBatch(command.getModifications());
- return factory.buildOptimisticPrepareCommand(command.getGlobalTransaction(), transformed, command.getData(), command.getLocalAddress(), command.isOnePhaseCommit());
- }
-
- @Override
- public Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
- {
- return factory.buildCreateNodeCommand(getBackupFqn(command.getFqn()));
- }
-
- /**
- * Assumes the backup Fqn if the current instance is the data owner.
- */
- public Fqn getBackupFqn(Fqn originalFqn)
- {
- return getBackupFqn(buddyGroupName, originalFqn);
- }
-
-
- public List<ReversibleCommand> transformBatch(List<ReversibleCommand> toTransform) throws Throwable
- {
- List<ReversibleCommand> transformedCommands = new ArrayList<ReversibleCommand>(toTransform.size());
- for (ReversibleCommand com : toTransform)
- {
- transformedCommands.add((ReversibleCommand) com.acceptVisitor(null, this));
- }
- return transformedCommands;
- }
-
- /**
- * Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the data owner's Address.
- *
- * @param dataOwnerAddress the JGroups {@link org.jgroups.Address} of the data owner
- * @param origFqn the original Fqn
- * @return a backup Fqn
- */
- public static Fqn getBackupFqn(Address dataOwnerAddress, Fqn origFqn)
- {
- return getBackupFqn(getGroupNameFromAddress(dataOwnerAddress), origFqn);
- }
-
- /**
- * Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the buddy group name.
- *
- * @param buddyGroupName the buddy group name
- * @param origFqn the original Fqn
- * @return a backup Fqn
- */
- public static Fqn getBackupFqn(String buddyGroupName, Fqn origFqn)
- {
- if (isBackupFqn(origFqn))
- throw new CacheException("Cannot make a backup Fqn from a backup Fqn! Attempting to create a backup of " + origFqn);
-
- List<Object> elements = new ArrayList<Object>(origFqn.size() + 2);
- elements.add(BuddyManager.BUDDY_BACKUP_SUBTREE);
- elements.add(buddyGroupName);
- elements.addAll(origFqn.peekElements());
-
- return Fqn.fromList(elements);
- }
-
- /**
- * Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the backup subtree for the
- * buddy group in question
- *
- * @param buddyGroupRoot the subtree under which data for a particular buddy is backed up
- * @param origFqn the original Fqn
- * @return a backup Fqn
- */
- public static Fqn getBackupFqn(Fqn buddyGroupRoot, Fqn origFqn)
- {
- if (isBackupFqn(origFqn))
- throw new CacheException("Cannot make a backup Fqn from a backup Fqn! Attempting to create a backup of " + origFqn);
-
- List<Object> elements = new ArrayList<Object>(origFqn.size() + 2);
- elements.add(BuddyManager.BUDDY_BACKUP_SUBTREE);
- elements.add(buddyGroupRoot.get(1));
- elements.addAll(origFqn.peekElements());
-
- return Fqn.fromList(elements);
- }
-
- public static boolean isBackupFqn(Fqn name)
- {
- return name != null && name.hasElement(BuddyManager.BUDDY_BACKUP_SUBTREE);
- }
-
- public static Fqn getActualFqn(Fqn fqn)
- {
- if (!isBackupFqn(fqn)) return fqn;
- // remove the first 2 (or 3 in the case of a dead backup region) elements
- return fqn.getSubFqn(isDeadBackupFqn(fqn) ? 3 : 2, fqn.size());
- }
-
- /**
- * Tests whether a given Fqn belongs to a dead backup region.
- *
- * @param name fqn to test
- * @return true if the fqn is a part of a dead backup region; false otherwise.
- */
- @SuppressWarnings("unchecked")
- public static boolean isDeadBackupFqn(Fqn name)
- {
- if (name == null || name.size() < 2) return false;
- Object elem1 = name.get(1);
- if (elem1 instanceof String)
- {
- String strElem1 = (String) elem1;
- return name.hasElement(BuddyManager.BUDDY_BACKUP_SUBTREE) && strElem1.endsWith(":DEAD");
- }
- else
- {
- return false;
- }
- }
-
- /**
- * @param dataOwner owner of a data set
- * @return a backup root for a given data owner
- */
- @SuppressWarnings("unchecked")
- public static Fqn<String> getBackupRoot(Address dataOwner)
- {
- return (Fqn) Fqn.fromRelativeElements(BUDDY_BACKUP_SUBTREE_FQN, getGroupNameFromAddress(dataOwner));
- }
-
- /**
- * Returns the backup root of a dead data owner
- *
- * @param dataOwner owner of data
- * @return Fqn of dead data owner's root
- */
- @SuppressWarnings("unchecked")
- public static Fqn<String> getDeadBackupRoot(Address dataOwner)
- {
- return (Fqn) Fqn.fromRelativeElements(BUDDY_BACKUP_SUBTREE_FQN, getGroupNameFromAddress(dataOwner) + ":DEAD");
- }
-
- public static boolean isDeadBackupRoot(Fqn f)
- {
- return f.getParent().equals(BUDDY_BACKUP_SUBTREE_FQN) && f.getLastElementAsString().endsWith(":DEAD");
- }
-
- public static String getGroupNameFromAddress(Address address)
- {
- return address.toString().replace(':', '_');
- }
-
- /**
- * Returns the buddy backp root portion of a given Fqn, provided it is a backup Fqn. If it is not a backup Fqn, Fqn.ROOT is returned.
- *
- * @param fqn fqn
- */
- public static Fqn getBackupRootFromFqn(Fqn fqn)
- {
- if (isBackupFqn(fqn))
- {
- return fqn.getSubFqn(0, isDeadBackupFqn(fqn) ? 3 : 2);
- }
- else
- {
- return Fqn.ROOT;
- }
- }
-}
Added: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -0,0 +1,157 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.CacheException;
+import org.jgroups.Address;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Knows how to transform between fqn and buddy-formated fqns.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 2.2
+ */
+public class BuddyFqnTransformer
+{
+ public static final String BUDDY_BACKUP_SUBTREE = "_BUDDY_BACKUP_";
+ public static final Fqn<String> BUDDY_BACKUP_SUBTREE_FQN = Fqn.fromString(BUDDY_BACKUP_SUBTREE);
+
+ /**
+ * Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the data owner's Address.
+ *
+ * @param dataOwnerAddress the JGroups {@link org.jgroups.Address} of the data owner
+ * @param origFqn the original Fqn
+ * @return a backup Fqn
+ */
+ public Fqn getBackupFqn(Address dataOwnerAddress, Fqn origFqn)
+ {
+ return getBackupFqn(getGroupNameFromAddress(dataOwnerAddress), origFqn);
+ }
+
+ /**
+ * Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the buddy group name.
+ *
+ * @param buddyGroupName the buddy group name
+ * @param origFqn the original Fqn
+ * @return a backup Fqn
+ */
+ public Fqn getBackupFqn(String buddyGroupName, Fqn origFqn)
+ {
+ if (isBackupFqn(origFqn))
+ throw new CacheException("Cannot make a backup Fqn from a backup Fqn! Attempting to create a backup of " + origFqn);
+
+ List<Object> elements = new ArrayList<Object>(origFqn.size() + 2);
+ elements.add(BuddyManager.BUDDY_BACKUP_SUBTREE);
+ elements.add(buddyGroupName);
+ elements.addAll(origFqn.peekElements());
+
+ return Fqn.fromList(elements);
+ }
+
+ /**
+ * Utility method that retrieves a buddy backup Fqn given the actual Fqn of some data and the backup subtree for the
+ * buddy group in question
+ *
+ * @param buddyGroupRoot the subtree under which data for a particular buddy is backed up
+ * @param origFqn the original Fqn
+ * @return a backup Fqn
+ */
+ public Fqn getBackupFqn(Fqn buddyGroupRoot, Fqn origFqn)
+ {
+ if (isBackupFqn(origFqn))
+ throw new CacheException("Cannot make a backup Fqn from a backup Fqn! Attempting to create a backup of " + origFqn);
+
+ List<Object> elements = new ArrayList<Object>(origFqn.size() + 2);
+ elements.add(BuddyManager.BUDDY_BACKUP_SUBTREE);
+ elements.add(buddyGroupRoot.get(1));
+ elements.addAll(origFqn.peekElements());
+
+ return Fqn.fromList(elements);
+ }
+
+ public boolean isBackupFqn(Fqn name)
+ {
+ return name != null && name.hasElement(BuddyManager.BUDDY_BACKUP_SUBTREE);
+ }
+
+ public Fqn getActualFqn(Fqn fqn)
+ {
+ if (!isBackupFqn(fqn)) return fqn;
+ if (fqn.equals(BUDDY_BACKUP_SUBTREE_FQN)) return Fqn.ROOT;
+ // remove the first 2 (or 3 in the case of a dead backup region) elements
+ return fqn.getSubFqn(isDeadBackupFqn(fqn) ? 3 : 2, fqn.size());
+ }
+
+ /**
+ * Tests whether a given Fqn belongs to a dead backup region.
+ *
+ * @param name fqn to test
+ * @return true if the fqn is a part of a dead backup region; false otherwise.
+ */
+ @SuppressWarnings("unchecked")
+ public boolean isDeadBackupFqn(Fqn name)
+ {
+ if (name == null || name.size() < 2) return false;
+ Object elem1 = name.get(1);
+ if (elem1 instanceof String)
+ {
+ String strElem1 = (String) elem1;
+ return name.hasElement(BuddyManager.BUDDY_BACKUP_SUBTREE) && strElem1.endsWith(":DEAD");
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * @param dataOwner owner of a data set
+ * @return a backup root for a given data owner
+ */
+ @SuppressWarnings("unchecked")
+ public Fqn<String> getBackupRoot(Address dataOwner)
+ {
+ return (Fqn) Fqn.fromRelativeElements(BUDDY_BACKUP_SUBTREE_FQN, getGroupNameFromAddress(dataOwner));
+ }
+
+ /**
+ * Returns the backup root of a dead data owner
+ *
+ * @param dataOwner owner of data
+ * @return Fqn of dead data owner's root
+ */
+ @SuppressWarnings("unchecked")
+ public Fqn<String> getDeadBackupRoot(Address dataOwner)
+ {
+ return (Fqn) Fqn.fromRelativeElements(BUDDY_BACKUP_SUBTREE_FQN, getGroupNameFromAddress(dataOwner) + ":DEAD");
+ }
+
+ public boolean isDeadBackupRoot(Fqn f)
+ {
+ return f.getParent().equals(BUDDY_BACKUP_SUBTREE_FQN) && f.getLastElementAsString().endsWith(":DEAD");
+ }
+
+ public String getGroupNameFromAddress(Address address)
+ {
+ return address.toString().replace(':', '_');
+ }
+
+ /**
+ * Returns the buddy backp root portion of a given Fqn, provided it is a backup Fqn. If it is not a backup Fqn, Fqn.ROOT is returned.
+ *
+ * @param fqn fqn
+ */
+ public Fqn getBackupRootFromFqn(Fqn fqn)
+ {
+ if (isBackupFqn(fqn))
+ {
+ return fqn.getSubFqn(0, isDeadBackupFqn(fqn) ? 3 : 2);
+ }
+ else
+ {
+ return Fqn.ROOT;
+ }
+ }
+}
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -69,7 +69,7 @@
BuddyLocator buddyLocator;
- BuddyFqnTransformer fqnTransformer;
+ Fqn2BuddyFqnVisitor fqnVisitorFqn2;
CommandsFactory commandsFactory;
@@ -143,6 +143,7 @@
private boolean receivedBuddyInfo;
private DataContainerImpl dataContainer;
+ private BuddyFqnTransformer buddyFqnTransformer;
public BuddyManager()
{
@@ -181,7 +182,7 @@
@Inject
public void injectDependencies(CacheSPI cache, Configuration configuration, RegionManager regionManager,
StateTransferManager stateTransferManager, RPCManager rpcManager, NotifierImpl notifier,
- CommandsFactory factory, DataContainerImpl dataContainer)
+ CommandsFactory factory, DataContainerImpl dataContainer, BuddyFqnTransformer transformer)
{
this.cache = cache;
this.configuration = configuration;
@@ -191,6 +192,7 @@
this.notifier = notifier;
this.commandsFactory = factory;
this.dataContainer = dataContainer;
+ buddyFqnTransformer = transformer;
}
public BuddyReplicationConfig getConfig()
@@ -270,7 +272,7 @@
throw new CacheException("Unable to initialize BuddyManager - the RPCManager has not connected to the cluster and local Address is null!");
}
}
- buddyGroup.setGroupName(BuddyFqnTransformer.getGroupNameFromAddress(localAddress));
+ buddyGroup.setGroupName(buddyFqnTransformer.getGroupNameFromAddress(localAddress));
if (config.getBuddyPoolName() != null)
{
@@ -300,7 +302,8 @@
void initFqnTransformer(String groupName, CommandsFactory commandsFactory)
{
- fqnTransformer = new BuddyFqnTransformer(groupName, commandsFactory);
+ fqnVisitorFqn2 = new Fqn2BuddyFqnVisitor(groupName, commandsFactory);
+ fqnVisitorFqn2.setBuddyFqnTransformer(buddyFqnTransformer);
}
public boolean isAutoDataGravitation()
@@ -563,7 +566,7 @@
buddyGroupsIParticipateIn.put(newGroup.getDataOwner(), newGroup);
// Integrate state transfer from the data owner of the buddy group
- Fqn integrationBase = BuddyFqnTransformer.getBackupRoot(newGroup.getDataOwner());
+ Fqn integrationBase = buddyFqnTransformer.getBackupRoot(newGroup.getDataOwner());
if (state.isEmpty())
{
@@ -676,14 +679,14 @@
/**
- * @see org.jboss.cache.buddyreplication.BuddyFqnTransformer
+ * @see Fqn2BuddyFqnVisitor
*/
public VisitableCommand transformFqns(VisitableCommand call)
{
try
{
- VisitableCommand transformed = (VisitableCommand) call.acceptVisitor(null, fqnTransformer);
+ VisitableCommand transformed = (VisitableCommand) call.acceptVisitor(null, fqnVisitorFqn2);
if (trace) log.trace("Transformed " + call + " to " + transformed);
return transformed;
}
@@ -1018,17 +1021,6 @@
}
- /**
- * Assumes the backup Fqn if the current instance is the data owner
- *
- * @param originalFqn
- * @return backup fqn
- */
- public Fqn getBackupFqn(Fqn originalFqn)
- {
- return BuddyFqnTransformer.getBackupFqn(buddyGroup == null || buddyGroup.getGroupName() == null ? "null" : buddyGroup.getGroupName(), originalFqn);
- }
-
private void migrateDefunctData(Node backupRoot, Address dataOwner)
{
Fqn defunctBackupRootFqn = getDefunctBackupRootFqn(dataOwner);
@@ -1051,7 +1043,7 @@
{
// the defunct Fqn should be: /_BUDDY_BACKUP_/dataOwnerAddess:DEAD/N
// where N is a number.
- Fqn<String> defunctRoot = BuddyFqnTransformer.getDeadBackupRoot(dataOwner);
+ Fqn<String> defunctRoot = buddyFqnTransformer.getDeadBackupRoot(dataOwner);
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
Node defunctRootNode = cache.getRoot().addChild(defunctRoot);
SortedSet childrenNames = new TreeSet(defunctRootNode.getChildrenNames()); // will be naturally sorted.
@@ -1177,7 +1169,7 @@
for (Address a : toRemove)
{
BuddyGroup bg = buddyGroupsIParticipateIn.remove(a);
- Fqn backupRootFqn = BuddyFqnTransformer.getBackupRoot(bg.getDataOwner());
+ Fqn backupRootFqn = buddyFqnTransformer.getBackupRoot(bg.getDataOwner());
Node backupRoot = cache.getNode(backupRootFqn);
if (backupRoot != null)
{
Copied: core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java (from rev 5970, core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -0,0 +1,216 @@
+package org.jboss.cache.buddyreplication;
+
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.AbstractVisitor;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.commands.read.*;
+import org.jboss.cache.commands.tx.CommitCommand;
+import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
+import org.jboss.cache.commands.tx.PrepareCommand;
+import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.*;
+import org.jboss.cache.factories.CommandsFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * For each command the fqns are changed such that they are under the current buddy group's backup subtree
+ * (e.g., /_buddy_backup_/my_host:7890/) rather than the root (/).
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 2.2
+ */
+public class Fqn2BuddyFqnVisitor extends AbstractVisitor
+{
+ public static final String BUDDY_BACKUP_SUBTREE = "_BUDDY_BACKUP_";
+ public static final Fqn<String> BUDDY_BACKUP_SUBTREE_FQN = Fqn.fromString(BUDDY_BACKUP_SUBTREE);
+
+ private BuddyFqnTransformer buddyFqnTransformer;
+
+ private final String buddyGroupName;
+
+ CommandsFactory factory;
+
+ public Fqn2BuddyFqnVisitor(String buddyGroupName)
+ {
+ this.buddyGroupName = buddyGroupName == null ? "null" : buddyGroupName;
+ }
+
+ public Fqn2BuddyFqnVisitor(String buddyGroupName, CommandsFactory cf)
+ {
+ this.buddyGroupName = buddyGroupName == null ? "null" : buddyGroupName;
+ this.factory = cf;
+ }
+
+ @Override
+ public Object visitCommitCommand(InvocationContext ctx, CommitCommand commitCommand) throws Throwable
+ {
+ return commitCommand;
+ }
+
+ @Override
+ public Object visitPutDataMapCommand(InvocationContext ctx, PutDataMapCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildPutDataMapCommand(null, transformed, command.getData());
+ }
+
+ @Override
+ public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildPutKeyValueCommand(null, transformed, command.getKey(), command.getValue());
+ }
+
+ @Override
+ public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildPutForExternalReadCommand(null, transformed, command.getKey(), command.getValue());
+ }
+
+ @Override
+ public Object visitRemoveNodeCommand(InvocationContext ctx, RemoveNodeCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildRemoveNodeCommand(command.getGlobalTransaction(), transformed);
+ }
+
+ @Override
+ public Object visitClearDataCommand(InvocationContext ctx, ClearDataCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildClearDataCommand(command.getGlobalTransaction(), transformed);
+ }
+
+ @Override
+ public Object visitEvictFqnCommand(InvocationContext ctx, EvictCommand command) throws Throwable
+ {
+ Fqn fqn = getBackupFqn(command.getFqn());
+ return factory.buildEvictFqnCommand(fqn);
+ }
+
+ @Override
+ public Object visitInvalidateCommand(InvocationContext ctx, InvalidateCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildInvalidateCommand(transformed);
+ }
+
+ @Override
+ public Object visitRemoveKeyCommand(InvocationContext ctx, RemoveKeyCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildRemoveKeyCommand(null, transformed, command.getKey());
+ }
+
+ @Override
+ public Object visitGetDataMapCommand(InvocationContext ctx, GetDataMapCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildGetDataMapCommand(transformed);
+ }
+
+ @Override
+ public Object visitExistsNodeCommand(InvocationContext ctx, ExistsCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildEvictFqnCommand(transformed);
+ }
+
+ @Override
+ public Object visitGetKeyValueCommand(InvocationContext ctx, GetKeyValueCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildGetKeyValueCommand(transformed, command.getKey(), command.isSendNodeEvent());
+ }
+
+ @Override
+ public Object visitGetNodeCommand(InvocationContext ctx, GetNodeCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildGetNodeCommand(transformed);
+ }
+
+ @Override
+ public Object visitGetKeysCommand(InvocationContext ctx, GetKeysCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildGetKeysCommand(transformed);
+ }
+
+ @Override
+ public Object visitGetChildrenNamesCommand(InvocationContext ctx, GetChildrenNamesCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildGetChildrenNamesCommand(transformed);
+ }
+
+ @Override
+ public Object visitMoveCommand(InvocationContext ctx, MoveCommand command) throws Throwable
+ {
+ Fqn transformedFrom = getBackupFqn(command.getFqn());
+ Fqn transformedTo = getBackupFqn(command.getTo());
+ return factory.buildMoveCommand(transformedFrom, transformedTo);
+ }
+
+ @Override
+ public Object visitGravitateDataCommand(InvocationContext ctx, GravitateDataCommand command) throws Throwable
+ {
+ Fqn transformed = getBackupFqn(command.getFqn());
+ return factory.buildGravitateDataCommand(transformed, command.isSearchSubtrees());
+ }
+
+ @Override
+ public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
+ {
+ List<ReversibleCommand> toTransform = command.getModifications();
+ List<ReversibleCommand> transformedCommands = transformBatch(toTransform);
+ return factory.buildPrepareCommand(command.getGlobalTransaction(), transformedCommands, command.getLocalAddress(), command.isOnePhaseCommit());
+ }
+
+ @Override
+ public Object visitRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
+ {
+ return factory.buildRollbackCommand(null);
+ }
+
+ @Override
+ public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
+ {
+ List<ReversibleCommand> transformed = transformBatch(command.getModifications());
+ return factory.buildOptimisticPrepareCommand(command.getGlobalTransaction(), transformed, command.getData(), command.getLocalAddress(), command.isOnePhaseCommit());
+ }
+
+ @Override
+ public Object visitCreateNodeCommand(InvocationContext ctx, CreateNodeCommand command) throws Throwable
+ {
+ return factory.buildCreateNodeCommand(getBackupFqn(command.getFqn()));
+ }
+
+ public List<ReversibleCommand> transformBatch(List<ReversibleCommand> toTransform) throws Throwable
+ {
+ List<ReversibleCommand> transformedCommands = new ArrayList<ReversibleCommand>(toTransform.size());
+ for (ReversibleCommand com : toTransform)
+ {
+ transformedCommands.add((ReversibleCommand) com.acceptVisitor(null, this));
+ }
+ return transformedCommands;
+ }
+
+
+ /**
+ * Assumes the backup Fqn if the current instance is the data owner.
+ */
+ public Fqn getBackupFqn(Fqn originalFqn)
+ {
+ return buddyFqnTransformer.getBackupFqn(buddyGroupName, originalFqn);
+ }
+
+ public void setBuddyFqnTransformer(BuddyFqnTransformer buddyFqnTransformer)
+ {
+ this.buddyFqnTransformer = buddyFqnTransformer;
+ }
+}
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-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -37,6 +37,7 @@
private static final Log log = LogFactory.getLog(GravitateDataCommand.class);
private static boolean trace = log.isTraceEnabled();
+ private BuddyFqnTransformer buddyFqnTransformer;
public GravitateDataCommand(Fqn fqn, boolean searchSubtrees, Address localAddress)
{
@@ -50,10 +51,11 @@
this.localAddress = localAddress;
}
- public void initialize(DataContainer dataContainer, CacheSPI spi)
+ public void initialize(DataContainer dataContainer, CacheSPI spi, BuddyFqnTransformer transformer)
{
this.dataContainer = dataContainer;
this.spi = spi;
+ buddyFqnTransformer = transformer;
}
/**
@@ -96,7 +98,7 @@
// groupName is the name of a buddy group since all child names in this
// collection are direct children of BUDDY_BACKUP_SUBTREE_FQN
Fqn backupRoot = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, groupName);
- if (BuddyFqnTransformer.isDeadBackupRoot(backupRoot))
+ if (buddyFqnTransformer.isDeadBackupRoot(backupRoot))
{
Set<Integer> deadChildNames = new TreeSet<Integer>(spi.getChildrenNames(backupRoot));
Integer[] elems = deadChildNames.toArray(new Integer[deadChildNames.size()]);
@@ -147,7 +149,7 @@
if (backupNodeFqn == null && searchSubtrees)
{
- backupNodeFqn = BuddyFqnTransformer.getBackupFqn(BuddyFqnTransformer.getGroupNameFromAddress(localAddress), fqn);
+ backupNodeFqn = buddyFqnTransformer.getBackupFqn(buddyFqnTransformer.getGroupNameFromAddress(localAddress), fqn);
}
List<NodeData> list = dataContainer.buildNodeData(new LinkedList<NodeData>(), (NodeSPI) actualNode);
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -44,6 +44,7 @@
private GlobalTransaction globalTransaction;
private Fqn fqn;
private Fqn backup;
+ private BuddyFqnTransformer buddyFqnTransformer;
public DataGravitationCleanupCommand(Fqn primary, Fqn backup)
@@ -57,13 +58,14 @@
}
public void initialize(BuddyManager buddyManager, InterceptorChain invoker, TransactionTable transactionTable,
- CommandsFactory commandsFactory, DataContainerImpl dataContainer)
+ CommandsFactory commandsFactory, DataContainerImpl dataContainer, BuddyFqnTransformer buddyFqnTransformer)
{
this.buddyManager = buddyManager;
this.invoker = invoker;
this.transactionTable = transactionTable;
this.commandsFactory = commandsFactory;
this.dataContainer = dataContainer;
+ this.buddyFqnTransformer = buddyFqnTransformer;
}
/**
@@ -84,7 +86,7 @@
if (wasNodeRemoved(result))
{
// if this is a DIRECT child of a DEAD buddy backup region, then remove the empty dead region structural node.
- if (BuddyFqnTransformer.isDeadBackupFqn(backup) && BuddyFqnTransformer.isDeadBackupRoot(backup.getParent().getParent()))
+ if (buddyFqnTransformer.isDeadBackupFqn(backup) && buddyFqnTransformer.isDeadBackupRoot(backup.getParent().getParent()))
{
NodeSPI deadBackupRoot = dataContainer.peek(backup.getParent(), false);
if (deadBackupRoot.getChildrenMapDirect().isEmpty())
Modified: core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -7,6 +7,7 @@
import org.jboss.cache.RPCManager;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.buddyreplication.BuddyManager;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.commands.DataCommand;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.ReversibleCommand;
@@ -61,6 +62,7 @@
private CacheSPI cacheSpi;
private Configuration configuration;
private TransactionManager txManager;
+ private BuddyFqnTransformer buddyFqnTransformer;
public CommandsFactory()
{
@@ -69,7 +71,7 @@
@Inject
public void initialize(RPCManager rpc, DataContainerImpl dataContainer, NotifierImpl notifier, BuddyManager buddyManager,
InterceptorChain invoker, TransactionTable transactionTable, CacheSPI cacheSpi,
- Configuration configuration, TransactionManager txManager)
+ Configuration configuration, TransactionManager txManager, BuddyFqnTransformer buddyFqnTransformer)
{
this.rpcManager = rpc;
this.dataContainer = dataContainer;
@@ -80,6 +82,7 @@
this.cacheSpi = cacheSpi;
this.configuration = configuration;
this.txManager = txManager;
+ this.buddyFqnTransformer = buddyFqnTransformer;
}
public PutDataMapCommand buildPutDataMapCommand(GlobalTransaction gtx, Fqn fqn, Map data)
@@ -135,14 +138,14 @@
public DataGravitationCleanupCommand buildDataGravitationCleanupCommand(Fqn primaryFqn, Fqn backupFqn)
{
DataGravitationCleanupCommand command = new DataGravitationCleanupCommand(primaryFqn, backupFqn);
- command.initialize(buddyManager, invoker, transactionTable, this, dataContainer);
+ command.initialize(buddyManager, invoker, transactionTable, this, dataContainer, buddyFqnTransformer);
return command;
}
public GravitateDataCommand buildGravitateDataCommand(Fqn fqn, Boolean searchSubtrees)
{
GravitateDataCommand command = new GravitateDataCommand(fqn, searchSubtrees, rpcManager.getLocalAddress());
- command.initialize(dataContainer, cacheSpi);
+ command.initialize(dataContainer, cacheSpi, buddyFqnTransformer);
return command;
}
@@ -239,13 +242,6 @@
return command;
}
- public GravitateDataCommand buildGravitateDataCacheCommand(Fqn fqn, boolean searchSubtrees)
- {
- GravitateDataCommand command = new GravitateDataCommand(fqn, searchSubtrees, rpcManager.getLocalAddress());
- command.initialize(dataContainer, cacheSpi);
- return command;
- }
-
public RollbackCommand buildRollbackCommand(GlobalTransaction gtx)
{
return new RollbackCommand(gtx);
@@ -495,14 +491,14 @@
case DataGravitationCleanupCommand.METHOD_ID:
{
DataGravitationCleanupCommand returnValue = new DataGravitationCleanupCommand();
- returnValue.initialize(buddyManager, invoker, transactionTable, this, dataContainer);
+ returnValue.initialize(buddyManager, invoker, transactionTable, this, dataContainer, buddyFqnTransformer);
command = returnValue;
break;
}
case GravitateDataCommand.METHOD_ID:
{
GravitateDataCommand returnValue = new GravitateDataCommand(rpcManager.getLocalAddress());
- returnValue.initialize(dataContainer, cacheSpi);
+ returnValue.initialize(dataContainer, cacheSpi, buddyFqnTransformer);
command = returnValue;
break;
}
Modified: core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/factories/EmptyConstructorFactory.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -2,6 +2,7 @@
import org.jboss.cache.DataContainerImpl;
import org.jboss.cache.RegionManager;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.config.ConfigurationException;
import org.jboss.cache.factories.annotations.DefaultFactoryFor;
import org.jboss.cache.invocation.CacheInvocationDelegate;
@@ -22,10 +23,9 @@
* @since 2.1.0
*/
@DefaultFactoryFor(classes = {StateTransferManager.class, RegionManager.class, NotifierImpl.class,
- ChannelMessageListener.class, CacheLoaderManager.class, Marshaller.class,
- InvocationContextContainer.class, CacheInvocationDelegate.class,
- TransactionTable.class, DataContainerImpl.class, CommandsFactory.class,
- LockStrategyFactory.class})
+ ChannelMessageListener.class, CacheLoaderManager.class, Marshaller.class, InvocationContextContainer.class,
+ CacheInvocationDelegate.class, TransactionTable.class, DataContainerImpl.class, CommandsFactory.class,
+ LockStrategyFactory.class, BuddyFqnTransformer.class})
public class EmptyConstructorFactory extends ComponentFactory
{
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BuddyRegionAwareEvictionInterceptor.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -2,6 +2,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
+import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.eviction.NodeEventType;
@@ -13,17 +14,25 @@
*/
public class BuddyRegionAwareEvictionInterceptor extends EvictionInterceptor
{
+ private BuddyFqnTransformer buddyFqnTransformer;
+
+ @Inject
+ public void initialize(BuddyFqnTransformer transformer)
+ {
+ this.buddyFqnTransformer = transformer;
+ }
+
@Override
protected Region getRegion(Fqn fqn, NodeEventType type)
{
Region r = super.getRegion(fqn, type);
if (r != null)
return r;
- else if (BuddyFqnTransformer.isBackupFqn(fqn))
+ else if (buddyFqnTransformer.isBackupFqn(fqn))
{
// try and grab a backup region, creating one if need be.
- Fqn actualFqn = BuddyFqnTransformer.getActualFqn(fqn);
- Fqn backupRoot = BuddyFqnTransformer.getBackupRootFromFqn(fqn);
+ Fqn actualFqn = buddyFqnTransformer.getActualFqn(fqn);
+ Fqn backupRoot = buddyFqnTransformer.getBackupRootFromFqn(fqn);
// the actual region could be a few levels higher than actualFqn
Region actualRegion = regionManager.getRegion(actualFqn, Region.Type.EVICTION, false);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -6,20 +6,13 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.DataContainerImpl;
import org.jboss.cache.*;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.DataCommand;
import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.commands.read.ExistsCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GetNodeCommand;
-import org.jboss.cache.commands.read.GravitateDataCommand;
+import org.jboss.cache.commands.read.*;
import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
@@ -69,14 +62,16 @@
private DataContainerImpl dataContainer;
private CommandsFactory commandsFactory;
private CacheSPI cacheSPI;
+ private BuddyFqnTransformer buddyFqnTransformer;
@Inject
- public void injectComponents(BuddyManager buddyManager, DataContainerImpl dataContainer, CommandsFactory commandsFactory, CacheSPI cacheSPI)
+ public void injectComponents(BuddyManager buddyManager, DataContainerImpl dataContainer, CommandsFactory commandsFactory, CacheSPI cacheSPI, BuddyFqnTransformer transformer)
{
this.buddyManager = buddyManager;
this.dataContainer = dataContainer;
this.commandsFactory = commandsFactory;
this.cacheSPI = cacheSPI;
+ buddyFqnTransformer = transformer;
}
@Override
@@ -149,7 +144,7 @@
{
// test that the Fqn being requested exists locally in the cache.
if (trace) log.trace("Checking local existence of command " + command);
- if (BuddyFqnTransformer.isBackupFqn(command.getFqn()))
+ if (buddyFqnTransformer.isBackupFqn(command.getFqn()))
{
log.info("Is call for a backup Fqn, not performing any gravitation. Direct calls on internal backup nodes are *not* supported.");
}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -228,7 +228,7 @@
public GravitateResult gravitateData(Fqn fqn, boolean searchBuddyBackupSubtrees, InvocationContext ctx)
{
cacheStatusCheck(ctx);
- GravitateDataCommand command = commandsFactory.buildGravitateDataCacheCommand(fqn, searchBuddyBackupSubtrees);
+ GravitateDataCommand command = commandsFactory.buildGravitateDataCommand(fqn, searchBuddyBackupSubtrees);
return (GravitateResult) invoker.invoke(ctx, command);
// return (GravitateResult) command.perform(null);
}
Modified: core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -8,12 +8,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.Region;
-import org.jboss.cache.RegionManager;
+import org.jboss.cache.*;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.marshall.Marshaller;
@@ -24,7 +19,10 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.util.*;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -46,6 +44,7 @@
protected RegionManager regionManager;
private static final Log log = LogFactory.getLog(AbstractCacheLoader.class);
private static final boolean trace = log.isTraceEnabled();
+ protected BuddyFqnTransformer buddyFqnTransformer = new BuddyFqnTransformer();
/**
* HashMap<Object,List<Modification>>. List of open transactions. Note that this is purely transient, as
* we don't use a log, recovery is not available
@@ -117,7 +116,7 @@
Fqn fqn;
if (moveToBuddy)
{
- fqn = BuddyFqnTransformer.getBackupFqn(subtree, nd.getFqn());
+ fqn = buddyFqnTransformer.getBackupFqn(subtree, nd.getFqn());
}
else
{
Modified: core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/loader/JDBCCacheLoader.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -4,7 +4,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
import org.jboss.cache.marshall.NodeData;
@@ -90,7 +89,7 @@
Fqn fqn;
if (moveToBuddy)
{
- fqn = BuddyFqnTransformer.getBackupFqn(subtree, nd.getFqn());
+ fqn = buddyFqnTransformer.getBackupFqn(subtree, nd.getFqn());
}
else
{
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/AbstractMarshaller.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -15,23 +15,9 @@
import org.jboss.cache.commands.DataCommand;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.ReversibleCommand;
-import org.jboss.cache.commands.read.ExistsCommand;
-import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.commands.read.GetDataMapCommand;
-import org.jboss.cache.commands.read.GetKeyValueCommand;
-import org.jboss.cache.commands.read.GetKeysCommand;
-import org.jboss.cache.commands.read.GravitateDataCommand;
-import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
-import org.jboss.cache.commands.remote.AssignToBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ClusteredGetCommand;
-import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
-import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
-import org.jboss.cache.commands.remote.ReplicateCommand;
-import org.jboss.cache.commands.tx.AbstractTransactionCommand;
-import org.jboss.cache.commands.tx.CommitCommand;
-import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
-import org.jboss.cache.commands.tx.PrepareCommand;
-import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.read.*;
+import org.jboss.cache.commands.remote.*;
+import org.jboss.cache.commands.tx.*;
import org.jboss.cache.commands.write.EvictCommand;
import org.jboss.cache.commands.write.InvalidateCommand;
import org.jboss.cache.config.Configuration;
@@ -57,6 +43,7 @@
protected boolean defaultInactive;
protected Log log;
protected boolean trace;
+ private BuddyFqnTransformer buddyFqnTransformer;
/**
* Map<GlobalTransaction, Fqn> for prepared tx that have not committed
@@ -67,11 +54,12 @@
protected boolean useRefs = false;
@Inject
- void injectDependencies(RegionManager regionManager, Configuration configuration, ClassLoader defaultClassLoader)
+ void injectDependencies(RegionManager regionManager, Configuration configuration, ClassLoader defaultClassLoader, BuddyFqnTransformer transformer)
{
this.defaultClassLoader = defaultClassLoader;
this.regionManager = regionManager;
this.configuration = configuration;
+ this.buddyFqnTransformer = transformer;
}
@Start
@@ -200,10 +188,10 @@
protected Region getRegion(Fqn fqn)
{
if (fqn == null) return null;
- if (BuddyFqnTransformer.isBackupFqn(fqn))
+ if (buddyFqnTransformer.isBackupFqn(fqn))
{
// Strip out the buddy group portion
- fqn = BuddyFqnTransformer.getActualFqn(fqn);
+ fqn = buddyFqnTransformer.getActualFqn(fqn);
}
return regionManager.getRegion(fqn, Region.Type.MARSHALLING, false);
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -90,7 +90,7 @@
assert latch.await(getSleepTimeout(), TimeUnit.MILLISECONDS) : "Buddy groups not formed after " + getSleepTimeout() + " millis!";
- Fqn<String> test = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), main);
+ Fqn<String> test = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), main);
assertEquals("State not transferred", "Joe", caches.get(1).get(test, "name"));
@@ -161,11 +161,11 @@
Fqn mainD = Fqn.fromString("/d/e/f");
caches.get(0).put(mainD, "name", "Joe");
- Fqn testA = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), mainA);
+ Fqn testA = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), mainA);
assertEquals("/a replicated", "Joe", caches.get(1).get(testA, "name"));
assertNull("No backup of /a", caches.get(2).get(testA, "name"));
- Fqn testD = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), mainD);
+ Fqn testD = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), mainD);
assertEquals("/d replicated", "Joe", caches.get(1).get(testD, "name"));
assertNull("No backup of /d", caches.get(2).get(testD, "name"));
@@ -212,7 +212,7 @@
assert latch.await(getSleepTimeout(), TimeUnit.MILLISECONDS) : "Buddy groups not formed after " + getSleepTimeout() + " millis!";
- Fqn test = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), main);
+ Fqn test = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), main);
assertFalse("/a/b/c shld not be bin memory", caches.get(1).exists(test));
assertNotNull("/a/b/c shld be in CL", caches.get(1).getCacheLoaderManager().getCacheLoader().get(test));
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyBackupActivationInactivationTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -70,7 +70,7 @@
System.out.println("cache1 " + CachePrinter.printCacheDetails(cache1));
System.out.println("cache2 " + CachePrinter.printCacheDetails(cache2));
- Fqn fqn = BuddyFqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);
+ Fqn fqn = fqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);
assertEquals("State transferred with activation", JOE, cache2.get(fqn, "name"));
}
@@ -81,7 +81,7 @@
CacheSPI cache2 = createCache("cache2", true, true, true);
TestingUtil.blockUntilViewsReceived(VIEW_BLOCK_TIMEOUT, cache1, cache2);
- Fqn backupFqn = BuddyFqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);
+ Fqn backupFqn = fqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);
Fqn<String> A = Fqn.fromString("/a");
Region regionA = cache1.getRegion(A, true);
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyFqnTransformerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyFqnTransformerTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyFqnTransformerTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -7,17 +7,19 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 2.2.0
*/
-@Test(groups = "functional")
+@Test(groups = "unit")
public class BuddyFqnTransformerTest
{
+ private BuddyFqnTransformer buddyFqnTransformer = new BuddyFqnTransformer();
+
public void testActualFqn()
{
Fqn backupFqn = Fqn.fromString("/_BUDDY_BACKUP_/1.2.3.4_5678/a/b/c/d");
- assert BuddyFqnTransformer.getActualFqn(backupFqn).equals(Fqn.fromString("/a/b/c/d"));
+ assert buddyFqnTransformer.getActualFqn(backupFqn).equals(Fqn.fromString("/a/b/c/d"));
backupFqn = Fqn.fromString("/_BUDDY_BACKUP_/1.2.3.4_5678");
- Fqn actual = BuddyFqnTransformer.getActualFqn(backupFqn);
+ Fqn actual = buddyFqnTransformer.getActualFqn(backupFqn);
assert actual.equals(Fqn.ROOT);
}
@@ -25,6 +27,11 @@
public void testBackupRootFqn()
{
Fqn backupFqn = Fqn.fromString("/_BUDDY_BACKUP_/1.2.3.4_5678/a/b/c/d");
- assert BuddyFqnTransformer.getBackupRootFromFqn(backupFqn).equals(Fqn.fromString("/_BUDDY_BACKUP_/1.2.3.4_5678")) : "Got " + BuddyFqnTransformer.getBackupRootFromFqn(backupFqn);
+ assert buddyFqnTransformer.getBackupRootFromFqn(backupFqn).equals(Fqn.fromString("/_BUDDY_BACKUP_/1.2.3.4_5678")) : "Got " + buddyFqnTransformer.getBackupRootFromFqn(backupFqn);
}
+
+ public void testGetActualFqnOnBuddyBackupRoot()
+ {
+ assert Fqn.ROOT == buddyFqnTransformer.getActualFqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN);
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyGroupAssignmentTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -23,6 +23,7 @@
public class BuddyGroupAssignmentTest extends BuddyReplicationTestsBase
{
private Log log = LogFactory.getLog(BuddyGroupAssignmentTest.class);
+ BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
public void testSingleBuddy() throws Exception
{
@@ -140,11 +141,11 @@
System.out.println("*** Testing cache 1:");
assertIsBuddy(caches.get(1), caches.get(0), true);
- assert caches.get(0).peek(BuddyFqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for self";
- assert caches.get(0).peek(BuddyFqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have backup region for buddy";
+ assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for self";
+ assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have backup region for buddy";
- assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have backup region for buddy";
- assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have backup region for self";
+ assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have backup region for buddy";
+ assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have backup region for self";
caches.add(createCache(1, null));
@@ -162,23 +163,23 @@
System.out.println("1 Lock info: " + CachePrinter.printCacheLockingInfo(caches.get(1)));
System.out.println("2 Lock info: " + CachePrinter.printCacheLockingInfo(caches.get(2)));
- assert caches.get(0).peek(BuddyFqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for self";
- assert caches.get(0).peek(BuddyFqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should have backup region for non-buddy";
- assert caches.get(0).peek(BuddyFqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) != null : "Should have backup region for buddy";
+ assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for self";
+ assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should have backup region for non-buddy";
+ assert caches.get(0).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) != null : "Should have backup region for buddy";
- assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have backup region for buddy";
- assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have backup region for self";
- assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have backup region for non-buddy";
+ assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) != null : "Should have backup region for buddy";
+ assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have backup region for self";
+ assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have backup region for non-buddy";
- assert caches.get(2).peek(BuddyFqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for non-buddy";
- assert caches.get(2).peek(BuddyFqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have backup region for buddy";
- assert caches.get(2).peek(BuddyFqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have backup region for self";
+ assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have backup region for non-buddy";
+ assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have backup region for buddy";
+ assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have backup region for self";
// ensure no state transfer has happened!!
assert caches.get(2).peek(Fqn.fromString("/cache0"), false) == null : "Unnecessary state should not have been transferred!";
assert caches.get(2).peek(Fqn.fromString("/cache1"), false) == null : "Unnecessary state should not have been transferred!";
// ensure backup state has been transferred.
- assert caches.get(2).peek(BuddyFqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), Fqn.fromString("/cache1")), false) != null : "Backup state should have transferred!";
+ assert caches.get(2).peek(fqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), Fqn.fromString("/cache1")), false) != null : "Backup state should have transferred!";
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyManagerTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -31,6 +31,7 @@
public class BuddyManagerTest
{
private static final String DUMMY_LOCAL_ADDRESS = "myLocalAddress:12345";
+ private BuddyFqnTransformer fqnTransformer;
/**
* Constructs a buddy manager using the default buddy locator but with some specific properties.
@@ -125,7 +126,7 @@
BuddyReplicationConfig cfg = XmlConfigurationParser.parseBuddyReplicationConfig(element);
bm = new BuddyManager(cfg);
CommandsFactory commandsFactory = new CommandsFactory();
- commandsFactory.initialize(null, null, null, null, null, null, null, new Configuration(), null);
+ commandsFactory.initialize(null, null, null, null, null, null, null, new Configuration(), null, new BuddyFqnTransformer());
bm.initFqnTransformer(DUMMY_LOCAL_ADDRESS, commandsFactory);
}
catch (Exception e)
@@ -206,8 +207,9 @@
public void testGetActualFqn()
{
+ fqnTransformer = new BuddyFqnTransformer();
Fqn<String> x = Fqn.fromString("/x");
- Fqn backup = BuddyFqnTransformer.getBackupFqn("y", x);
- assertEquals(x, BuddyFqnTransformer.getActualFqn(backup));
+ Fqn backup = fqnTransformer.getBackupFqn("y", x);
+ assertEquals(x, fqnTransformer.getActualFqn(backup));
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationContentTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -33,6 +33,7 @@
private String key = "key";
private String value = "value";
private Log log = LogFactory.getLog(BuddyGroupAssignmentTest.class);
+ BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
private void assertNoStaleLocks(List<CacheSPI<Object, Object>> caches)
@@ -51,7 +52,7 @@
caches = createCaches(3, false);
String fqn = "/test";
- String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyFqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
+ String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
assertNoStaleLocks(caches);
@@ -83,7 +84,7 @@
caches = createCaches(3, false);
String fqn = "/test";
- String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyFqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
+ String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
assertNoStaleLocks(caches);
@@ -127,7 +128,7 @@
caches = createCaches(2, 4, false);
String fqn = "/test";
- String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyFqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
+ String backupFqn = "/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + fqn;
// put something in cache 1
assertNoStaleLocks(caches);
@@ -176,7 +177,7 @@
try
{
Fqn fqn = Fqn.fromString("/test");
- Fqn backupFqn = BuddyFqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), fqn);
+ Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), fqn);
assertNoStaleLocks(caches);
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationFailoverTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -25,6 +25,7 @@
protected boolean optimisticLocks = false;
private String key = "key";
private String value = "value";
+ BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
public void testDataGravitationKillOwner() throws Exception
{
@@ -41,7 +42,7 @@
caches = createCaches(3, false, true, optimisticLocks);
Fqn fqn = Fqn.fromString("/test");
- Fqn backupFqn = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
+ Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
TestingUtil.dumpCacheContents(caches);
@@ -70,15 +71,15 @@
System.out.println("Killed. Testing backup roots.");
TestingUtil.dumpCacheContents(caches);
// assert that the remaining caches have picked new buddies. Cache 1 should have cache 2's backup data.
- assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
- assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
- assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
- assert caches.get(1).peek(Fqn.fromRelativeElements(BuddyFqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) != null : "Should have dead node as a defunct backup root.";
+ assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(2).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(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
+ assert caches.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) != null : "Should have dead node as a defunct backup root.";
- assert caches.get(2).peek(BuddyFqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have self as a backup root.";
- assert caches.get(2).peek(BuddyFqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
- assert caches.get(2).peek(BuddyFqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
- assert caches.get(2).peek(Fqn.fromRelativeElements(BuddyFqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
+ assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have self as a backup root.";
+ assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
+ assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
+ assert caches.get(2).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
}
System.out.println("***** Killed original data owner, about to call a get on a different cache instance. *****");
@@ -91,7 +92,7 @@
TestingUtil.dumpCacheContents(caches);
// now lets test the eviction part of gravitation
- Fqn newBackupFqn = BuddyFqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
+ Fqn newBackupFqn = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
// use exists instead of get() to prevent going up the interceptor stack
if (!killOwner)
@@ -100,16 +101,16 @@
}
else
{
- assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
- assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) == null : "Should not have self as a backup root.";
- assert caches.get(1).peek(BuddyFqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
- assert caches.get(1).peek(Fqn.fromRelativeElements(BuddyFqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
- assert caches.get(1).peek(BuddyFqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a defunct backup root.";
+ assert caches.get(1).peek(fqnTransformer.getBackupRoot(caches.get(2).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(1).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
+ assert caches.get(1).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
+ assert caches.get(1).peek(fqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a defunct backup root.";
- assert caches.get(2).peek(BuddyFqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have self as a backup root.";
- assert caches.get(2).peek(BuddyFqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
- assert caches.get(2).peek(BuddyFqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
- assert caches.get(2).peek(Fqn.fromRelativeElements(BuddyFqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
+ assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(2).getLocalAddress()), false) == null : "Should not have self as a backup root.";
+ assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(1).getLocalAddress()), false) != null : "Should have new buddy's backup root.";
+ assert caches.get(2).peek(fqnTransformer.getBackupRoot(caches.get(0).getLocalAddress()), false) == null : "Should not have dead node as a backup root.";
+ assert caches.get(2).peek(Fqn.fromRelativeElements(fqnTransformer.getDeadBackupRoot(caches.get(0).getLocalAddress()), 1), false) == null : "Should not have dead node as a defunct backup root.";
}
assertTrue("Should be false", !caches.get(1).exists(fqn));
@@ -149,7 +150,7 @@
caches = createCaches(3, false, false, optimisticLocks);
Fqn fqn = Fqn.fromString("/test");
- Fqn backupFqn = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
+ Fqn backupFqn = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
caches.get(0).put(fqn, key, value);
TestingUtil.dumpCacheContents(caches);
@@ -163,7 +164,7 @@
assertNoLocks(caches);
- backupFqn = BuddyFqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), fqn);
+ backupFqn = fqnTransformer.getBackupFqn(caches.get(1).getLocalAddress(), fqn);
System.out.println("*** Calling get() on cache[1] with force option");
@@ -187,8 +188,8 @@
Fqn<String> fqn = Fqn.fromString("/test");
Fqn<String> fqn2 = Fqn.fromString("/test/subtree");
- Fqn<String> backupFqn = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
- Fqn<String> backupFqn2 = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn2);
+ Fqn<String> backupFqn = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
+ Fqn<String> backupFqn2 = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn2);
caches.get(0).put(fqn, key, value);
caches.get(0).put(fqn2, key, value);
@@ -214,8 +215,8 @@
caches.get(2).getNode(fqn); // expect entire subtree to gravitate.
delay(); // cleanup commands are async
- Fqn<String> newBackupFqn = BuddyFqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
- Fqn<String> newBackupFqn2 = BuddyFqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn2);
+ Fqn<String> newBackupFqn = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
+ Fqn<String> newBackupFqn2 = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn2);
assertEquals(value, caches.get(2).get(fqn, key));
assertTrue(caches.get(2).exists(fqn2));
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -40,6 +40,7 @@
public abstract class BuddyReplicationTestsBase
{
protected List<CacheSPI<Object, Object>> caches;
+ protected BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
@AfterMethod(alwaysRun = true)
public void tearDown() throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -118,8 +118,8 @@
// test that data does exist in loader2
assertTrue("should exist in loader2", passivation ? !loaders[2].exists(fqn) : loaders[2].exists(fqn));
- Fqn b1 = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
- Fqn b2 = BuddyFqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
+ Fqn b1 = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
+ Fqn b2 = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
// test that bkup does exist in cache0
assertTrue("should not exist in cache0", !caches.get(0).exists(b1));
@@ -175,8 +175,8 @@
// create 3 caches
caches = createCachesWithCacheLoader(3, autoGravitate, false, passivation);
CacheLoader[] loaders = getLoaders(caches);
- Fqn b1 = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
- Fqn b2 = BuddyFqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
+ Fqn b1 = fqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
+ Fqn b2 = fqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
// put stuff in cache0
caches.get(0).put(fqn, key, value);
@@ -263,7 +263,7 @@
Fqn foo = Fqn.fromString("/foo");
- Fqn backupFoo = BuddyFqnTransformer.getBackupFqn(cache0.getLocalAddress(), foo);
+ Fqn backupFoo = fqnTransformer.getBackupFqn(cache0.getLocalAddress(), foo);
cache0.put(foo, "key", "value");
assert cache0.exists(foo) : "Data should exist in data owner";
@@ -318,7 +318,7 @@
assert (cache0.getBuddyManager().getBuddyAddresses().contains(cache1.getLocalAddress())) : "Cache1 should be cache0's buddy!";
Fqn foo = Fqn.fromString("/foo");
- Fqn backupFoo = BuddyFqnTransformer.getBackupFqn(cache0.getLocalAddress(), foo);
+ Fqn backupFoo = fqnTransformer.getBackupFqn(cache0.getLocalAddress(), foo);
cache0.put(foo, "key", "value");
// test that the data exists in both the data owner and the buddy
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithOptimisticLockingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithOptimisticLockingTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithOptimisticLockingTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -18,4 +18,10 @@
{
optimisticLocks = true;
}
+
+ @Override
+ public void testDataGravitationKillOwner() throws Exception
+ {
+ super.testDataGravitationKillOwner();
+ }
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithTransactionsTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -23,14 +23,15 @@
private Fqn fqn = Fqn.fromString("test");
private String key = "key";
private String value = "value";
+ BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
public void testTransactionsCommit() throws Exception
{
caches = createCaches(3, false, true, false);
caches.get(0).put(fqn, key, value);
- Fqn oldBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyFqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + "/test");
- Fqn newBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyFqnTransformer.getGroupNameFromAddress(caches.get(2).getLocalAddress()) + "/test");
+ Fqn oldBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + "/test");
+ Fqn newBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(2).getLocalAddress()) + "/test");
dumpCacheContents(caches);
@@ -95,8 +96,8 @@
caches = createCaches(3, false, true, false);
caches.get(0).put(fqn, key, value);
- Fqn oldBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyFqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + "/test");
- Fqn newBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + BuddyFqnTransformer.getGroupNameFromAddress(caches.get(2).getLocalAddress()) + "/test");
+ Fqn oldBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(0).getLocalAddress()) + "/test");
+ Fqn newBackupFqn = Fqn.fromString("/" + BuddyManager.BUDDY_BACKUP_SUBTREE + "/" + fqnTransformer.getGroupNameFromAddress(caches.get(2).getLocalAddress()) + "/test");
dumpCacheContents(caches);
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/DisabledStateTransferTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -37,7 +37,7 @@
int backupIndex = i == 2 ? 0 : i + 1;
assert caches.get(i).exists("/" + i) : "Data should exist on owner (cache #" + i + ")";
- Fqn backup = BuddyFqnTransformer.getBackupFqn(caches.get(i).getLocalAddress(), Fqn.fromString("/" + i));
+ Fqn backup = fqnTransformer.getBackupFqn(caches.get(i).getLocalAddress(), Fqn.fromString("/" + i));
assert caches.get(backupIndex).exists(backup.getParent()) : "Backup region should have been created on buddy (cache #" + backupIndex + ")";
boolean backupStatePropagated = caches.get(backupIndex).exists(backup);
@@ -58,7 +58,7 @@
int backupIndex = i == 2 ? 0 : i + 1;
assert caches.get(i).exists("/" + i + "_NEW") : "Data should exist on owner (cache #" + i + ")";
- Fqn backup = BuddyFqnTransformer.getBackupFqn(caches.get(i).getLocalAddress(), Fqn.fromString("/" + i + "_NEW"));
+ Fqn backup = fqnTransformer.getBackupFqn(caches.get(i).getLocalAddress(), Fqn.fromString("/" + i + "_NEW"));
assert caches.get(backupIndex).exists(backup.getParent()) : "Backup region should have been created on buddy (cache #" + backupIndex + ")";
assert caches.get(backupIndex).exists(backup) : "Backup state should NOT have been transferred to buddy (cache #" + backupIndex + ")";
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/EmptyRegionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/EmptyRegionTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/EmptyRegionTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -73,7 +73,7 @@
System.out.println("Cache2 " + CachePrinter.printCacheDetails(c2));
// make sure region2 stuff did get transmitted!
- assert c2.peek(BuddyFqnTransformer.getBackupFqn(c1.getLocalAddress(), region2Fqn), false) != null : "Region2 state should have transferred!";
+ assert c2.peek(fqnTransformer.getBackupFqn(c1.getLocalAddress(), region2Fqn), false) != null : "Region2 state should have transferred!";
}
@CacheListener
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/EvictionOfBuddyBackupsTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -62,12 +62,12 @@
{
cache1.put(fqn, "k", "v");
assert cache1.peek(fqn, false, false) != null : "Node should exist";
- assert cache2.peek(BuddyFqnTransformer.getBackupFqn(cache1.getLocalAddress(), fqn), false, false) != null : "Node should exist on backup";
+ assert cache2.peek(fqnTransformer.getBackupFqn(cache1.getLocalAddress(), fqn), false, false) != null : "Node should exist on backup";
// now wait for eviction to kick in - for up to 2 secs
TestingUtil.sleepThread(2000);
assert cache1.peek(fqn, false, false) == null : "Node should have evicted";
- assert cache2.peek(BuddyFqnTransformer.getBackupFqn(cache1.getLocalAddress(), fqn), false, false) == null : "Node should have evicted on backup";
+ assert cache2.peek(fqnTransformer.getBackupFqn(cache1.getLocalAddress(), fqn), false, false) == null : "Node should have evicted on backup";
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -15,6 +15,7 @@
{
Fqn fqn = Fqn.fromString("/a/b/c");
Object key = "key", value = "value";
+ BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
public void testStaleRegionOnDataOwnerPessimistic() throws Exception
{
@@ -50,13 +51,13 @@
System.out.println("buddy: " + CachePrinter.printCacheLockingInfo(buddy));
assert dataOwner.peek(fqn, false) != null : "Should have data";
- assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
- assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+ assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
+ assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
assert buddy.peek(fqn, false) == null : "Should not have data";
- assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
- assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
- assert buddy.peek(BuddyFqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) != null : "Should have backup data";
+ assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+ assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
+ assert buddy.peek(fqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) != null : "Should have backup data";
// now do a gravitate call.
assert buddy.get(fqn, key).equals(value) : "Data should have gravitated!";
@@ -67,13 +68,13 @@
System.out.println("buddy: " + CachePrinter.printCacheLockingInfo(buddy));
assert buddy.peek(fqn, false) != null : "Should have data";
- assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
- assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+ assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
+ assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
assert dataOwner.peek(fqn, false) == null : "Should not have data";
- assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
- assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
- assert dataOwner.peek(BuddyFqnTransformer.getBackupFqn(buddy.getLocalAddress(), fqn), false) != null : "Should have backup data";
+ assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+ assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
+ assert dataOwner.peek(fqnTransformer.getBackupFqn(buddy.getLocalAddress(), fqn), false) != null : "Should have backup data";
}
private void testBuddy(boolean optimistic) throws Exception
@@ -96,14 +97,14 @@
System.out.println("thirdInstance: " + CachePrinter.printCacheLockingInfo(thirdInstance));
assert dataOwner.peek(fqn, false) != null : "Should have data";
- assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null : "Should have backup node for buddy";
- assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
- assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for 2nd instance!";
+ assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null : "Should have backup node for buddy";
+ assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+ assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for 2nd instance!";
assert buddy.peek(fqn, false) == null : "Should not have data";
- assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
- assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
- assert buddy.peek(BuddyFqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) != null : "Should have backup data";
+ assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+ assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null : "Should have backup node for buddy";
+ assert buddy.peek(fqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) != null : "Should have backup data";
// now do a gravitate call.
assert thirdInstance.get(fqn, key).equals(value) : "Data should have gravitated!";
@@ -116,16 +117,16 @@
System.out.println("thirdInstance: " + CachePrinter.printCacheLockingInfo(thirdInstance));
assert thirdInstance.peek(fqn, false) != null : "Should have data";
- assert thirdInstance.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
- assert thirdInstance.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+ assert thirdInstance.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null : "Should have backup node for buddy";
+ assert thirdInstance.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
assert dataOwner.peek(fqn, false) == null : "Should not have data";
- assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
- assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, BuddyFqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null : "Should have backup node for buddy";
- assert dataOwner.peek(BuddyFqnTransformer.getBackupFqn(thirdInstance.getLocalAddress(), fqn), false) != null : "Should have backup data";
+ assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null : "Should NOT have backup node for self!";
+ assert dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, fqnTransformer.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null : "Should have backup node for buddy";
+ assert dataOwner.peek(fqnTransformer.getBackupFqn(thirdInstance.getLocalAddress(), fqn), false) != null : "Should have backup data";
assert buddy.peek(fqn, false) == null : "Should not have data";
assert buddy.peek(fqn.getParent(), false) == null : "Should not have any part of the data";
- assert buddy.peek(BuddyFqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) == null : "Should NOT have backup data";
+ assert buddy.peek(fqnTransformer.getBackupFqn(dataOwner.getLocalAddress(), fqn), false) == null : "Should NOT have backup data";
}
private void cleanupDelay()
Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/GravitateDataCommandTest.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -30,6 +30,7 @@
IMocksControl control;
Fqn fqn = Fqn.fromString("/dummy");
InvocationContext ctx;
+ BuddyFqnTransformer fqnTransformer;
@BeforeMethod
public void setUp()
@@ -38,7 +39,7 @@
containerMock = control.createMock(DataContainer.class);
spiMock = control.createMock(CacheSPI.class);
command = new GravitateDataCommand(fqn, true, new IpAddress());
- command.initialize(containerMock, spiMock);
+ command.initialize(containerMock, spiMock, new BuddyFqnTransformer());
ctx = new InvocationContext();
}
@@ -108,14 +109,14 @@
//add first dead child
IpAddress firstAddress = new IpAddress("127.0.0.1", 1234);
- NodeSpiMock firstDeadNode = (NodeSpiMock) root.addChildDirect(BuddyFqnTransformer.getDeadBackupRoot(firstAddress));
+ NodeSpiMock firstDeadNode = (NodeSpiMock) root.addChildDirect(fqnTransformer.getDeadBackupRoot(firstAddress));
firstDeadNode.addChildDirect(Fqn.fromElements(0));
firstDeadNode.addChildDirect(Fqn.fromElements(1));
firstDeadNode.addChildDirect(Fqn.fromElements(2));
//add second dead child
IpAddress secondAddress = new IpAddress("127.0.0.1", 4321);
- NodeSpiMock secondDeadNode = (NodeSpiMock) root.addChildDirect(BuddyFqnTransformer.getDeadBackupRoot(secondAddress));
+ NodeSpiMock secondDeadNode = (NodeSpiMock) root.addChildDirect(fqnTransformer.getDeadBackupRoot(secondAddress));
secondDeadNode.addChildDirect(Fqn.fromElements(0));
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/CacheMarshaller200Test.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -9,6 +9,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.commands.remote.ClusteredGetCommand;
import org.testng.annotations.Test;
@@ -37,7 +38,7 @@
// need to test what's going on with
CacheMarshaller200 cm200 = new CacheMarshaller200();
c.setUseRegionBasedMarshalling(true);
- cm200.injectDependencies(new RegionManager(), c, getClass().getClassLoader());
+ cm200.injectDependencies(new RegionManager(), c, getClass().getClassLoader(), new BuddyFqnTransformer());
cm200.init();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
Modified: core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2008-06-11 23:23:57 UTC (rev 5975)
+++ core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2008-06-12 11:36:26 UTC (rev 5976)
@@ -80,11 +80,12 @@
// Pause to give caches time to see each other
TestingUtil.blockUntilViewsReceived(60000, cache1, cache2);
+ BuddyFqnTransformer fqnTransformer = new BuddyFqnTransformer();
// now peek into cache 2 to check that this state has been transferred into the backup subtree
- Fqn test = BuddyFqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);
+ Fqn test = fqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_B);
assertEquals("/a/b state should have integrated in backup region " + test, JOE, cache2.get(test, "name"));
- test = BuddyFqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_C);
+ test = fqnTransformer.getBackupFqn(cache1.getLocalAddress(), A_C);
assertEquals("/a/c state should have integrated in backup region " + test, JANE, cache2.get(test, "name"));
}
16 years, 6 months