Author: manik.surtani(a)jboss.com
Date: 2008-04-09 10:33:24 -0400 (Wed, 09 Apr 2008)
New Revision: 5523
Modified:
core/trunk/src/main/java/org/jboss/cache/Fqn.java
core/trunk/src/main/java/org/jboss/cache/Modification.java
core/trunk/src/main/java/org/jboss/cache/RegionManager.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCacheCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/MoveCommand.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheData.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java
core/trunk/src/test/java/org/jboss/cache/integration/hibernate/UpdateTimestampsCachingTest.java
core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ComparatorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
Log:
Updated Fqn, and code that uses deprecated Fqn constructors
Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-04-09 09:08:28 UTC (rev 5522)
+++ core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-04-09 14:33:24 UTC (rev 5523)
@@ -109,18 +109,23 @@
*/
private String cachedStringRep;
+ // ----------------- START: Private constructors for use by factory methods only.
----------------------
+
+ // TODO: Remove the unnecessary internalMarker boolean parameters to these methods
once the deprecated public constructors are removed in 3.0.0.
+
private Fqn(boolean internalMarker)
{
elements = Collections.emptyList();
size = 0;
}
- private Fqn(boolean internalMarker, List<E> names, boolean safe)
+ @SuppressWarnings("unchecked")
+ private Fqn(boolean internalMarker, List<?> names, boolean safe)
{
if (names != null)
{
// if not safe make a defensive copy
- elements = safe ? names : new ArrayList<E>(names);
+ elements = safe ? names : new ArrayList(names);
size = elements.size();
}
else
@@ -130,15 +135,18 @@
}
}
- private Fqn(boolean internalMarker, Fqn<E> base, List<E> relative)
+ @SuppressWarnings("unchecked")
+ private Fqn(boolean internalMarker, Fqn<?> base, List<?> relative)
{
- List<E> elements = new ArrayList<E>(base.elements.size() +
relative.size());
+ List elements = new ArrayList(base.elements.size() + relative.size());
elements.addAll(base.elements);
elements.addAll(relative);
this.elements = elements;
size = elements.size();
}
+ // ----------------- END: Private constructors for use by factory methods only.
----------------------
+
/**
* Constructs a root Fqn
*
@@ -237,9 +245,9 @@
* @return an Fqn
* @since 2.2.0
*/
- public static <E> Fqn<E> fromRelativeFqn(Fqn<E> base, Fqn<E>
relative)
+ public static Fqn<Object> fromRelativeFqn(Fqn<?> base, Fqn<?>
relative)
{
- return new Fqn<E>(true, base, relative.elements);
+ return new Fqn<Object>(true, base, relative.elements);
}
/**
@@ -263,9 +271,9 @@
* @return an Fqn
* @since 2.2.0
*/
- public static <E> Fqn<E> fromRelativeList(Fqn<E> base, List<E>
relativeElements)
+ public static Fqn<Object> fromRelativeList(Fqn<?> base, List<?>
relativeElements)
{
- return new Fqn<E>(true, base, relativeElements);
+ return new Fqn<Object>(true, base, relativeElements);
}
/**
@@ -289,9 +297,9 @@
* @return an Fqn
* @since 2.2.0
*/
- public static <E> Fqn<E> fromRelativeElements(Fqn<E> base, E...
relativeElements)
+ public static Fqn<Object> fromRelativeElements(Fqn<?> base, Object...
relativeElements)
{
- return new Fqn<E>(true, base, Arrays.asList(relativeElements));
+ return new Fqn<Object>(true, base, Arrays.asList(relativeElements));
}
/**
@@ -327,6 +335,23 @@
}
/**
+ * Retrieves an Fqn read from an object input stream, typically written to using
{@link #writeExternal(java.io.ObjectOutput)}.
+ *
+ * @param in input stream
+ * @return an Fqn
+ * @throws IOException in the event of a problem reading the stream
+ * @throws ClassNotFoundException in the event of classes that comprise the element
list of this Fqn not being found
+ * @since 2.2.0
+ */
+ public static Fqn<Object> fromExternalStream(ObjectInput in) throws IOException,
ClassNotFoundException
+ {
+ Fqn<Object> f = new Fqn<Object>(true);
+ f.readExternal(in);
+ return f;
+ }
+
+
+ /**
* Obtains an ancestor of the current Fqn. Literally performs
<code>elements.subList(0, generation)</code>
* such that if
* <code>
Modified: core/trunk/src/main/java/org/jboss/cache/Modification.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Modification.java 2008-04-09 09:08:28 UTC
(rev 5522)
+++ core/trunk/src/main/java/org/jboss/cache/Modification.java 2008-04-09 14:33:24 UTC
(rev 5523)
@@ -248,8 +248,7 @@
if (in.readBoolean())
{
- fqn = new Fqn();
- fqn.readExternal(in);
+ fqn = Fqn.fromExternalStream(in);
}
key = in.readObject();
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-04-09 09:08:28 UTC
(rev 5522)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManager.java 2008-04-09 14:33:24 UTC
(rev 5523)
@@ -4,8 +4,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.jboss.cache.Region.Type.*;
-import org.jboss.cache.buddyreplication.BuddyManager;
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;
@@ -23,7 +23,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -43,7 +42,7 @@
* eviction settings bound under this 'default' Fqn is appplied to {@link
org.jboss.cache.Fqn#ROOT} internally so
* any region that is not explicitly defined comes under the settings defined for this
default.
*/
- public static final Fqn<?> DEFAULT_REGION = new
Fqn<String>("_default_");
+ public static final Fqn<?> DEFAULT_REGION =
Fqn.fromString("/_default_");
/**
* A registry of regions that have been defined.
@@ -566,19 +565,17 @@
Set buddies = cache.peek(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, false,
false).getChildrenNames();
if (buddies != null)
{
- for (Iterator it = buddies.iterator(); it.hasNext();)
+ for (Object buddy : buddies)
{
- Fqn base = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, it.next());
- list.add(new Fqn(base, fqn));
+ list.add(BuddyFqnTransformer.getBackupFqn((String) buddy, fqn));
}
}
}
long stateFetchTimeout = cache.getConfiguration().getLockAcquisitionTimeout() +
5000;
// Remove the subtree from the main cache and any buddy backup trees
- for (Iterator<Fqn> it = list.iterator(); it.hasNext();)
+ for (Fqn subtree : list)
{
- Fqn subtree = it.next();
subtreeRoot = cache.peek(subtree, false, false);
if (subtreeRoot != null)
{
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-04-09 09:08:28 UTC
(rev 5522)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-04-09 14:33:24 UTC
(rev 5523)
@@ -9,6 +9,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.jboss.cache.AbstractNode.NodeFlags.*;
+import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.cachedata.RemoveFqnCommand;
import org.jboss.cache.factories.annotations.CacheInjectionMethods;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.lock.IdentityLock;
@@ -16,8 +18,6 @@
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
-import org.jboss.cache.commands.CacheCommandsFactory;
-import org.jboss.cache.commands.cachedata.RemoveFqnCommand;
import java.util.Collections;
import java.util.HashMap;
@@ -256,7 +256,7 @@
{
// construct the new child outside the synchronized block to avoid
// spending any more time than necessary in the synchronized section
- Fqn child_fqn = new Fqn(this.fqn, child_name);
+ Fqn child_fqn = Fqn.fromRelativeElements(this.fqn, child_name);
NodeSPI newChild = (NodeSPI)
cache.getConfiguration().getRuntimeConfig().getNodeFactory().createNode(child_name,
delegate, null);
if (newChild == null)
{
@@ -607,7 +607,7 @@
for (Map.Entry<Object, ? extends Node> me : children.entrySet())
{
NodeSPI n = (NodeSPI) me.getValue();
- Fqn cfqn = new Fqn(fqn, me.getKey());
+ Fqn cfqn = Fqn.fromRelativeElements(fqn, me.getKey());
n.setFqn(cfqn);
}
}
Modified:
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyFqnTransformer.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -3,14 +3,23 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
import org.jboss.cache.InvocationContext;
-import org.jboss.cache.commands.*;
-import org.jboss.cache.commands.visitors.AbstractCommandsVisitor;
+import org.jboss.cache.commands.CacheCommand;
+import org.jboss.cache.commands.CacheCommandsFactory;
+import org.jboss.cache.commands.EvictFqnCommand;
+import org.jboss.cache.commands.GravitateDataCacheCommand;
+import org.jboss.cache.commands.InvalidateCommand;
import org.jboss.cache.commands.cachedata.*;
-import org.jboss.cache.commands.remote.*;
+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.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.visitors.AbstractCommandsVisitor;
import org.jgroups.Address;
import java.util.ArrayList;
@@ -241,7 +250,7 @@
elements.add(buddyGroupName);
elements.addAll(origFqn.peekElements());
- return new Fqn(elements, true);
+ return Fqn.fromList(elements);
}
/**
@@ -262,7 +271,7 @@
elements.add(buddyGroupRoot.get(1));
elements.addAll(origFqn.peekElements());
- return new Fqn(elements, true);
+ return Fqn.fromList(elements);
}
public static boolean isBackupFqn(Fqn name)
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-04-09
09:08:28 UTC (rev 5522)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -664,9 +664,11 @@
* @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 new Fqn<String>(BUDDY_BACKUP_SUBTREE_FQN,
getGroupNameFromAddress(dataOwner));
+ Fqn f = Fqn.fromRelativeElements(BUDDY_BACKUP_SUBTREE_FQN,
getGroupNameFromAddress(dataOwner));
+ return f;
}
/**
@@ -675,9 +677,11 @@
* @param dataOwner owner of data
* @return Fqn of dead data owner's root
*/
+ @SuppressWarnings("unchecked")
public static Fqn<String> getDeadBackupRoot(Address dataOwner)
{
- return new Fqn<String>(BUDDY_BACKUP_SUBTREE_FQN,
getGroupNameFromAddress(dataOwner) + ":DEAD");
+ Fqn f = Fqn.fromRelativeElements(BUDDY_BACKUP_SUBTREE_FQN,
getGroupNameFromAddress(dataOwner) + ":DEAD");
+ return f;
}
public static boolean isDeadBackupRoot(Fqn f)
@@ -685,6 +689,13 @@
return f.getParent().equals(BUDDY_BACKUP_SUBTREE_FQN) &&
f.getLastElementAsString().endsWith(":DEAD");
}
+ /**
+ * 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) return false;
@@ -1045,8 +1056,8 @@
}
cache.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
- defunctRootNode.addChild(new Fqn<Integer>(childName));
- return new Fqn(defunctRoot, childName);
+ defunctRootNode.addChild(Fqn.fromElements(childName));
+ return Fqn.fromRelativeElements(defunctRoot, childName);
}
Modified:
core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCacheCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCacheCommand.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/main/java/org/jboss/cache/commands/GravitateDataCacheCommand.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -2,7 +2,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.RPCManager;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
@@ -77,7 +82,7 @@
{
// childName is the name of a buddy group since all child names in
this
// collection are direct children of BUDDY_BACKUP_SUBTREE_FQN
- Fqn backupRoot = new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
childName);
+ Fqn backupRoot =
Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, childName);
if (BuddyManager.isDeadBackupRoot(backupRoot))
{
//actualNode = searchDeadRoot(backupRoot, fqn);
@@ -88,7 +93,7 @@
for (int i = elems.length - 1; i > -1; i--)
{
Integer versionOfDefunctData = elems[i];
- backupNodeFqn = new Fqn(new Fqn(backupRoot,
versionOfDefunctData), fqn);
+ backupNodeFqn =
Fqn.fromRelativeFqn(Fqn.fromRelativeElements(backupRoot, versionOfDefunctData), fqn);
// use a get() call into the cache to make sure cache loading
takes place.
ctx.getOptionOverrides().setSkipDataGravitation(true);
@@ -98,9 +103,10 @@
// break out of the inner loop searching through the dead
node's various backups
if (actualNode != null) break;
}
- } else
+ }
+ else
{
- backupNodeFqn = new Fqn(backupRoot, fqn);
+ backupNodeFqn = Fqn.fromRelativeFqn(backupRoot, fqn);
// use a get() call into the cache to make sure cache loading
takes place.
ctx.getOptionOverrides().setSkipDataGravitation(true);
actualNode = spi.getNode(backupNodeFqn);
@@ -120,7 +126,8 @@
if (actualNode == null)
{
return GravitateResult.noDataFound();
- } else
+ }
+ else
{
// make sure we LOAD data for this node!!
actualNode.getData();
Modified: core/trunk/src/main/java/org/jboss/cache/commands/cachedata/MoveCommand.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/MoveCommand.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/main/java/org/jboss/cache/commands/cachedata/MoveCommand.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -1,11 +1,15 @@
package org.jboss.cache.commands.cachedata;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeNotExistsException;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.CacheCommandsVisitor;
+import org.jboss.cache.commands.TxCacheCommand;
+import org.jboss.cache.invocation.CacheData;
+import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.TransactionTable;
-import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.commands.TxCacheCommand;
-import org.jboss.cache.commands.CacheCommandsVisitor;
/**
* @author Mircea.Markus(a)jboss.com
@@ -18,7 +22,7 @@
private Notifier notifier;
private CacheSPI spi;
private TransactionTable transactionTable;
-
+
private Fqn from;
private Fqn to;
@@ -36,13 +40,13 @@
public void rollback()
{
- _move(new Fqn(to, from.getLastElement()), from.getParent(), true);
+ _move(Fqn.fromRelativeElements(to, from.getLastElement()), from.getParent(),
true);
}
private void moveFqns(NodeSPI node, Fqn newBase)
{
- Fqn newFqn = new Fqn(newBase, node.getFqn().getLastElement());
+ Fqn newFqn = Fqn.fromRelativeElements(newBase, node.getFqn().getLastElement());
node.setFqn(newFqn);
}
@@ -80,13 +84,13 @@
// notify
if (!skipNotifications)
- notifier.notifyNodeMoved(nodeToMoveFqn, new Fqn(newParentFqn,
nodeToMoveFqn.getLastElement()), true, ctx);
+ notifier.notifyNodeMoved(nodeToMoveFqn, Fqn.fromRelativeElements(newParentFqn,
nodeToMoveFqn.getLastElement()), true, ctx);
// now adjust Fqns of node and all children.
moveFqns(node, newParent.getFqn());
if (!skipNotifications)
- notifier.notifyNodeMoved(nodeToMoveFqn, new Fqn(newParentFqn,
nodeToMoveFqn.getLastElement()), false, ctx);
+ notifier.notifyNodeMoved(nodeToMoveFqn, Fqn.fromRelativeElements(newParentFqn,
nodeToMoveFqn.getLastElement()), false, ctx);
// now register an undo op
if (ctx.getTransaction() != null)
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -1,21 +1,24 @@
package org.jboss.cache.interceptors;
-import org.jboss.cache.*;
-import org.jboss.cache.interceptors.base.ChainedInterceptor;
-import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.invocation.InterceptorChain;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.config.Configuration;
import static org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
+import org.jboss.cache.interceptors.base.ChainedInterceptor;
+import org.jboss.cache.invocation.CacheData;
+import org.jboss.cache.invocation.InterceptorChain;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
+import org.jboss.cache.lock.LockManager;
import org.jboss.cache.lock.NodeLock;
-import org.jboss.cache.lock.LockManager;
import org.jboss.cache.marshall.MethodCall;
+import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
@@ -273,7 +276,8 @@
// just create a dummy node in memory
n = createTempNode(fqn, entry);
}
- } else
+ }
+ else
{
n = loadNode(ctx, fqn, n, entry);
}
@@ -331,7 +335,7 @@
// Create one DataNode per child, mark as UNINITIALIZED
for (Object name : childrenNames)
{
- Fqn childFqn = new Fqn(name);// this is a RELATIVE Fqn!!
+ Fqn childFqn = Fqn.fromElements(name);// this is a RELATIVE Fqn!!
// create child if it didn't exist
NodeSPI child = node.addChildDirect(childFqn);
@@ -531,7 +535,8 @@
if (nodeExists)
{
cacheLoads++;
- } else
+ }
+ else
{
cacheMisses++;
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -5,12 +5,17 @@
import org.jboss.cache.Modification;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.TxCacheCommand;
-import org.jboss.cache.commands.visitors.AbstractCommandsVisitor;
-import org.jboss.cache.commands.cachedata.*;
+import org.jboss.cache.commands.cachedata.MoveCommand;
+import org.jboss.cache.commands.cachedata.PutDataMapCommand;
+import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
+import org.jboss.cache.commands.cachedata.RemoveDataCommand;
+import org.jboss.cache.commands.cachedata.RemoveFqnCommand;
+import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
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.visitors.AbstractCommandsVisitor;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
@@ -23,7 +28,12 @@
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -118,7 +128,8 @@
storeInternalState(affectedFqns);
}
return returnValue;
- } else
+ }
+ else
{
if (trace) log.trace("Commit called with no modifications;
ignoring.");
}
@@ -145,7 +156,8 @@
{
txStores.remove(gtx);
}
- } else
+ }
+ else
{
if (trace) log.trace("Rollback called with no modifications;
ignoring.");
}
@@ -231,7 +243,7 @@
{
return returnValue;
}
- Fqn newNodeFqn = new Fqn(command.getTo(), command.getFrom().getLastElement());
+ Fqn newNodeFqn = Fqn.fromRelativeElements(command.getTo(),
command.getFrom().getLastElement());
recursiveMove(command.getFrom(), newNodeFqn);
loader.remove(command.getFrom());
return returnValue;
@@ -252,7 +264,8 @@
NodeSPI n = cacheData.peek(command.getFqn(), false, false);//cache.peek(fqn,
false);
n.setDataLoaded(true);
return returnValue;
- } else
+ }
+ else
{
loader.put(command.getFqn(), command.getData());
if (configuration.getExposeManagementStatistics() &&
getStatisticsEnabled())
@@ -391,7 +404,8 @@
if (command.isEraseContents())
{
modifications.add(new
Modification(Modification.ModificationType.PUT_DATA_ERASE, command.getFqn(),
command.getData()));
- } else
+ }
+ else
{
modifications.add(new Modification(Modification.ModificationType.PUT_DATA,
command.getFqn(), command.getData()));
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -15,7 +15,12 @@
import org.jboss.cache.commands.CacheCommandsFactory;
import org.jboss.cache.commands.InvalidateCommand;
import org.jboss.cache.commands.TxCacheCommand;
-import org.jboss.cache.commands.cachedata.*;
+import org.jboss.cache.commands.cachedata.MoveCommand;
+import org.jboss.cache.commands.cachedata.PutDataMapCommand;
+import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
+import org.jboss.cache.commands.cachedata.RemoveDataCommand;
+import org.jboss.cache.commands.cachedata.RemoveFqnCommand;
+import org.jboss.cache.commands.cachedata.RemoveKeyCommand;
import org.jboss.cache.commands.remote.DataGravitationCleanupCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
@@ -30,11 +35,20 @@
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
-import org.jboss.cache.transaction.*;
+import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.transaction.TxUtil;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/**
@@ -139,7 +153,8 @@
if (modifications.size() > 0)
{
broadcastInvalidate(modifications, gtx, tx, ctx);
- } else
+ }
+ else
{
log.debug("Nothing to invalidate - no modifications in the
transaction.");
}
@@ -231,7 +246,8 @@
if (filterVisitor.containsPutForExternalRead)
{
log.debug("Modification list contains a putForExternalRead operation. Not
invalidating.");
- } else
+ }
+ else
{
try
{
@@ -310,7 +326,7 @@
// now if this is a "move" operation, then we also have another Fqn -
Object le = command.getFrom().getLastElement();
Fqn parent = command.getTo();
- result.add(new Fqn(parent, le));
+ result.add(Fqn.fromRelativeElements(parent, le));
return null;
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -6,13 +6,17 @@
*/
package org.jboss.cache.interceptors;
-import org.jboss.cache.*;
-import org.jboss.cache.invocation.CacheData;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
+import org.jboss.cache.NodeFactory;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.cachedata.MoveCommand;
import org.jboss.cache.commands.cachedata.PutDataMapCommand;
import org.jboss.cache.commands.cachedata.PutKeyValueCommand;
-import org.jboss.cache.commands.cachedata.MoveCommand;
-import org.jboss.cache.commands.CacheCommand;
import org.jboss.cache.factories.annotations.Inject;
+import org.jboss.cache.invocation.CacheData;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DefaultDataVersion;
@@ -22,7 +26,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
/**
* Used to create new {@link NodeSPI} instances in the main data structure and then copy
it into the
@@ -81,7 +84,7 @@
List<Fqn> fqns = new ArrayList<Fqn>();
fqns.add((Fqn) command.getTo());
// peek into Node and get a hold of all child fqns as these need to be in the
workspace.
- NodeSPI node = cacheData.peek( command.getFrom(), true, true);
+ NodeSPI node = cacheData.peek(command.getFrom(), true, true);
greedyGetFqns(fqns, node, (Fqn) command.getTo());
if (trace) log.trace("Adding Fqns " + fqns + " for a move()
operation.");
for (Fqn f : fqns)
@@ -153,7 +156,7 @@
if (currentNode == null)
{
// first test that it exists in the workspace and has been created in thix
tx!
- WorkspaceNode peekInWorkspace = workspace.getNode(new
Fqn(workspaceNode.getFqn(), childName));
+ WorkspaceNode peekInWorkspace =
workspace.getNode(Fqn.fromRelativeElements(workspaceNode.getFqn(), childName));
if (peekInWorkspace.isDeleted()) undeleteWorkspaceNode(peekInWorkspace,
workspaceNode);
}
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -92,13 +92,14 @@
for (int i = 0; i < treeNodeSize; i++)
{
Object childName = command.getFqn().get(i);
- Fqn childFqn = new Fqn(childName);
+ Fqn childFqn = Fqn.fromElements(childName);
NodeSPI childNode = n.getChildDirect(childFqn);
if (childNode == null) childNode = n.addChildDirect(childFqn);
lockManager.manageReverseRemove(ctx.getGlobalTransaction(), childNode, true,
null);
n = childNode;
}
- } else
+ }
+ else
{
lockManager.acquireLocksWithTimeout(ctx, command.getFqn(),
NodeLock.LockType.WRITE, true, false, false, true, null, false);
}
@@ -146,7 +147,8 @@
if (entry == null)
{
log.error("entry for transaction " + command.getGlobalTransaction() +
" not found (transaction has possibly already been rolled back)");
- } else
+ }
+ else
{
for (Fqn fqn : entry.getRemovedNodes())
{
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheData.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheData.java 2008-04-09 09:08:28
UTC (rev 5522)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheData.java 2008-04-09 14:33:24
UTC (rev 5523)
@@ -2,15 +2,24 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeNotExistsException;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* todo - consider moving all this functionality to node class itself
@@ -131,10 +140,12 @@
if (n == null)
{
return null;
- } else if (!includeDeletedNodes && n.isDeleted())
+ }
+ else if (!includeDeletedNodes && n.isDeleted())
{
return null;
- } else if (!includeInvalidNodes && !n.isValid())
+ }
+ else if (!includeInvalidNodes && !n.isValid())
{
return null;
}
@@ -184,7 +195,8 @@
if (recursive)
{
recursiveAddEvictionNodes(node, result);
- } else
+ }
+ else
{
buildNodesForEviction(node, result);
}
@@ -211,9 +223,10 @@
{
for (Object childName : node.getChildrenNames())
{
- if (node != null && node.isResident()) nodes.add(new
Fqn<Object>(fqn, childName));
+ if (node != null && node.isResident())
nodes.add(Fqn.fromRelativeElements(fqn, childName));
}
- } else
+ }
+ else
{
nodes.add(fqn);
}
@@ -254,7 +267,8 @@
{
sb.append(getClass().getName()).append("
[").append(getNumberOfNodes()).append(" nodes, ");
sb.append(getNumberOfLocksHeld()).append(" locks]");
- } else
+ }
+ else
{
if (root == null)
return sb.toString();
@@ -409,14 +423,16 @@
n.setValid(false, true);
n.setValid(true, false);
return true;
- } else
+ }
+ else
{
// mark the node to be removed (and all children) as invalid so anyone
holding a direct reference to it will
// be aware that it is no longer valid.
n.setValid(false, true);
return n.getParent().removeChildDirect(n.getFqn().getLastElement());
}
- } else
+ }
+ else
{
if (log.isDebugEnabled()) log.debug("Node " + f + " NOT marked
for removal as expected, not removing!");
return false;
@@ -441,7 +457,8 @@
{
removeData(fqn);
return false;
- } else
+ }
+ else
{
removeNode(fqn);
return true;
@@ -483,14 +500,15 @@
for (int i = 0; i < size; i++)
{
Object childName = fqn.get(i);
- tmpFqn = new Fqn(tmpFqn, childName);
+ tmpFqn = Fqn.fromRelativeElements(tmpFqn, childName);
NodeSPI childNode;
Map children = n.getChildrenMapDirect();
if (children == null)
{
childNode = null;
- } else
+ }
+ else
{
childNode = (NodeSPI) children.get(childName);
}
@@ -498,7 +516,7 @@
if (childNode == null)
{
- result.add(n.addChildDirect(new Fqn(childName)));
+ result.add(n.addChildDirect(Fqn.fromElements(childName)));
}
n = childNode;
@@ -508,7 +526,7 @@
/**
* Returns true if a node has all children loaded and initialized.
- * todo - this belongs to NodeSPI, should be moved in 3.x
+ * todo - this belongs to NodeSPI, should be moved in 3.x
*/
public boolean allInitialized(NodeSPI<?, ?> n)
{
@@ -535,7 +553,7 @@
for (int i = 0; i < treeNodeSize; i++)
{
Object childName = fqn.get(i);
- NodeSPI childNode = n.addChildDirect(new Fqn<Object>(childName));
+ NodeSPI childNode = n.addChildDirect(Fqn.fromElements(childName));
if (childNode == null)
{
if (log.isTraceEnabled())
Modified:
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -6,9 +6,9 @@
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.CacheCommandsFactory;
import org.jboss.cache.commands.GravitateDataCacheCommand;
+import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.commands.channel.BlockChannelCommand;
import org.jboss.cache.commands.channel.UnblockChannelCommand;
-import org.jboss.cache.commands.cachedata.*;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.annotations.Inject;
@@ -23,7 +23,11 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
/**
* The delegate that users (and ChainedInterceptor authors) interact with when they
create a cache by using a cache factory.
@@ -368,14 +372,15 @@
Set<Fqn> internalFqns = getInternalFqns();
for (Object childName : peek(fqn, false, false).getChildrenNames())
{
- if (!internalFqns.contains(new Fqn(childName)))
+ if (!internalFqns.contains(Fqn.fromElements(childName)))
{
ctx.setOptionOverrides(o);
- result = removeNode(new Fqn<Object>((Fqn<Object>) fqn,
childName)) && result;
+ result = removeNode(Fqn.fromRelativeElements(fqn, childName)) &&
result;
}
}
return result;
- } else
+ }
+ else
{
GlobalTransaction tx = transactionHelper.getCurrentTransaction();
RemoveFqnCommand command = commandsFactory.buildRemoveFqnCommand(tx, fqn, true,
false);
@@ -433,7 +438,8 @@
getInvocationContext().getOptionOverrides().setForceAsynchronous(true);
PutKeyValueCommand command = commandsFactory.buildPutKeyValueCommand(null, fqn,
key, value);
invoke(command);
- } else
+ }
+ else
{
if (log.isDebugEnabled())
log.debug("putForExternalRead() called with Fqn " + fqn + "
and this node already exists. This method is hence a no op.");
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -244,7 +244,7 @@
Set<Node<K, V>> children = new HashSet<Node<K, V>>();
for (Object c : spi.getChildrenNames(getFqn()))
{
- Node n = spi.getNode(new Fqn(getFqn(), c));
+ Node n = spi.getNode(Fqn.fromRelativeElements(getFqn(), c));
if (n != null) children.add(n);
}
return Collections.unmodifiableSet(children);
@@ -279,7 +279,7 @@
{
// TODO: Revisit. Is this really threadsafe? See comment in putIfAbsent() - same
solution should be applied here too.
assertValid();
- Fqn nf = new Fqn(getFqn(), f);
+ Fqn nf = Fqn.fromRelativeFqn(getFqn(), f);
Option o1 = null;
try
{
@@ -316,25 +316,25 @@
public boolean removeChild(Fqn<?> f)
{
assertValid();
- return spi.removeNode(new Fqn(getFqn(), f));
+ return spi.removeNode(Fqn.fromRelativeFqn(getFqn(), f));
}
public boolean removeChild(Object childName)
{
assertValid();
- return spi.removeNode(new Fqn(getFqn(), childName));
+ return spi.removeNode(Fqn.fromRelativeElements(getFqn(), childName));
}
public Node<K, V> getChild(Fqn<?> f)
{
assertValid();
- return spi.getNode(new Fqn(getFqn(), f));
+ return spi.getNode(Fqn.fromRelativeFqn(getFqn(), f));
}
public Node<K, V> getChild(Object name)
{
assertValid();
- return spi.getNode(new Fqn(getFqn(), name));
+ return spi.getNode(Fqn.fromRelativeElements(getFqn(), name));
}
public V put(K key, V value)
Modified: core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-04-09
09:08:28 UTC (rev 5522)
+++ core/trunk/src/main/java/org/jboss/cache/loader/AbstractCacheLoader.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -14,8 +14,8 @@
import org.jboss.cache.Modification;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.marshall.Marshaller;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.marshall.NodeDataExceptionMarker;
@@ -283,7 +283,7 @@
for (Object children_name : children_names)
{
child_name = (String) children_name;
- tmp_fqn = new Fqn(fqn, child_name);
+ tmp_fqn = Fqn.fromRelativeElements(fqn, child_name);
if (!cache.getInternalFqns().contains(tmp_fqn)) getNodeDataList(tmp_fqn, list);
}
}
@@ -326,7 +326,7 @@
private void _move(Fqn fqn, Fqn parent) throws Exception
{
Object name = fqn.getLastElement();
- Fqn newFqn = new Fqn(parent, name);
+ Fqn newFqn = Fqn.fromRelativeElements(parent, name);
// start deep.
Set childrenNames = getChildrenNames(fqn);
@@ -334,7 +334,7 @@
{
for (Object c : childrenNames)
{
- _move(new Fqn(fqn, c), newFqn);
+ _move(Fqn.fromRelativeElements(fqn, c), newFqn);
}
}
// get data for node.
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-04-09 09:08:28 UTC
(rev 5522)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-04-09 14:33:24 UTC
(rev 5523)
@@ -1,25 +1,22 @@
package org.jboss.cache.lock;
-import org.jboss.cache.InvocationContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.cachedata.PutDataMapCommand;
import org.jboss.cache.commands.CacheCommandsFactory;
-import org.jboss.cache.marshall.MethodCall;
-import org.jboss.cache.marshall.MethodCallFactory;
-import org.jboss.cache.marshall.MethodDeclarations;
-import org.jboss.cache.transaction.TxUtil;
+import org.jboss.cache.commands.cachedata.PutDataMapCommand;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.invocation.CacheData;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.transaction.TransactionEntry;
-import org.jboss.cache.invocation.CacheData;
-import org.jboss.cache.config.Configuration;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
+import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.transaction.TxUtil;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.HashMap;
import java.util.Set;
/**
@@ -51,8 +48,8 @@
public boolean acquireLocksWithTimeout(InvocationContext ctx, Fqn fqn,
NodeLock.LockType lockType,
- boolean createIfNotExists, boolean
zeroLockTimeout,
- boolean acquireLockOnParent, boolean
reverseRemoveCheck, List<NodeSPI> createdNodes, boolean skipNotification)
+ boolean createIfNotExists, boolean
zeroLockTimeout,
+ boolean acquireLockOnParent, boolean
reverseRemoveCheck, List<NodeSPI> createdNodes, boolean skipNotification)
throws InterruptedException
{
if (fqn == null || configuration.getIsolationLevel() == IsolationLevel.NONE) return
false;
@@ -90,7 +87,7 @@
* @param skipNotification
*/
public boolean lock(InvocationContext ctx, Fqn fqn, NodeLock.LockType lockType,
boolean createIfNotExists, long timeout,
- boolean acquireWriteLockOnParent, boolean reverseRemoveCheck,
List<NodeSPI> createdNodes, boolean skipNotification)
+ boolean acquireWriteLockOnParent, boolean reverseRemoveCheck,
List<NodeSPI> createdNodes, boolean skipNotification)
throws TimeoutException, LockingException, InterruptedException
{
Thread currentThread = Thread.currentThread();
@@ -160,7 +157,8 @@
if (parent == null || cacheData.peek(parent.getFqn(), true, true) == null)
{
// crap!
- if (log.isTraceEnabled()) log.trace("Parent has been deleted again.
Go through the lock method all over again.");
+ if (log.isTraceEnabled())
+ log.trace("Parent has been deleted again. Go through the lock
method all over again.");
currentNode = rootNode;
currentIndex = -1;
parent = null;
@@ -172,7 +170,7 @@
parent = null;
if (System.currentTimeMillis() > expiryTime)
{
- throw new TimeoutException("Unable to acquire lock on child node
" + new Fqn(currentNode.getFqn(), childName) + " after " + timeout + "
millis.");
+ throw new TimeoutException("Unable to acquire lock on child node
" + Fqn.fromRelativeElements(currentNode.getFqn(), childName) + " after " +
timeout + " millis.");
}
if (log.isTraceEnabled()) log.trace("Moving one level up, current
node is :" + currentNode);
}
@@ -263,7 +261,7 @@
childNode.markAsDeleted(false);
//if we'll rollback the tx data should be added to the node again
Map oldData = new HashMap(childNode.getDataDirect());
- PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(gtx, fqn,
oldData , false);
+ PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(gtx, fqn,
oldData, false);
txTable.get(gtx).addUndoOperation(command);
//we're prepared for rollback, now reset the node
childNode.clearDataDirect();
Modified: core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java 2008-04-09
09:08:28 UTC (rev 5522)
+++ core/trunk/src/main/java/org/jboss/cache/optimistic/WorkspaceNodeImpl.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -466,7 +466,7 @@
public boolean removeChild(Object childName)
{
//NodeSPI n = node.getChildDirect(childName);
- Fqn childFqn = new Fqn(getFqn(), childName);
+ Fqn childFqn = Fqn.fromRelativeElements(getFqn(), childName);
/*if (n != null)
{*/
getChildrenRemovedSet().add(childFqn);
Modified:
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
---
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -315,7 +315,7 @@
// change the Fqn to fit under it
if (offset > 0)
{
- fqn = new Fqn(parent.getFqn().getAncestor(offset), fqn);
+ fqn = Fqn.fromRelativeElements(parent.getFqn().getAncestor(offset), fqn);
}
size = fqn.size();
if (size <= parent_level)
@@ -380,7 +380,7 @@
{
Object name = internalFqn.get(parent.getFqn().size());
cache.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
- Node result = parent.getChild(new Fqn(name));
+ Node result = parent.getChild(name);
if (result != null)
{
if (internalFqn.size() < result.getFqn().size())
@@ -410,7 +410,7 @@
Fqn descFqn = descendant.getFqn();
Fqn ancFqn = ancestor.getFqn();
Object name = descFqn.get(ancFqn.size());
- NodeSPI child = (NodeSPI) ancestor.getChild(new Fqn(name));
+ NodeSPI child = (NodeSPI) ancestor.getChild(name);
if (ancFqn.size() == descFqn.size() + 1)
{
if (child == null)
@@ -429,7 +429,7 @@
// Missing level -- have to create empty node
// This shouldn't really happen -- internal fqns should
// be immediately under the root
- child = factory.createDataNode(name, new Fqn(ancFqn, name), ancestor, null,
true);
+ child = factory.createDataNode(name, Fqn.fromRelativeElements(ancFqn, name),
ancestor, null, true);
ancestor.addChild(name, child);
}
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-04-09 09:08:28
UTC (rev 5522)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-04-09 14:33:24
UTC (rev 5523)
@@ -91,7 +91,7 @@
cache.move(nodeC.getFqn(), nodeB.getFqn());
// re-fetch nodeC
- nodeC = cache.getNode(new Fqn<String>(genericize(nodeB.getFqn()), C));
+ nodeC = cache.getNode(Fqn.fromRelativeFqn(nodeB.getFqn(), C));
log.info("POST MOVE " + cache);
log.info("HC " + nodeC + " " +
System.identityHashCode(nodeC));
@@ -119,12 +119,6 @@
}
@SuppressWarnings("unchecked")
- private Fqn<String> genericize(Fqn fqn)
- {
- return (Fqn<String>) fqn;
- }
-
- @SuppressWarnings("unchecked")
private Node<Object, Object> genericize(Node node)
{
return (Node<Object, Object>) node;
@@ -327,9 +321,9 @@
assertNotNull(cache.peek(A, false));
assertNotNull(cache.peek(B, false));
assertNull(cache.peek(C, false));
- assertNotNull(cache.peek(new Fqn<String>(A, C), false));
- assertNotNull(cache.peek(new Fqn<String>(new Fqn<String>(A, C), D),
false));
- assertNotNull(cache.peek(new Fqn<String>(new Fqn<String>(new
Fqn<String>(A, C), D), E), false));
+ assertNotNull(cache.peek(Fqn.fromRelativeFqn(A, C), false));
+ assertNotNull(cache.peek(Fqn.fromRelativeFqn(Fqn.fromRelativeFqn(A, C), D),
false));
+
assertNotNull(cache.peek(Fqn.fromRelativeFqn(Fqn.fromRelativeFqn(Fqn.fromRelativeFqn(A,
C), D), E), false));
// test data
assertEquals(vA, nodeA.get(k));
@@ -377,18 +371,18 @@
log.info("nodeD get child E ");
nodeE = nodeD.getChild(E);
- Fqn<String> old_C = new Fqn<String>(C);
- Fqn<String> old_D = new Fqn<String>(old_C, D);
- Fqn<String> old_E = new Fqn<String>(old_D, E);
+ Fqn old_C = C.clone();
+ Fqn old_D = Fqn.fromRelativeFqn(old_C, D);
+ Fqn old_E = Fqn.fromRelativeFqn(old_D, E);
assertNotNull(cache.peek(A, false));
assertNotNull(cache.peek(B, false));
assertNull(cache.peek(C, false));
- assertNull(cache.peek(new Fqn<String>(A, C), false));
- assertNotNull(cache.peek(new Fqn<String>(B, C), false));
+ assertNull(cache.peek(Fqn.fromRelativeFqn(A, C), false));
+ assertNotNull(cache.peek(Fqn.fromRelativeFqn(B, C), false));
- assertNotNull(cache.peek(new Fqn<String>(new Fqn<String>(B, C), D),
false));
- assertNotNull(cache.peek(new Fqn<String>(new Fqn<String>(new
Fqn<String>(B, C), D), E), false));
+ assertNotNull(cache.peek(Fqn.fromRelativeFqn(Fqn.fromRelativeFqn(B, C), D),
false));
+
assertNotNull(cache.peek(Fqn.fromRelativeFqn(Fqn.fromRelativeFqn(Fqn.fromRelativeFqn(B,
C), D), E), false));
// test data
assertEquals(vA, nodeA.get(k));
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyAssignmentStateTransferTest.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -43,9 +43,7 @@
TestingUtil.blockUntilViewsReceived(caches.toArray(new CacheSPI[0]),
VIEW_BLOCK_TIMEOUT);
TestingUtil.sleepThread(getSleepTimeout());
- Fqn<String> test = new
Fqn<String>(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
- BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress()));
- test = new Fqn<String>(test, main);
+ Fqn<String> test =
BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), main);
assertEquals("State transferred", "Joe",
caches.get(1).get(test, "name"));
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationWithCacheLoaderTest.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -115,8 +115,8 @@
// test that data does exist in loader2
assertTrue("should exist in loader2", passivation ?
!loaders[2].exists(fqn) : loaders[2].exists(fqn));
- Fqn<String> b1 = new Fqn<String>(new
Fqn<String>(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(caches.get(0).getLocalAddress())),
fqn.peekElements());
- Fqn<String> b2 = new Fqn<String>(new
Fqn<String>(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(caches.get(2).getLocalAddress())),
fqn.peekElements());
+ Fqn b1 = BuddyFqnTransformer.getBackupFqn(caches.get(0).getLocalAddress(), fqn);
+ Fqn b2 = BuddyFqnTransformer.getBackupFqn(caches.get(2).getLocalAddress(), fqn);
// test that bkup does exist in cache0
assertTrue("should not exist in cache0", !caches.get(0).exists(b1));
Modified:
core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/test/java/org/jboss/cache/buddyreplication/GravitationCleanupTest.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -49,12 +49,12 @@
System.out.println("buddy: " +
CachePrinter.printCacheLockingInfo(buddy));
assert dataOwner.peek(fqn, false) != null : "Should have data";
- assert dataOwner.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null :
"Should have backup node for buddy";
- assert dataOwner.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
+ assert
dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null :
"Should have backup node for buddy";
+ assert
dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.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(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
- assert buddy.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null :
"Should have backup node for buddy";
+ assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
+ assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.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";
// now do a gravitate call.
@@ -64,12 +64,12 @@
System.out.println("buddy: " +
CachePrinter.printCacheLockingInfo(buddy));
assert buddy.peek(fqn, false) != null : "Should have data";
- assert buddy.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null :
"Should have backup node for buddy";
- assert buddy.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
+ assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null :
"Should have backup node for buddy";
+ assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.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(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
- assert dataOwner.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null :
"Should have backup node for buddy";
+ assert
dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
+ assert
dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.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";
}
@@ -93,13 +93,13 @@
System.out.println("thirdInstance: " +
CachePrinter.printCacheLockingInfo(thirdInstance));
assert dataOwner.peek(fqn, false) != null : "Should have data";
- assert dataOwner.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null :
"Should have backup node for buddy";
- assert dataOwner.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
- assert dataOwner.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null :
"Should NOT have backup node for 2nd instance!";
+ assert
dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null :
"Should have backup node for buddy";
+ assert
dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
+ assert
dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.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(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
- assert buddy.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) != null :
"Should have backup node for buddy";
+ assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
+ assert buddy.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.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";
// now do a gravitate call.
@@ -110,12 +110,12 @@
System.out.println("thirdInstance: " +
CachePrinter.printCacheLockingInfo(thirdInstance));
assert thirdInstance.peek(fqn, false) != null : "Should have data";
- assert thirdInstance.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null :
"Should have backup node for buddy";
- assert thirdInstance.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
+ assert
thirdInstance.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(buddy.getLocalAddress())), false) != null :
"Should have backup node for buddy";
+ assert
thirdInstance.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.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(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
- assert dataOwner.peek(new Fqn(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(thirdInstance.getLocalAddress())), false) != null :
"Should have backup node for buddy";
+ assert
dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.getGroupNameFromAddress(dataOwner.getLocalAddress())), false) == null :
"Should NOT have backup node for self!";
+ assert
dataOwner.peek(Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
BuddyManager.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 buddy.peek(fqn, false) == null : "Should not have data";
assert buddy.peek(fqn.getParent(), false) == null : "Should not have any part
of the data";
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/FIFOMinTTLTest.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -1,24 +1,20 @@
package org.jboss.cache.eviction.minttl;
-import org.testng.annotations.Test;
-import org.testng.annotations.AfterMethod;
+import org.jboss.cache.Fqn;
import org.jboss.cache.eviction.EvictionPolicyConfigBase;
-import org.jboss.cache.eviction.LRUConfiguration;
import org.jboss.cache.eviction.FIFOConfiguration;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.CacheStatus;
-import org.jboss.cache.util.CachePrinter;
import org.jboss.cache.misc.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
/**
- *
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.1.0
*/
@Test(groups = {"functional"})
public class FIFOMinTTLTest extends MinTTLTestBase
{
- private Fqn fqn2 = new Fqn(region, "b");
+ private Fqn fqn2 = Fqn.fromRelativeElements(region, "b");
private Thread busyThread;
private boolean busyThreadRunning = true;
@@ -63,7 +59,7 @@
}
while (busyThreadRunning)
- {
+ {
cache.put(fqn2, "k", "v");
TestingUtil.sleepRandom(150);
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.java 2008-04-09
09:08:28 UTC (rev 5522)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MRUMinTTLTest.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -1,22 +1,21 @@
package org.jboss.cache.eviction.minttl;
-import org.testng.annotations.Test;
+import org.jboss.cache.CacheStatus;
+import org.jboss.cache.Fqn;
import org.jboss.cache.eviction.EvictionPolicyConfigBase;
-import org.jboss.cache.eviction.LRUConfiguration;
import org.jboss.cache.eviction.MRUConfiguration;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.CacheStatus;
import org.jboss.cache.misc.TestingUtil;
+import org.testng.annotations.Test;
/**
- *
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 2.1.0
*/
@Test(groups = {"functional"})
public class MRUMinTTLTest extends MinTTLTestBase
{
- private Fqn fqn2 = new Fqn(region, "b");
+ private Fqn fqn2 = Fqn.fromRelativeElements(region, "b");
+
@Override
protected EvictionPolicyConfigBase getEvictionPolicyConfig()
{
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/test/java/org/jboss/cache/eviction/minttl/MinTTLTestBase.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -12,7 +12,6 @@
import org.testng.annotations.Test;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.concurrent.CountDownLatch;
@@ -29,7 +28,7 @@
protected Cache cache;
protected Fqn region = Fqn.fromString("/test-region");
- protected Fqn fqn = new Fqn(region, "a");
+ protected Fqn fqn = Fqn.fromRelativeElements(region, "a");
// allows the test methods to notify any support threads in subclasses that data is in
the cache and the test is about to begin
protected CountDownLatch cacheInitialisedLatch;
Modified:
core/trunk/src/test/java/org/jboss/cache/integration/hibernate/UpdateTimestampsCachingTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/integration/hibernate/UpdateTimestampsCachingTest.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/test/java/org/jboss/cache/integration/hibernate/UpdateTimestampsCachingTest.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -1,15 +1,5 @@
package org.jboss.cache.integration.hibernate;
-import java.util.HashSet;
-import java.util.Set;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.jboss.cache.integration.hibernate.HibernateIntegrationTestUtil.*;
-
-import javax.transaction.Synchronization;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Cache;
@@ -17,10 +7,18 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration;
+import static org.jboss.cache.integration.hibernate.HibernateIntegrationTestUtil.*;
+import static org.testng.AssertJUnit.assertEquals;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import javax.transaction.Synchronization;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* Tests that mimic the Hibernate Second Level Cache UpdateTimestamps
* use case.
@@ -35,9 +33,9 @@
public class UpdateTimestampsCachingTest
{
private static final Log log = LogFactory.getLog(UpdateTimestampsCachingTest.class);
-
+
private static final Fqn<String> ENTITY_TYPE_FQN =
Fqn.fromString("/com/foo/MyEntity");
-
+
private Set<Cache<String, Object>> caches;
@BeforeMethod(alwaysRun = true)
@@ -52,7 +50,7 @@
for (Cache<String, Object> cache : caches)
cache.stop();
}
-
+
private Cache<String, Object> createCache(boolean optimistic)
{
CacheFactory<String, Object> cf = new DefaultCacheFactory<String,
Object>();
@@ -62,20 +60,20 @@
caches.add(cache);
return cache;
}
-
+
public void testTimestampUpdateInAfterCompletionPessimistic() throws Exception
{
timestampUpdateInAfterCompletionTest(false);
}
-
+
public void testTimestampUpdateInAfterCompletionOptimistic() throws Exception
{
timestampUpdateInAfterCompletionTest(true);
}
-
+
/**
* FIXME Make this use a cluster, not just a single cache
- *
+ *
* @param optimistic
* @throws Exception
*/
@@ -83,36 +81,36 @@
{
Cache<String, Object> cache = createCache(optimistic);
TransactionManager tm =
cache.getConfiguration().getRuntimeConfig().getTransactionManager();
-
+
tm.begin();
Transaction tx = tm.getTransaction();
UpdateTimestampsSynchronization sync = new
UpdateTimestampsSynchronization(ENTITY_TYPE_FQN, cache, tm);
tx.registerSynchronization(sync);
-
- Fqn<String> fqn = new Fqn<String>(REGION_PREFIX_FQN, ENTITY_TYPE_FQN);
- fqn = new Fqn<String>(fqn, "1");
+
+ Fqn fqn = Fqn.fromRelativeFqn(REGION_PREFIX_FQN, ENTITY_TYPE_FQN);
+ fqn = Fqn.fromRelativeElements(fqn, "1");
cache.put(fqn, ITEM, "value");
-
+
tm.commit();
-
- fqn = new Fqn<String>(HibernateIntegrationTestUtil.TS_FQN, ENTITY_TYPE_FQN);
+
+ fqn = Fqn.fromRelativeFqn(HibernateIntegrationTestUtil.TS_FQN, ENTITY_TYPE_FQN);
assertEquals(sync.getTimestamp(), cache.get(fqn, ITEM));
}
-
+
private class UpdateTimestampsSynchronization implements Synchronization
{
private final Cache<String, Object> cache;
private final Fqn<String> entityType;
private final TransactionManager tm;
private Long timestamp;
-
+
UpdateTimestampsSynchronization(Fqn<String> entityType, Cache<String,
Object> cache, TransactionManager tm)
{
this.entityType = entityType;
this.cache = cache;
this.tm = tm;
}
-
+
public Long getTimestamp()
{
return timestamp;
@@ -125,11 +123,11 @@
public void afterCompletion(int status)
{
- Fqn<String> fqn = new Fqn<String>(TS_FQN, entityType);
+ Fqn fqn = Fqn.fromRelativeFqn(TS_FQN, entityType);
try
{
- timestamp = new Long(System.currentTimeMillis());
-
+ timestamp = System.currentTimeMillis();
+
Transaction tx = tm.suspend();
cache.getInvocationContext().getOptionOverrides().setForceAsynchronous(true);
cache.put(fqn, ITEM, timestamp);
@@ -139,8 +137,8 @@
catch (Exception e)
{
log.error("Problem updating timestamp " + entityType, e);
- throw new RuntimeException(e);
- }
+ throw new RuntimeException(e);
+ }
}
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-04-09
09:08:28 UTC (rev 5522)
+++ core/trunk/src/test/java/org/jboss/cache/loader/CacheLoaderTestsBase.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -47,14 +47,14 @@
private static final Log log = LogFactory.getLog(CacheLoaderTestsBase.class);
CacheSPI<Object, Object> cache;
CacheLoader loader = null;
- static final Fqn<String> FQN = new Fqn<String>("key");
- private static final Fqn<String> SUBTREE_FQN = new Fqn<String>(FQN,
"subtree");
+ static final Fqn<String> FQN = Fqn.fromString("/key");
+ private static final Fqn SUBTREE_FQN = Fqn.fromRelativeElements(FQN,
"subtree");
- private static final Fqn<String> BUDDY_BASE = new
Fqn<String>(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
+ private static final Fqn BUDDY_BASE =
Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN, "test");
- private static final Fqn<String> BUDDY_PLUS_FQN = new
Fqn<String>(BUDDY_BASE, FQN);
+ private static final Fqn BUDDY_PLUS_FQN = Fqn.fromRelativeElements(BUDDY_BASE, FQN);
- private static final Fqn<String> BUDDY_PLUS_SUBTREE_FQN = new
Fqn<String>(BUDDY_BASE, SUBTREE_FQN);
+ private static final Fqn BUDDY_PLUS_SUBTREE_FQN = Fqn.fromRelativeElements(BUDDY_BASE,
SUBTREE_FQN);
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
@@ -1128,25 +1128,25 @@
{
/* One FQN only. */
- doPutTests(new Fqn<String>("key"));
- doRemoveTests(new Fqn<String>("key"));
+ doPutTests(Fqn.fromString("/key"));
+ doRemoveTests(Fqn.fromString("/key"));
// assertEquals(0, loader.loadEntireState().length);
/* Add three FQNs, middle FQN last. */
- doPutTests(new Fqn<String>("key1"));
- doPutTests(new Fqn<String>("key3"));
- doPutTests(new Fqn<String>("key2"));
- assertEquals(4, loader.get(new Fqn<String>("key1")).size());
- assertEquals(4, loader.get(new Fqn<String>("key2")).size());
- assertEquals(4, loader.get(new Fqn<String>("key3")).size());
+ doPutTests(Fqn.fromString("/key1"));
+ doPutTests(Fqn.fromString("/key3"));
+ doPutTests(Fqn.fromString("/key2"));
+ assertEquals(4, loader.get(Fqn.fromString("/key1")).size());
+ assertEquals(4, loader.get(Fqn.fromString("/key2")).size());
+ assertEquals(4, loader.get(Fqn.fromString("/key3")).size());
/* Remove middle FQN first, then the others. */
- doRemoveTests(new Fqn<String>("key2"));
- doRemoveTests(new Fqn<String>("key3"));
- doRemoveTests(new Fqn<String>("key1"));
- assertNull(loader.get(new Fqn<String>("key1")));
- assertNull(loader.get(new Fqn<String>("key2")));
- assertNull(loader.get(new Fqn<String>("key3")));
+ doRemoveTests(Fqn.fromString("/key2"));
+ doRemoveTests(Fqn.fromString("/key3"));
+ doRemoveTests(Fqn.fromString("/key1"));
+ assertNull(loader.get(Fqn.fromString("/key1")));
+ assertNull(loader.get(Fqn.fromString("/key2")));
+ assertNull(loader.get(Fqn.fromString("/key3")));
// assertEquals(0, loader.loadEntireState().length);
}
@@ -1238,12 +1238,12 @@
{
/* Create top level node implicitly. */
- assertTrue(!loader.exists(new Fqn<String>("key0")));
+ assertTrue(!loader.exists(Fqn.fromString("/key0")));
loader.put(Fqn.fromString("/key0/level1/level2"), null);
addDelay();
assertTrue(loader.exists(Fqn.fromString("/key0/level1/level2")));
assertTrue(loader.exists(Fqn.fromString("/key0/level1")));
- assertTrue(loader.exists(new Fqn<String>("key0")));
+ assertTrue(loader.exists(Fqn.fromString("/key0")));
/* Remove leaf, leaving implicitly created middle level. */
loader.put(Fqn.fromString("/key0/x/y"), null);
@@ -1256,21 +1256,21 @@
assertTrue(loader.exists(Fqn.fromString("/key0/x")));
/* Delete top level to delete everything. */
- loader.remove(new Fqn<String>("key0"));
+ loader.remove(Fqn.fromString("/key0"));
addDelay();
- assertTrue(!loader.exists(new Fqn<String>("key0")));
+ assertTrue(!loader.exists(Fqn.fromString("/key0")));
assertTrue(!loader.exists(Fqn.fromString("/key0/level1/level2")));
assertTrue(!loader.exists(Fqn.fromString("/key0/level1")));
assertTrue(!loader.exists(Fqn.fromString("/key0/x")));
/* Add three top level nodes as context. */
- loader.put(new Fqn<String>("key1"), null);
- loader.put(new Fqn<String>("key2"), null);
- loader.put(new Fqn<String>("key3"), null);
+ loader.put(Fqn.fromString("/key1"), null);
+ loader.put(Fqn.fromString("/key2"), null);
+ loader.put(Fqn.fromString("/key3"), null);
addDelay();
- assertTrue(loader.exists(new Fqn<String>("key1")));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(loader.exists(new Fqn<String>("key3")));
+ assertTrue(loader.exists(Fqn.fromString("/key1")));
+ assertTrue(loader.exists(Fqn.fromString("/key2")));
+ assertTrue(loader.exists(Fqn.fromString("/key3")));
/* Put /key3/level1/level2. level1 should be implicitly created. */
assertTrue(!loader.exists(Fqn.fromString("/key3/level1")));
@@ -1281,9 +1281,9 @@
assertTrue(loader.exists(Fqn.fromString("/key3/level1")));
/* Context nodes should still be intact. */
- assertTrue(loader.exists(new Fqn<String>("key1")));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(loader.exists(new Fqn<String>("key3")));
+ assertTrue(loader.exists(Fqn.fromString("/key1")));
+ assertTrue(loader.exists(Fqn.fromString("/key2")));
+ assertTrue(loader.exists(Fqn.fromString("/key3")));
/* Remove middle level only. */
loader.remove(Fqn.fromString("/key3/level1"));
@@ -1292,40 +1292,40 @@
assertTrue(!loader.exists(Fqn.fromString("/key3/level1")));
/* Context nodes should still be intact. */
- assertTrue(loader.exists(new Fqn<String>("key1")));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(loader.exists(new Fqn<String>("key3")));
+ assertTrue(loader.exists(Fqn.fromString("/key1")));
+ assertTrue(loader.exists(Fqn.fromString("/key2")));
+ assertTrue(loader.exists(Fqn.fromString("/key3")));
/* Delete first root, leaving other roots. */
- loader.remove(new Fqn<String>("key1"));
+ loader.remove(Fqn.fromString("/key1"));
addDelay();
- assertTrue(!loader.exists(new Fqn<String>("key1")));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(loader.exists(new Fqn<String>("key3")));
+ assertTrue(!loader.exists(Fqn.fromString("/key1")));
+ assertTrue(loader.exists(Fqn.fromString("/key2")));
+ assertTrue(loader.exists(Fqn.fromString("/key3")));
/* Delete last root, leaving other roots. */
- loader.remove(new Fqn<String>("key3"));
+ loader.remove(Fqn.fromString("/key3"));
addDelay();
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(!loader.exists(new Fqn<String>("key3")));
+ assertTrue(loader.exists(Fqn.fromString("/key2")));
+ assertTrue(!loader.exists(Fqn.fromString("/key3")));
/* Delete final root, leaving none. */
- loader.remove(new Fqn<String>("key2"));
+ loader.remove(Fqn.fromString("/key2"));
addDelay();
- assertTrue(!loader.exists(new Fqn<String>("key0")));
- assertTrue(!loader.exists(new Fqn<String>("key1")));
- assertTrue(!loader.exists(new Fqn<String>("key2")));
- assertTrue(!loader.exists(new Fqn<String>("key3")));
+ assertTrue(!loader.exists(Fqn.fromString("/key0")));
+ assertTrue(!loader.exists(Fqn.fromString("/key1")));
+ assertTrue(!loader.exists(Fqn.fromString("/key2")));
+ assertTrue(!loader.exists(Fqn.fromString("/key3")));
/* Repeat all tests above using put(Fqn,Object,Object) and get(Fqn) */
- assertNull(loader.get(new Fqn<String>("key0")));
+ assertNull(loader.get(Fqn.fromString("/key0")));
loader.put(Fqn.fromString("/key0/level1/level2"), "a",
"b");
addDelay();
assertNotNull(loader.get(Fqn.fromString("/key0/level1/level2")));
assertNotNull(loader.get(Fqn.fromString("/key0/level1")));
assertEquals(0, loader.get(Fqn.fromString("/key0/level1")).size());
- assertEquals(0, loader.get(new Fqn<String>("key0")).size());
+ assertEquals(0, loader.get(Fqn.fromString("/key0")).size());
loader.put(Fqn.fromString("/key0/x/y"), "a", "b");
addDelay();
@@ -1338,20 +1338,20 @@
assertNotNull(loader.get(Fqn.fromString("/key0/x")));
assertEquals(0, loader.get(Fqn.fromString("/key0/x")).size());
- loader.remove(new Fqn<String>("key0"));
+ loader.remove(Fqn.fromString("/key0"));
addDelay();
- assertNull(loader.get(new Fqn<String>("key0")));
+ assertNull(loader.get(Fqn.fromString("/key0")));
assertNull(loader.get(Fqn.fromString("/key0/level1/level2")));
assertNull(loader.get(Fqn.fromString("/key0/level1")));
assertNull(loader.get(Fqn.fromString("/key0/x")));
- loader.put(new Fqn<String>("key1"), "a", "b");
- loader.put(new Fqn<String>("key2"), "a", "b");
- loader.put(new Fqn<String>("key3"), "a", "b");
+ loader.put(Fqn.fromString("/key1"), "a", "b");
+ loader.put(Fqn.fromString("/key2"), "a", "b");
+ loader.put(Fqn.fromString("/key3"), "a", "b");
addDelay();
- assertNotNull(loader.get(new Fqn<String>("key1")));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNotNull(loader.get(new Fqn<String>("key3")));
+ assertNotNull(loader.get(Fqn.fromString("/key1")));
+ assertNotNull(loader.get(Fqn.fromString("/key2")));
+ assertNotNull(loader.get(Fqn.fromString("/key3")));
assertNull(loader.get(Fqn.fromString("/key3/level1")));
assertNull(loader.get(Fqn.fromString("/key3/level1/level2")));
@@ -1361,36 +1361,36 @@
assertNotNull(loader.get(Fqn.fromString("/key3/level1")));
assertEquals(0, loader.get(Fqn.fromString("/key3/level1")).size());
- assertNotNull(loader.get(new Fqn<String>("key1")));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNotNull(loader.get(new Fqn<String>("key3")));
+ assertNotNull(loader.get(Fqn.fromString("/key1")));
+ assertNotNull(loader.get(Fqn.fromString("/key2")));
+ assertNotNull(loader.get(Fqn.fromString("/key3")));
loader.remove(Fqn.fromString("/key3/level1"));
addDelay();
assertNull(loader.get(Fqn.fromString("/key3/level1/level2")));
assertNull(loader.get(Fqn.fromString("/key3/level1")));
- assertNotNull(loader.get(new Fqn<String>("key1")));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNotNull(loader.get(new Fqn<String>("key3")));
+ assertNotNull(loader.get(Fqn.fromString("/key1")));
+ assertNotNull(loader.get(Fqn.fromString("/key2")));
+ assertNotNull(loader.get(Fqn.fromString("/key3")));
- loader.remove(new Fqn<String>("key1"));
+ loader.remove(Fqn.fromString("/key1"));
addDelay();
- assertNull(loader.get(new Fqn<String>("key1")));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNotNull(loader.get(new Fqn<String>("key3")));
+ assertNull(loader.get(Fqn.fromString("/key1")));
+ assertNotNull(loader.get(Fqn.fromString("/key2")));
+ assertNotNull(loader.get(Fqn.fromString("/key3")));
- loader.remove(new Fqn<String>("key3"));
+ loader.remove(Fqn.fromString("/key3"));
addDelay();
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNull(loader.get(new Fqn<String>("key3")));
+ assertNotNull(loader.get(Fqn.fromString("/key2")));
+ assertNull(loader.get(Fqn.fromString("/key3")));
- loader.remove(new Fqn<String>("key2"));
+ loader.remove(Fqn.fromString("/key2"));
addDelay();
- assertNull(loader.get(new Fqn<String>("key0")));
- assertNull(loader.get(new Fqn<String>("key1")));
- assertNull(loader.get(new Fqn<String>("key2")));
- assertNull(loader.get(new Fqn<String>("key3")));
+ assertNull(loader.get(Fqn.fromString("/key0")));
+ assertNull(loader.get(Fqn.fromString("/key1")));
+ assertNull(loader.get(Fqn.fromString("/key2")));
+ assertNull(loader.get(Fqn.fromString("/key3")));
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java 2008-04-09
09:08:28 UTC (rev 5522)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/AsyncReplTest.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -110,7 +110,7 @@
if (useMarshalledValues) Thread.currentThread().setContextClassLoader(cla);
cache1.put(aop, "person", ben_);
- cache1.put(new Fqn<String>("alias"), "person", ben_);
+ cache1.put(Fqn.fromString("/alias"), "person", ben_);
if (useMarshalledValues) resetContextClassLoader();
TestingUtil.sleepThread(1000);
@@ -254,12 +254,12 @@
clazz = cl2.loadFoo();
Object custom2 = clazz.newInstance();
- Fqn<Object> base = new Fqn<Object>("aop");
- Fqn<Object> fqn = new Fqn<Object>(base, custom1);
+ Fqn base = Fqn.fromString("/aop");
+ Fqn fqn = Fqn.fromRelativeElements(base, custom1);
cache1.put(fqn, "key", "value");
TestingUtil.sleepThread(1000);
- Fqn<Object> fqn2 = new Fqn<Object>(base, custom2);
+ Fqn fqn2 = Fqn.fromRelativeElements(base, custom2);
Object val = cache2.get(fqn2, "key");
assertEquals("value", val);
}
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java 2008-04-09
09:08:28 UTC (rev 5522)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/SyncReplTest.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -394,11 +394,11 @@
clazz = cl2.loadFoo();
Object custom2 = clazz.newInstance();
- cache1.put(new Fqn<Object>("aop", custom1), "key",
"value");
+ cache1.put(Fqn.fromElements("aop", custom1), "key",
"value");
try
{
- Object val = cache2.get(new Fqn<Object>("aop", custom2),
"key");
+ Object val = cache2.get(Fqn.fromElements("aop", custom2),
"key");
assertEquals("value", val);
}
catch (Exception ex)
Modified:
core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -365,7 +365,7 @@
assertEquals("Event log should be empty", Collections.emptyList(),
eventLog2.events);
cache1.move(n1.getFqn(), n2.getFqn());
- Fqn<String> newFqn = new Fqn<String>(newParent, fqn.getLastElement());
+ Fqn newFqn = Fqn.fromRelativeElements(newParent, fqn.getLastElement());
List<Event> expected = new ArrayList<Event>();
if (optLocking)
@@ -610,7 +610,7 @@
tm1.begin();
Transaction tx = tm1.getTransaction();
- Fqn<String> newFqn = new Fqn<String>(newParent, fqn.getLastElement());
+ Fqn newFqn = Fqn.fromRelativeElements(newParent, fqn.getLastElement());
cache1.move(n1.getFqn(), n2.getFqn());
List<Event> expected = new ArrayList<Event>();
expected.add(new EventImpl(false, cache1, null, null, null, tx, true, null, false,
null, TRANSACTION_REGISTERED));
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ComparatorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ComparatorTest.java 2008-04-09
09:08:28 UTC (rev 5522)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ComparatorTest.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -32,8 +32,8 @@
public void testNullCompare()
{
- Fqn<String> fqn1 = new Fqn<String>(new ArrayList<String>());
- Fqn<String> fqn2 = new Fqn<String>(new ArrayList<String>());
+ Fqn<String> fqn1 = Fqn.fromList(new ArrayList<String>());
+ Fqn<String> fqn2 = Fqn.fromList(new ArrayList<String>());
assertTrue(comp.compare(fqn1, fqn2) == 0);
assertTrue(comp.compare(fqn2, fqn1) == 0);
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -329,7 +329,7 @@
assertEquals(true,
workspace.getNode(Fqn.fromString("/one")).isDeleted());
//now put /one back in
- cache.put(new Fqn("one"), "key1", "value2");
+ cache.put(Fqn.fromString("/one"), "key1", "value2");
WorkspaceNode oneAfter = workspace.getNode(Fqn.fromString("/one"));
WorkspaceNode twoAfter = workspace.getNode(Fqn.fromString("/one/two"));
Modified: core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/test/java/org/jboss/cache/passivation/PassivationTestsBase.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -51,7 +51,7 @@
//Cache Loader fields
CacheSPI<Object, Object> cache;
CacheLoader loader = null;
- static final Fqn<String> FQN = new Fqn<String>("key");
+ static final Fqn<String> FQN = Fqn.fromString("/key");
protected CacheLoaderConfig getCacheLoaderConfig(String preload, String
cacheloaderClass, String properties, boolean async, boolean fetchPersistentState) throws
Exception
@@ -73,7 +73,7 @@
@BeforeMethod(alwaysRun = true)
public void setUp() throws Exception
{
- cache = (CacheSPI<Object, Object>) new
DefaultCacheFactory().createCache(false);
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object,
Object>().createCache(false);
cache.getConfiguration().setCacheMode("local");
configureCache();
cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
@@ -867,25 +867,25 @@
{
/* One FQN only. */
- doPutTests(new Fqn<String>("key"));
- doRemoveTests(new Fqn<String>("key"));
+ doPutTests(Fqn.fromString("/key"));
+ doRemoveTests(Fqn.fromString("/key"));
// assertEquals(0, loader.loadEntireState().length);
/* Add three FQNs, middle FQN last. */
- doPutTests(new Fqn<String>("key1"));
- doPutTests(new Fqn<String>("key3"));
- doPutTests(new Fqn<String>("key2"));
- assertEquals(4, loader.get(new Fqn<String>("key1")).size());
- assertEquals(4, loader.get(new Fqn<String>("key2")).size());
- assertEquals(4, loader.get(new Fqn<String>("key3")).size());
+ doPutTests(Fqn.fromString("/key1"));
+ doPutTests(Fqn.fromString("/key3"));
+ doPutTests(Fqn.fromString("/key2"));
+ assertEquals(4, loader.get(Fqn.fromString("/key1")).size());
+ assertEquals(4, loader.get(Fqn.fromString("/key2")).size());
+ assertEquals(4, loader.get(Fqn.fromString("/key3")).size());
/* Remove middle FQN first, then the others. */
- doRemoveTests(new Fqn<String>("key2"));
- doRemoveTests(new Fqn<String>("key3"));
- doRemoveTests(new Fqn<String>("key1"));
- assertEquals(null, loader.get(new Fqn<String>("key1")));
- assertEquals(null, loader.get(new Fqn<String>("key2")));
- assertEquals(null, loader.get(new Fqn<String>("key3")));
+ doRemoveTests(Fqn.fromString("/key2"));
+ doRemoveTests(Fqn.fromString("/key3"));
+ doRemoveTests(Fqn.fromString("/key1"));
+ assertEquals(null, loader.get(Fqn.fromString("/key1")));
+ assertEquals(null, loader.get(Fqn.fromString("/key2")));
+ assertEquals(null, loader.get(Fqn.fromString("/key3")));
// assertEquals(0, loader.loadEntireState().length);
}
@@ -1003,13 +1003,13 @@
assertTrue(!loader.exists(Fqn.fromString("/key0/x")));
/* Add three top level nodes as context. */
- loader.put(new Fqn<String>("key1"), null);
- loader.put(new Fqn<String>("key2"), null);
- loader.put(new Fqn<String>("key3"), null);
+ loader.put(Fqn.fromString("/key1"), null);
+ loader.put(Fqn.fromString("/key2"), null);
+ loader.put(Fqn.fromString("/key3"), null);
addDelay();
- assertTrue(loader.exists(new Fqn<String>("key1")));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(loader.exists(new Fqn<String>("key3")));
+ assertTrue(loader.exists(Fqn.fromString("/key1")));
+ assertTrue(loader.exists(Fqn.fromString("/key2")));
+ assertTrue(loader.exists(Fqn.fromString("/key3")));
/* Put /key3/level1/level2. level1 should be implicitly created. */
assertTrue(!loader.exists(Fqn.fromString("/key3/level1")));
@@ -1020,9 +1020,9 @@
assertTrue(loader.exists(Fqn.fromString("/key3/level1")));
/* Context nodes should still be intact. */
- assertTrue(loader.exists(new Fqn<String>("key1")));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(loader.exists(new Fqn<String>("key3")));
+ assertTrue(loader.exists(Fqn.fromString("/key1")));
+ assertTrue(loader.exists(Fqn.fromString("/key2")));
+ assertTrue(loader.exists(Fqn.fromString("/key3")));
/* Remove middle level only. */
loader.remove(Fqn.fromString("/key3/level1"));
@@ -1031,30 +1031,30 @@
assertTrue(!loader.exists(Fqn.fromString("/key3/level1")));
/* Context nodes should still be intact. */
- assertTrue(loader.exists(new Fqn<String>("key1")));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(loader.exists(new Fqn<String>("key3")));
+ assertTrue(loader.exists(Fqn.fromString("/key1")));
+ assertTrue(loader.exists(Fqn.fromString("/key2")));
+ assertTrue(loader.exists(Fqn.fromString("/key3")));
/* Delete first root, leaving other roots. */
- loader.remove(new Fqn<String>("key1"));
+ loader.remove(Fqn.fromString("/key1"));
addDelay();
- assertTrue(!loader.exists(new Fqn<String>("key1")));
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(loader.exists(new Fqn<String>("key3")));
+ assertTrue(!loader.exists(Fqn.fromString("/key1")));
+ assertTrue(loader.exists(Fqn.fromString("/key2")));
+ assertTrue(loader.exists(Fqn.fromString("/key3")));
/* Delete last root, leaving other roots. */
- loader.remove(new Fqn<String>("key3"));
+ loader.remove(Fqn.fromString("/key3"));
addDelay();
- assertTrue(loader.exists(new Fqn<String>("key2")));
- assertTrue(!loader.exists(new Fqn<String>("key3")));
+ assertTrue(loader.exists(Fqn.fromString("/key2")));
+ assertTrue(!loader.exists(Fqn.fromString("/key3")));
/* Delete final root, leaving none. */
- loader.remove(new Fqn<String>("key2"));
+ loader.remove(Fqn.fromString("/key2"));
addDelay();
assertTrue(!loader.exists(new Fqn<String>("key0")));
- assertTrue(!loader.exists(new Fqn<String>("key1")));
- assertTrue(!loader.exists(new Fqn<String>("key2")));
- assertTrue(!loader.exists(new Fqn<String>("key3")));
+ assertTrue(!loader.exists(Fqn.fromString("/key1")));
+ assertTrue(!loader.exists(Fqn.fromString("/key2")));
+ assertTrue(!loader.exists(Fqn.fromString("/key3")));
/* Repeat all tests above using put(Fqn,Object,Object) and get(Fqn) */
@@ -1085,13 +1085,13 @@
assertNull(loader.get(Fqn.fromString("/key0/level1")));
assertNull(loader.get(Fqn.fromString("/key0/x")));
- loader.put(new Fqn<String>("key1"), "a", "b");
- loader.put(new Fqn<String>("key2"), "a", "b");
- loader.put(new Fqn<String>("key3"), "a", "b");
+ loader.put(Fqn.fromString("/key1"), "a", "b");
+ loader.put(Fqn.fromString("/key2"), "a", "b");
+ loader.put(Fqn.fromString("/key3"), "a", "b");
addDelay();
- assertNotNull(loader.get(new Fqn<String>("key1")));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNotNull(loader.get(new Fqn<String>("key3")));
+ assertNotNull(loader.get(Fqn.fromString("/key1")));
+ assertNotNull(loader.get(Fqn.fromString("/key2")));
+ assertNotNull(loader.get(Fqn.fromString("/key3")));
assertNull(loader.get(Fqn.fromString("/key3/level1")));
assertNull(loader.get(Fqn.fromString("/key3/level1/level2")));
@@ -1101,36 +1101,36 @@
assertNotNull(loader.get(Fqn.fromString("/key3/level1")));
assertTrue(loader.get(Fqn.fromString("/key3/level1")).isEmpty());
- assertNotNull(loader.get(new Fqn<String>("key1")));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNotNull(loader.get(new Fqn<String>("key3")));
+ assertNotNull(loader.get(Fqn.fromString("/key1")));
+ assertNotNull(loader.get(Fqn.fromString("/key2")));
+ assertNotNull(loader.get(Fqn.fromString("/key3")));
loader.remove(Fqn.fromString("/key3/level1"));
addDelay();
assertNull(loader.get(Fqn.fromString("/key3/level1/level2")));
assertNull(loader.get(Fqn.fromString("/key3/level1")));
- assertNotNull(loader.get(new Fqn<String>("key1")));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNotNull(loader.get(new Fqn<String>("key3")));
+ assertNotNull(loader.get(Fqn.fromString("/key1")));
+ assertNotNull(loader.get(Fqn.fromString("/key2")));
+ assertNotNull(loader.get(Fqn.fromString("/key3")));
- loader.remove(new Fqn<String>("key1"));
+ loader.remove(Fqn.fromString("/key1"));
addDelay();
- assertNull(loader.get(new Fqn<String>("key1")));
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNotNull(loader.get(new Fqn<String>("key3")));
+ assertNull(loader.get(Fqn.fromString("/key1")));
+ assertNotNull(loader.get(Fqn.fromString("/key2")));
+ assertNotNull(loader.get(Fqn.fromString("/key3")));
- loader.remove(new Fqn<String>("key3"));
+ loader.remove(Fqn.fromString("/key3"));
addDelay();
- assertNotNull(loader.get(new Fqn<String>("key2")));
- assertNull(loader.get(new Fqn<String>("key3")));
+ assertNotNull(loader.get(Fqn.fromString("/key2")));
+ assertNull(loader.get(Fqn.fromString("/key3")));
- loader.remove(new Fqn<String>("key2"));
+ loader.remove(Fqn.fromString("/key2"));
addDelay();
assertNull(loader.get(new Fqn<String>("key0")));
- assertNull(loader.get(new Fqn<String>("key1")));
- assertNull(loader.get(new Fqn<String>("key2")));
- assertNull(loader.get(new Fqn<String>("key3")));
+ assertNull(loader.get(Fqn.fromString("/key1")));
+ assertNull(loader.get(Fqn.fromString("/key2")));
+ assertNull(loader.get(Fqn.fromString("/key3")));
}
/**
Modified:
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java
===================================================================
---
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2008-04-09
09:08:28 UTC (rev 5522)
+++
core/trunk/src/test/java/org/jboss/cache/statetransfer/StateTransfer200Test.java 2008-04-09
14:33:24 UTC (rev 5523)
@@ -11,8 +11,8 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.Region;
+import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
-import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.config.BuddyReplicationConfig;
import org.jboss.cache.factories.XmlConfigurationParser;
import org.jboss.cache.loader.CacheLoader;
@@ -51,7 +51,7 @@
cache1.start();
- Fqn<String> backup = new Fqn<String>(BuddyManager.BUDDY_BACKUP_SUBTREE,
"test");
+ Fqn backup = Fqn.fromRelativeElements(BuddyManager.BUDDY_BACKUP_SUBTREE_FQN,
"test");
cache1.getInvocationContext().getOptionOverrides().setCacheModeLocal(true);
cache1.put(backup, "name", JOE);
cache1.put(A_B, "age", TWENTY);