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@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"));
}