JBoss Cache SVN: r6615 - core/trunk/src/main/java/org/jboss/cache/eviction.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-08-26 02:44:18 -0400 (Tue, 26 Aug 2008)
New Revision: 6615
Removed:
core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java
Log:
Ghost file
Deleted: core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java 2008-08-25 23:17:22 UTC (rev 6614)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/Modernizable.java 2008-08-26 06:44:18 UTC (rev 6615)
@@ -1,17 +0,0 @@
-package org.jboss.cache.eviction;
-
-import org.jboss.cache.config.EvictionAlgorithmConfig;
-
-/**
- * Attached to deprecated eviction configuration elements that know how to map to modern counterparts. This interface
- * is itself deprecated and is only used to bridge deprecated configurations.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 3.0
- * @deprecated
- */
-@Deprecated
-public interface Modernizable
-{
- EvictionAlgorithmConfig modernize();
-}
16 years, 6 months
JBoss Cache SVN: r6614 - in core/trunk/src: main/java/org/jboss/cache/buddyreplication and 31 other directories.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2008-08-25 19:17:22 -0400 (Mon, 25 Aug 2008)
New Revision: 6614
Added:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
Removed:
core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContext.java
Modified:
core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java
core/trunk/src/main/java/org/jboss/cache/Cache.java
core/trunk/src/main/java/org/jboss/cache/CacheSPI.java
core/trunk/src/main/java/org/jboss/cache/Fqn.java
core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
core/trunk/src/main/java/org/jboss/cache/NodeSPI.java
core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java
core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/PessGetChildrenNamesCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/CreateNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/LegacyEvictCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessClearDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessMoveCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutDataMapCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutForExternalReadCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutKeyValueCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemoveKeyCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemoveNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/VersionedInvalidateCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactionCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
core/trunk/src/main/java/org/jboss/cache/factories/context/ContextFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/context/MVCCContextFactory.java
core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticContextFactory.java
core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/BatchingInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyPassivationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java
core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java
core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java
core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/lock/AbstractLockManager.java
core/trunk/src/main/java/org/jboss/cache/lock/FqnLockManager.java
core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java
core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java
core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java
core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java
core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java
core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java
core/trunk/src/test/java/org/jboss/cache/commands/TestContextBase.java
core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateDataCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutDataMapCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeyValueCommandTest.java
core/trunk/src/test/java/org/jboss/cache/commands/write/AbstractVersionedDataCommandTest.java
core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java
core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java
core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java
core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java
Log:
Fix more BC issues
Move InvocationContext to org.jboss.cache, where it was originally
Improve Generics usage on Fqn to be friendlier and BC
Modified: core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/AbstractNodeFactory.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -11,7 +11,6 @@
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.InterceptorChain;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.invocation.NodeInvocationDelegate;
import org.jboss.cache.mvcc.ReadCommittedNode;
Modified: core/trunk/src/main/java/org/jboss/cache/Cache.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/Cache.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -8,7 +8,6 @@
import net.jcip.annotations.ThreadSafe;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.invocation.InvocationContext;
import org.jgroups.Address;
import java.util.List;
@@ -352,7 +351,7 @@
InvocationContext getInvocationContext();
/**
- * Sets the passed in {@link org.jboss.cache.invocation.InvocationContext} as current.
+ * Sets the passed in {@link org.jboss.cache.InvocationContext} as current.
*
* @param ctx invocation context to use
* @throws IllegalStateException if the cache has been destroyed.
Modified: core/trunk/src/main/java/org/jboss/cache/CacheSPI.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/CacheSPI.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -10,7 +10,6 @@
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.Marshaller;
Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -79,14 +79,14 @@
*/
@Immutable
@Compat(notes = "The generics, while originally intended to be removed in 3.0, have been retained for backward compat.")
-public class Fqn<E> implements Comparable<Fqn>, Externalizable
+public class Fqn<E> implements Comparable<Fqn<?>>, Externalizable
{
/**
* Separator between FQN elements.
*/
public static final String SEPARATOR = "/";
- protected List<Object> elements;
+ protected List<E> elements;
private transient int hash_code = 0;
protected int size = 0;
@@ -121,7 +121,7 @@
*/
@Deprecated
@Compat
- public Fqn(List<E> names)
+ public Fqn(List<? extends E> names)
{
// the list is unsafe - may be referenced externally
this(names, false);
@@ -150,7 +150,7 @@
*/
@Deprecated
@Compat
- public Fqn(Fqn<E> base, Fqn<E> relative)
+ public Fqn(Fqn<? extends E> base, Fqn<? extends E> relative)
{
this(base, relative.elements);
}
@@ -164,7 +164,7 @@
*/
@Deprecated
@Compat
- public Fqn(Fqn<E> base, E... childNames)
+ public Fqn(Fqn<? extends E> base, E... childNames)
{
this(base, Arrays.asList(childNames));
}
@@ -183,12 +183,12 @@
@Deprecated
@Compat(notes = "Not truly deprecated, this constructor should really be protected and not public. Marked as deprecated for anyone using it as a public API.")
@SuppressWarnings("unchecked")
- protected Fqn(List<?> names, boolean safe)
+ protected Fqn(List<? extends E> names, boolean safe)
{
if (names != null)
{
// if not safe make a defensive copy
- elements = safe ? (List<Object>) names : Immutables.immutableListCopy(names);
+ elements = safe ? (List<E>)names : Immutables.immutableListCopy(names);
size = elements.size();
}
else
@@ -198,7 +198,7 @@
}
}
- protected Fqn(Fqn base, List<?> relative)
+ protected Fqn(Fqn<? extends E> base, List<? extends E> relative)
{
elements = Immutables.immutableListMerge(base.elements, relative);
size = elements.size();
@@ -214,9 +214,9 @@
* @since 2.2.0
*/
@SuppressWarnings("unchecked")
- public static <T> Fqn fromList(List<T> names)
+ public static <T> Fqn<T> fromList(List<? extends T> names)
{
- return new Fqn(names, false);
+ return new Fqn<T>(names, false);
}
/**
@@ -230,9 +230,9 @@
* @return an Fqn
*/
@SuppressWarnings("unchecked")
- public static Fqn fromList(List<?> names, boolean safe)
+ public static <T> Fqn<T> fromList(List<? extends T> names, boolean safe)
{
- return new Fqn(names, safe);
+ return new Fqn<T>(names, safe);
}
/**
@@ -242,9 +242,9 @@
* @return an Fqn
* @since 2.2.0
*/
- public static Fqn fromElements(Object... elements)
+ public static <T> Fqn<T> fromElements(T... elements)
{
- return new Fqn(Arrays.asList(elements), true);
+ return new Fqn<T>(Arrays.asList(elements), true);
}
/**
@@ -255,9 +255,9 @@
* @return an Fqn
* @since 2.2.0
*/
- public static Fqn fromRelativeFqn(Fqn base, Fqn relative)
+ public static <T> Fqn<T> fromRelativeFqn(Fqn<? extends T> base, Fqn<? extends T> relative)
{
- return new Fqn(base, relative.elements);
+ return new Fqn<T>(base, relative.elements);
}
/**
@@ -268,9 +268,9 @@
* @return an Fqn
* @since 2.2.0
*/
- public static Fqn fromRelativeList(Fqn base, List<?> relativeElements)
+ public static <T> Fqn<T> fromRelativeList(Fqn<? extends T> base, List<? extends T> relativeElements)
{
- return new Fqn(base, relativeElements);
+ return new Fqn<T>(base, relativeElements);
}
/**
@@ -281,9 +281,9 @@
* @return an Fqn
* @since 2.2.0
*/
- public static Fqn fromRelativeElements(Fqn base, Object... relativeElements)
+ public static <T> Fqn<T> fromRelativeElements(Fqn<? extends T> base, T... relativeElements)
{
- return new Fqn(base, Arrays.asList(relativeElements));
+ return new Fqn<T>(base, Arrays.asList(relativeElements));
}
/**
@@ -302,7 +302,7 @@
* @return an Fqn<String> constructed from the string representation passed in
*/
@SuppressWarnings("unchecked")
- public static Fqn fromString(String stringRepresentation)
+ public static Fqn<String> fromString(String stringRepresentation)
{
if (stringRepresentation == null || stringRepresentation.equals(SEPARATOR) || stringRepresentation.equals(""))
return root();
@@ -321,9 +321,9 @@
* @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 fromExternalStream(ObjectInput in) throws IOException, ClassNotFoundException
+ public static Fqn<?> fromExternalStream(ObjectInput in) throws IOException, ClassNotFoundException
{
- Fqn f = new Fqn();
+ Fqn<?> f = new Fqn<Object>();
f.readExternal(in);
return f;
}
@@ -352,7 +352,7 @@
* @param generation the generation of the ancestor to retrieve
* @return an ancestor of the current Fqn
*/
- public Fqn getAncestor(int generation)
+ public Fqn<E> getAncestor(int generation)
{
if (generation == 0) return root();
return getSubFqn(0, generation);
@@ -365,10 +365,10 @@
* @param endIndex end index
* @return a subFqn
*/
- public Fqn getSubFqn(int startIndex, int endIndex)
+ public Fqn<E> getSubFqn(int startIndex, int endIndex)
{
- List<Object> el = elements.subList(startIndex, endIndex);
- return new Fqn(el, true);
+ List<E> el = elements.subList(startIndex, endIndex);
+ return new Fqn<E>(el, true);
}
/**
@@ -421,7 +421,7 @@
{
return false;
}
- Fqn other = (Fqn) obj;
+ Fqn<?> other = (Fqn<?>) obj;
return size == other.size() && elements.equals(other.elements);
}
@@ -470,8 +470,8 @@
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
size = in.readShort();
- this.elements = new ArrayList<Object>(size);
- for (int i = 0; i < size; i++) elements.add(in.readObject());
+ this.elements = new ArrayList<E>(size);
+ for (int i = 0; i < size; i++) elements.add((E)in.readObject());
}
@@ -489,7 +489,7 @@
* @param parentFqn candidate parent to test against
* @return true if the target is a child of parentFqn
*/
- public boolean isChildOf(Fqn parentFqn)
+ public boolean isChildOf(Fqn<? super E> parentFqn)
{
return parentFqn.size() != size && isChildOrEquals(parentFqn);
}
@@ -501,7 +501,7 @@
* @param parentFqn parentFqn to compare with
* @return true if this is a direct child, false otherwise.
*/
- public boolean isDirectChildOf(Fqn parentFqn)
+ public boolean isDirectChildOf(Fqn<? super E> parentFqn)
{
return size == parentFqn.size() + 1 && isChildOf(parentFqn);
}
@@ -520,9 +520,9 @@
* @param parentFqn candidate parent to test against
* @return true if this Fqn is equals or the child of parentFqn.
*/
- public boolean isChildOrEquals(Fqn parentFqn)
+ public boolean isChildOrEquals(Fqn<? super E> parentFqn)
{
- List<Object> parentList = parentFqn.elements;
+ List<? super E> parentList = parentFqn.elements;
if (parentList.size() > size)
{
return false;
@@ -550,7 +550,7 @@
return hashCode;
}
- protected String getStringRepresentation(List<Object> elements)
+ protected String getStringRepresentation(List<E> elements)
{
StringBuilder builder = new StringBuilder();
for (Object e : elements)
@@ -580,7 +580,7 @@
*
* @return the parent Fqn
*/
- public Fqn getParent()
+ public Fqn<E> getParent()
{
switch (size)
{
@@ -592,7 +592,7 @@
}
}
- public static final Fqn root() // declared final so compilers can optimise and in-line.
+ public static final <T> Fqn<T> root() // declared final so compilers can optimise and in-line.
{
return ROOT;
}
@@ -634,7 +634,7 @@
*
* @return an unmodifiable list
*/
- public List<Object> peekElements()
+ public List<E> peekElements()
{
return elements;
}
@@ -642,7 +642,7 @@
/**
* Compares this Fqn to another using {@link FqnComparator}.
*/
- public int compareTo(Fqn fqn)
+ public int compareTo(Fqn<?> fqn)
{
return FqnComparator.INSTANCE.compare(this, fqn);
}
@@ -654,11 +654,11 @@
* @param newAncestor nw ancestor to replace with
* @return a new Fqn with ancestors replaced.
*/
- public Fqn replaceAncestor(Fqn oldAncestor, Fqn newAncestor)
+ public Fqn<E> replaceAncestor(Fqn<E> oldAncestor, Fqn<E> newAncestor)
{
if (!isChildOf(oldAncestor))
throw new IllegalArgumentException("Old ancestor must be an ancestor of the current Fqn!");
- Fqn subFqn = this.getSubFqn(oldAncestor.size(), size());
+ Fqn<E> subFqn = this.getSubFqn(oldAncestor.size(), size());
return Fqn.fromRelativeFqn(newAncestor, subFqn);
}
}
\ No newline at end of file
Copied: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java (from rev 6611, core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContext.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -0,0 +1,314 @@
+package org.jboss.cache;
+
+import org.jboss.cache.commands.VisitableCommand;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.marshall.MethodCall;
+import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.cache.transaction.TransactionContext;
+
+import javax.transaction.Transaction;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A context that holds information regarding the scope of a single invocation. May delegate some calls to a {@link org.jboss.cache.transaction.TransactionContext}
+ * if one is in scope.
+ * <p/>
+ * Note that prior to 3.0.0, InvocationContext was a concrete class and not an interface.
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @see org.jboss.cache.transaction.TransactionContext
+ */
+@SuppressWarnings("deprecation")
+public interface InvocationContext
+{
+ /**
+ * Retrieves a node from the registry of looked up nodes in the current scope.
+ *
+ * @param fqn fqn to look up
+ * @return a node, or null if it cannot be found.
+ * @since 3.0.
+ */
+ NodeSPI lookUpNode(Fqn fqn);
+
+ /**
+ * Puts an entry in the registry of looked up nodes in the current scope.
+ *
+ * @param f fqn to add
+ * @param n node to add
+ * @since 3.0.
+ */
+ void putLookedUpNode(Fqn f, NodeSPI n);
+
+ /**
+ * Clears the registry of looked up nodes.
+ *
+ * @since 3.0.
+ */
+ void clearLookedUpNodes();
+
+ /**
+ * Retrieves a map of nodes looked up within the current invocation's scope.
+ *
+ * @return a map of looked up nodes.
+ * @since 3.0
+ */
+ Map<Fqn, NodeSPI> getLookedUpNodes();
+
+ /**
+ * Marks teh context as only rolling back.
+ *
+ * @param localRollbackOnly if true, the context is only rolling back.
+ */
+ void setLocalRollbackOnly(boolean localRollbackOnly);
+
+ /**
+ * Retrieves the transaction associated with this invocation
+ *
+ * @return The transaction associated with this invocation
+ */
+ Transaction getTransaction();
+
+ /**
+ * Sets a transaction object on the invocation context.
+ *
+ * @param transaction transaction to set
+ */
+ void setTransaction(Transaction transaction);
+
+ /**
+ * @return the transaction entry associated with the current transaction, or null if the current thread is not associated with a transaction.
+ * @since 2.2.0
+ */
+ TransactionContext getTransactionContext();
+
+ /**
+ * Sets the transaction context to be associated with the current thread.
+ *
+ * @param transactionContext transaction context to set
+ * @since 2.2.0
+ */
+ void setTransactionContext(TransactionContext transactionContext);
+
+ /**
+ * Retrieves the global transaction associated with this invocation
+ *
+ * @return the global transaction associated with this invocation
+ */
+ GlobalTransaction getGlobalTransaction();
+
+ /**
+ * Sets the global transaction associated with this invocation
+ *
+ * @param globalTransaction global transaction to set
+ */
+ void setGlobalTransaction(GlobalTransaction globalTransaction);
+
+ /**
+ * Retrieves the option overrides associated with this invocation
+ *
+ * @return the option overrides associated with this invocation
+ */
+ Option getOptionOverrides();
+
+ /**
+ * @return true of no options have been set on this context, false otherwise.
+ */
+ boolean isOptionsUninitialised();
+
+ /**
+ * Sets the option overrides to be associated with this invocation
+ *
+ * @param optionOverrides options to set
+ */
+ void setOptionOverrides(Option optionOverrides);
+
+ /**
+ * Tests if this invocation originated locally or from a remote cache.
+ *
+ * @return true if the invocation originated locally.
+ */
+ boolean isOriginLocal();
+
+ /**
+ * Returns an immutable, defensive copy of the List of locks currently maintained for the current scope.
+ * <p/>
+ * Note that if a transaction is in scope, implementations should retrieve these locks from the {@link org.jboss.cache.transaction.TransactionContext}.
+ * Retrieving locks from this method should always ensure they are retrieved from the appropriate scope.
+ * <p/>
+ * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to return <tt>List<Fqn></tt>.
+ *
+ * @return locks held in current scope.
+ */
+ @SuppressWarnings("unchecked")
+ List getLocks();
+
+ /**
+ * Adds a List of locks to the currently maintained collection of locks acquired.
+ * <p/>
+ * Note that if a transaction is in scope, implementations should record locks on the {@link org.jboss.cache.transaction.TransactionContext}.
+ * Adding locks using this method should always ensure they are applied to the appropriate scope.
+ * <p/>
+ * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept <tt>List<Fqn></tt>.
+ *
+ * @param locks locks to add
+ */
+ @SuppressWarnings("unchecked")
+ void addAllLocks(List locks);
+
+ /**
+ * Adds a lock to the currently maintained collection of locks acquired.
+ * <p/>
+ * Note that if a transaction is in scope, implementations should record this lock on the {@link org.jboss.cache.transaction.TransactionContext}.
+ * Using this method should always ensure that the appropriate scope is used.
+ * <p/>
+ * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
+ *
+ * @param lock lock to add
+ */
+ @SuppressWarnings("unchecked")
+ void addLock(Object lock);
+
+ /**
+ * Removes a lock from the currently maintained collection of locks acquired.
+ * <p/>
+ * Note that if a transaction is in scope, implementations should remove this lock from the {@link org.jboss.cache.transaction.TransactionContext}.
+ * Using this method should always ensure that the lock is removed from the appropriate scope.
+ * <p/>
+ * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
+ *
+ * @param lock lock to remove
+ */
+ @SuppressWarnings("unchecked")
+ void removeLock(Object lock);
+
+ /**
+ * Clears all locks from the currently maintained collection of locks acquired.
+ * <p/>
+ * Note that if a transaction is in scope, implementations should clear locks from the {@link org.jboss.cache.transaction.TransactionContext}.
+ * Using this method should always ensure locks are cleared in the appropriate scope.
+ * <p/>
+ * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
+ */
+ void clearLocks();
+
+
+ /**
+ * Note that if a transaction is in scope, implementations should test this lock from on {@link org.jboss.cache.transaction.TransactionContext}.
+ * Using this method should always ensure locks checked in the appropriate scope.
+ *
+ * @param lock lock to test
+ * @return true if the lock being tested is already held in the current scope, false otherwise.
+ */
+ boolean hasLock(Object lock);
+
+ /**
+ * @return true if options exist to suppress locking - false otherwise. Note that this is only used by the {@link org.jboss.cache.interceptors.PessimisticLockInterceptor}.
+ */
+ boolean isLockingSuppressed();
+
+ /**
+ * If set to true, the invocation is assumed to have originated locally. If set to false,
+ * assumed to have originated from a remote cache.
+ *
+ * @param originLocal flag to set
+ */
+ void setOriginLocal(boolean originLocal);
+
+ /**
+ * @return true if the current transaction is set to rollback only.
+ */
+ boolean isLocalRollbackOnly();
+
+ /**
+ * Resets the context, freeing up any references.
+ */
+ void reset();
+
+ /**
+ * This is a "copy-factory-method" that should be used whenever a clone of this class is needed. The resulting instance
+ * is equal() to, but not ==, to the InvocationContext invoked on. Note that this is a shallow copy with the exception
+ * of the Option object, which is deep, as well as any collections held on the context such as locks. Note that the reference
+ * to a {@link org.jboss.cache.transaction.TransactionContext}, if any, is maintained.
+ *
+ * @return a new InvocationContext
+ */
+ @SuppressWarnings("unchecked")
+ InvocationContext copy();
+
+ /**
+ * Sets the state of the InvocationContext based on the template context passed in
+ *
+ * @param template template to copy from
+ */
+ void setState(InvocationContext template);
+
+ /**
+ * @return the method call associated with this invocation
+ */
+ @Deprecated
+ @SuppressWarnings("deprecation")
+ MethodCall getMethodCall();
+
+
+ /**
+ * Sets the method call associated with this invocation.
+ *
+ * @param methodCall methodcall to set
+ * @deprecated not used anymore. Interceptors will get a {@link org.jboss.cache.commands.ReplicableCommand} instance passed in along with an InvocationContext.
+ */
+ @Deprecated
+ void setMethodCall(MethodCall methodCall);
+
+ /**
+ * If the lock acquisition timeout is overridden for current call using an option, then return that one.
+ * If not overridden, return default value.
+ *
+ * @param defaultTimeout timeout to fall back to
+ * @return timeout to use
+ */
+ long getLockAcquisitionTimeout(long defaultTimeout);
+
+ /**
+ * This is only used for backward compatibility with old interceptors implementation and should <b>NOT</b> be
+ * use by any new custom interceptors. The commands is now passed in as the second param in each implementing
+ * handlers (handler = method in ChainedInterceptor class)
+ *
+ * @param cacheCommand command to set
+ */
+ @Deprecated
+ @SuppressWarnings("deprecation")
+ void setCommand(VisitableCommand cacheCommand);
+
+ /**
+ * @return command that is in scope
+ * @see #setCommand(org.jboss.cache.commands.VisitableCommand)
+ */
+ @Deprecated
+ @SuppressWarnings("deprecation")
+ VisitableCommand getCommand();
+
+ /**
+ * @return true if there is current transaction associated with the invocation, and this transaction is in a valid state.
+ */
+ boolean isValidTransaction();
+
+ /**
+ * Throws the given throwable provided no options suppress or prevent this from happening.
+ *
+ * @param throwable throwable to throw
+ * @throws Throwable if allowed to throw one.
+ */
+ void throwIfNeeded(Throwable throwable) throws Throwable;
+}
Modified: core/trunk/src/main/java/org/jboss/cache/NodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/NodeFactory.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,6 +1,5 @@
package org.jboss.cache;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.mvcc.ReadCommittedNode;
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
Modified: core/trunk/src/main/java/org/jboss/cache/NodeSPI.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/NodeSPI.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/NodeSPI.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -7,7 +7,6 @@
package org.jboss.cache;
import net.jcip.annotations.NotThreadSafe;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/PessimisticUnversionedNode.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -10,7 +10,6 @@
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.IdentityLock;
import org.jboss.cache.lock.LockStrategyFactory;
import org.jboss.cache.marshall.MarshalledValue;
Modified: core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/RPCManagerImpl.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -17,7 +17,6 @@
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
import org.jboss.cache.interceptors.InterceptorChain;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.lock.LockUtil;
Modified: core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/RegionManagerImpl.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -15,7 +15,6 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.LockManager;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.util.concurrent.locks.LockContainer;
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,6 +1,7 @@
package org.jboss.cache.buddyreplication;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.WriteCommand;
@@ -25,7 +26,6 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.ArrayList;
import java.util.List;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/AbstractVisitor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,5 +1,6 @@
package org.jboss.cache.commands;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
@@ -21,7 +22,6 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.Collection;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,6 +1,6 @@
package org.jboss.cache.commands;
-import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.InvocationContext;
/**
* The core of the command-based cache framework. Commands correspond to specific areas of functionality in the cache,
Modified: core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/VisitableCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,6 +1,6 @@
package org.jboss.cache.commands;
-import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.InvocationContext;
/**
* A type of command that can accept {@link org.jboss.cache.commands.Visitor}s, such as {@link org.jboss.cache.interceptors.base.CommandInterceptor}s.
Modified: core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/Visitor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,5 +1,6 @@
package org.jboss.cache.commands;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
@@ -21,7 +22,6 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.invocation.InvocationContext;
/**
* This interface is the core of JBoss Cache, where each {@link VisitableCommand} can be visited by a Visitor implementation.
Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/PessGetChildrenNamesCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/PessGetChildrenNamesCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/read/PessGetChildrenNamesCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,10 +1,10 @@
package org.jboss.cache.commands.legacy.read;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.Collection;
import java.util.Collections;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/CreateNodeCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/CreateNodeCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/CreateNodeCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,12 +1,12 @@
package org.jboss.cache.commands.legacy.write;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.WriteCommand;
import org.jboss.cache.commands.legacy.ReversibleCommand;
import org.jboss.cache.commands.read.AbstractDataCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.LinkedList;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/LegacyEvictCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/LegacyEvictCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/LegacyEvictCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,9 +1,9 @@
package org.jboss.cache.commands.legacy.write;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.write.EvictCommand;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.Collection;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessClearDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessClearDataCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessClearDataCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,10 +1,10 @@
package org.jboss.cache.commands.legacy.write;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.legacy.ReversibleCommand;
import org.jboss.cache.commands.write.ClearDataCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.HashMap;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessMoveCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessMoveCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessMoveCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,11 +1,11 @@
package org.jboss.cache.commands.legacy.write;
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.legacy.ReversibleCommand;
import org.jboss.cache.commands.write.MoveCommand;
-import org.jboss.cache.invocation.InvocationContext;
/**
* A version of {@link org.jboss.cache.commands.write.MoveCommand} which can be rolled back, for use with
Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutDataMapCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutDataMapCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutDataMapCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,10 +1,10 @@
package org.jboss.cache.commands.legacy.write;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.legacy.ReversibleCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.HashMap;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutForExternalReadCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutForExternalReadCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutForExternalReadCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -2,10 +2,10 @@
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.legacy.ReversibleCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutKeyValueCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutKeyValueCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessPutKeyValueCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -2,10 +2,10 @@
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.legacy.ReversibleCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemoveKeyCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemoveKeyCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemoveKeyCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,10 +1,10 @@
package org.jboss.cache.commands.legacy.write;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.legacy.ReversibleCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemoveNodeCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemoveNodeCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/PessRemoveNodeCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,10 +1,10 @@
package org.jboss.cache.commands.legacy.write;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.legacy.ReversibleCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import java.util.HashMap;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/VersionedInvalidateCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/VersionedInvalidateCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/legacy/write/VersionedInvalidateCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -4,11 +4,11 @@
import org.apache.commons.logging.LogFactory;
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.VersionedDataCommand;
import org.jboss.cache.commands.write.InvalidateCommand;
import org.jboss.cache.config.Option;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DataVersioningException;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/ExistsCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,8 +1,8 @@
package org.jboss.cache.commands.read;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
/**
* Checks whether a given node exists in current in-memory state of the cache.
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetChildrenNamesCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -4,9 +4,9 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.mvcc.ReadCommittedNode;
import java.util.Collection;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetDataMapCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,9 +1,9 @@
package org.jboss.cache.commands.read;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.util.Immutables;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeyValueCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -4,9 +4,9 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.Notifier;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetKeysCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,9 +1,9 @@
package org.jboss.cache.commands.read;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
/**
* Implements functionality defined by {@link org.jboss.cache.Cache#getKeys(org.jboss.cache.Fqn)}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GetNodeCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,9 +3,9 @@
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.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
/**
* Implements functionality defined by {@link org.jboss.cache.Cache#getNode(org.jboss.cache.Fqn)}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/read/GravitateDataCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -6,13 +6,13 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.marshall.NodeData;
import org.jgroups.Address;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/AnnounceBuddyPoolNameCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -2,9 +2,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jgroups.Address;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/AssignToBuddyGroupCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,10 +1,10 @@
package org.jboss.cache.commands.remote;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.Arrays;
import java.util.Map;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ClusteredGetCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,13 +3,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.DataCommand;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
import org.jboss.cache.interceptors.InterceptorChain;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.ArrayList;
import java.util.Collections;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/DataGravitationCleanupCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -4,6 +4,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.commands.CommandsFactory;
@@ -11,7 +12,6 @@
import org.jboss.cache.commands.write.EvictCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.interceptors.InterceptorChain;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/RemoveFromBuddyGroupCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,8 +1,8 @@
package org.jboss.cache.commands.remote;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.invocation.InvocationContext;
/**
* Removes a buddy from a group. This is not a {@link org.jboss.cache.commands.VisitableCommand} and hence
Modified: core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -2,12 +2,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.read.GravitateDataCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.interceptors.InterceptorChain;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.ArrayList;
import java.util.List;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactionCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactionCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/AbstractTransactionCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,7 +1,7 @@
package org.jboss.cache.commands.tx;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/CommitCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,7 +1,7 @@
package org.jboss.cache.commands.tx;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,8 +1,8 @@
package org.jboss.cache.commands.tx;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jgroups.Address;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,9 +1,9 @@
package org.jboss.cache.commands.tx;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.WriteCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jgroups.Address;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/RollbackCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,7 +1,7 @@
package org.jboss.cache.commands.tx;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/AbstractVersionedDataCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -2,10 +2,10 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VersionedDataCommand;
import org.jboss.cache.commands.read.AbstractDataCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DataVersioningException;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/ClearDataCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,9 +3,9 @@
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.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/EvictCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -5,10 +5,10 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.read.AbstractDataCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.mvcc.ReadCommittedNode;
import org.jboss.cache.notifications.Notifier;
@@ -62,7 +62,7 @@
/**
* Evicts a node.
* <p/>
- * See {@link org.jboss.cache.interceptors.EvictionInterceptor#visitEvictFqnCommand(org.jboss.cache.invocation.InvocationContext , EvictCommand)}
+ * See {@link org.jboss.cache.interceptors.EvictionInterceptor#visitEvictFqnCommand(org.jboss.cache.InvocationContext , EvictCommand)}
* which is where the return value is used
*
* @return true if the node was removed from the tree or if it is resident. Returns false if the node still exists; i.e. was only data removed because it still has children.
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/InvalidateCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -5,10 +5,10 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.read.AbstractDataCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.Notifier;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/MoveCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -5,11 +5,11 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
import org.jboss.cache.commands.WriteCommand;
import org.jboss.cache.commands.read.AbstractDataCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutDataMapCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,10 +3,10 @@
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.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutForExternalReadCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,8 +1,8 @@
package org.jboss.cache.commands.write;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/PutKeyValueCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,10 +3,10 @@
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.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveKeyCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,9 +3,9 @@
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.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/commands/write/RemoveNodeCommand.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,9 +3,9 @@
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.Visitor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/factories/context/ContextFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/context/ContextFactory.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/factories/context/ContextFactory.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,6 +1,6 @@
package org.jboss.cache.factories.context;
-import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.transaction.TransactionContext;
import javax.transaction.RollbackException;
@@ -8,7 +8,7 @@
import javax.transaction.Transaction;
/**
- * This is the factory responsible for creating {@link org.jboss.cache.invocation.InvocationContext}s and {@link org.jboss.cache.transaction.TransactionContext}s
+ * This is the factory responsible for creating {@link org.jboss.cache.InvocationContext}s and {@link org.jboss.cache.transaction.TransactionContext}s
* for requests, based on the configuration used.
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
Modified: core/trunk/src/main/java/org/jboss/cache/factories/context/MVCCContextFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/context/MVCCContextFactory.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/factories/context/MVCCContextFactory.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,6 +1,6 @@
package org.jboss.cache.factories.context;
-import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.invocation.MVCCInvocationContext;
import org.jboss.cache.transaction.MVCCTransactionContext;
import org.jboss.cache.transaction.TransactionContext;
Modified: core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticContextFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticContextFactory.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/factories/context/PessimisticContextFactory.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,8 +1,8 @@
package org.jboss.cache.factories.context;
import org.jboss.cache.DataContainer;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.LegacyInvocationContext;
import org.jboss.cache.transaction.PessimisticTransactionContext;
import org.jboss.cache.transaction.TransactionContext;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -2,6 +2,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Modification;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
@@ -21,7 +22,6 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,6 +3,7 @@
*/
package org.jboss.cache.interceptors;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.cluster.ReplicationQueue;
@@ -13,7 +14,6 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,9 +1,9 @@
package org.jboss.cache.interceptors;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BatchingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BatchingInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BatchingInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,10 +1,10 @@
package org.jboss.cache.interceptors;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.batch.BatchContainer;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -4,6 +4,7 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
@@ -26,7 +27,6 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.mvcc.MVCCNodeHelper;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheMgmtInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -22,6 +22,7 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.DataContainer;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.commands.read.GetKeyValueCommand;
@@ -31,7 +32,6 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.HashMap;
import java.util.Map;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -2,6 +2,7 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Modification;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.jmx.annotations.ManagedOperation;
@@ -25,7 +26,6 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.SkipCheckChainedInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,5 +1,6 @@
package org.jboss.cache.interceptors;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.WriteCommand;
@@ -17,7 +18,6 @@
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import javax.transaction.Transaction;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/DataGravitatorInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,8 +1,8 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.mvcc.MVCCNodeHelper;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/EvictionInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -9,6 +9,7 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Region;
import org.jboss.cache.RegionManager;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -25,7 +26,6 @@
import static org.jboss.cache.eviction.EvictionEvent.Type.*;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
/**
* Eviction Interceptor.
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/Interceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -22,11 +22,11 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.CacheSPI;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
/**
* Class representing an interceptor.
@@ -62,7 +62,7 @@
/**
* Using this method call for forwarding a call in the chain is not redable and error prone in the case of interceptors
* extending other interceptors. This metod rather refers to interceptor doing its business operations rather than
- * delegating to the nextInterceptor interceptor in chain. For delegation please use {@link #nextInterceptor(org.jboss.cache.invocation.InvocationContext)}
+ * delegating to the nextInterceptor interceptor in chain. For delegation please use {@link #nextInterceptor(org.jboss.cache.InvocationContext)}
*/
public Object invoke(InvocationContext ctx) throws Throwable
{
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InterceptorChain.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,11 +3,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.util.CachePrinter;
@@ -258,7 +258,7 @@
}
/**
- * Similar to {@link #invoke(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}, but
+ * Similar to {@link #invoke(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)}, but
* constructs a invocation context on the fly, using {@link InvocationContextContainer#get()}
*/
public Object invokeRemote(VisitableCommand cacheCommand) throws Throwable
@@ -269,7 +269,7 @@
}
/**
- * Similar to {@link #invoke(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}, but
+ * Similar to {@link #invoke(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)}, but
* constructs a invocation context on the fly, using {@link InvocationContextContainer#get()} and setting the origin local flag to it's default value.
*/
public Object invoke(VisitableCommand cacheCommand) throws Throwable
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -7,6 +7,7 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.commands.AbstractVisitor;
@@ -30,7 +31,6 @@
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.optimistic.TransactionWorkspace;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvocationContextInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -6,6 +6,7 @@
*/
package org.jboss.cache.interceptors;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.read.ExistsCommand;
@@ -21,7 +22,6 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyActivationInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,6 +1,7 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Modification;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.jmx.annotations.ManagedOperation;
@@ -20,7 +21,6 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyCacheLoaderInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,6 +3,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.WriteCommand;
import org.jboss.cache.commands.read.*;
@@ -14,7 +15,6 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.loader.CacheLoader;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitatorInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyDataGravitatorInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -10,6 +10,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
@@ -27,7 +28,6 @@
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.marshall.NodeData;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jgroups.Address;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyPassivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyPassivationInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/LegacyPassivationInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -2,9 +2,9 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.write.EvictCommand;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.List;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MVCCLockingInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,6 +3,7 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.read.ExistsCommand;
@@ -26,7 +27,6 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.PrePostProcessingCommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.mvcc.MVCCNodeHelper;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/MarshalledValueInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,5 +1,6 @@
package org.jboss.cache.interceptors;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
import org.jboss.cache.commands.read.GetDataMapCommand;
@@ -12,7 +13,6 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.marshall.MarshalledValue;
import org.jboss.cache.marshall.MarshalledValueHelper;
import org.jboss.cache.marshall.MarshalledValueMap;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/NotificationInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,10 +1,10 @@
package org.jboss.cache.interceptors;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.Notifier;
/**
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticCreateIfNotExistsInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -10,6 +10,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DataContainer;
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.write.MoveCommand;
@@ -18,7 +19,6 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DefaultDataVersion;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -8,11 +8,11 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.LockManager;
import static org.jboss.cache.lock.LockType.READ;
import org.jboss.cache.lock.TimeoutException;
@@ -76,9 +76,9 @@
}
/**
- * @return the {@link org.jboss.cache.transaction.GlobalTransaction}, extracted from the current {@link org.jboss.cache.invocation.InvocationContext}.
+ * @return the {@link org.jboss.cache.transaction.GlobalTransaction}, extracted from the current {@link org.jboss.cache.InvocationContext}.
* @throws CacheException if the {@link org.jboss.cache.transaction.GlobalTransaction} or {@link javax.transaction.Transaction} associated with the
- * {@link org.jboss.cache.invocation.InvocationContext} is null.
+ * {@link org.jboss.cache.InvocationContext} is null.
*/
protected GlobalTransaction getGlobalTransaction(InvocationContext ctx) throws CacheException
{
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -7,13 +7,13 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.CacheException;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
import static org.jboss.cache.lock.LockType.READ;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.optimistic.TransactionWorkspace;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -10,6 +10,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
@@ -29,7 +30,6 @@
import org.jboss.cache.config.Option;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.Notifier;
import static org.jboss.cache.notifications.event.NodeModifiedEvent.ModificationType.*;
import org.jboss.cache.optimistic.DataVersion;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -8,6 +8,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.ReplicableCommand;
@@ -27,7 +28,6 @@
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.optimistic.TransactionWorkspace;
@@ -45,8 +45,8 @@
* Replication interceptor for the optimistically locked interceptor chain. Responsible for replicating
* state to remote nodes. Unlike it's cousin, the {@link org.jboss.cache.interceptors.ReplicationInterceptor}, this interceptor
* only deals with transactional calls. Just like all things to do with Optimistic Locking, it is a requirement that
- * everything is done in a transaction and the transaction context is available via {@link org.jboss.cache.invocation.InvocationContext#getTransaction()}
- * and {@link org.jboss.cache.invocation.InvocationContext#getGlobalTransaction()}.
+ * everything is done in a transaction and the transaction context is available via {@link org.jboss.cache.InvocationContext#getTransaction()}
+ * and {@link org.jboss.cache.InvocationContext#getGlobalTransaction()}.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
* @author <a href="mailto:stevew@jofti.com">Steve Woodcock (stevew(a)jofti.com)</a>
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,5 +1,6 @@
package org.jboss.cache.interceptors;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.VersionedDataCommand;
import org.jboss.cache.commands.VisitableCommand;
@@ -11,7 +12,6 @@
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Option;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionContext;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticValidatorInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -9,13 +9,13 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
import static org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.optimistic.DataVersioningException;
import org.jboss.cache.optimistic.DefaultDataVersion;
import org.jboss.cache.optimistic.TransactionWorkspace;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PassivationInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,12 +1,12 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.write.EvictCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.JmxStatsCommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.jmx.annotations.ManagedAttribute;
import org.jboss.cache.jmx.annotations.ManagedOperation;
import org.jboss.cache.loader.CacheLoader;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -8,6 +8,7 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.CommandsFactory;
import org.jboss.cache.commands.DataCommand;
@@ -31,7 +32,6 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.PrePostProcessingCommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.IsolationLevel;
import org.jboss.cache.lock.LockManager;
import static org.jboss.cache.lock.LockType.READ;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,5 +1,6 @@
package org.jboss.cache.interceptors;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.WriteCommand;
import org.jboss.cache.commands.tx.CommitCommand;
@@ -13,7 +14,6 @@
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -7,6 +7,7 @@
package org.jboss.cache.interceptors;
import org.jboss.cache.CacheException;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
import org.jboss.cache.ReplicationException;
import org.jboss.cache.jmx.annotations.MBean;
@@ -31,7 +32,6 @@
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.context.ContextFactory;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.notifications.Notifier;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/CommandInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -2,11 +2,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.AbstractVisitor;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.invocation.InvocationContext;
/**
* This is the base class for all interceptors to extend, and implements the {@link org.jboss.cache.commands.Visitor} interface
@@ -17,11 +17,11 @@
* public interface, or by the {@link org.jboss.cache.marshall.CommandAwareRpcDispatcher} for remotely originating invocations, and
* are passed up the interceptor chain by using the {@link org.jboss.cache.interceptors.InterceptorChain} helper class.
* <p/>
- * When writing interceptors, authors can either override a specific visitXXX() method (such as {@link #visitGetKeyValueCommand(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.read.GetKeyValueCommand)})
- * or the more generic {@link #handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)} which is the default behaviour of
- * any visit method, as defined in {@link org.jboss.cache.commands.AbstractVisitor#handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}.
+ * When writing interceptors, authors can either override a specific visitXXX() method (such as {@link #visitGetKeyValueCommand(org.jboss.cache.InvocationContext , org.jboss.cache.commands.read.GetKeyValueCommand)})
+ * or the more generic {@link #handleDefault(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)} which is the default behaviour of
+ * any visit method, as defined in {@link org.jboss.cache.commands.AbstractVisitor#handleDefault(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)}.
* <p/>
- * The preferred approach is to override the specific visitXXX() methods that are of interest rather than to override {@link #handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}
+ * The preferred approach is to override the specific visitXXX() methods that are of interest rather than to override {@link #handleDefault(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)}
* and then write a series of if statements or a switch block, if command-specific behaviour is needed.
* <p/>
*
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/PrePostProcessingCommandInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,5 +1,6 @@
package org.jboss.cache.interceptors.base;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.legacy.write.CreateNodeCommand;
import org.jboss.cache.commands.read.ExistsCommand;
@@ -22,18 +23,17 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.invocation.InvocationContext;
/**
* This interceptor adds pre and post processing to each <tt>visitXXX()</tt> method.
* <p/>
- * For each <tt>visitXXX()</tt> method invoked, it will first call {@link #doBeforeCall(org.jboss.cache.invocation.InvocationContext, org.jboss.cache.commands.VisitableCommand)}
- * and if this method returns true, it will proceed to invoking a <tt>handleXXX()</tt> method and lastly, {@link #doAfterCall(org.jboss.cache.invocation.InvocationContext, org.jboss.cache.commands.VisitableCommand)}
+ * For each <tt>visitXXX()</tt> method invoked, it will first call {@link #doBeforeCall(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}
+ * and if this method returns true, it will proceed to invoking a <tt>handleXXX()</tt> method and lastly, {@link #doAfterCall(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}
* in a <tt>finally</tt> block. Note that the <tt>doAfterCall()</tt> method is still invoked even if <tt>doBeforeCall()</tt> returns <tt>false</tt>.
* <p/>
* Instead of overriding <tt>visitXXX()</tt> methods, implementations should override their <tt>handleXXX()</tt> counterparts defined in this class
- * instead, as well as the {@link #doAfterCall(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method and
- * optionally {@link #doBeforeCall(org.jboss.cache.invocation.InvocationContext, org.jboss.cache.commands.VisitableCommand)}.
+ * instead, as well as the {@link #doAfterCall(org.jboss.cache.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method and
+ * optionally {@link #doBeforeCall(org.jboss.cache.InvocationContext, org.jboss.cache.commands.VisitableCommand)}.
* <p/>
*
* @author Mircea.Markus(a)jboss.com
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/base/SkipCheckChainedInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,5 +1,6 @@
package org.jboss.cache.interceptors.base;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.read.ExistsCommand;
import org.jboss.cache.commands.read.GetChildrenNamesCommand;
@@ -21,18 +22,17 @@
import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.invocation.InvocationContext;
/**
- * This interceptor will call {@link #skipInterception(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} before invoking each visit method
- * (and the {@link #handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)} method). If
- * {@link #skipInterception(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} returns <tt>false</tt>, the invocation will be skipped
+ * This interceptor will call {@link #skipInterception(org.jboss.cache.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} before invoking each visit method
+ * (and the {@link #handleDefault(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)} method). If
+ * {@link #skipInterception(org.jboss.cache.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} returns <tt>false</tt>, the invocation will be skipped
* and passed up the interceptor chain instead.
* <p/>
* Instead of overriding visitXXX() methods, implementations should override their handleXXX() counterparts defined in this class
- * instead, as well as the {@link #skipInterception(org.jboss.cache.invocation.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method.
- * Also, instead of overriding {@link #handleDefault(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}, implementors
- * should override {@link #handleAll(org.jboss.cache.invocation.InvocationContext , org.jboss.cache.commands.VisitableCommand)}.
+ * instead, as well as the {@link #skipInterception(org.jboss.cache.InvocationContext ,org.jboss.cache.commands.VisitableCommand)} method.
+ * Also, instead of overriding {@link #handleDefault(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)}, implementors
+ * should override {@link #handleAll(org.jboss.cache.InvocationContext , org.jboss.cache.commands.VisitableCommand)}.
*
* @author Mircea.Markus(a)jboss.com
* @since 2.2
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationContext.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -14,6 +14,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.config.Option;
import org.jboss.cache.marshall.MethodCall;
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/AbstractInvocationDelegate.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,5 +1,6 @@
package org.jboss.cache.invocation;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.factories.annotations.Inject;
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/CacheInvocationDelegate.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -7,6 +7,7 @@
import org.jboss.cache.CacheStatus;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.RPCManager;
Deleted: core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContext.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContext.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,316 +0,0 @@
-package org.jboss.cache.invocation;
-
-import org.jboss.cache.Fqn;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.VisitableCommand;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.marshall.MethodCall;
-import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionContext;
-
-import javax.transaction.Transaction;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A context that holds information regarding the scope of a single invocation. May delegate some calls to a {@link org.jboss.cache.transaction.TransactionContext}
- * if one is in scope.
- * <p/>
- * Note that prior to 3.0.0, InvocationContext was a concrete class and not an interface.
- * <p/>
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @see org.jboss.cache.transaction.TransactionContext
- */
-@SuppressWarnings("deprecation")
-public interface InvocationContext
-{
- /**
- * Retrieves a node from the registry of looked up nodes in the current scope.
- *
- * @param fqn fqn to look up
- * @return a node, or null if it cannot be found.
- * @since 3.0.
- */
- NodeSPI lookUpNode(Fqn fqn);
-
- /**
- * Puts an entry in the registry of looked up nodes in the current scope.
- *
- * @param f fqn to add
- * @param n node to add
- * @since 3.0.
- */
- void putLookedUpNode(Fqn f, NodeSPI n);
-
- /**
- * Clears the registry of looked up nodes.
- *
- * @since 3.0.
- */
- void clearLookedUpNodes();
-
- /**
- * Retrieves a map of nodes looked up within the current invocation's scope.
- *
- * @return a map of looked up nodes.
- * @since 3.0
- */
- Map<Fqn, NodeSPI> getLookedUpNodes();
-
- /**
- * Marks teh context as only rolling back.
- *
- * @param localRollbackOnly if true, the context is only rolling back.
- */
- void setLocalRollbackOnly(boolean localRollbackOnly);
-
- /**
- * Retrieves the transaction associated with this invocation
- *
- * @return The transaction associated with this invocation
- */
- Transaction getTransaction();
-
- /**
- * Sets a transaction object on the invocation context.
- *
- * @param transaction transaction to set
- */
- void setTransaction(Transaction transaction);
-
- /**
- * @return the transaction entry associated with the current transaction, or null if the current thread is not associated with a transaction.
- * @since 2.2.0
- */
- TransactionContext getTransactionContext();
-
- /**
- * Sets the transaction context to be associated with the current thread.
- *
- * @param transactionContext transaction context to set
- * @since 2.2.0
- */
- void setTransactionContext(TransactionContext transactionContext);
-
- /**
- * Retrieves the global transaction associated with this invocation
- *
- * @return the global transaction associated with this invocation
- */
- GlobalTransaction getGlobalTransaction();
-
- /**
- * Sets the global transaction associated with this invocation
- *
- * @param globalTransaction global transaction to set
- */
- void setGlobalTransaction(GlobalTransaction globalTransaction);
-
- /**
- * Retrieves the option overrides associated with this invocation
- *
- * @return the option overrides associated with this invocation
- */
- Option getOptionOverrides();
-
- /**
- * @return true of no options have been set on this context, false otherwise.
- */
- boolean isOptionsUninitialised();
-
- /**
- * Sets the option overrides to be associated with this invocation
- *
- * @param optionOverrides options to set
- */
- void setOptionOverrides(Option optionOverrides);
-
- /**
- * Tests if this invocation originated locally or from a remote cache.
- *
- * @return true if the invocation originated locally.
- */
- boolean isOriginLocal();
-
- /**
- * Returns an immutable, defensive copy of the List of locks currently maintained for the current scope.
- * <p/>
- * Note that if a transaction is in scope, implementations should retrieve these locks from the {@link org.jboss.cache.transaction.TransactionContext}.
- * Retrieving locks from this method should always ensure they are retrieved from the appropriate scope.
- * <p/>
- * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to return <tt>List<Fqn></tt>.
- *
- * @return locks held in current scope.
- */
- @SuppressWarnings("unchecked")
- List getLocks();
-
- /**
- * Adds a List of locks to the currently maintained collection of locks acquired.
- * <p/>
- * Note that if a transaction is in scope, implementations should record locks on the {@link org.jboss.cache.transaction.TransactionContext}.
- * Adding locks using this method should always ensure they are applied to the appropriate scope.
- * <p/>
- * Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept <tt>List<Fqn></tt>.
- *
- * @param locks locks to add
- */
- @SuppressWarnings("unchecked")
- void addAllLocks(List locks);
-
- /**
- * Adds a lock to the currently maintained collection of locks acquired.
- * <p/>
- * Note that if a transaction is in scope, implementations should record this lock on the {@link org.jboss.cache.transaction.TransactionContext}.
- * Using this method should always ensure that the appropriate scope is used.
- * <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
- *
- * @param lock lock to add
- */
- @SuppressWarnings("unchecked")
- void addLock(Object lock);
-
- /**
- * Removes a lock from the currently maintained collection of locks acquired.
- * <p/>
- * Note that if a transaction is in scope, implementations should remove this lock from the {@link org.jboss.cache.transaction.TransactionContext}.
- * Using this method should always ensure that the lock is removed from the appropriate scope.
- * <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
- *
- * @param lock lock to remove
- */
- @SuppressWarnings("unchecked")
- void removeLock(Object lock);
-
- /**
- * Clears all locks from the currently maintained collection of locks acquired.
- * <p/>
- * Note that if a transaction is in scope, implementations should clear locks from the {@link org.jboss.cache.transaction.TransactionContext}.
- * Using this method should always ensure locks are cleared in the appropriate scope.
- * <p/>
- * Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
- */
- void clearLocks();
-
-
- /**
- * Note that if a transaction is in scope, implementations should test this lock from on {@link org.jboss.cache.transaction.TransactionContext}.
- * Using this method should always ensure locks checked in the appropriate scope.
- *
- * @param lock lock to test
- * @return true if the lock being tested is already held in the current scope, false otherwise.
- */
- boolean hasLock(Object lock);
-
- /**
- * @return true if options exist to suppress locking - false otherwise. Note that this is only used by the {@link org.jboss.cache.interceptors.PessimisticLockInterceptor}.
- */
- boolean isLockingSuppressed();
-
- /**
- * If set to true, the invocation is assumed to have originated locally. If set to false,
- * assumed to have originated from a remote cache.
- *
- * @param originLocal flag to set
- */
- void setOriginLocal(boolean originLocal);
-
- /**
- * @return true if the current transaction is set to rollback only.
- */
- boolean isLocalRollbackOnly();
-
- /**
- * Resets the context, freeing up any references.
- */
- void reset();
-
- /**
- * This is a "copy-factory-method" that should be used whenever a clone of this class is needed. The resulting instance
- * is equal() to, but not ==, to the InvocationContext invoked on. Note that this is a shallow copy with the exception
- * of the Option object, which is deep, as well as any collections held on the context such as locks. Note that the reference
- * to a {@link org.jboss.cache.transaction.TransactionContext}, if any, is maintained.
- *
- * @return a new InvocationContext
- */
- @SuppressWarnings("unchecked")
- InvocationContext copy();
-
- /**
- * Sets the state of the InvocationContext based on the template context passed in
- *
- * @param template template to copy from
- */
- void setState(InvocationContext template);
-
- /**
- * @return the method call associated with this invocation
- */
- @Deprecated
- @SuppressWarnings("deprecation")
- MethodCall getMethodCall();
-
-
- /**
- * Sets the method call associated with this invocation.
- *
- * @param methodCall methodcall to set
- * @deprecated not used anymore. Interceptors will get a {@link org.jboss.cache.commands.ReplicableCommand} instance passed in along with an InvocationContext.
- */
- @Deprecated
- void setMethodCall(MethodCall methodCall);
-
- /**
- * If the lock acquisition timeout is overridden for current call using an option, then return that one.
- * If not overridden, return default value.
- *
- * @param defaultTimeout timeout to fall back to
- * @return timeout to use
- */
- long getLockAcquisitionTimeout(long defaultTimeout);
-
- /**
- * This is only used for backward compatibility with old interceptors implementation and should <b>NOT</b> be
- * use by any new custom interceptors. The commands is now passed in as the second param in each implementing
- * handlers (handler = method in ChainedInterceptor class)
- *
- * @param cacheCommand command to set
- */
- @Deprecated
- @SuppressWarnings("deprecation")
- void setCommand(VisitableCommand cacheCommand);
-
- /**
- * @return command that is in scope
- * @see #setCommand(org.jboss.cache.commands.VisitableCommand)
- */
- @Deprecated
- @SuppressWarnings("deprecation")
- VisitableCommand getCommand();
-
- /**
- * @return true if there is current transaction associated with the invocation, and this transaction is in a valid state.
- */
- boolean isValidTransaction();
-
- /**
- * Throws the given throwable provided no options suppress or prevent this from happening.
- *
- * @param throwable throwable to throw
- * @throws Throwable if allowed to throw one.
- */
- void throwIfNeeded(Throwable throwable) throws Throwable;
-}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/InvocationContextContainer.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,5 +1,6 @@
package org.jboss.cache.invocation;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.context.ContextFactory;
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/LegacyInvocationContext.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -2,6 +2,7 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import java.util.Map;
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/MVCCInvocationContext.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,6 +1,7 @@
package org.jboss.cache.invocation;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.transaction.MVCCTransactionContext;
import org.jboss.cache.transaction.TransactionContext;
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -7,6 +7,7 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeNotValidException;
import org.jboss.cache.NodeSPI;
Modified: core/trunk/src/main/java/org/jboss/cache/lock/AbstractLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/AbstractLockManager.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/lock/AbstractLockManager.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,9 +1,9 @@
package org.jboss.cache.lock;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
/**
* Common lock manager functionality
Modified: core/trunk/src/main/java/org/jboss/cache/lock/FqnLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/FqnLockManager.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/lock/FqnLockManager.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,7 +1,7 @@
package org.jboss.cache.lock;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.Collection;
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockManager.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,8 +1,8 @@
package org.jboss.cache.lock;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.Collection;
@@ -73,9 +73,9 @@
* is specified in {@link org.jboss.cache.config.Option#getLockAcquisitionTimeout()} and, if this is unset, the default timeout
* set in {@link org.jboss.cache.config.Configuration#getLockAcquisitionTimeout()} is used.
* <p/>
- * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.invocation.InvocationContext#addLock(Object)}.
+ * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.InvocationContext#addLock(Object)}.
* <p/>
- * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}.
+ * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.InvocationContext)}.
* <p/>
*
* @param fqn Fqn to lock
@@ -91,9 +91,9 @@
* is specified in {@link org.jboss.cache.config.Option#getLockAcquisitionTimeout()} and, if this is unset, the default timeout
* set in {@link org.jboss.cache.config.Configuration#getLockAcquisitionTimeout()} is used.
* <p/>
- * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.invocation.InvocationContext#addLock(Object)}.
+ * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.InvocationContext#addLock(Object)}.
* <p/>
- * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}.
+ * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.InvocationContext)}.
* <p/>
*
* @param node Fqn to lock
@@ -125,7 +125,7 @@
* <p/>
* Locks are released in reverse order of which they are acquired and registered.
* <p/>
- * Lock owner is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}
+ * Lock owner is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.InvocationContext)}
* <p/>
*
* @param ctx invocation context to inspect
@@ -176,9 +176,9 @@
* Locks the node and all child nodes, acquiring lock of type specified for the owner specified. If only some locks are
* acquired, all locks are released and the method returns false.
* <p/>
- * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.invocation.InvocationContext#addLock(Object)}.
+ * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.InvocationContext#addLock(Object)}.
* <p/>
- * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}.
+ * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.InvocationContext)}.
* <p/>
*
* @param node Node to lock
@@ -192,9 +192,9 @@
* Locks the node and all child nodes, acquiring lock of type specified for the owner specified. If only some locks are
* acquired, all locks are released and the method returns false.
* <p/>
- * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.invocation.InvocationContext#addLock(Object)}.
+ * In addition, any locks acquired are added to the context OR transaction entry using {@link org.jboss.cache.InvocationContext#addLock(Object)}.
* <p/>
- * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.invocation.InvocationContext)}.
+ * The owner for the lock is determined by passing the invocation context to {@link #getLockOwner(org.jboss.cache.InvocationContext)}.
* <p/>
*
* @param fqn Node to lock
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,10 +3,10 @@
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.CommandsFactory;
import org.jboss.cache.commands.write.PutDataMapCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
Modified: core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/lock/MVCCLockManager.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -6,11 +6,11 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import static org.jboss.cache.lock.LockType.READ;
import org.jboss.cache.util.concurrent.locks.LockContainer;
Modified: core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -4,10 +4,10 @@
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.ArrayList;
import java.util.Collection;
Modified: core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,10 +3,10 @@
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.CommandsFactory;
import org.jboss.cache.factories.annotations.Inject;
-import org.jboss.cache.invocation.InvocationContext;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionTable;
Modified: core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/marshall/CommandAwareRpcDispatcher.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,5 +1,6 @@
package org.jboss.cache.marshall;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.remote.AnnounceBuddyPoolNameCommand;
@@ -7,7 +8,6 @@
import org.jboss.cache.commands.remote.RemoveFromBuddyGroupCommand;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.interceptors.InterceptorChain;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jgroups.Address;
import org.jgroups.Channel;
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeFactory.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -5,10 +5,10 @@
import org.jboss.cache.AbstractNodeFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.UnversionedNode;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.IsolationLevel;
import java.util.Map;
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/MVCCNodeHelper.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -6,6 +6,7 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
@@ -13,7 +14,6 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.LockManager;
import static org.jboss.cache.lock.LockType.WRITE;
import org.jboss.cache.lock.TimeoutException;
@@ -87,7 +87,7 @@
}
/**
- * Similar to {@link #wrapNodesForReading(org.jboss.cache.invocation.InvocationContext, java.util.Collection)} except
+ * Similar to {@link #wrapNodesForReading(org.jboss.cache.InvocationContext, java.util.Collection)} except
* that this version takes a single Fqn parameter to wrap a single node.
*
* @param ctx current invocation context
@@ -243,7 +243,7 @@
}
/**
- * The same as {@link #wrapNodeForWriting(org.jboss.cache.invocation.InvocationContext, org.jboss.cache.Fqn, boolean, boolean, boolean, boolean, boolean)}
+ * The same as {@link #wrapNodeForWriting(org.jboss.cache.InvocationContext, org.jboss.cache.Fqn, boolean, boolean, boolean, boolean, boolean)}
* except that it takes in an {@link org.jboss.cache.InternalNode} instead of a {@link Fqn}. Saves on a lookup.
* <p/>
* Also assumes that the node exists, and hence will not be created.
@@ -371,7 +371,7 @@
}
/**
- * Identical to {@link #lockForWritingRecursive(org.jboss.cache.Fqn, org.jboss.cache.invocation.InvocationContext, java.util.List)}
+ * Identical to {@link #lockForWritingRecursive(org.jboss.cache.Fqn, org.jboss.cache.InvocationContext, java.util.List)}
* except that it uses an {@link org.jboss.cache.InternalNode} instead of an {@link Fqn} - saves a lookup.
*
* @param node node to lock recursively
@@ -425,7 +425,7 @@
}
/**
- * An overloaded version of {@link #isParentLockNeeded(org.jboss.cache.Fqn, org.jboss.cache.invocation.InvocationContext)}
+ * An overloaded version of {@link #isParentLockNeeded(org.jboss.cache.Fqn, org.jboss.cache.InvocationContext)}
* which takes in an {@link org.jboss.cache.InternalNode} instead of a {@link Fqn}.
*
* @param parent parent node to test
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/ReadCommittedNode.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -5,9 +5,9 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.NodeInvocationDelegate;
import static org.jboss.cache.mvcc.ReadCommittedNode.Flags.*;
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/RepeatableReadNode.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -5,7 +5,8 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
-import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.InvocationContext;
+
import static org.jboss.cache.mvcc.ReadCommittedNode.Flags.CHANGED;
import static org.jboss.cache.mvcc.ReadCommittedNode.Flags.DELETED;
import org.jboss.cache.optimistic.DataVersioningException;
Modified: core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/Notifier.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,8 +1,8 @@
package org.jboss.cache.notifications;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyGroup;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
import org.jgroups.View;
Modified: core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/notifications/NotifierImpl.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -49,6 +49,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Destroy;
@@ -56,7 +57,6 @@
import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.factories.annotations.Stop;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.marshall.MarshalledValueMap;
import org.jboss.cache.notifications.annotation.BuddyGroupChanged;
import org.jboss.cache.notifications.annotation.CacheBlocked;
@@ -673,7 +673,7 @@
/**
* Resets the current (passed-in) invocation, and returns a temp InvocationContext containing its state so it can
- * be restored later using {@link #restoreInvocationContext(org.jboss.cache.invocation.InvocationContext)}
+ * be restored later using {@link #restoreInvocationContext(org.jboss.cache.InvocationContext)}
*
* @param ctx the current context to be reset
* @return a clone of ctx, before it was reset
Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/DefaultStateTransferIntegrator.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -12,13 +12,13 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.NodeData;
Modified: core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/statetransfer/LegacyStateTransferIntegrator.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -11,6 +11,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeFactory;
import org.jboss.cache.NodeSPI;
@@ -20,7 +21,6 @@
import org.jboss.cache.eviction.EvictionEvent;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.marshall.NodeData;
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/MVCCTransactionContext.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -27,7 +27,7 @@
/**
* Retrieves a node from the registry of looked up nodes in the current scope.
* <p/>
- * This is not normally called directly since {@link org.jboss.cache.invocation.InvocationContext#lookUpNode(org.jboss.cache.Fqn)}
+ * This is not normally called directly since {@link org.jboss.cache.InvocationContext#lookUpNode(org.jboss.cache.Fqn)}
* would delegate to this method if a transaction is in scope.
* <p/>
*
@@ -42,7 +42,7 @@
/**
* Puts an entry in the registry of looked up nodes in the current scope.
* <p/>
- * This is not normally called directly since {@link org.jboss.cache.invocation.InvocationContext#putLookedUpNode(org.jboss.cache.Fqn, org.jboss.cache.NodeSPI)}
+ * This is not normally called directly since {@link org.jboss.cache.InvocationContext#putLookedUpNode(org.jboss.cache.Fqn, org.jboss.cache.NodeSPI)}
* would delegate to this method if a transaction is in scope.
* <p/>
*
@@ -57,7 +57,7 @@
/**
* Clears the registry of looked up nodes.
* <p/>
- * This is not normally called directly since {@link org.jboss.cache.invocation.InvocationContext#clearLookedUpNodes()}
+ * This is not normally called directly since {@link org.jboss.cache.InvocationContext#clearLookedUpNodes()}
* would delegate to this method if a transaction is in scope.
* <p/>
*/
@@ -69,7 +69,7 @@
/**
* Retrieves a map of nodes looked up within the current invocation's scope.
* <p/>
- * This is not normally called directly since {@link org.jboss.cache.invocation.InvocationContext#getLookedUpNodes()}
+ * This is not normally called directly since {@link org.jboss.cache.InvocationContext#getLookedUpNodes()}
* would delegate to this method if a transaction is in scope.
* <p/>
*
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -15,7 +15,7 @@
* <p/>
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @see org.jboss.cache.invocation.InvocationContext
+ * @see org.jboss.cache.InvocationContext
*/
public interface TransactionContext
{
@@ -80,7 +80,7 @@
/**
* Adds a lock to the currently maintained collection of locks acquired.
* <p/>
- * Most code could not use this method directly, but use {@link org.jboss.cache.invocation.InvocationContext#addLock(Object)} instead,
+ * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#addLock(Object)} instead,
* which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
* <p/>
* Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link org.jboss.cache.Fqn}s as locks)
@@ -88,7 +88,7 @@
* legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link org.jboss.cache.Fqn}.
*
* @param lock lock to add
- * @see org.jboss.cache.invocation.InvocationContext#addLock(Object)
+ * @see org.jboss.cache.InvocationContext#addLock(Object)
*/
@SuppressWarnings("unchecked")
void addLock(Object lock);
@@ -96,7 +96,7 @@
/**
* Removes a lock from the currently maintained collection of locks acquired.
* <p/>
- * Most code could not use this method directly, but use {@link org.jboss.cache.invocation.InvocationContext#removeLock(Object)} instead,
+ * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#removeLock(Object)} instead,
* which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
* <p/>
* Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link org.jboss.cache.Fqn}s as locks)
@@ -104,7 +104,7 @@
* legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link org.jboss.cache.Fqn}.
*
* @param lock lock to remove
- * @see org.jboss.cache.invocation.InvocationContext#removeLock(Object)
+ * @see org.jboss.cache.InvocationContext#removeLock(Object)
*/
@SuppressWarnings("unchecked")
void removeLock(Object lock);
@@ -112,21 +112,21 @@
/**
* Clears all locks from the currently maintained collection of locks acquired.
* <p/>
- * Most code could not use this method directly, but use {@link org.jboss.cache.invocation.InvocationContext#clearLocks()} instead,
+ * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#clearLocks()} instead,
* which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
* <p/>
* Note that currently (as of 3.0.0) this lock is weakly typed. This is to allow support for both MVCC (which uses {@link org.jboss.cache.Fqn}s as locks)
* as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link org.jboss.cache.lock.NodeLock} as locks). Once support for
* legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link org.jboss.cache.Fqn}.
*
- * @see org.jboss.cache.invocation.InvocationContext#clearLocks()
+ * @see org.jboss.cache.InvocationContext#clearLocks()
*/
void clearLocks();
/**
* Adds a List of locks to the currently maintained collection of locks acquired.
* <p/>
- * Most code could not use this method directly, but use {@link org.jboss.cache.invocation.InvocationContext#addAllLocks(java.util.List)} instead,
+ * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#addAllLocks(java.util.List)} instead,
* which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
* <p/>
* Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
@@ -134,7 +134,7 @@
* legacy node locking schemes are dropped, this method will be more strongly typed to accept <tt>List<Fqn></tt>.
*
* @param newLocks locks to add
- * @see org.jboss.cache.invocation.InvocationContext#addAllLocks(java.util.List)
+ * @see org.jboss.cache.InvocationContext#addAllLocks(java.util.List)
*/
@SuppressWarnings("unchecked")
void addAllLocks(List newLocks);
@@ -142,7 +142,7 @@
/**
* Returns an immutable, defensive copy of the List of locks currently maintained for the transaction.
* <p/>
- * Most code could not use this method directly, but use {@link org.jboss.cache.invocation.InvocationContext#getLocks()} instead,
+ * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#getLocks()} instead,
* which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
* <p/>
* Note that currently (as of 3.0.0) this list is unchecked. This is to allow support for both MVCC (which uses Fqns as locks)
@@ -150,13 +150,13 @@
* legacy node locking schemes are dropped, this method will be more strongly typed to return <tt>List<Fqn></tt>.
*
* @return locks held in current scope.
- * @see org.jboss.cache.invocation.InvocationContext#getLocks()
+ * @see org.jboss.cache.InvocationContext#getLocks()
*/
@SuppressWarnings("unchecked")
List getLocks();
/**
- * Most code could not use this method directly, but use {@link org.jboss.cache.invocation.InvocationContext#hasLock(Object)} ()} instead,
+ * Most code could not use this method directly, but use {@link org.jboss.cache.InvocationContext#hasLock(Object)} ()} instead,
* which would delegate to this method if a transaction is in scope or otherwise use invocation-specific locks.
*
* @param lock lock to test
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -9,11 +9,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.CacheException;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.NonVolatile;
import org.jboss.cache.factories.context.ContextFactory;
-import org.jboss.cache.invocation.InvocationContext;
import org.jgroups.Address;
import javax.transaction.Status;
Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -11,12 +11,12 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -11,12 +11,12 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.config.Configuration.NodeLockingScheme;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/TestContextBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/TestContextBase.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/commands/TestContextBase.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,7 +1,7 @@
package org.jboss.cache.commands;
import org.jboss.cache.DataContainer;
-import org.jboss.cache.invocation.InvocationContext;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.invocation.LegacyInvocationContext;
import org.jboss.cache.invocation.MVCCInvocationContext;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateDataCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateDataCommandTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/read/GravitateDataCommandTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -6,11 +6,11 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.buddyreplication.BuddyFqnTransformer;
import org.jboss.cache.buddyreplication.BuddyManager;
import org.jboss.cache.buddyreplication.GravitateResult;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.LegacyInvocationContext;
import org.jboss.cache.mock.MockNodesFixture;
import org.jboss.cache.mock.NodeSpiMock;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutDataMapCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutDataMapCommandTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/commands/legacy/write/PutDataMapCommandTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -5,8 +5,8 @@
import org.easymock.IMocksControl;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.TestContextBase;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.mock.NodeSpiMock;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.notifications.event.NodeModifiedEvent;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataCommandTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/AbstractDataCommandTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,8 +3,8 @@
import static org.easymock.EasyMock.createMock;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.TestContextBase;
-import org.jboss.cache.invocation.InvocationContext;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeyValueCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeyValueCommandTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/commands/read/GetKeyValueCommandTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -5,8 +5,8 @@
import org.easymock.IMocksControl;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.TestContextBase;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.mock.NodeSpiMock;
import org.jboss.cache.notifications.Notifier;
import org.testng.annotations.BeforeMethod;
Modified: core/trunk/src/test/java/org/jboss/cache/commands/write/AbstractVersionedDataCommandTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/commands/write/AbstractVersionedDataCommandTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/commands/write/AbstractVersionedDataCommandTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -4,8 +4,8 @@
import org.easymock.IMocksControl;
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.TestContextBase;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.mock.MockNodesFixture;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.optimistic.DataVersion;
Modified: core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/interceptors/LegacyInterceptorTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -4,8 +4,8 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
Modified: core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,10 +1,10 @@
package org.jboss.cache.lock;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.UnversionedNode;
import org.jboss.cache.factories.context.ContextFactory;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.InvocationContextContainer;
import org.jboss.cache.invocation.NodeInvocationDelegate;
import static org.jboss.cache.lock.LockType.WRITE;
Modified: core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/marshall/MarshalledValueTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,6 +3,7 @@
import org.jboss.cache.CacheException;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
@@ -13,7 +14,6 @@
import org.jboss.cache.interceptors.MarshalledValueInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.invocation.CacheInvocationDelegate;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.DummyInMemoryCacheLoader;
import org.jboss.cache.notifications.annotation.CacheListener;
import org.jboss.cache.notifications.annotation.NodeModified;
Modified: core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/mock/NodeSpiMock.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -4,9 +4,9 @@
import org.jboss.cache.DataContainer;
import org.jboss.cache.Fqn;
import org.jboss.cache.InternalNode;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/NotifierTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -3,9 +3,9 @@
import static org.easymock.EasyMock.createNiceMock;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.buddyreplication.BuddyGroup;
import org.jboss.cache.config.Configuration;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.invocation.LegacyInvocationContext;
import org.jboss.cache.notifications.annotation.*;
import org.jboss.cache.notifications.event.*;
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ConcurrentTransactionTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -8,13 +8,13 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
import org.jboss.cache.interceptors.TxInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/MockFailureInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,9 +1,9 @@
package org.jboss.cache.optimistic;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.ArrayList;
import java.util.List;
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/MockInterceptor.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -1,9 +1,9 @@
package org.jboss.cache.optimistic;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import java.util.ArrayList;
import java.util.List;
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticLockInterceptorTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -2,11 +2,11 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.interceptors.OptimisticInterceptor;
import org.jboss.cache.interceptors.OptimisticLockingInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.lock.LockType;
import static org.jboss.cache.lock.LockType.READ;
import static org.jboss.cache.lock.LockType.WRITE;
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -8,6 +8,7 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.commands.VisitableCommand;
import org.jboss.cache.commands.tx.CommitCommand;
@@ -18,7 +19,6 @@
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.OptimisticValidatorInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.OptimisticTransactionContext;
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -9,12 +9,12 @@
import org.jboss.cache.Cache;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.Node;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
import org.jboss.cache.invocation.CacheInvocationDelegate;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
Modified: core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java 2008-08-25 22:08:47 UTC (rev 6613)
+++ core/trunk/src/test/java/org/jboss/cache/util/internals/ReplicationListener.java 2008-08-25 23:17:22 UTC (rev 6614)
@@ -2,12 +2,12 @@
import org.jboss.cache.Cache;
import org.jboss.cache.Fqn;
+import org.jboss.cache.InvocationContext;
import org.jboss.cache.RPCManager;
import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.remote.ReplicateCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.factories.ComponentRegistry;
-import org.jboss.cache.invocation.InvocationContext;
import org.jboss.cache.io.ByteBuffer;
import org.jboss.cache.marshall.AbstractMarshaller;
import org.jboss.cache.marshall.CommandAwareRpcDispatcher;
16 years, 6 months
JBoss Cache SVN: r6613 - core/trunk/src/main/java/org/jboss/cache/jmx.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2008-08-25 18:08:47 -0400 (Mon, 25 Aug 2008)
New Revision: 6613
Added:
core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java
Log:
Resurect JmxUtil for API compatibility
Copied: core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java (from rev 6545, core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/JmxUtil.java 2008-08-25 22:08:47 UTC (rev 6613)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache.jmx;
+
+import org.jboss.cache.config.Configuration;
+
+import javax.management.JMException;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+/**
+ * Various JMX related utilities
+ *
+ * @author Jerry Gauthier
+ * @author Manik Surtani
+ * @version $Id$
+ */
+@Deprecated
+public class JmxUtil
+{
+ public static final String JBOSS_SERVER_DOMAIN = "jboss";
+ public static final String JBOSS_CACHE_DOMAIN = "jboss.cache";
+ public static final String SERVICE_KEY_NAME = "service";
+ public static final String BASE_PREFIX = JBOSS_CACHE_DOMAIN + ":" + SERVICE_KEY_NAME + "=JBossCache";
+ public static final String CLUSTER_KEY = "cluster";
+ public static final String PREFIX = BASE_PREFIX + "," + CLUSTER_KEY + "=";
+ public static final String UNIQUE_ID_KEY = "uniqueId";
+ public static final String NO_CLUSTER_PREFIX = BASE_PREFIX + "," + UNIQUE_ID_KEY + "=";
+ public static final String CACHE_TYPE_KEY = "cacheType";
+ public static final String PLAIN_CACHE_TYPE = "Cache";
+ public static final String MBEAN_CLASS_SUFFIX = "MBean";
+ public static final String JMX_RESOURCE_KEY = ",jmx-resource=";
+
+ public static void registerCacheMBean(MBeanServer server, CacheJmxWrapperMBean cache, String cacheObjectName)
+ throws JMException
+ {
+ ObjectName on = new ObjectName(cacheObjectName);
+ if (!server.isRegistered(on))
+ {
+ server.registerMBean(cache, on);
+ }
+ }
+
+ public static String getDefaultCacheObjectName(org.jboss.cache.Cache cache)
+ {
+ // get the cache's registration name
+ return getDefaultCacheObjectName(cache.getConfiguration(), cache.getClass().getName());
+ }
+
+ public static String getDefaultCacheObjectName(Configuration config, String cacheImplClass)
+ {
+ // get the cache's registration name
+ String tmpName;
+ if (config.getClusterName() == null)
+ {
+ tmpName = NO_CLUSTER_PREFIX + getUniqueId(cacheImplClass);
+ }
+ else
+ {
+ tmpName = PREFIX + config.getClusterName();
+ }
+ return tmpName;
+ }
+
+ public static String getUniqueId(String cacheImplClass)
+ {
+ return cacheImplClass + System.currentTimeMillis();
+ }
+
+ public static void unregisterCacheMBean(MBeanServer server, String cacheObjectName)
+ throws Exception
+ {
+ server.unregisterMBean(new ObjectName(cacheObjectName));
+ }
+}
16 years, 6 months
JBoss Cache SVN: r6612 - core/trunk/src/main/java/org/jboss/cache.
by jbosscache-commits@lists.jboss.org
Author: jason.greene(a)jboss.com
Date: 2008-08-25 16:09:54 -0400 (Mon, 25 Aug 2008)
New Revision: 6612
Modified:
core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
Log:
This was called getInstance()
Modified: core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-08-25 17:50:21 UTC (rev 6611)
+++ core/trunk/src/main/java/org/jboss/cache/DefaultCacheFactory.java 2008-08-25 20:09:54 UTC (rev 6612)
@@ -42,7 +42,7 @@
@SuppressWarnings("unchecked")
@Deprecated
@Compat
- public static DefaultCacheFactory newInstance()
+ public static DefaultCacheFactory getInstance()
{
return new DefaultCacheFactory();
}
16 years, 6 months
JBoss Cache SVN: r6611 - in core/trunk/src: main/java/org/jboss/cache/jmx and 8 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2008-08-25 13:50:21 -0400 (Mon, 25 Aug 2008)
New Revision: 6611
Added:
core/trunk/src/test/java/org/jboss/cache/multiplexer/PessimisticSyncReplTxTest.java
core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSilentlyTest.java
core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcquisitionTimeoutTest.java
core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppressLockingTest.java
core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSyncReplTxTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AbortionTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/IsolationLevelNoneTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PessimisticTransactionTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PrepareTxTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/StatusUnknownTest.java
Removed:
core/trunk/src/test/java/org/jboss/cache/multiplexer/SyncReplTxTest.java
core/trunk/src/test/java/org/jboss/cache/options/FailSilentlyTest.java
core/trunk/src/test/java/org/jboss/cache/options/LockAcquisitionTimeoutTest.java
core/trunk/src/test/java/org/jboss/cache/options/SuppressLockingTest.java
core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/AsyncRollbackTxTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTransactionalTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelNoneTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/PrepareTxTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/StatusUnknownTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java
core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionManager.java
core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/IsolationLevelTestBase.java
Log:
fixed tests after changing default node locking scheme to MVCC
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -176,6 +176,7 @@
*/
private void removeNodeFromCacheLoader(Fqn fqn) throws Throwable
{
+ if (fqn == null) return;
InternalNode n;
if (((n = dataContainer.peekInternalNode(fqn, true)) != null) && n.isDataLoaded() && loader.exists(fqn))
{
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -91,8 +91,8 @@
int i = 0;
if (log.isInfoEnabled())
{
- log.info("Processing class " + instance.getClass());
- log.info("Number of attributes: " + atts.size());
+ log.trace("Processing class " + instance.getClass());
+ log.trace("Number of attributes: " + atts.size());
}
MBeanAttributeInfo info;
for (AttributeEntry entry : atts.values())
@@ -101,7 +101,7 @@
attrInfo[i++] = info;
if (log.isInfoEnabled())
{
- log.info("Attribute " + info.getName()
+ log.trace("Attribute " + info.getName()
+ "[r="
+ info.isReadable()
+ ",w="
@@ -120,10 +120,10 @@
if (log.isInfoEnabled())
{
if (ops.size() > 0)
- log.info("Operations are:");
+ log.trace("Operations are:");
for (MBeanOperationInfo op : opInfo)
{
- log.info("Operation " + op.getReturnType() + " " + op.getName());
+ log.trace("Operation " + op.getReturnType() + " " + op.getName());
}
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransaction.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -24,7 +24,7 @@
{
private int status = Status.STATUS_UNKNOWN;
private static final Log log = LogFactory.getLog(DummyTransaction.class);
- DummyBaseTransactionManager tm_;
+ protected DummyBaseTransactionManager tm_;
protected final Set<Synchronization> participants = new CopyOnWriteArraySet<Synchronization>();
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionManager.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/DummyTransactionManager.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -19,10 +19,10 @@
*/
public class DummyTransactionManager extends DummyBaseTransactionManager
{
- static DummyTransactionManager instance = null;
- static DummyUserTransaction utx = null;
+ protected static DummyTransactionManager instance = null;
+ protected static DummyUserTransaction utx = null;
- static Log log = LogFactory.getLog(DummyTransactionManager.class);
+ protected static Log log = LogFactory.getLog(DummyTransactionManager.class);
private static final long serialVersionUID = 4396695354693176535L;
Copied: core/trunk/src/test/java/org/jboss/cache/multiplexer/PessimisticSyncReplTxTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/multiplexer/SyncReplTxTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/PessimisticSyncReplTxTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/PessimisticSyncReplTxTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache.multiplexer;
+
+import org.jboss.cache.Cache;
+import org.testng.AssertJUnit;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Repeats the superclass tests, but with the multiplexer enabled.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @version $Revision$
+ */
+@Test(groups = {"functional", "jgroups"}, enabled = true)
+public class PessimisticSyncReplTxTest extends org.jboss.cache.replicated.PessimisticSyncReplTxTest
+{
+ private MultiplexerTestHelper muxHelper;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ muxHelper = new MultiplexerTestHelper();
+
+ super.setUp();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ try
+ {
+ super.tearDown();
+ }
+ finally
+ {
+ if (muxHelper != null)
+ {
+ muxHelper.tearDown();
+ muxHelper = null;
+ }
+ }
+ }
+
+ @Override
+ protected void configureMultiplexer(Cache cache) throws Exception
+ {
+ muxHelper.configureCacheForMux(cache);
+ }
+
+ @Override
+ protected void validateMultiplexer(Cache cache)
+ {
+ AssertJUnit.assertTrue("Cache is using multiplexer", cache.getConfiguration().isUsingMultiplexer());
+ }
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/multiplexer/PessimisticSyncReplTxTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: core/trunk/src/test/java/org/jboss/cache/multiplexer/SyncReplTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/multiplexer/SyncReplTxTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/multiplexer/SyncReplTxTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.cache.multiplexer;
-
-import org.jboss.cache.Cache;
-import org.testng.AssertJUnit;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-/**
- * Repeats the superclass tests, but with the multiplexer enabled.
- *
- * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-@Test(groups = {"functional", "jgroups"}, enabled = true)
-public class SyncReplTxTest extends org.jboss.cache.replicated.SyncReplTxTest
-{
- private MultiplexerTestHelper muxHelper;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
- muxHelper = new MultiplexerTestHelper();
-
- super.setUp();
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
- {
- try
- {
- super.tearDown();
- }
- finally
- {
- if (muxHelper != null)
- {
- muxHelper.tearDown();
- muxHelper = null;
- }
- }
- }
-
- @Override
- protected void configureMultiplexer(Cache cache) throws Exception
- {
- muxHelper.configureCacheForMux(cache);
- }
-
- @Override
- protected void validateMultiplexer(Cache cache)
- {
- AssertJUnit.assertTrue("Cache is using multiplexer", cache.getConfiguration().isUsingMultiplexer());
- }
-}
Modified: core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/notifications/RemoteCacheListenerTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -615,6 +615,7 @@
expected.add(new EventImpl(false, cache1, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
expected.add(new EventImpl(true, cache1, null, null, fqn, tx, true, newFqn, false, null, NODE_MOVED));
expected.add(new EventImpl(false, cache1, null, null, fqn, tx, true, newFqn, false, null, NODE_MOVED));
+ assertEquals(expected.size(), eventLog1.events.size());
assertEquals(expected, eventLog1.events);
assertEquals("Events log should be empty until commit time", 0, eventLog2.events.size());
tm1.commit();
Deleted: core/trunk/src/test/java/org/jboss/cache/options/FailSilentlyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/FailSilentlyTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/options/FailSilentlyTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -1,167 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.options;
-
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import static org.testng.AssertJUnit.assertEquals;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Tests passing in the failSilently option in various scenarios.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- */
-@Test(groups = {"functional"})
-public class FailSilentlyTest
-{
- private CacheSPI cache;
- private TransactionManager manager;
- private Transaction tx;
- private Fqn fqn = Fqn.fromString("/a");
- private String key = "key";
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
- if (cache != null)
- tearDown();
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache = (CacheSPI) instance.createCache(false);
- // very short acquisition timeout
- cache.getConfiguration().setLockAcquisitionTimeout(100);
- cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
- cache.start();
- manager = cache.getTransactionManager();
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown()
- {
- if (tx != null)
- {
- try
- {
- manager.resume(tx);
- manager.rollback();
- }
- catch (Exception e)
- {
- // who cares
- }
- }
- if (cache != null)
- {
- cache.stop();
- cache = null;
- }
- }
-
- public void testPutKeyValue() throws Exception
- {
- manager.begin();
- cache.put(fqn, key, "value");
- tx = manager.suspend();
- cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
- cache.put(fqn, key, "value2");
- }
-
- public void testPutData() throws Exception
- {
- Map<String, String> data = new HashMap<String, String>();
- data.put(key, "value");
- manager.begin();
- cache.put(fqn, data);
- tx = manager.suspend();
- cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
- cache.put(fqn, data);
- }
-
- public void testRemoveNode() throws Exception
- {
- cache.put(fqn, key, "value");
- manager.begin();
- // get a read lock
- cache.get(fqn, key);
- tx = manager.suspend();
- cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
- cache.removeNode(fqn);
- }
-
- public void testRemoveKey() throws Exception
- {
- cache.put(fqn, key, "value");
- manager.begin();
- // get a read lock
- cache.get(fqn, key);
- tx = manager.suspend();
- cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
- cache.remove(fqn, key);
- }
-
- public void testGetNode() throws Exception
- {
- cache.put(fqn, key, "value");
- manager.begin();
- // get a WL
- cache.put(fqn, key, "value2");
- tx = manager.suspend();
- cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
- cache.getNode(fqn);
- }
-
- public void testGetKey() throws Exception
- {
- cache.put(fqn, key, "value");
- manager.begin();
- // get a WL
- cache.put(fqn, key, "value2");
- tx = manager.suspend();
- cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
- cache.get(fqn, key);
- }
-
- public void testGetChildrenNames() throws Exception
- {
- cache.put(fqn, key, "value");
- manager.begin();
- // get a WL
- cache.put(fqn, key, "value2");
- tx = manager.suspend();
- cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
- cache.getChildrenNames(fqn);
-
- }
-
- public void testPutThatWillFail() throws Exception
- {
- manager.begin();
- cache.put(fqn, "k", "v");// this will get WLs on / and /a
- tx = manager.suspend();
-
- assertEquals(2, cache.getNumberOfLocksHeld());
-
- // now this call WILL fail, but should fail silently - i.e., not roll back.
- manager.begin();
- cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
- cache.put(fqn, "x", "y");
-
- // should not roll back, despite the cache put call failing/timing out.
- manager.commit();
- }
-}
Deleted: core/trunk/src/test/java/org/jboss/cache/options/LockAcquisitionTimeoutTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/LockAcquisitionTimeoutTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/options/LockAcquisitionTimeoutTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -1,359 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.options;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.lock.TimeoutException;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.transaction.TransactionManager;
-
-/**
- * Test functionality of {@link Option#setLockAcquisitionTimeout(int)}.
- *
- * @author Brian Stansberry
- */
-@Test(groups = {"functional"})
-public class LockAcquisitionTimeoutTest
-{
- private static final Log log = LogFactory.getLog(LockAcquisitionTimeoutTest.class);
-
- private static final Fqn FQNA = Fqn.fromString("/A");
- private static final Fqn FQNB = Fqn.fromString("/B");
- private static final String KEY = "key";
- private static final String VALUE1 = "value1";
- private static final String VALUE2 = "value2";
-
- private CacheSPI<Object, Object> cache;
- private Option option;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
- cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- Configuration c = cache.getConfiguration();
- c.setCacheMode("REPL_SYNC");
- c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
-
- cache.start();
-
- option = new Option();
- option.setLockAcquisitionTimeout(0);
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown()
- {
- if (cache != null)
- {
- cache.stop();
- cache = null;
- }
- }
-
- /**
- * Confirms that doing a put with a lockAcquisitionTime option set
- * does the put as expected. There is no other thread or tx contesting
- * the lock the put needs, so this is just a simple test that the option
- * doesn't somehow screw up the put.
- *
- * @throws Exception
- */
- public void testSimplePut() throws Exception
- {
- log.info("++++ testSimplePut() ++++");
- simplePutTest(false);
- }
-
- /**
- * Confirms that doing a put with a lockAcquisitionTime option set
- * does the put as expected when executed within a transaction. There is no
- * other thread or tx contesting the lock the put needs, so this is just a
- * simple test that the option doesn't somehow screw up the put.
- *
- * @throws Exception
- */
- public void testSimplePutWithTx() throws Exception
- {
- log.info("++++ testSimplePutWithTx() ++++");
- simplePutTest(true);
- }
-
- private void simplePutTest(boolean useTx) throws Exception
- {
- TransactionManager tm = useTx ? cache.getTransactionManager() : null;
- LowTimeoutSetter setter = new LowTimeoutSetter(tm);
- setter.start();
-
- setter.join(2000);
- if (!setter.finished)
- {
- setter.interrupt();
- fail("Puts failed to complete in a timely manner");
- }
-
- assertNull("LowTimeoutSetter saw no TimeoutException", setter.te);
- assertNull("LowTimeoutSetter saw no misc Exception", setter.failure);
- assertEquals("Cache correct for " + FQNA, VALUE2, cache.get(FQNA, KEY));
- assertEquals("Cache correct for " + FQNB, VALUE2, cache.get(FQNB, KEY));
- }
-
- /**
- * Confirms that a put with a lockAcquisitionTimeout option set to zero
- * fails promptly in the presence of a lock on the target node.
- *
- * @throws Exception
- */
- public void testContestedPut() throws Exception
- {
- log.info("++++ testContestedPut() ++++");
- contestedPutTest(false);
- }
-
- /**
- * Confirms that a put with a lockAcquisitionTimeout option set to zero
- * is ignored if executed within a transaction.
- *
- * @throws Exception
- */
- public void testContestedPutWithTx() throws Exception
- {
- log.info("++++ testContestedPutWithTx() ++++");
- contestedPutTest(true);
- }
-
- private void contestedPutTest(boolean tx) throws Exception
- {
- TransactionManager mgr = cache.getTransactionManager();
- mgr.begin();
-
- LowTimeoutSetter setter = null;
- try
- {
- // Put a WL on /A
- cache.put(FQNA, KEY, VALUE1);
-
- // Launch a thread that tries to write to /A
- setter = new LowTimeoutSetter(tx ? mgr : null);
- setter.start();
-
- setter.join(2000);
- if (!setter.finished)
- {
- setter.interrupt();
- fail("Puts failed to complete in a timely manner");
- }
- }
- finally
- {
- // always commit the tx
- mgr.commit();
- }
-
- assertNotNull("LowTimeoutSetter saw TimeoutException", setter.te);
- assertNull("LowTimeoutSetter saw no misc Exception", setter.failure);
- assertEquals("Cache correct for " + FQNA, VALUE1, cache.get(FQNA, KEY));
- assertEquals("Cache correct for " + FQNB, VALUE2, cache.get(FQNB, KEY));
-
- }
-
- public void testSimpleRead() throws Exception
- {
- log.info("++++++ testSimpleRead() ++++++");
- simpleReadTest(false);
- }
-
- public void testSimpleReadWithTx() throws Exception
- {
- log.info("++++++ testSimpleReadWithTx() ++++++");
- simpleReadTest(true);
- }
-
- private void simpleReadTest(boolean useTx) throws Exception
- {
- TransactionManager tm = useTx ? cache.getTransactionManager() : null;
- LowTimeoutReader reader = new LowTimeoutReader(tm);
-
- cache.put(FQNA, KEY, VALUE1);
-
- reader.start();
-
- reader.join(2000);
- if (!reader.finished)
- {
- reader.interrupt();
- fail("Read failed to complete in a timely manner");
- }
-
- assertNull("LowTimeoutSetter saw no TimeoutException", reader.te);
- assertNull("LowTimeoutSetter saw no misc Exception", reader.failure);
- assertEquals("LowTimeoutSetter correct for " + FQNA, VALUE1, reader.value);
-
- }
-
- public void testContestedRead() throws Exception
- {
- log.info("++++++ testContestedRead() ++++++");
- contestedReadTest(false);
- }
-
- public void testContestedReadWithTx() throws Exception
- {
- log.info("++++++ testContestedReadWithTx() ++++++");
- contestedReadTest(true);
- }
-
- private void contestedReadTest(boolean tx) throws Exception
- {
- TransactionManager mgr = cache.getTransactionManager();
- mgr.begin();
-
- LowTimeoutReader reader = null;
- try
- {
- // Put a WL on /A
- cache.put(FQNA, KEY, VALUE1);
-
- // Launch a thread that tries to read from /A
- reader = new LowTimeoutReader(tx ? mgr : null);
- reader.start();
-
- reader.join(2000);
- if (!reader.finished)
- {
- reader.interrupt();
- fail("Read failed to complete in a timely manner");
- }
- }
- finally
- {
- // always commit the tx
- mgr.commit();
- }
-
- assertNotNull("LowTimeoutSetter saw TimeoutException", reader.te);
- assertNull("LowTimeoutSetter saw no misc Exception", reader.failure);
- assertNull("LowTimeoutSetter unable to read " + FQNA, reader.value);
-
- }
-
- class LowTimeoutSetter extends Thread
- {
- TransactionManager tm;
- TimeoutException te;
- Throwable failure;
- boolean finished;
-
- LowTimeoutSetter(TransactionManager tm)
- {
- this.tm = tm;
- }
-
- public void run()
- {
- try
- {
- try
- {
- if (tm != null)
- {
- tm.begin();
- }
-
- cache.put(FQNB, KEY, VALUE2);
-
- cache.getInvocationContext().setOptionOverrides(option);
- cache.put(FQNA, KEY, VALUE2);
- }
- catch (TimeoutException te)
- {
- this.te = te;
- }
- catch (Exception e)
- {
- if (tm != null)
- tm.setRollbackOnly();
- throw e;
- }
- finally
- {
- if (tm != null)
- {
- tm.commit();
- }
- finished = true;
- }
- }
- catch (Throwable t)
- {
- failure = t;
- }
- }
- }
-
- class LowTimeoutReader extends Thread
- {
- TransactionManager tm;
- TimeoutException te;
- Throwable failure;
- Object value;
- boolean finished;
-
- LowTimeoutReader(TransactionManager tm)
- {
- this.tm = tm;
- }
-
- public void run()
- {
- try
- {
- try
- {
- if (tm != null)
- {
- tm.begin();
- }
-
- cache.getInvocationContext().setOptionOverrides(option);
- value = cache.get(FQNA, KEY);
- }
- catch (TimeoutException te)
- {
- this.te = te;
- }
- catch (Exception e)
- {
- if (tm != null)
- tm.setRollbackOnly();
- throw e;
- }
- finally
- {
- if (tm != null)
- {
- tm.commit();
- }
- finished = true;
- }
- }
- catch (Throwable t)
- {
- failure = t;
- }
- }
- }
-}
Copied: core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSilentlyTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/options/FailSilentlyTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSilentlyTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSilentlyTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -0,0 +1,168 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.options;
+
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import static org.testng.AssertJUnit.assertEquals;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Tests passing in the failSilently option in various scenarios.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ */
+@Test(groups = {"functional"})
+public class PessimisticFailSilentlyTest
+{
+ private CacheSPI cache;
+ private TransactionManager manager;
+ private Transaction tx;
+ private Fqn fqn = Fqn.fromString("/a");
+ private String key = "key";
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ if (cache != null)
+ tearDown();
+ CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ cache = (CacheSPI) instance.createCache(false);
+ // very short acquisition timeout
+ cache.getConfiguration().setLockAcquisitionTimeout(100);
+ cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+ cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache.start();
+ manager = cache.getTransactionManager();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown()
+ {
+ if (tx != null)
+ {
+ try
+ {
+ manager.resume(tx);
+ manager.rollback();
+ }
+ catch (Exception e)
+ {
+ // who cares
+ }
+ }
+ if (cache != null)
+ {
+ cache.stop();
+ cache = null;
+ }
+ }
+
+ public void testPutKeyValue() throws Exception
+ {
+ manager.begin();
+ cache.put(fqn, key, "value");
+ tx = manager.suspend();
+ cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
+ cache.put(fqn, key, "value2");
+ }
+
+ public void testPutData() throws Exception
+ {
+ Map<String, String> data = new HashMap<String, String>();
+ data.put(key, "value");
+ manager.begin();
+ cache.put(fqn, data);
+ tx = manager.suspend();
+ cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
+ cache.put(fqn, data);
+ }
+
+ public void testRemoveNode() throws Exception
+ {
+ cache.put(fqn, key, "value");
+ manager.begin();
+ // get a read lock
+ cache.get(fqn, key);
+ tx = manager.suspend();
+ cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
+ cache.removeNode(fqn);
+ }
+
+ public void testRemoveKey() throws Exception
+ {
+ cache.put(fqn, key, "value");
+ manager.begin();
+ // get a read lock
+ cache.get(fqn, key);
+ tx = manager.suspend();
+ cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
+ cache.remove(fqn, key);
+ }
+
+ public void testGetNode() throws Exception
+ {
+ cache.put(fqn, key, "value");
+ manager.begin();
+ // get a WL
+ cache.put(fqn, key, "value2");
+ tx = manager.suspend();
+ cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
+ cache.getNode(fqn);
+ }
+
+ public void testGetKey() throws Exception
+ {
+ cache.put(fqn, key, "value");
+ manager.begin();
+ // get a WL
+ cache.put(fqn, key, "value2");
+ tx = manager.suspend();
+ cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
+ cache.get(fqn, key);
+ }
+
+ public void testGetChildrenNames() throws Exception
+ {
+ cache.put(fqn, key, "value");
+ manager.begin();
+ // get a WL
+ cache.put(fqn, key, "value2");
+ tx = manager.suspend();
+ cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
+ cache.getChildrenNames(fqn);
+
+ }
+
+ public void testPutThatWillFail() throws Exception
+ {
+ manager.begin();
+ cache.put(fqn, "k", "v");// this will get WLs on / and /a
+ tx = manager.suspend();
+
+ assertEquals(2, cache.getNumberOfLocksHeld());
+
+ // now this call WILL fail, but should fail silently - i.e., not roll back.
+ manager.begin();
+ cache.getInvocationContext().getOptionOverrides().setFailSilently(true);
+ cache.put(fqn, "x", "y");
+
+ // should not roll back, despite the cache put call failing/timing out.
+ manager.commit();
+ }
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/options/PessimisticFailSilentlyTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcquisitionTimeoutTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/options/LockAcquisitionTimeoutTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcquisitionTimeoutTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcquisitionTimeoutTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -0,0 +1,360 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.options;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.lock.TimeoutException;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.TransactionManager;
+
+/**
+ * Test functionality of {@link Option#setLockAcquisitionTimeout(int)}.
+ *
+ * @author Brian Stansberry
+ */
+@Test(groups = {"functional"})
+public class PessimisticLockAcquisitionTimeoutTest
+{
+ private static final Log log = LogFactory.getLog(PessimisticLockAcquisitionTimeoutTest.class);
+
+ private static final Fqn FQNA = Fqn.fromString("/A");
+ private static final Fqn FQNB = Fqn.fromString("/B");
+ private static final String KEY = "key";
+ private static final String VALUE1 = "value1";
+ private static final String VALUE2 = "value2";
+
+ private CacheSPI<Object, Object> cache;
+ private Option option;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ cache = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ Configuration c = cache.getConfiguration();
+ c.setCacheMode("REPL_SYNC");
+ cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ c.setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+
+ cache.start();
+
+ option = new Option();
+ option.setLockAcquisitionTimeout(0);
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown()
+ {
+ if (cache != null)
+ {
+ cache.stop();
+ cache = null;
+ }
+ }
+
+ /**
+ * Confirms that doing a put with a lockAcquisitionTime option set
+ * does the put as expected. There is no other thread or tx contesting
+ * the lock the put needs, so this is just a simple test that the option
+ * doesn't somehow screw up the put.
+ *
+ * @throws Exception
+ */
+ public void testSimplePut() throws Exception
+ {
+ log.info("++++ testSimplePut() ++++");
+ simplePutTest(false);
+ }
+
+ /**
+ * Confirms that doing a put with a lockAcquisitionTime option set
+ * does the put as expected when executed within a transaction. There is no
+ * other thread or tx contesting the lock the put needs, so this is just a
+ * simple test that the option doesn't somehow screw up the put.
+ *
+ * @throws Exception
+ */
+ public void testSimplePutWithTx() throws Exception
+ {
+ log.info("++++ testSimplePutWithTx() ++++");
+ simplePutTest(true);
+ }
+
+ private void simplePutTest(boolean useTx) throws Exception
+ {
+ TransactionManager tm = useTx ? cache.getTransactionManager() : null;
+ LowTimeoutSetter setter = new LowTimeoutSetter(tm);
+ setter.start();
+
+ setter.join(2000);
+ if (!setter.finished)
+ {
+ setter.interrupt();
+ fail("Puts failed to complete in a timely manner");
+ }
+
+ assertNull("LowTimeoutSetter saw no TimeoutException", setter.te);
+ assertNull("LowTimeoutSetter saw no misc Exception", setter.failure);
+ assertEquals("Cache correct for " + FQNA, VALUE2, cache.get(FQNA, KEY));
+ assertEquals("Cache correct for " + FQNB, VALUE2, cache.get(FQNB, KEY));
+ }
+
+ /**
+ * Confirms that a put with a lockAcquisitionTimeout option set to zero
+ * fails promptly in the presence of a lock on the target node.
+ *
+ * @throws Exception
+ */
+ public void testContestedPut() throws Exception
+ {
+ log.info("++++ testContestedPut() ++++");
+ contestedPutTest(false);
+ }
+
+ /**
+ * Confirms that a put with a lockAcquisitionTimeout option set to zero
+ * is ignored if executed within a transaction.
+ *
+ * @throws Exception
+ */
+ public void testContestedPutWithTx() throws Exception
+ {
+ log.info("++++ testContestedPutWithTx() ++++");
+ contestedPutTest(true);
+ }
+
+ private void contestedPutTest(boolean tx) throws Exception
+ {
+ TransactionManager mgr = cache.getTransactionManager();
+ mgr.begin();
+
+ LowTimeoutSetter setter = null;
+ try
+ {
+ // Put a WL on /A
+ cache.put(FQNA, KEY, VALUE1);
+
+ // Launch a thread that tries to write to /A
+ setter = new LowTimeoutSetter(tx ? mgr : null);
+ setter.start();
+
+ setter.join(2000);
+ if (!setter.finished)
+ {
+ setter.interrupt();
+ fail("Puts failed to complete in a timely manner");
+ }
+ }
+ finally
+ {
+ // always commit the tx
+ mgr.commit();
+ }
+
+ assertNotNull("LowTimeoutSetter saw TimeoutException", setter.te);
+ assertNull("LowTimeoutSetter saw no misc Exception", setter.failure);
+ assertEquals("Cache correct for " + FQNA, VALUE1, cache.get(FQNA, KEY));
+ assertEquals("Cache correct for " + FQNB, VALUE2, cache.get(FQNB, KEY));
+
+ }
+
+ public void testSimpleRead() throws Exception
+ {
+ log.info("++++++ testSimpleRead() ++++++");
+ simpleReadTest(false);
+ }
+
+ public void testSimpleReadWithTx() throws Exception
+ {
+ log.info("++++++ testSimpleReadWithTx() ++++++");
+ simpleReadTest(true);
+ }
+
+ private void simpleReadTest(boolean useTx) throws Exception
+ {
+ TransactionManager tm = useTx ? cache.getTransactionManager() : null;
+ LowTimeoutReader reader = new LowTimeoutReader(tm);
+
+ cache.put(FQNA, KEY, VALUE1);
+
+ reader.start();
+
+ reader.join(2000);
+ if (!reader.finished)
+ {
+ reader.interrupt();
+ fail("Read failed to complete in a timely manner");
+ }
+
+ assertNull("LowTimeoutSetter saw no TimeoutException", reader.te);
+ assertNull("LowTimeoutSetter saw no misc Exception", reader.failure);
+ assertEquals("LowTimeoutSetter correct for " + FQNA, VALUE1, reader.value);
+
+ }
+
+ public void testContestedRead() throws Exception
+ {
+ log.info("++++++ testContestedRead() ++++++");
+ contestedReadTest(false);
+ }
+
+ public void testContestedReadWithTx() throws Exception
+ {
+ log.info("++++++ testContestedReadWithTx() ++++++");
+ contestedReadTest(true);
+ }
+
+ private void contestedReadTest(boolean tx) throws Exception
+ {
+ TransactionManager mgr = cache.getTransactionManager();
+ mgr.begin();
+
+ LowTimeoutReader reader = null;
+ try
+ {
+ // Put a WL on /A
+ cache.put(FQNA, KEY, VALUE1);
+
+ // Launch a thread that tries to read from /A
+ reader = new LowTimeoutReader(tx ? mgr : null);
+ reader.start();
+
+ reader.join(2000);
+ if (!reader.finished)
+ {
+ reader.interrupt();
+ fail("Read failed to complete in a timely manner");
+ }
+ }
+ finally
+ {
+ // always commit the tx
+ mgr.commit();
+ }
+
+ assertNotNull("LowTimeoutSetter saw TimeoutException", reader.te);
+ assertNull("LowTimeoutSetter saw no misc Exception", reader.failure);
+ assertNull("LowTimeoutSetter unable to read " + FQNA, reader.value);
+
+ }
+
+ class LowTimeoutSetter extends Thread
+ {
+ TransactionManager tm;
+ TimeoutException te;
+ Throwable failure;
+ boolean finished;
+
+ LowTimeoutSetter(TransactionManager tm)
+ {
+ this.tm = tm;
+ }
+
+ public void run()
+ {
+ try
+ {
+ try
+ {
+ if (tm != null)
+ {
+ tm.begin();
+ }
+
+ cache.put(FQNB, KEY, VALUE2);
+
+ cache.getInvocationContext().setOptionOverrides(option);
+ cache.put(FQNA, KEY, VALUE2);
+ }
+ catch (TimeoutException te)
+ {
+ this.te = te;
+ }
+ catch (Exception e)
+ {
+ if (tm != null)
+ tm.setRollbackOnly();
+ throw e;
+ }
+ finally
+ {
+ if (tm != null)
+ {
+ tm.commit();
+ }
+ finished = true;
+ }
+ }
+ catch (Throwable t)
+ {
+ failure = t;
+ }
+ }
+ }
+
+ class LowTimeoutReader extends Thread
+ {
+ TransactionManager tm;
+ TimeoutException te;
+ Throwable failure;
+ Object value;
+ boolean finished;
+
+ LowTimeoutReader(TransactionManager tm)
+ {
+ this.tm = tm;
+ }
+
+ public void run()
+ {
+ try
+ {
+ try
+ {
+ if (tm != null)
+ {
+ tm.begin();
+ }
+
+ cache.getInvocationContext().setOptionOverrides(option);
+ value = cache.get(FQNA, KEY);
+ }
+ catch (TimeoutException te)
+ {
+ this.te = te;
+ }
+ catch (Exception e)
+ {
+ if (tm != null)
+ tm.setRollbackOnly();
+ throw e;
+ }
+ finally
+ {
+ if (tm != null)
+ {
+ tm.commit();
+ }
+ finished = true;
+ }
+ }
+ catch (Throwable t)
+ {
+ failure = t;
+ }
+ }
+ }
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/options/PessimisticLockAcquisitionTimeoutTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ native
Copied: core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppressLockingTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/options/SuppressLockingTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppressLockingTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppressLockingTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -0,0 +1,185 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.options;
+
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.transaction.DummyTransactionManagerLookup;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.TransactionManager;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Tests the suppression of locking nodes
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ */
+@Test(groups = {"functional"})
+public class PessimisticSuppressLockingTest
+{
+ private Fqn fqn = Fqn.fromString("/blah");
+ private Fqn fqn1 = Fqn.fromString("/blah/1");
+
+ private CacheSPI<String, String> cache;
+
+ private TransactionManager m;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp()
+ {
+ Configuration config = new Configuration();
+ config.setCacheMode(Configuration.CacheMode.LOCAL);
+ config.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+ CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ config.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache = (CacheSPI<String, String>) instance.createCache(config);
+ m = cache.getTransactionManager();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown()
+ {
+ if (cache != null)
+ {
+ cache.stop();
+ cache = null;
+ }
+ m = null;
+ }
+
+ public void testSuppressionOfWriteLocks() throws Exception
+ {
+ TransactionManager m = cache.getTransactionManager();
+
+ m.begin();
+ assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
+ cache.put(fqn, "x", "1");
+ assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
+ assertEquals(2, cache.getNumberOfLocksHeld());
+ m.commit();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ cache.removeNode(fqn);
+
+ m.begin();
+ cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
+ assertTrue(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
+ cache.put(fqn, "x", "2");
+ assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ m.commit();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ // test normal operation again
+ cache.removeNode(fqn);
+
+ m.begin();
+ assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
+ cache.put(fqn, "x", "3");
+ assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
+ assertEquals(2, cache.getNumberOfLocksHeld());
+ m.commit();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ }
+
+ /**
+ * This one fails now.
+ *
+ * @throws Exception
+ */
+ public void testSuppressionOf2WriteLocks() throws Exception
+ {
+ TransactionManager m = cache.getTransactionManager();
+
+ m.begin();
+ cache.put(fqn, "x", "1");
+ assertEquals(2, cache.getNumberOfLocksHeld());
+ m.commit();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ cache.removeNode(fqn);
+
+ m.begin();
+ cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
+ cache.put(fqn, "x", "2");
+ cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
+ cache.put(fqn1, "y", "3");
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ m.commit();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("x", "1");
+ m.begin();
+ cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
+ cache.put(fqn, map);
+ cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
+ cache.put(fqn1, map);
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ m.commit();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ // test normal operation again
+ cache.removeNode(fqn);
+
+ m.begin();
+ cache.put(fqn, "x", "3");
+ assertEquals(2, cache.getNumberOfLocksHeld());
+ m.commit();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ }
+
+ public void testSuppressionOfReadLocks() throws Exception
+ {
+ cache.put(fqn, "x", "y");
+
+ m.begin();
+ assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
+ cache.get(fqn, "x");
+ assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
+ assertEquals(2, cache.getNumberOfLocksHeld());
+ m.commit();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ m.begin();
+ cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
+ assertTrue(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
+ cache.get(fqn, "x");
+ assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ m.commit();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ // test normal operation again
+
+ m.begin();
+ assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
+ cache.get(fqn, "x");
+ assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
+ assertEquals(2, cache.getNumberOfLocksHeld());
+ m.commit();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ }
+
+ public void testNodeCreation()
+ {
+ assertNull(cache.getRoot().getChild(fqn));
+ cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
+ cache.put(fqn, "x", "y");
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ assertEquals("y", cache.getRoot().getChild(fqn).get("x"));
+ }
+
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/options/PessimisticSuppressLockingTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: core/trunk/src/test/java/org/jboss/cache/options/SuppressLockingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/options/SuppressLockingTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/options/SuppressLockingTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -1,184 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.options;
-
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.transaction.DummyTransactionManagerLookup;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.transaction.TransactionManager;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Tests the suppression of locking nodes
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- */
-@Test(groups = {"functional"})
-public class SuppressLockingTest
-{
- private Fqn fqn = Fqn.fromString("/blah");
- private Fqn fqn1 = Fqn.fromString("/blah/1");
-
- private CacheSPI<String, String> cache;
-
- private TransactionManager m;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp()
- {
- Configuration config = new Configuration();
- config.setCacheMode(Configuration.CacheMode.LOCAL);
- config.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache = (CacheSPI<String, String>) instance.createCache(config);
- m = cache.getTransactionManager();
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown()
- {
- if (cache != null)
- {
- cache.stop();
- cache = null;
- }
- m = null;
- }
-
- public void testSuppressionOfWriteLocks() throws Exception
- {
- TransactionManager m = cache.getTransactionManager();
-
- m.begin();
- assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
- cache.put(fqn, "x", "1");
- assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
- assertEquals(2, cache.getNumberOfLocksHeld());
- m.commit();
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- cache.removeNode(fqn);
-
- m.begin();
- cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
- assertTrue(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
- cache.put(fqn, "x", "2");
- assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
- assertEquals(0, cache.getNumberOfLocksHeld());
- m.commit();
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- // test normal operation again
- cache.removeNode(fqn);
-
- m.begin();
- assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
- cache.put(fqn, "x", "3");
- assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
- assertEquals(2, cache.getNumberOfLocksHeld());
- m.commit();
- assertEquals(0, cache.getNumberOfLocksHeld());
- }
-
- /**
- * This one fails now.
- *
- * @throws Exception
- */
- public void testSuppressionOf2WriteLocks() throws Exception
- {
- TransactionManager m = cache.getTransactionManager();
-
- m.begin();
- cache.put(fqn, "x", "1");
- assertEquals(2, cache.getNumberOfLocksHeld());
- m.commit();
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- cache.removeNode(fqn);
-
- m.begin();
- cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
- cache.put(fqn, "x", "2");
- cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
- cache.put(fqn1, "y", "3");
- assertEquals(0, cache.getNumberOfLocksHeld());
- m.commit();
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- Map<String, String> map = new HashMap<String, String>();
- map.put("x", "1");
- m.begin();
- cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
- cache.put(fqn, map);
- cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
- cache.put(fqn1, map);
- assertEquals(0, cache.getNumberOfLocksHeld());
- m.commit();
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- // test normal operation again
- cache.removeNode(fqn);
-
- m.begin();
- cache.put(fqn, "x", "3");
- assertEquals(2, cache.getNumberOfLocksHeld());
- m.commit();
- assertEquals(0, cache.getNumberOfLocksHeld());
- }
-
- public void testSuppressionOfReadLocks() throws Exception
- {
- cache.put(fqn, "x", "y");
-
- m.begin();
- assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
- cache.get(fqn, "x");
- assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
- assertEquals(2, cache.getNumberOfLocksHeld());
- m.commit();
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- m.begin();
- cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
- assertTrue(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
- cache.get(fqn, "x");
- assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
- assertEquals(0, cache.getNumberOfLocksHeld());
- m.commit();
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- // test normal operation again
-
- m.begin();
- assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
- cache.get(fqn, "x");
- assertFalse(cache.getInvocationContext().getOptionOverrides().isSuppressLocking());
- assertEquals(2, cache.getNumberOfLocksHeld());
- m.commit();
- assertEquals(0, cache.getNumberOfLocksHeld());
- }
-
- public void testNodeCreation()
- {
- assertNull(cache.getRoot().getChild(fqn));
- cache.getInvocationContext().getOptionOverrides().setSuppressLocking(true);
- cache.put(fqn, "x", "y");
- assertEquals(0, cache.getNumberOfLocksHeld());
- assertEquals("y", cache.getRoot().getChild(fqn).get("x"));
- }
-
-}
Copied: core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSyncReplTxTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSyncReplTxTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSyncReplTxTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -0,0 +1,1239 @@
+/*
+ *
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.replicated;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.lock.TimeoutException;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.notifications.annotation.CacheListener;
+import org.jboss.cache.notifications.annotation.NodeModified;
+import org.jboss.cache.notifications.event.NodeEvent;
+import org.jboss.cache.transaction.TransactionSetup;
+import org.jboss.cache.util.CachePrinter;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Semaphore;
+
+/**
+ * Replicated unit test for sync transactional CacheImpl
+ * Note: we use DummyTransactionManager for Tx purpose instead of relying on
+ * jta.
+ *
+ * @version $Revision$
+ */
+@Test(groups = {"functional", "jgroups", "transaction"})
+public class PessimisticSyncReplTxTest
+{
+ private static Log log = LogFactory.getLog(PessimisticSyncReplTxTest.class);
+ private CacheSPI<Object, Object> cache1;
+ private CacheSPI<Object, Object> cache2;
+
+ Semaphore lock;
+ private Throwable t1_ex;
+ private Throwable t2_ex;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ t1_ex = t2_ex = null;
+ lock = new Semaphore(1);
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ TransactionSetup.cleanup();
+ destroyCaches();
+ }
+
+ private TransactionManager beginTransaction() throws SystemException, NotSupportedException
+ {
+ return beginTransaction(cache1);
+ }
+
+ private TransactionManager beginTransaction(CacheSPI c) throws SystemException, NotSupportedException
+ {
+ TransactionManager mgr = c.getConfiguration().getRuntimeConfig().getTransactionManager();
+ mgr.begin();
+ return mgr;
+ }
+
+ private void initCaches(Configuration.CacheMode caching_mode) throws Exception
+ {
+ cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ cache1.getConfiguration().setCacheMode(caching_mode);
+ cache2.getConfiguration().setCacheMode(caching_mode);
+ cache1.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache2.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache1.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
+ cache2.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
+
+ cache1.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ cache2.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ cache1.getConfiguration().setLockAcquisitionTimeout(5000);
+ cache2.getConfiguration().setLockAcquisitionTimeout(5000);
+
+ configureMultiplexer(cache1);
+ configureMultiplexer(cache2);
+
+ cache1.start();
+ cache2.start();
+
+ validateMultiplexer(cache1);
+ validateMultiplexer(cache2);
+ }
+
+ /**
+ * Provides a hook for multiplexer integration. This default implementation
+ * is a no-op; subclasses that test mux integration would override
+ * to integrate the given cache with a multiplexer.
+ * <p/>
+ * param cache a cache that has been configured but not yet created.
+ *
+ * @param cache cache
+ * @throws Exception exception
+ */
+ protected void configureMultiplexer(Cache cache) throws Exception
+ {
+ // default does nothing
+ }
+
+ /**
+ * Provides a hook to check that the cache's channel came from the
+ * multiplexer, or not, as expected. This default impl asserts that
+ * the channel did not come from the multiplexer.
+ *
+ * @param cache a cache that has already been started
+ */
+ protected void validateMultiplexer(Cache cache)
+ {
+ assertFalse("Cache is not using multiplexer", cache.getConfiguration().isUsingMultiplexer());
+ }
+
+ private void destroyCaches()
+ {
+ if (cache1 != null)
+ {
+ cache1.stop();
+ }
+ if (cache2 != null)
+ {
+ cache2.stop();
+ }
+ cache1 = null;
+ cache2 = null;
+ }
+
+ public void testLockRemoval() throws Exception
+ {
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+ cache1.getConfiguration().setSyncCommitPhase(true);
+ TestingUtil.extractLockManager(cache1).unlockAll(cache1.getRoot());
+ TransactionManager tm = beginTransaction();
+ cache1.put("/bela/ban", "name", "Bela Ban");
+ assertEquals(3, cache1.getNumberOfLocksHeld());
+ assertEquals(0, cache2.getNumberOfLocksHeld());
+ tm.commit();
+ assertEquals(0, cache1.getNumberOfLocksHeld());
+ assertEquals(0, cache2.getNumberOfLocksHeld());
+ }
+
+ public void testSyncRepl() throws Exception
+ {
+ Integer age;
+ Transaction tx;
+
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+ cache1.getConfiguration().setSyncCommitPhase(true);
+ cache2.getConfiguration().setSyncCommitPhase(true);
+
+ TransactionManager mgr = beginTransaction();
+ cache1.put("/a/b/c", "age", 38);
+ tx = mgr.suspend();
+ assertNull("age on cache2 must be null as the TX has not yet been committed", cache2.get("/a/b/c", "age"));
+ log.debug("cache1: locks held before commit: " + CachePrinter.printCacheLockingInfo(cache1));
+ log.debug("cache2: locks held before commit: " + CachePrinter.printCacheLockingInfo(cache2));
+ mgr.resume(tx);
+ mgr.commit();
+ log.debug("cache1: locks held after commit: " + CachePrinter.printCacheLockingInfo(cache1));
+ log.debug("cache2: locks held after commit: " + CachePrinter.printCacheLockingInfo(cache2));
+
+ // value on cache2 must be 38
+ age = (Integer) cache2.get("/a/b/c", "age");
+ assertNotNull("\"age\" obtained from cache2 must be non-null ", age);
+ assertTrue("\"age\" must be 38", age == 38);
+ }
+
+ public void testSimplePut() throws Exception
+ {
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+
+ cache1.put("/JSESSION/localhost/192.168.1.10:32882/Courses/0", "Instructor", "Ben Wang");
+
+ cache1.put("/JSESSION/localhost/192.168.1.10:32882/1", "Number", 10);
+ }
+
+ public void testSimpleTxPut() throws Exception
+ {
+ TransactionManager tm;
+ final Fqn NODE1 = Fqn.fromString("/one/two/three");
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+
+ tm = beginTransaction();
+ cache1.put(NODE1, "age", 38);
+ System.out.println("TransactionTable for cache1 after cache1.put():\n" + cache1.getTransactionTable().toString(true));
+ tm.commit();
+
+ /*
+ tx=beginTransaction();
+ cache1.put(NODE1, "age", new Integer(38));
+ cache1.put(NODE2, "name", "Ben of The Far East");
+ cache1.put(NODE3, "key", "UnknowKey");
+ System.out.println("TransactionTable for cache1 after cache1.put():\n" + cache1.getTransactionTable().toString(true));
+
+ tx.commit();
+ */
+
+ /*
+ tx=beginTransaction();
+ cache1.put(NODE1, "age", new Integer(38));
+ cache1.put(NODE1, "AOPInstance", new AOPInstance());
+ cache1.put(NODE2, "AOPInstance", new AOPInstance());
+ cache1.put(NODE1, "AOPInstance", new AOPInstance());
+ tx.commit();
+ System.out.println("TransactionTable for cache1 after cache1.put():\n" + cache1.getTransactionTable().toString(true));
+ */
+ }
+
+ public void testSyncReplWithModficationsOnBothCaches() throws Exception
+ {
+ TransactionManager tm;
+ final Fqn NODE1 = Fqn.fromString("/one/two/three");
+ final Fqn NODE2 = Fqn.fromString("/eins/zwei/drei");
+
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+
+ // create roots first
+ cache1.put("/one/two", null);
+ cache2.put("/eins/zwei", null);
+
+ cache1.getConfiguration().setSyncCommitPhase(true);
+ cache2.getConfiguration().setSyncCommitPhase(true);
+
+ tm = beginTransaction();
+ cache1.put(NODE1, "age", 38);
+ System.out.println("TransactionTable for cache1 after cache1.put():\n" + cache1.getTransactionTable().toString(true));
+
+ cache2.put(NODE2, "age", 39);
+ System.out.println("TransactionTable for cache2 after cache2.put():\n" + cache2.getTransactionTable().toString(true));
+
+ System.out.println("cache1 before commit:\n" + CachePrinter.printCacheLockingInfo(cache1));
+ System.out.println("cache2 before commit:\n" + CachePrinter.printCacheLockingInfo(cache2));
+
+ try
+ {
+ tm.commit();
+ fail("Should not succeed with SERIALIZABLE semantics");
+ }
+ catch (Exception e)
+ {
+ //should be a classic deadlock here.
+ }
+
+ System.out.println("cache1 after commit:\n" + CachePrinter.printCacheLockingInfo(cache1));
+ System.out.println("cache2 after commit:\n" + CachePrinter.printCacheLockingInfo(cache2));
+
+ /*
+ assertTrue(cache1.exists(NODE1));
+ assertTrue(cache1.exists(NODE2));
+ assertTrue(cache1.exists(NODE1));
+ assertTrue(cache2.exists(NODE2));
+
+ age = (Integer) cache1.get(NODE1, "age");
+ assertNotNull("\"age\" obtained from cache1 for " + NODE1 + " must be non-null ", age);
+ assertTrue("\"age\" must be 38", age == 38);
+
+ age = (Integer) cache2.get(NODE1, "age");
+ assertNotNull("\"age\" obtained from cache2 for " + NODE1 + " must be non-null ", age);
+ assertTrue("\"age\" must be 38", age == 38);
+
+ age = (Integer) cache1.get(NODE2, "age");
+ assertNotNull("\"age\" obtained from cache1 for " + NODE2 + " must be non-null ", age);
+ assertTrue("\"age\" must be 39", age == 39);
+
+ age = (Integer) cache2.get(NODE2, "age");
+ assertNotNull("\"age\" obtained from cache2 for " + NODE2 + " must be non-null ", age);
+ assertTrue("\"age\" must be 39", age == 39);
+ */
+
+ assertEquals(0, cache1.getNumberOfLocksHeld());
+ assertEquals(0, cache2.getNumberOfLocksHeld());
+ System.out.println("TransactionTable for cache1:\n" + cache1.getTransactionTable().toString(true));
+ System.out.println("TransactionTable for cache2:\n" + cache2.getTransactionTable().toString(true));
+ }
+
+ public void testSyncReplWithModficationsOnBothCachesSameData() throws Exception
+ {
+ TransactionManager tm;
+ final Fqn NODE = Fqn.fromString("/one/two/three");
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+ tm = beginTransaction();
+ cache1.put(NODE, "age", 38);
+ System.out.println("TransactionTable for cache1 after cache1.put():\n" + cache1.getTransactionTable().toString(true));
+
+ cache2.put(NODE, "age", 39);
+ System.out.println("TransactionTable for cache2 after cache2.put():\n" + cache2.getTransactionTable().toString(true));
+
+ System.out.println("cache1 before commit:\n" + CachePrinter.printCacheLockingInfo(cache1));
+ System.out.println("cache2 before commit:\n" + CachePrinter.printCacheLockingInfo(cache2));
+
+ try
+ {
+ tm.commit();
+ fail("commit should throw a RollbackException, we should not get here");
+ }
+ catch (RollbackException rollback)
+ {
+ System.out.println("Transaction was rolled back, this is correct");
+ }
+
+ System.out.println("cache1 after commit:\n" + CachePrinter.printCacheLockingInfo(cache1));
+ System.out.println("cache2 after commit:\n" + CachePrinter.printCacheLockingInfo(cache2));
+
+ assertEquals(0, cache1.getNumberOfLocksHeld());
+ assertEquals(0, cache2.getNumberOfLocksHeld());
+
+ assertEquals(0, cache1.getNumberOfNodes());
+ assertEquals(0, cache2.getNumberOfNodes());
+ }
+
+ public void testSyncReplWithModficationsOnBothCachesWithRollback() throws Exception
+ {
+ TransactionManager tm;
+ final Fqn fqn1 = Fqn.fromString("/one/two/three");
+ final Fqn fqn2 = Fqn.fromString("/eins/zwei/drei");
+
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+
+ cache1.getConfiguration().setSyncRollbackPhase(true);
+ cache2.getConfiguration().setSyncRollbackPhase(true);
+
+ tm = beginTransaction();
+ cache1.put(fqn1, "age", 38);
+ cache2.put(fqn2, "age", 39);
+
+ System.out.println("cache1 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache1));
+ System.out.println("cache2 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache2));
+
+ // this will rollback the transaction
+ Transaction tx = tm.getTransaction();
+ tx.registerSynchronization(new TransactionAborter(tx));
+
+ try
+ {
+ tm.commit();
+ fail("commit should throw a RollbackException, we should not get here");
+ }
+ catch (RollbackException rollback)
+ {
+ System.out.println("Transaction was rolled back, this is correct");
+ }
+
+ System.out.println("cache1 (after rollback):\n" + CachePrinter.printCacheLockingInfo(cache1));
+ System.out.println("cache2 (after rollback):\n" + CachePrinter.printCacheLockingInfo(cache2));
+
+ assertEquals(0, cache1.getNumberOfLocksHeld());
+ assertEquals(0, cache2.getNumberOfLocksHeld());
+
+ assertEquals(0, cache1.getNumberOfNodes());
+ assertEquals(0, cache2.getNumberOfNodes());
+ }
+
+ /**
+ * Test for JBCACHE-361 -- does marking a tx on the remote side
+ * rollback-only cause a rollback on the originating side?
+ */
+ public void testSyncReplWithRemoteRollback() throws Exception
+ {
+ TransactionManager tm;
+ final Fqn NODE1 = Fqn.fromString("/one/two/three");
+
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+
+ cache1.getConfiguration().setSyncRollbackPhase(true);
+ cache2.getConfiguration().setSyncRollbackPhase(true);
+
+ // Test with a rollback on the remote side
+
+ // listener aborts any active tx
+ //TransactionAborterListener tal = new TransactionAborterListener(cache2);
+
+ tm = beginTransaction();
+ cache1.put(NODE1, "age", 38);
+
+ System.out.println("cache1 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache1));
+ System.out.println("cache2 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache2));
+
+ // instead of a listener lets just get a WL on ROOT on cache2. And hold on to it.
+ Transaction tx = tm.suspend();
+
+ tm.begin();
+ cache2.getRoot().put("x", "y");
+ Transaction tx2 = cache2.getTransactionManager().suspend();
+
+ System.out.println("cache2 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache2));
+ tm.resume(tx);
+
+ try
+ {
+ tm.commit();
+ fail("commit should throw a RollbackException, we should not get here");
+ }
+ catch (RollbackException rollback)
+ {
+ System.out.println("Transaction was rolled back, this is correct");
+ }
+ finally
+ {
+ tm.resume(tx2);
+ tm.rollback();
+ }
+
+ // Sleep, as the commit call to cache2 is async
+ TestingUtil.sleepThread(1000);
+
+ System.out.println("cache1 (after rollback):\n" + CachePrinter.printCacheLockingInfo(cache1));
+ System.out.println("cache2 (after rollback):\n" + CachePrinter.printCacheLockingInfo(cache2));
+
+ //assertNull(tal.getCallbackException());
+
+ assertEquals(0, cache1.getNumberOfLocksHeld());
+ assertEquals(0, cache2.getNumberOfLocksHeld());
+
+ assertEquals(0, cache1.getNumberOfNodes());
+ assertEquals(0, cache2.getNumberOfNodes());
+
+ }
+
+ public void testASyncRepl() throws Exception
+ {
+ Integer age;
+ TransactionManager tm;
+
+ initCaches(Configuration.CacheMode.REPL_ASYNC);
+
+ tm = beginTransaction();
+ cache1.put("/a/b/c", "age", 38);
+ Thread.sleep(1000);
+ assertNull("age on cache2 must be null as the TX has not yet been committed", cache2.get("/a/b/c", "age"));
+ tm.commit();
+ Thread.sleep(1000);
+
+ // value on cache2 must be 38
+ age = (Integer) cache2.get("/a/b/c", "age");
+ assertNotNull("\"age\" obtained from cache2 is null ", age);
+ assertTrue("\"age\" must be 38", age == 38);
+
+ }
+
+ /**
+ * Tests concurrent modifications: thread1 succeeds and thread2 is blocked until thread1 is done, and then succeeds
+ * too. However, this is flawed with the introduction of interceptors, here's why.<br/>
+ * <ul>
+ * <li>Thread1 acquires the lock for /bela/ban on cache1
+ * <li>Thread2 blocks on Thread1 to release the lock
+ * <li>Thread1 commits: this means the TransactionInterceptor and the ReplicationInterceptor are called in
+ * the sequence in which they registered. Unfortunately, the TransactionInterceptor registered first. In the
+ * PREPARE phase, the ReplicationInterceptor calls prepare() in cache2 synchronously. The TxInterceptor
+ * does nothing. The the COMMIT phase, the TxInterceptor commits the data by releasing the locks locally and
+ * then the ReplicationInterceptor sends an asynchronous COMMIT to cache2.
+ * <li>Because the TxInterceptor for Thread1 releases the locks locally <em>before</em> sending the async COMMIT,
+ * Thread2 is able to acquire the lock for /bela/ban in cache1 and then starts the PREPARE phase by sending a
+ * synchronous PREPARE to cache2. If this PREPARE arrives at cache2 <em>before</em> the COMMIT from Thread1,
+ * the PREPARE will block because it attempts to acquire a lock on /bela/ban on cache2 still held by Thread1
+ * (which would be released by Thread1's COMMIT). This results in deadlock, which is resolved by Thread2 running
+ * into a timeout with subsequent rollback and Thread1 succeeding.<br/>
+ * </ul>
+ * There are 3 solutions to this:
+ * <ol>
+ * <li>Do nothing. This is standard behavior for concurrent access to the same data. Same thing if the 2 threads
+ * operated on the same data in <em>separate</em> caches, e.g. Thread1 on /bela/ban in cache1 and Thread2 on
+ * /bela/ban in cache2. The semantics of Tx commit as handled by the interceptors is: after tx1.commit() returns
+ * the locks held by tx1 are release and a COMMIT message is on the way (if sent asynchronously).
+ * <li>Force an order over TxInterceptor and ReplicationInterceptor. This would require ReplicationInterceptor
+ * to always be fired first on TX commit. Downside: the interceptors have an implicit dependency, which is not
+ * nice.
+ * <li>Priority-order requests at the receiver; e.g. a COMMIT could release a blocked PREPARE. This is bad because
+ * it violates JGroups' FIFO ordering guarantees.
+ * </ol>
+ * I'm currently investigating solution #2, ie. creating an OrderedSynchronizationHandler, which allows other
+ * SynchronizationHandlers to register (atHead, atTail), and the OrderedSynchronizationHandler would call the
+ * SynchronizationHandler in the order in which they are defined.
+ *
+ * @throws Exception exception
+ */
+ public void testConcurrentPuts() throws Exception
+ {
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+ cache1.getConfiguration().setSyncCommitPhase(true);
+
+ Thread t1 = new Thread("Thread1")
+ {
+ TransactionManager tm;
+
+ public void run()
+ {
+ try
+ {
+ tm = beginTransaction();
+ cache1.put("/bela/ban", "name", "Bela Ban");
+ TestingUtil.sleepThread(2000);// Thread2 will be blocked until we commit
+ tm.commit();
+ System.out.println("[Thread1] ** LOCK INFO cache1: " + CachePrinter.printCacheLockingInfo(cache1));
+ System.out.println("[Thread1] ** LOCK INFO cache2: " + CachePrinter.printCacheLockingInfo(cache2));
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ t1_ex = ex;
+ }
+ }
+ };
+
+ Thread t2 = new Thread("Thread2")
+ {
+ TransactionManager tm;
+
+ public void run()
+ {
+ try
+ {
+ TestingUtil.sleepThread(1000);// give Thread1 time to acquire the lock
+ tm = beginTransaction();
+ System.out.println("[Thread2] ** LOCK INFO cache1: " + CachePrinter.printCacheLockingInfo(cache1));
+ System.out.println("[Thread2] ** LOCK INFO cache2: " + CachePrinter.printCacheLockingInfo(cache2));
+ cache1.put("/bela/ban", "name", "Michelle Ban");
+ System.out.println("[Thread2] ** LOCK INFO cache1: " + CachePrinter.printCacheLockingInfo(cache1));
+ System.out.println("[Thread2] ** LOCK INFO cache2: " + CachePrinter.printCacheLockingInfo(cache2));
+ tm.commit();
+ System.out.println("[Thread2] ** LOCK INFO cache1: " + CachePrinter.printCacheLockingInfo(cache1));
+ System.out.println("[Thread2] ** LOCK INFO cache2: " + CachePrinter.printCacheLockingInfo(cache2));
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ t2_ex = ex;
+ }
+ }
+ };
+
+ // Let the game start
+ t1.start();
+ t2.start();
+
+ // Wait for threads to die
+ t1.join();
+ t2.join();
+
+ if (t1_ex != null)
+ {
+ fail("Thread1 failed: " + t1_ex);
+ }
+ if (t2_ex != null)
+ {
+ fail("Thread2 failed: " + t2_ex);
+ }
+
+ assertEquals("Michelle Ban", cache1.get("/bela/ban", "name"));
+ }
+
+ /**
+ * Should reproduce JBCACHE-32 problem (http://jira.jboss.com/jira/browse/JBCACHE-32)
+ */
+ public void testConcurrentCommitsWith1Thread() throws Exception
+ {
+ _testConcurrentCommits(1);
+ }
+
+ /**
+ * Should reproduce JBCACHE-32 problem (http://jira.jboss.com/jira/browse/JBCACHE-32)
+ */
+ public void testConcurrentCommitsWith5Threads() throws Exception
+ {
+ _testConcurrentCommits(5);
+ }
+
+ /**
+ * Should reproduce JBCACHE-32 problem (http://jira.jboss.com/jira/browse/JBCACHE-32)
+ */
+ private void _testConcurrentCommits(int num_threads)
+ {
+ Object myMutex = new Object();
+
+ final CacheSPI<Object, Object> c1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ final CacheSPI<Object, Object> c2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
+ c1.getConfiguration().setClusterName("TempCluster");
+ c2.getConfiguration().setClusterName("TempCluster");
+ c1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ c1.getConfiguration().setSyncCommitPhase(true);
+ c2.getConfiguration().setSyncCommitPhase(true);
+ c1.getConfiguration().setSyncRollbackPhase(true);
+ c2.getConfiguration().setSyncRollbackPhase(true);
+ c1.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ c2.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ c1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ c2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ c1.getConfiguration().setLockAcquisitionTimeout(5000);
+ c2.getConfiguration().setLockAcquisitionTimeout(5000);
+ c1.start();
+ c2.start();
+ final List<Exception> exceptions = new ArrayList<Exception>();
+
+ class MyThread extends Thread
+ {
+ final Object mutex;
+
+ public MyThread(String name, Object mutex)
+ {
+ super(name);
+ this.mutex = mutex;
+ }
+
+ public void run()
+ {
+ TransactionManager tm = null;
+
+ try
+ {
+ tm = beginTransaction(c1);
+ c1.put("/thread/" + getName(), null);
+ System.out.println("Thread " + getName() + " after put(): " + c1.toString());
+ System.out.println("Thread " + getName() + " waiting on mutex");
+ synchronized (mutex)
+ {
+ mutex.wait();
+ }
+ System.out.println("Thread " + getName() + " committing");
+ tm.commit();
+ System.out.println("Thread " + getName() + " committed successfully");
+ }
+ catch (Exception e)
+ {
+ exceptions.add(e);
+ }
+ finally
+ {
+ try
+ {
+ if (tm != null)
+ tm.rollback();
+ }
+ catch (Exception e)
+ {
+ // do nothing
+ }
+ }
+ }
+ }
+
+ MyThread[] threads = new MyThread[num_threads];
+ for (int i = 0; i < threads.length; i++)
+ {
+ threads[i] = new MyThread("#" + i, myMutex);
+ }
+ for (int i = 0; i < threads.length; i++)
+ {
+ MyThread thread = threads[i];
+ System.out.println("starting thread #" + i);
+ thread.start();
+ }
+
+ TestingUtil.sleepThread(6000);
+ synchronized (myMutex)
+ {
+ System.out.println("cache is " + CachePrinter.printCacheLockingInfo(c1));
+ System.out.println("******************* SIGNALLING THREADS ********************");
+ myMutex.notifyAll();
+ }
+
+ for (MyThread thread : threads)
+ {
+ try
+ {
+ thread.join();
+ System.out.println("Joined thread " + thread.getName());
+ }
+ catch (InterruptedException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ System.out.println("FINAL c1:\n" + CachePrinter.printCacheDetails(c1) + "\nlocks:\n" + CachePrinter.printCacheLockingInfo(c1));
+
+ assertEquals(0, c1.getNumberOfLocksHeld());
+ assertEquals(0, c2.getNumberOfLocksHeld());
+
+ c1.stop();
+ c2.stop();
+
+ // if(ex != null)
+ // {
+ // ex.printStackTrace();
+ // fail("Thread failed: " + ex);
+ // }
+
+ // we can only expect 1 thread to succeed. The others will fail. So, threads.length -1 exceptions.
+ // this is a timing issue - 2 threads still may succeed on a multi cpu system
+ // assertEquals(threads.length - 1, exceptions.size());
+
+ for (Exception exception : exceptions)
+ assertEquals(TimeoutException.class, exception.getClass());
+ }
+
+ /**
+ * Conncurrent put on 2 different instances.
+ */
+ public void testConcurrentPutsOnTwoInstances() throws Exception
+ {
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+ final CacheSPI<Object, Object> c1 = this.cache1;
+ final CacheSPI<Object, Object> c2 = this.cache2;
+
+ Thread t1 = new Thread()
+ {
+ TransactionManager tm;
+
+ public void run()
+ {
+ try
+ {
+ tm = beginTransaction();
+ c1.put("/ben/wang", "name", "Ben Wang");
+ TestingUtil.sleepThread(8000);
+ tm.commit();// This should go thru
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ t1_ex = ex;
+ }
+ }
+ };
+
+ Thread t2 = new Thread()
+ {
+ TransactionManager tm;
+
+ public void run()
+ {
+ try
+ {
+ TestingUtil.sleepThread(1000);// give Thread1 time to acquire the lock
+ tm = beginTransaction();
+ c2.put("/ben/wang", "name", "Ben Jr.");
+ tm.commit();// This will time out and rollback first because Thread1 has a tx going as well.
+ }
+ catch (RollbackException rollback_ex)
+ {
+ System.out.println("received rollback exception as expected");
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ t2_ex = ex;
+ }
+ }
+ };
+
+ // Let the game start
+ t1.start();
+ t2.start();
+
+ // Wait for thread to die but put an insurance of 5 seconds on it.
+ t1.join();
+ t2.join();
+
+ if (t1_ex != null)
+ {
+ fail("Thread1 failed: " + t1_ex);
+ }
+ if (t2_ex != null)
+ {
+ fail("Thread2 failed: " + t2_ex);
+ }
+ assertEquals("Ben Wang", c1.get("/ben/wang", "name"));
+ }
+
+ public void testPut() throws Exception
+ {
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+ final CacheSPI<Object, Object> c1 = this.cache1;
+
+ Thread t1 = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ lock.acquire();
+ System.out.println("-- t1 has lock");
+ c1.put("/a/b/c", "age", 38);
+ System.out.println("[Thread1] set value to 38");
+
+ System.out.println("-- t1 releases lock");
+ lock.release();
+ TestingUtil.sleepThread(300);
+ Thread.yield();
+
+ lock.acquire();
+ System.out.println("-- t1 has lock");
+ c1.put("/a/b/c", "age", 39);
+ System.out.println("[Thread1] set value to 39");
+
+ System.out.println("-- t1 releases lock");
+ lock.release();
+ assertEquals(39, c1.get("/a/b/c", "age"));
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ t1_ex = ex;
+ }
+ finally
+ {
+ lock.release();
+ }
+ }
+ };
+
+ Thread t2 = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ TestingUtil.sleepThread(100);
+ Thread.yield();
+ lock.acquire();
+ System.out.println("-- t2 has lock");
+ // Should replicate the value right away.
+ Integer val = (Integer) cache2.get("/a/b/c", "age");
+ System.out.println("[Thread2] value is " + val);
+ assertEquals(new Integer(38), val);
+ System.out.println("-- t2 releases lock");
+ lock.release();
+ TestingUtil.sleepThread(300);
+ Thread.yield();
+ TestingUtil.sleepThread(500);
+ lock.acquire();
+ System.out.println("-- t2 has lock");
+ val = (Integer) cache2.get("/a/b/c", "age");
+ System.out.println("-- t2 releases lock");
+ lock.release();
+ assertEquals(new Integer(39), val);
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ t2_ex = ex;
+ }
+ finally
+ {
+ lock.release();
+ }
+ }
+ };
+
+ // Let the game start
+ t1.start();
+ t2.start();
+
+ // Wait for thread to die but put an insurance of 5 seconds on it.
+ t1.join();
+ t2.join();
+ if (t1_ex != null)
+ {
+ fail("Thread1 failed: " + t1_ex);
+ }
+ if (t2_ex != null)
+ {
+ fail("Thread2 failed: " + t2_ex);
+ }
+ }
+
+ /**
+ * Test replicated cache with transaction. Idea is to have two threads running
+ * a local cache each that is replicating. Depending on whether cache1 commit/rollback or not,
+ * the cache2.get will get different values.
+ * Note that we have used sleep to interpose thread execution sequence.
+ * Although it's not fool proof, it is rather simple and intuitive.
+ */
+ public void testPutTx() throws Exception
+ {
+ TransactionManager tm;
+
+ try
+ {
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+ cache1.getConfiguration().setSyncCommitPhase(true);
+ cache2.getConfiguration().setSyncCommitPhase(true);
+ tm = beginTransaction();
+ cache1.put("/a/b/c", "age", 38);
+ cache1.put("/a/b/c", "age", 39);
+ Object val = cache2.get("/a/b/c", "age");// must be null as not yet committed
+ assertNull(val);
+ tm.commit();
+
+ tm = beginTransaction();
+ assertEquals(39, cache2.get("/a/b/c", "age"));// must not be null
+ tm.commit();
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ t1_ex = t;
+ }
+ finally
+ {
+ lock.release();
+ }
+ }
+
+ /**
+ * Have both cache1 and cache2 do add and commit. cache1 commit should time out
+ * since it can't obtain the lock when trying to replicate cache2. On the other hand,
+ * cache2 commit will succeed since now that cache1 is rollbacked and lock is
+ * released.
+ */
+ public void testPutTx1() throws Exception
+ {
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+ final CacheSPI<Object, Object> c1 = this.cache1;
+ Thread t1 = new Thread()
+ {
+ public void run()
+ {
+ TransactionManager tm;
+
+ try
+ {
+ lock.acquire();
+ tm = beginTransaction();
+ c1.put("/a/b/c", "age", 38);
+ c1.put("/a/b/c", "age", 39);
+ lock.release();
+
+ TestingUtil.sleepThread(300);
+ lock.acquire();
+ try
+ {
+ tm.commit();
+ }
+ catch (RollbackException ex)
+ {
+ System.out.println("[Thread1] received RollbackException, as expected. Rolling back changes");
+ }
+ finally
+ {
+ lock.release();
+ }
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ t1_ex = ex;
+ }
+ finally
+ {
+ lock.release();
+ }
+ }
+ };
+
+ Thread t2 = new Thread()
+ {
+ public void run()
+ {
+ TransactionManager tm;
+
+ try
+ {
+ sleep(200);
+ Thread.yield();
+ lock.acquire();
+ tm = beginTransaction();
+ assertNull(cache2.get("/a/b/c", "age"));// must be null as not yet committed
+ cache2.put("/a/b/c", "age", 40);
+ lock.release();
+
+ TestingUtil.sleepThread(300);
+ lock.acquire();
+ assertEquals(40, cache2.get("/a/b/c", "age"));// must not be null
+ tm.commit();
+ lock.release();
+
+ TestingUtil.sleepThread(1000);
+ tm = beginTransaction();
+ assertEquals("After cache2 commit", 40, cache2.get("/a/b/c", "age"));
+ tm.commit();
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ t2_ex = ex;
+ }
+ finally
+ {
+ lock.release();
+ }
+ }
+ };
+
+ // Let the game start
+ t1.start();
+ t2.start();
+
+ t1.join();
+ t2.join();
+
+ if (t1_ex != null)
+ {
+ fail("Thread1 failed: " + t1_ex);
+ }
+ if (t2_ex != null)
+ {
+ fail("Thread2 failed: " + t2_ex);
+ }
+ }
+
+ public void testPutTxWithRollback() throws Exception
+ {
+ initCaches(Configuration.CacheMode.REPL_SYNC);
+ final CacheSPI<Object, Object> c2 = this.cache1;
+ Thread t1 = new Thread()
+ {
+ public void run()
+ {
+ TransactionManager tm;
+
+ try
+ {
+ lock.acquire();
+ tm = beginTransaction();
+ c2.put("/a/b/c", "age", 38);
+ c2.put("/a/b/c", "age", 39);
+ lock.release();
+
+ TestingUtil.sleepThread(100);
+ lock.acquire();
+ tm.rollback();
+ lock.release();
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ t1_ex = ex;
+ }
+ finally
+ {
+ lock.release();
+ }
+ }
+ };
+
+ Thread t2 = new Thread()
+ {
+ public void run()
+ {
+ TransactionManager tm;
+
+ try
+ {
+ sleep(200);
+ Thread.yield();
+ lock.acquire();
+ tm = beginTransaction();
+ assertNull(cache2.get("/a/b/c", "age"));// must be null as not yet committed
+ lock.release();
+
+ TestingUtil.sleepThread(100);
+ lock.acquire();
+ assertNull(cache2.get("/a/b/c", "age"));// must be null as rolledback
+ tm.commit();
+ lock.release();
+ }
+ catch (Throwable ex)
+ {
+ ex.printStackTrace();
+ t2_ex = ex;
+ }
+ finally
+ {
+ lock.release();
+ }
+ }
+ };
+
+ // Let the game start
+ t1.start();
+ t2.start();
+
+ // Wait for thread to die but put an insurance of 5 seconds on it.
+ t1.join();
+ t2.join();
+ if (t1_ex != null)
+ {
+ fail("Thread1 failed: " + t1_ex);
+ }
+ if (t2_ex != null)
+ {
+ fail("Thread2 failed: " + t2_ex);
+ }
+ }
+
+ static class TransactionAborter implements Synchronization
+ {
+ Transaction ltx = null;
+
+ public TransactionAborter(Transaction ltx)
+ {
+ this.ltx = ltx;
+ }
+
+ public void beforeCompletion()
+ {
+ try
+ {
+ ltx.setRollbackOnly();
+ }
+ catch (SystemException e)
+ {
+ // who cares
+ }
+ }
+
+ public void afterCompletion(int status)
+ {
+ }
+ }
+
+ @CacheListener
+ static class CallbackListener
+ {
+
+ CacheSPI<Object, Object> callbackCache;
+ Object callbackKey;
+ Exception ex;
+ final Object mutex = new Object();
+
+ CallbackListener(CacheSPI<Object, Object> cache, Object callbackKey)
+ {
+ this.callbackCache = cache;
+ this.callbackKey = callbackKey;
+ cache.getNotifier().addCacheListener(this);
+ }
+
+ @NodeModified
+ public void nodeModified(NodeEvent e)
+ {
+ if (!e.isPre())
+ {
+ // Lock on a mutex so test can't check for an exception
+ // until the get call completes
+ synchronized (mutex)
+ {
+ try
+ {
+ callbackCache.get(e.getFqn(), callbackKey);
+ }
+ catch (CacheException exc)
+ {
+ exc.printStackTrace();
+ ex = exc;
+ }
+ }
+ }
+ }
+
+ Exception getCallbackException()
+ {
+ synchronized (mutex)
+ {
+ return ex;
+ }
+ }
+
+ }
+
+ static class TransactionAborterCallbackListener extends CallbackListener
+ {
+
+ TransactionManager callbackTM;
+
+ TransactionAborterCallbackListener(CacheSPI<Object, Object> cache, Object callbackKey)
+ {
+ super(cache, callbackKey);
+ callbackTM = callbackCache.getTransactionManager();
+ }
+
+ @NodeModified
+ public void nodeModified(NodeEvent ne)
+ {
+ if (!ne.isPre())
+ {
+ try
+ {
+ Transaction tx = callbackTM.getTransaction();
+ if (tx != null && tx.getStatus() == Status.STATUS_ACTIVE)
+ {
+ // this will rollback the transaction
+ tx.registerSynchronization(new TransactionAborter(tx));
+ }
+ else
+ {
+ super.nodeModified(ne);
+ }
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ if (ex == null)
+ {
+ ex = e;
+ }
+ }
+ }
+ }
+
+ }
+
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/replicated/PessimisticSyncReplTxTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTxTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -1,1327 +0,0 @@
-/*
- *
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.replicated;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.lock.TimeoutException;
-import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.notifications.annotation.CacheListener;
-import org.jboss.cache.notifications.annotation.NodeModified;
-import org.jboss.cache.notifications.event.NodeEvent;
-import org.jboss.cache.transaction.TransactionSetup;
-import org.jboss.cache.util.CachePrinter;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.Semaphore;
-
-/**
- * Replicated unit test for sync transactional CacheImpl
- * Note: we use DummyTransactionManager for Tx purpose instead of relying on
- * jta.
- *
- * @version $Revision$
- */
-@Test(groups = {"functional", "jgroups", "transaction"})
-public class SyncReplTxTest
-{
- private static Log log = LogFactory.getLog(SyncReplTxTest.class);
- private CacheSPI<Object, Object> cache1;
- private CacheSPI<Object, Object> cache2;
-
- Semaphore lock;
- private Throwable t1_ex;
- private Throwable t2_ex;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
- t1_ex = t2_ex = null;
- lock = new Semaphore(1);
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
- {
- TransactionSetup.cleanup();
- destroyCaches();
- }
-
- private TransactionManager beginTransaction() throws SystemException, NotSupportedException
- {
- return beginTransaction(cache1);
- }
-
- private TransactionManager beginTransaction(CacheSPI c) throws SystemException, NotSupportedException
- {
- TransactionManager mgr = c.getConfiguration().getRuntimeConfig().getTransactionManager();
- mgr.begin();
- return mgr;
- }
-
- private void initCaches(Configuration.CacheMode caching_mode) throws Exception
- {
- cache1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- cache1.getConfiguration().setCacheMode(caching_mode);
- cache2.getConfiguration().setCacheMode(caching_mode);
- cache1.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache2.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
-
- cache1.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache2.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache1.getConfiguration().setLockAcquisitionTimeout(5000);
- cache2.getConfiguration().setLockAcquisitionTimeout(5000);
-
- configureMultiplexer(cache1);
- configureMultiplexer(cache2);
-
- cache1.start();
- cache2.start();
-
- validateMultiplexer(cache1);
- validateMultiplexer(cache2);
- }
-
- /**
- * Provides a hook for multiplexer integration. This default implementation
- * is a no-op; subclasses that test mux integration would override
- * to integrate the given cache with a multiplexer.
- * <p/>
- * param cache a cache that has been configured but not yet created.
- *
- * @param cache cache
- * @throws Exception exception
- */
- protected void configureMultiplexer(Cache cache) throws Exception
- {
- // default does nothing
- }
-
- /**
- * Provides a hook to check that the cache's channel came from the
- * multiplexer, or not, as expected. This default impl asserts that
- * the channel did not come from the multiplexer.
- *
- * @param cache a cache that has already been started
- */
- protected void validateMultiplexer(Cache cache)
- {
- assertFalse("Cache is not using multiplexer", cache.getConfiguration().isUsingMultiplexer());
- }
-
- private void destroyCaches()
- {
- if (cache1 != null)
- {
- cache1.stop();
- }
- if (cache2 != null)
- {
- cache2.stop();
- }
- cache1 = null;
- cache2 = null;
- }
-
- public void testLockRemoval() throws Exception
- {
- initCaches(Configuration.CacheMode.REPL_SYNC);
- cache1.getConfiguration().setSyncCommitPhase(true);
- TestingUtil.extractLockManager(cache1).unlockAll(cache1.getRoot());
- TransactionManager tm = beginTransaction();
- cache1.put("/bela/ban", "name", "Bela Ban");
- assertEquals(3, cache1.getNumberOfLocksHeld());
- assertEquals(0, cache2.getNumberOfLocksHeld());
- tm.commit();
- assertEquals(0, cache1.getNumberOfLocksHeld());
- assertEquals(0, cache2.getNumberOfLocksHeld());
- }
-
- public void testSyncRepl() throws Exception
- {
- Integer age;
- Transaction tx;
-
- initCaches(Configuration.CacheMode.REPL_SYNC);
- cache1.getConfiguration().setSyncCommitPhase(true);
- cache2.getConfiguration().setSyncCommitPhase(true);
-
- TransactionManager mgr = beginTransaction();
- cache1.put("/a/b/c", "age", 38);
- tx = mgr.suspend();
- assertNull("age on cache2 must be null as the TX has not yet been committed", cache2.get("/a/b/c", "age"));
- log.debug("cache1: locks held before commit: " + CachePrinter.printCacheLockingInfo(cache1));
- log.debug("cache2: locks held before commit: " + CachePrinter.printCacheLockingInfo(cache2));
- mgr.resume(tx);
- mgr.commit();
- log.debug("cache1: locks held after commit: " + CachePrinter.printCacheLockingInfo(cache1));
- log.debug("cache2: locks held after commit: " + CachePrinter.printCacheLockingInfo(cache2));
-
- // value on cache2 must be 38
- age = (Integer) cache2.get("/a/b/c", "age");
- assertNotNull("\"age\" obtained from cache2 must be non-null ", age);
- assertTrue("\"age\" must be 38", age == 38);
- }
-
- public void testSimplePut() throws Exception
- {
- initCaches(Configuration.CacheMode.REPL_SYNC);
-
- cache1.put("/JSESSION/localhost/192.168.1.10:32882/Courses/0", "Instructor", "Ben Wang");
-
- cache1.put("/JSESSION/localhost/192.168.1.10:32882/1", "Number", 10);
- }
-
- public void testSimpleTxPut() throws Exception
- {
- TransactionManager tm;
- final Fqn NODE1 = Fqn.fromString("/one/two/three");
- initCaches(Configuration.CacheMode.REPL_SYNC);
-
- tm = beginTransaction();
- cache1.put(NODE1, "age", 38);
- System.out.println("TransactionTable for cache1 after cache1.put():\n" + cache1.getTransactionTable().toString(true));
- tm.commit();
-
- /*
- tx=beginTransaction();
- cache1.put(NODE1, "age", new Integer(38));
- cache1.put(NODE2, "name", "Ben of The Far East");
- cache1.put(NODE3, "key", "UnknowKey");
- System.out.println("TransactionTable for cache1 after cache1.put():\n" + cache1.getTransactionTable().toString(true));
-
- tx.commit();
- */
-
- /*
- tx=beginTransaction();
- cache1.put(NODE1, "age", new Integer(38));
- cache1.put(NODE1, "AOPInstance", new AOPInstance());
- cache1.put(NODE2, "AOPInstance", new AOPInstance());
- cache1.put(NODE1, "AOPInstance", new AOPInstance());
- tx.commit();
- System.out.println("TransactionTable for cache1 after cache1.put():\n" + cache1.getTransactionTable().toString(true));
- */
- }
-
- public void testSyncReplWithModficationsOnBothCaches() throws Exception
- {
- TransactionManager tm;
- final Fqn NODE1 = Fqn.fromString("/one/two/three");
- final Fqn NODE2 = Fqn.fromString("/eins/zwei/drei");
-
- initCaches(Configuration.CacheMode.REPL_SYNC);
-
- // create roots first
- cache1.put("/one/two", null);
- cache2.put("/eins/zwei", null);
-
- cache1.getConfiguration().setSyncCommitPhase(true);
- cache2.getConfiguration().setSyncCommitPhase(true);
-
- tm = beginTransaction();
- cache1.put(NODE1, "age", 38);
- System.out.println("TransactionTable for cache1 after cache1.put():\n" + cache1.getTransactionTable().toString(true));
-
- cache2.put(NODE2, "age", 39);
- System.out.println("TransactionTable for cache2 after cache2.put():\n" + cache2.getTransactionTable().toString(true));
-
- System.out.println("cache1 before commit:\n" + CachePrinter.printCacheLockingInfo(cache1));
- System.out.println("cache2 before commit:\n" + CachePrinter.printCacheLockingInfo(cache2));
-
- try
- {
- tm.commit();
- fail("Should not succeed with SERIALIZABLE semantics");
- }
- catch (Exception e)
- {
- //should be a classic deadlock here.
- }
-
- System.out.println("cache1 after commit:\n" + CachePrinter.printCacheLockingInfo(cache1));
- System.out.println("cache2 after commit:\n" + CachePrinter.printCacheLockingInfo(cache2));
-
- /*
- assertTrue(cache1.exists(NODE1));
- assertTrue(cache1.exists(NODE2));
- assertTrue(cache1.exists(NODE1));
- assertTrue(cache2.exists(NODE2));
-
- age = (Integer) cache1.get(NODE1, "age");
- assertNotNull("\"age\" obtained from cache1 for " + NODE1 + " must be non-null ", age);
- assertTrue("\"age\" must be 38", age == 38);
-
- age = (Integer) cache2.get(NODE1, "age");
- assertNotNull("\"age\" obtained from cache2 for " + NODE1 + " must be non-null ", age);
- assertTrue("\"age\" must be 38", age == 38);
-
- age = (Integer) cache1.get(NODE2, "age");
- assertNotNull("\"age\" obtained from cache1 for " + NODE2 + " must be non-null ", age);
- assertTrue("\"age\" must be 39", age == 39);
-
- age = (Integer) cache2.get(NODE2, "age");
- assertNotNull("\"age\" obtained from cache2 for " + NODE2 + " must be non-null ", age);
- assertTrue("\"age\" must be 39", age == 39);
- */
-
- assertEquals(0, cache1.getNumberOfLocksHeld());
- assertEquals(0, cache2.getNumberOfLocksHeld());
- System.out.println("TransactionTable for cache1:\n" + cache1.getTransactionTable().toString(true));
- System.out.println("TransactionTable for cache2:\n" + cache2.getTransactionTable().toString(true));
- }
-
- public void testSyncReplWithModficationsOnBothCachesSameData() throws Exception
- {
- TransactionManager tm;
- final Fqn NODE = Fqn.fromString("/one/two/three");
- initCaches(Configuration.CacheMode.REPL_SYNC);
- tm = beginTransaction();
- cache1.put(NODE, "age", 38);
- System.out.println("TransactionTable for cache1 after cache1.put():\n" + cache1.getTransactionTable().toString(true));
-
- cache2.put(NODE, "age", 39);
- System.out.println("TransactionTable for cache2 after cache2.put():\n" + cache2.getTransactionTable().toString(true));
-
- System.out.println("cache1 before commit:\n" + CachePrinter.printCacheLockingInfo(cache1));
- System.out.println("cache2 before commit:\n" + CachePrinter.printCacheLockingInfo(cache2));
-
- try
- {
- tm.commit();
- fail("commit should throw a RollbackException, we should not get here");
- }
- catch (RollbackException rollback)
- {
- System.out.println("Transaction was rolled back, this is correct");
- }
-
- System.out.println("cache1 after commit:\n" + CachePrinter.printCacheLockingInfo(cache1));
- System.out.println("cache2 after commit:\n" + CachePrinter.printCacheLockingInfo(cache2));
-
- assertEquals(0, cache1.getNumberOfLocksHeld());
- assertEquals(0, cache2.getNumberOfLocksHeld());
-
- assertEquals(0, cache1.getNumberOfNodes());
- assertEquals(0, cache2.getNumberOfNodes());
- }
-
- public void testSyncReplWithModficationsOnBothCachesWithRollback() throws Exception
- {
- TransactionManager tm;
- final Fqn fqn1 = Fqn.fromString("/one/two/three");
- final Fqn fqn2 = Fqn.fromString("/eins/zwei/drei");
-
- initCaches(Configuration.CacheMode.REPL_SYNC);
-
- cache1.getConfiguration().setSyncRollbackPhase(true);
- cache2.getConfiguration().setSyncRollbackPhase(true);
-
- tm = beginTransaction();
- cache1.put(fqn1, "age", 38);
- cache2.put(fqn2, "age", 39);
-
- System.out.println("cache1 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache1));
- System.out.println("cache2 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache2));
-
- // this will rollback the transaction
- Transaction tx = tm.getTransaction();
- tx.registerSynchronization(new TransactionAborter(tx));
-
- try
- {
- tm.commit();
- fail("commit should throw a RollbackException, we should not get here");
- }
- catch (RollbackException rollback)
- {
- System.out.println("Transaction was rolled back, this is correct");
- }
-
- System.out.println("cache1 (after rollback):\n" + CachePrinter.printCacheLockingInfo(cache1));
- System.out.println("cache2 (after rollback):\n" + CachePrinter.printCacheLockingInfo(cache2));
-
- assertEquals(0, cache1.getNumberOfLocksHeld());
- assertEquals(0, cache2.getNumberOfLocksHeld());
-
- assertEquals(0, cache1.getNumberOfNodes());
- assertEquals(0, cache2.getNumberOfNodes());
- }
-
- /**
- * Test for JBCACHE-359 -- does a callback into cache from a listener
- * interfere with transaction rollback.
- *
- * @throws Exception
- */
-
- // Is this test still valid after JBCACHE-1022 ?
- // public void testSyncReplWithRollbackAndListener() throws Exception
- // {
- // Transaction tx;
- // final Fqn NODE1 = Fqn.fromString("/one/two/three");
- //
- // initCaches(Configuration.CacheMode.REPL_SYNC);
- //
- // cache1.getConfiguration().setSyncRollbackPhase(true);
- // cache2.getConfiguration().setSyncRollbackPhase(true);
- //
- // // Test with a rollback on the sending side
- //
- // CallbackListener cbl1 = new CallbackListener(cache1, "age");
- // CallbackListener cbl2 = new CallbackListener(cache2, "age");
- //
- // tx = beginTransaction();
- // cache1.put(NODE1, "age", 38);
- //
- // System.out.println("cache1 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache1));
- // System.out.println("cache2 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache2));
- //
- // // this will rollback the transaction
- // tx.registerSynchronization(new TransactionAborter(tx));
- //
- // try
- // {
- // tx.commit();
- // fail("commit should throw a RollbackException, we should not get here");
- // }
- // catch (RollbackException rollback)
- // {
- // rollback.printStackTrace();
- // System.out.println("Transaction was rolled back, this is correct");
- // }
- //
- // // Sleep, as the rollback call to cache2 is async
- // TestingUtil.sleepThread(1000);
- //
- // System.out.println("cache1 (after rollback):\n" + CachePrinter.printCacheLockingInfo(cache1));
- // System.out.println("cache2 (after rollback):\n" + CachePrinter.printCacheLockingInfo(cache2));
- //
- // assertNull(cbl1.getCallbackException());
- // assertNull(cbl2.getCallbackException());
- //
- // assertEquals(0, cache1.getNumberOfLocksHeld());
- // assertEquals(0, cache2.getNumberOfLocksHeld());
- //
- // assertEquals(0, cache1.getNumberOfNodes());
- // assertEquals(0, cache2.getNumberOfNodes());
- //
- // // Test with a rollback on the receiving side
- //
- // cache2.getNotifier().removeCacheListener(cbl2);
- // // listener aborts any active tx
- // cbl2 = new TransactionAborterCallbackListener(cache2, "age");
- //
- // tx = beginTransaction();
- // cache1.put(NODE1, "age", 38);
- //
- // System.out.println("cache1 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache1));
- // System.out.println("cache2 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache2));
- //
- // tx.commit();
- //
- // // Sleep, as the commit call to cache2 is async
- // TestingUtil.sleepThread(1000);
- //
- // System.out.println("cache1 (after rollback):\n" + CachePrinter.printCacheLockingInfo(cache1));
- // System.out.println("cache2 (after rollback):\n" + CachePrinter.printCacheLockingInfo(cache2));
- //
- // assertNull(cbl1.getCallbackException());
- // assertNull(cbl2.getCallbackException());
- //
- // assertEquals(0, cache1.getNumberOfLocksHeld());
- // assertEquals(0, cache2.getNumberOfLocksHeld());
- //
- // // cache1 didn't fail, so should have 3 nodes
- // assertEquals(3, cache1.getNumberOfNodes());
- // assertEquals(0, cache2.getNumberOfNodes());
- //
- // }
-
- /**
- * Test for JBCACHE-361 -- does marking a tx on the remote side
- * rollback-only cause a rollback on the originating side?
- */
- public void testSyncReplWithRemoteRollback() throws Exception
- {
- TransactionManager tm;
- final Fqn NODE1 = Fqn.fromString("/one/two/three");
-
- initCaches(Configuration.CacheMode.REPL_SYNC);
-
- cache1.getConfiguration().setSyncRollbackPhase(true);
- cache2.getConfiguration().setSyncRollbackPhase(true);
-
- // Test with a rollback on the remote side
-
- // listener aborts any active tx
- //TransactionAborterListener tal = new TransactionAborterListener(cache2);
-
- tm = beginTransaction();
- cache1.put(NODE1, "age", 38);
-
- System.out.println("cache1 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache1));
- System.out.println("cache2 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache2));
-
- // instead of a listener lets just get a WL on ROOT on cache2. And hold on to it.
- Transaction tx = tm.suspend();
-
- tm.begin();
- cache2.getRoot().put("x", "y");
- Transaction tx2 = cache2.getTransactionManager().suspend();
-
- System.out.println("cache2 (before commit):\n" + CachePrinter.printCacheLockingInfo(cache2));
- tm.resume(tx);
-
- try
- {
- tm.commit();
- fail("commit should throw a RollbackException, we should not get here");
- }
- catch (RollbackException rollback)
- {
- System.out.println("Transaction was rolled back, this is correct");
- }
- finally
- {
- tm.resume(tx2);
- tm.rollback();
- }
-
- // Sleep, as the commit call to cache2 is async
- TestingUtil.sleepThread(1000);
-
- System.out.println("cache1 (after rollback):\n" + CachePrinter.printCacheLockingInfo(cache1));
- System.out.println("cache2 (after rollback):\n" + CachePrinter.printCacheLockingInfo(cache2));
-
- //assertNull(tal.getCallbackException());
-
- assertEquals(0, cache1.getNumberOfLocksHeld());
- assertEquals(0, cache2.getNumberOfLocksHeld());
-
- assertEquals(0, cache1.getNumberOfNodes());
- assertEquals(0, cache2.getNumberOfNodes());
-
- }
-
- public void testASyncRepl() throws Exception
- {
- Integer age;
- TransactionManager tm;
-
- initCaches(Configuration.CacheMode.REPL_ASYNC);
-
- tm = beginTransaction();
- cache1.put("/a/b/c", "age", 38);
- Thread.sleep(1000);
- assertNull("age on cache2 must be null as the TX has not yet been committed", cache2.get("/a/b/c", "age"));
- tm.commit();
- Thread.sleep(1000);
-
- // value on cache2 must be 38
- age = (Integer) cache2.get("/a/b/c", "age");
- assertNotNull("\"age\" obtained from cache2 is null ", age);
- assertTrue("\"age\" must be 38", age == 38);
-
- }
-
- /**
- * Tests concurrent modifications: thread1 succeeds and thread2 is blocked until thread1 is done, and then succeeds
- * too. However, this is flawed with the introduction of interceptors, here's why.<br/>
- * <ul>
- * <li>Thread1 acquires the lock for /bela/ban on cache1
- * <li>Thread2 blocks on Thread1 to release the lock
- * <li>Thread1 commits: this means the TransactionInterceptor and the ReplicationInterceptor are called in
- * the sequence in which they registered. Unfortunately, the TransactionInterceptor registered first. In the
- * PREPARE phase, the ReplicationInterceptor calls prepare() in cache2 synchronously. The TxInterceptor
- * does nothing. The the COMMIT phase, the TxInterceptor commits the data by releasing the locks locally and
- * then the ReplicationInterceptor sends an asynchronous COMMIT to cache2.
- * <li>Because the TxInterceptor for Thread1 releases the locks locally <em>before</em> sending the async COMMIT,
- * Thread2 is able to acquire the lock for /bela/ban in cache1 and then starts the PREPARE phase by sending a
- * synchronous PREPARE to cache2. If this PREPARE arrives at cache2 <em>before</em> the COMMIT from Thread1,
- * the PREPARE will block because it attempts to acquire a lock on /bela/ban on cache2 still held by Thread1
- * (which would be released by Thread1's COMMIT). This results in deadlock, which is resolved by Thread2 running
- * into a timeout with subsequent rollback and Thread1 succeeding.<br/>
- * </ul>
- * There are 3 solutions to this:
- * <ol>
- * <li>Do nothing. This is standard behavior for concurrent access to the same data. Same thing if the 2 threads
- * operated on the same data in <em>separate</em> caches, e.g. Thread1 on /bela/ban in cache1 and Thread2 on
- * /bela/ban in cache2. The semantics of Tx commit as handled by the interceptors is: after tx1.commit() returns
- * the locks held by tx1 are release and a COMMIT message is on the way (if sent asynchronously).
- * <li>Force an order over TxInterceptor and ReplicationInterceptor. This would require ReplicationInterceptor
- * to always be fired first on TX commit. Downside: the interceptors have an implicit dependency, which is not
- * nice.
- * <li>Priority-order requests at the receiver; e.g. a COMMIT could release a blocked PREPARE. This is bad because
- * it violates JGroups' FIFO ordering guarantees.
- * </ol>
- * I'm currently investigating solution #2, ie. creating an OrderedSynchronizationHandler, which allows other
- * SynchronizationHandlers to register (atHead, atTail), and the OrderedSynchronizationHandler would call the
- * SynchronizationHandler in the order in which they are defined.
- *
- * @throws Exception exception
- */
- public void testConcurrentPuts() throws Exception
- {
- initCaches(Configuration.CacheMode.REPL_SYNC);
- cache1.getConfiguration().setSyncCommitPhase(true);
-
- Thread t1 = new Thread("Thread1")
- {
- TransactionManager tm;
-
- public void run()
- {
- try
- {
- tm = beginTransaction();
- cache1.put("/bela/ban", "name", "Bela Ban");
- TestingUtil.sleepThread(2000);// Thread2 will be blocked until we commit
- tm.commit();
- System.out.println("[Thread1] ** LOCK INFO cache1: " + CachePrinter.printCacheLockingInfo(cache1));
- System.out.println("[Thread1] ** LOCK INFO cache2: " + CachePrinter.printCacheLockingInfo(cache2));
- }
- catch (Throwable ex)
- {
- ex.printStackTrace();
- t1_ex = ex;
- }
- }
- };
-
- Thread t2 = new Thread("Thread2")
- {
- TransactionManager tm;
-
- public void run()
- {
- try
- {
- TestingUtil.sleepThread(1000);// give Thread1 time to acquire the lock
- tm = beginTransaction();
- System.out.println("[Thread2] ** LOCK INFO cache1: " + CachePrinter.printCacheLockingInfo(cache1));
- System.out.println("[Thread2] ** LOCK INFO cache2: " + CachePrinter.printCacheLockingInfo(cache2));
- cache1.put("/bela/ban", "name", "Michelle Ban");
- System.out.println("[Thread2] ** LOCK INFO cache1: " + CachePrinter.printCacheLockingInfo(cache1));
- System.out.println("[Thread2] ** LOCK INFO cache2: " + CachePrinter.printCacheLockingInfo(cache2));
- tm.commit();
- System.out.println("[Thread2] ** LOCK INFO cache1: " + CachePrinter.printCacheLockingInfo(cache1));
- System.out.println("[Thread2] ** LOCK INFO cache2: " + CachePrinter.printCacheLockingInfo(cache2));
- }
- catch (Throwable ex)
- {
- ex.printStackTrace();
- t2_ex = ex;
- }
- }
- };
-
- // Let the game start
- t1.start();
- t2.start();
-
- // Wait for threads to die
- t1.join();
- t2.join();
-
- if (t1_ex != null)
- {
- fail("Thread1 failed: " + t1_ex);
- }
- if (t2_ex != null)
- {
- fail("Thread2 failed: " + t2_ex);
- }
-
- assertEquals("Michelle Ban", cache1.get("/bela/ban", "name"));
- }
-
- /**
- * Should reproduce JBCACHE-32 problem (http://jira.jboss.com/jira/browse/JBCACHE-32)
- */
- public void testConcurrentCommitsWith1Thread() throws Exception
- {
- _testConcurrentCommits(1);
- }
-
- /**
- * Should reproduce JBCACHE-32 problem (http://jira.jboss.com/jira/browse/JBCACHE-32)
- */
- public void testConcurrentCommitsWith5Threads() throws Exception
- {
- _testConcurrentCommits(5);
- }
-
- /**
- * Should reproduce JBCACHE-32 problem (http://jira.jboss.com/jira/browse/JBCACHE-32)
- */
- private void _testConcurrentCommits(int num_threads)
- {
- Object myMutex = new Object();
-
- final CacheSPI<Object, Object> c1 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- final CacheSPI<Object, Object> c2 = (CacheSPI<Object, Object>) new DefaultCacheFactory<Object, Object>().createCache(false);
- c1.getConfiguration().setClusterName("TempCluster");
- c2.getConfiguration().setClusterName("TempCluster");
- c1.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- c2.getConfiguration().setCacheMode(Configuration.CacheMode.REPL_SYNC);
- c1.getConfiguration().setSyncCommitPhase(true);
- c2.getConfiguration().setSyncCommitPhase(true);
- c1.getConfiguration().setSyncRollbackPhase(true);
- c2.getConfiguration().setSyncRollbackPhase(true);
- c1.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
- c2.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
- c1.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- c2.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- c1.getConfiguration().setLockAcquisitionTimeout(5000);
- c2.getConfiguration().setLockAcquisitionTimeout(5000);
- c1.start();
- c2.start();
- final List<Exception> exceptions = new ArrayList<Exception>();
-
- class MyThread extends Thread
- {
- final Object mutex;
-
- public MyThread(String name, Object mutex)
- {
- super(name);
- this.mutex = mutex;
- }
-
- public void run()
- {
- TransactionManager tm = null;
-
- try
- {
- tm = beginTransaction(c1);
- c1.put("/thread/" + getName(), null);
- System.out.println("Thread " + getName() + " after put(): " + c1.toString());
- System.out.println("Thread " + getName() + " waiting on mutex");
- synchronized (mutex)
- {
- mutex.wait();
- }
- System.out.println("Thread " + getName() + " committing");
- tm.commit();
- System.out.println("Thread " + getName() + " committed successfully");
- }
- catch (Exception e)
- {
- exceptions.add(e);
- }
- finally
- {
- try
- {
- if (tm != null)
- tm.rollback();
- }
- catch (Exception e)
- {
- // do nothing
- }
- }
- }
- }
-
- MyThread[] threads = new MyThread[num_threads];
- for (int i = 0; i < threads.length; i++)
- {
- threads[i] = new MyThread("#" + i, myMutex);
- }
- for (int i = 0; i < threads.length; i++)
- {
- MyThread thread = threads[i];
- System.out.println("starting thread #" + i);
- thread.start();
- }
-
- TestingUtil.sleepThread(6000);
- synchronized (myMutex)
- {
- System.out.println("cache is " + CachePrinter.printCacheLockingInfo(c1));
- System.out.println("******************* SIGNALLING THREADS ********************");
- myMutex.notifyAll();
- }
-
- for (MyThread thread : threads)
- {
- try
- {
- thread.join();
- System.out.println("Joined thread " + thread.getName());
- }
- catch (InterruptedException e)
- {
- e.printStackTrace();
- }
- }
-
- System.out.println("FINAL c1:\n" + CachePrinter.printCacheDetails(c1) + "\nlocks:\n" + CachePrinter.printCacheLockingInfo(c1));
-
- assertEquals(0, c1.getNumberOfLocksHeld());
- assertEquals(0, c2.getNumberOfLocksHeld());
-
- c1.stop();
- c2.stop();
-
- // if(ex != null)
- // {
- // ex.printStackTrace();
- // fail("Thread failed: " + ex);
- // }
-
- // we can only expect 1 thread to succeed. The others will fail. So, threads.length -1 exceptions.
- // this is a timing issue - 2 threads still may succeed on a multi cpu system
- // assertEquals(threads.length - 1, exceptions.size());
-
- for (Exception exception : exceptions)
- assertEquals(TimeoutException.class, exception.getClass());
- }
-
- /**
- * Conncurrent put on 2 different instances.
- */
- public void testConcurrentPutsOnTwoInstances() throws Exception
- {
- initCaches(Configuration.CacheMode.REPL_SYNC);
- final CacheSPI<Object, Object> c1 = this.cache1;
- final CacheSPI<Object, Object> c2 = this.cache2;
-
- Thread t1 = new Thread()
- {
- TransactionManager tm;
-
- public void run()
- {
- try
- {
- tm = beginTransaction();
- c1.put("/ben/wang", "name", "Ben Wang");
- TestingUtil.sleepThread(8000);
- tm.commit();// This should go thru
- }
- catch (Throwable ex)
- {
- ex.printStackTrace();
- t1_ex = ex;
- }
- }
- };
-
- Thread t2 = new Thread()
- {
- TransactionManager tm;
-
- public void run()
- {
- try
- {
- TestingUtil.sleepThread(1000);// give Thread1 time to acquire the lock
- tm = beginTransaction();
- c2.put("/ben/wang", "name", "Ben Jr.");
- tm.commit();// This will time out and rollback first because Thread1 has a tx going as well.
- }
- catch (RollbackException rollback_ex)
- {
- System.out.println("received rollback exception as expected");
- }
- catch (Throwable ex)
- {
- ex.printStackTrace();
- t2_ex = ex;
- }
- }
- };
-
- // Let the game start
- t1.start();
- t2.start();
-
- // Wait for thread to die but put an insurance of 5 seconds on it.
- t1.join();
- t2.join();
-
- if (t1_ex != null)
- {
- fail("Thread1 failed: " + t1_ex);
- }
- if (t2_ex != null)
- {
- fail("Thread2 failed: " + t2_ex);
- }
- assertEquals("Ben Wang", c1.get("/ben/wang", "name"));
- }
-
- public void testPut() throws Exception
- {
- initCaches(Configuration.CacheMode.REPL_SYNC);
- final CacheSPI<Object, Object> c1 = this.cache1;
-
- Thread t1 = new Thread()
- {
- public void run()
- {
- try
- {
- lock.acquire();
- System.out.println("-- t1 has lock");
- c1.put("/a/b/c", "age", 38);
- System.out.println("[Thread1] set value to 38");
-
- System.out.println("-- t1 releases lock");
- lock.release();
- TestingUtil.sleepThread(300);
- Thread.yield();
-
- lock.acquire();
- System.out.println("-- t1 has lock");
- c1.put("/a/b/c", "age", 39);
- System.out.println("[Thread1] set value to 39");
-
- System.out.println("-- t1 releases lock");
- lock.release();
- assertEquals(39, c1.get("/a/b/c", "age"));
- }
- catch (Throwable ex)
- {
- ex.printStackTrace();
- t1_ex = ex;
- }
- finally
- {
- lock.release();
- }
- }
- };
-
- Thread t2 = new Thread()
- {
- public void run()
- {
- try
- {
- TestingUtil.sleepThread(100);
- Thread.yield();
- lock.acquire();
- System.out.println("-- t2 has lock");
- // Should replicate the value right away.
- Integer val = (Integer) cache2.get("/a/b/c", "age");
- System.out.println("[Thread2] value is " + val);
- assertEquals(new Integer(38), val);
- System.out.println("-- t2 releases lock");
- lock.release();
- TestingUtil.sleepThread(300);
- Thread.yield();
- TestingUtil.sleepThread(500);
- lock.acquire();
- System.out.println("-- t2 has lock");
- val = (Integer) cache2.get("/a/b/c", "age");
- System.out.println("-- t2 releases lock");
- lock.release();
- assertEquals(new Integer(39), val);
- }
- catch (Throwable ex)
- {
- ex.printStackTrace();
- t2_ex = ex;
- }
- finally
- {
- lock.release();
- }
- }
- };
-
- // Let the game start
- t1.start();
- t2.start();
-
- // Wait for thread to die but put an insurance of 5 seconds on it.
- t1.join();
- t2.join();
- if (t1_ex != null)
- {
- fail("Thread1 failed: " + t1_ex);
- }
- if (t2_ex != null)
- {
- fail("Thread2 failed: " + t2_ex);
- }
- }
-
- /**
- * Test replicated cache with transaction. Idea is to have two threads running
- * a local cache each that is replicating. Depending on whether cache1 commit/rollback or not,
- * the cache2.get will get different values.
- * Note that we have used sleep to interpose thread execution sequence.
- * Although it's not fool proof, it is rather simple and intuitive.
- */
- public void testPutTx() throws Exception
- {
- TransactionManager tm;
-
- try
- {
- initCaches(Configuration.CacheMode.REPL_SYNC);
- cache1.getConfiguration().setSyncCommitPhase(true);
- cache2.getConfiguration().setSyncCommitPhase(true);
- tm = beginTransaction();
- cache1.put("/a/b/c", "age", 38);
- cache1.put("/a/b/c", "age", 39);
- Object val = cache2.get("/a/b/c", "age");// must be null as not yet committed
- assertNull(val);
- tm.commit();
-
- tm = beginTransaction();
- assertEquals(39, cache2.get("/a/b/c", "age"));// must not be null
- tm.commit();
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- t1_ex = t;
- }
- finally
- {
- lock.release();
- }
- }
-
- /**
- * Have both cache1 and cache2 do add and commit. cache1 commit should time out
- * since it can't obtain the lock when trying to replicate cache2. On the other hand,
- * cache2 commit will succeed since now that cache1 is rollbacked and lock is
- * released.
- */
- public void testPutTx1() throws Exception
- {
- initCaches(Configuration.CacheMode.REPL_SYNC);
- final CacheSPI<Object, Object> c1 = this.cache1;
- Thread t1 = new Thread()
- {
- public void run()
- {
- TransactionManager tm;
-
- try
- {
- lock.acquire();
- tm = beginTransaction();
- c1.put("/a/b/c", "age", 38);
- c1.put("/a/b/c", "age", 39);
- lock.release();
-
- TestingUtil.sleepThread(300);
- lock.acquire();
- try
- {
- tm.commit();
- }
- catch (RollbackException ex)
- {
- System.out.println("[Thread1] received RollbackException, as expected. Rolling back changes");
- }
- finally
- {
- lock.release();
- }
- }
- catch (Throwable ex)
- {
- ex.printStackTrace();
- t1_ex = ex;
- }
- finally
- {
- lock.release();
- }
- }
- };
-
- Thread t2 = new Thread()
- {
- public void run()
- {
- TransactionManager tm;
-
- try
- {
- sleep(200);
- Thread.yield();
- lock.acquire();
- tm = beginTransaction();
- assertNull(cache2.get("/a/b/c", "age"));// must be null as not yet committed
- cache2.put("/a/b/c", "age", 40);
- lock.release();
-
- TestingUtil.sleepThread(300);
- lock.acquire();
- assertEquals(40, cache2.get("/a/b/c", "age"));// must not be null
- tm.commit();
- lock.release();
-
- TestingUtil.sleepThread(1000);
- tm = beginTransaction();
- assertEquals("After cache2 commit", 40, cache2.get("/a/b/c", "age"));
- tm.commit();
- }
- catch (Throwable ex)
- {
- ex.printStackTrace();
- t2_ex = ex;
- }
- finally
- {
- lock.release();
- }
- }
- };
-
- // Let the game start
- t1.start();
- t2.start();
-
- t1.join();
- t2.join();
-
- if (t1_ex != null)
- {
- fail("Thread1 failed: " + t1_ex);
- }
- if (t2_ex != null)
- {
- fail("Thread2 failed: " + t2_ex);
- }
- }
-
- public void testPutTxWithRollback() throws Exception
- {
- initCaches(Configuration.CacheMode.REPL_SYNC);
- final CacheSPI<Object, Object> c2 = this.cache1;
- Thread t1 = new Thread()
- {
- public void run()
- {
- TransactionManager tm;
-
- try
- {
- lock.acquire();
- tm = beginTransaction();
- c2.put("/a/b/c", "age", 38);
- c2.put("/a/b/c", "age", 39);
- lock.release();
-
- TestingUtil.sleepThread(100);
- lock.acquire();
- tm.rollback();
- lock.release();
- }
- catch (Throwable ex)
- {
- ex.printStackTrace();
- t1_ex = ex;
- }
- finally
- {
- lock.release();
- }
- }
- };
-
- Thread t2 = new Thread()
- {
- public void run()
- {
- TransactionManager tm;
-
- try
- {
- sleep(200);
- Thread.yield();
- lock.acquire();
- tm = beginTransaction();
- assertNull(cache2.get("/a/b/c", "age"));// must be null as not yet committed
- lock.release();
-
- TestingUtil.sleepThread(100);
- lock.acquire();
- assertNull(cache2.get("/a/b/c", "age"));// must be null as rolledback
- tm.commit();
- lock.release();
- }
- catch (Throwable ex)
- {
- ex.printStackTrace();
- t2_ex = ex;
- }
- finally
- {
- lock.release();
- }
- }
- };
-
- // Let the game start
- t1.start();
- t2.start();
-
- // Wait for thread to die but put an insurance of 5 seconds on it.
- t1.join();
- t2.join();
- if (t1_ex != null)
- {
- fail("Thread1 failed: " + t1_ex);
- }
- if (t2_ex != null)
- {
- fail("Thread2 failed: " + t2_ex);
- }
- }
-
- static class TransactionAborter implements Synchronization
- {
- Transaction ltx = null;
-
- public TransactionAborter(Transaction ltx)
- {
- this.ltx = ltx;
- }
-
- public void beforeCompletion()
- {
- try
- {
- ltx.setRollbackOnly();
- }
- catch (SystemException e)
- {
- // who cares
- }
- }
-
- public void afterCompletion(int status)
- {
- }
- }
-
- @CacheListener
- static class CallbackListener
- {
-
- CacheSPI<Object, Object> callbackCache;
- Object callbackKey;
- Exception ex;
- final Object mutex = new Object();
-
- CallbackListener(CacheSPI<Object, Object> cache, Object callbackKey)
- {
- this.callbackCache = cache;
- this.callbackKey = callbackKey;
- cache.getNotifier().addCacheListener(this);
- }
-
- @NodeModified
- public void nodeModified(NodeEvent e)
- {
- if (!e.isPre())
- {
- // Lock on a mutex so test can't check for an exception
- // until the get call completes
- synchronized (mutex)
- {
- try
- {
- callbackCache.get(e.getFqn(), callbackKey);
- }
- catch (CacheException exc)
- {
- exc.printStackTrace();
- ex = exc;
- }
- }
- }
- }
-
- Exception getCallbackException()
- {
- synchronized (mutex)
- {
- return ex;
- }
- }
-
- }
-
- static class TransactionAborterCallbackListener extends CallbackListener
- {
-
- TransactionManager callbackTM;
-
- TransactionAborterCallbackListener(CacheSPI<Object, Object> cache, Object callbackKey)
- {
- super(cache, callbackKey);
- callbackTM = callbackCache.getTransactionManager();
- }
-
- @NodeModified
- public void nodeModified(NodeEvent ne)
- {
- if (!ne.isPre())
- {
- try
- {
- Transaction tx = callbackTM.getTransaction();
- if (tx != null && tx.getStatus() == Status.STATUS_ACTIVE)
- {
- // this will rollback the transaction
- tx.registerSynchronization(new TransactionAborter(tx));
- }
- else
- {
- super.nodeModified(ne);
- }
-
- }
- catch (Exception e)
- {
- e.printStackTrace();
- if (ex == null)
- {
- ex = e;
- }
- }
- }
- }
-
- }
-
-}
Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -1,199 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.transaction;
-
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
-import org.jboss.cache.transaction.NotifyingTransactionManager.Notification;
-import org.jboss.cache.util.TestingUtil;
-import org.jgroups.JChannel;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-/**
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- */
-@Test(groups = {"functional"})
-public class AbortionTest
-{
- private CacheSPI cache1, cache2, cache3;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
- cache1 = initCache(false);
- TestingUtil.sleepThread(1500); // to ensure cache1 is the coordinator
- cache2 = initCache(false);
- cache3 = initCache(true);
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
- {
- TestingUtil.killCaches(cache3, cache2, cache1);
- }
-
- private CacheSPI initCache(boolean notifying)
- {
- CacheSPI c = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
- c.getConfiguration().setCacheMode("REPL_SYNC");
- c.getConfiguration().setClusterConfig(getJGroupsStack());
- c.getConfiguration().setFetchInMemoryState(false);
- if (!notifying)
- {
- c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
- }
- else
- {
- c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.NotifyingTransactionManager");
- }
- c.start();
- return c;
- }
-
- // we need a 'special' stack that does not attempt redelivery since we kill a channel midway during a tx in this test.
- private String getJGroupsStack()
- {
- return JChannel.DEFAULT_PROTOCOL_STACK;
- }
-
- private void destroyCache(CacheSPI c)
- {
- if (c != null)
- {
- c.stop();
- c.destroy();
- }
- }
-
- public void testSyncCaches() throws Exception
- {
- performTest(false, false);
- }
-
- public void testSyncCachesSyncCommitRollback() throws Exception
- {
- performTest(true, false);
- }
-
- /**
- * Note that this tests a *remote* beforeCompletion abort - which is a part of the calling instance's afterCompletion.
- *
- * @throws Exception
- */
- public void testAbortBeforeCompletion() throws Exception
- {
- performTest(true, true);
- }
-
- private void performTest(boolean syncCommitRollback, boolean abortBeforeCompletion) throws Exception
- {
- cache1.getConfiguration().setSyncCommitPhase(syncCommitRollback);
- cache1.getConfiguration().setSyncRollbackPhase(syncCommitRollback);
- cache2.getConfiguration().setSyncCommitPhase(syncCommitRollback);
- cache2.getConfiguration().setSyncRollbackPhase(syncCommitRollback);
- cache3.getConfiguration().setSyncCommitPhase(syncCommitRollback);
- cache3.getConfiguration().setSyncRollbackPhase(syncCommitRollback);
-
- TransactionManager mgr1 = cache1.getTransactionManager();
- TransactionManager mgr2 = cache2.getTransactionManager();
- assertTrue(cache3.getTransactionManager() instanceof NotifyingTransactionManager);
- NotifyingTransactionManager mgr3 = (NotifyingTransactionManager) cache3.getTransactionManager();
- mgr3.setCache(cache3);
-
- assertSame(mgr1, mgr2);
- assertNotSame(mgr1, mgr3);
- assertNotSame(mgr2, mgr3);
-
- assertTrue(mgr1 instanceof DummyTransactionManager);
- assertTrue(mgr2 instanceof DummyTransactionManager);
-
- cache1.put("/test", "key", "value");
-
- assertEquals("value", cache1.get("/test", "key"));
- assertEquals("value", cache2.get("/test", "key"));
- assertEquals("value", cache3.get("/test", "key"));
-
- mgr3.setNotification(new TestNotification(abortBeforeCompletion));
-
- mgr1.begin();
- cache1.put("/test", "key", "value2");
- mgr1.commit();
-
- TestingUtil.sleepThread(5000);
-
- // only test cache1 and cache2. Assume cache3 has crashed out.
- assertEquals(0, cache1.getNumberOfLocksHeld());
- assertEquals(0, cache2.getNumberOfLocksHeld());
- assertEquals("put in transaction should NOT have been rolled back", "value2", cache1.get("/test", "key"));
- assertEquals("put in transaction should NOT have been rolled back", "value2", cache2.get("/test", "key"));
-
- }
-
- class TestNotification implements Notification
- {
- boolean abortBeforeCompletion;
-
- public TestNotification(boolean abortBeforeCompletion)
- {
- this.abortBeforeCompletion = abortBeforeCompletion;
- }
-
- public void notify(Transaction tx, TransactionContext transactionContext) throws SystemException, RollbackException
- {
- OrderedSynchronizationHandler osh = transactionContext.getOrderedSynchronizationHandler();
-
- final Transaction finalTx = tx;
- System.out.println("Notify called.");
- // add an aborting sync handler.
- Synchronization abort = new Synchronization()
- {
-
- public void beforeCompletion()
- {
- if (abortBeforeCompletion)
- {
- cache3.getConfiguration().getRuntimeConfig().getChannel().close();
- System.out.println("Returning from abort.beforeCompletion");
- try
- {
- finalTx.setRollbackOnly();
- }
- catch (SystemException e)
- {
- throw new RuntimeException("Unable to set rollback", e);
- }
- throw new RuntimeException("Dummy exception");
- }
- }
-
- public void afterCompletion(int i)
- {
- if (!abortBeforeCompletion)
- {
- cache3.getConfiguration().getRuntimeConfig().getChannel().close();
- System.out.println("Returning from abort.afterCompletion");
- throw new RuntimeException("Dummy exception");
- }
- }
- };
-
- osh.registerAtHead(abort);
- System.out.println("Added sync handler.");
- }
-
- }
-}
Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/AsyncRollbackTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/AsyncRollbackTxTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/AsyncRollbackTxTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -1,239 +0,0 @@
-package org.jboss.cache.transaction;
-
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-
-/**
- * Test behaviour of async rollback timeouted transaction
- *
- * @author <a href="mailto:jhalat@infovide.pl">Jacek Halat</a>
- * @since 1.4.0
- */
-@Test(groups = {"functional"})
-public class AsyncRollbackTxTest
-{
- private CacheSPI<String, String> cache;
- private TransactionManager tm;
- private Fqn fqn = Fqn.fromString("/test");
- // This sleep time (millis) should be longer than the transaction timeout time.
- private long sleepTime = 2500;
- // seconds
- private int txTimeout = 2;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
- Configuration c = new Configuration();
- c.setTransactionManagerLookupClass("org.jboss.cache.transaction.AsyncRollbackTransactionManagerLookup");
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache = (CacheSPI<String, String>) instance.createCache(c);
- tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
- tm.setTransactionTimeout(txTimeout);
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown()
- {
- try
- {
- if (tm != null && tm.getTransaction() != null)
- {
- try
- {
- tm.rollback();
- }
- catch (SystemException e)
- {
- // do nothing
- }
- }
- }
- catch (SystemException e)
- {
- // do nothing
- }
- if (cache != null)
- cache.stop();
- cache = null;
- tm = null;
- }
-
- public void testCommitCreationInSameTx() throws Exception
- {
- assertEquals(0, cache.getNumberOfLocksHeld());
- tm.begin();
- cache.put(fqn, "k", "v");
- assertEquals(2, cache.getNumberOfLocksHeld());
- Thread.sleep(sleepTime);
- tm.commit();
- assertEquals(0, cache.getNumberOfLocksHeld());
- }
-
- public void testRollbackCreationInSameTx() throws Exception
- {
- assertEquals(0, cache.getNumberOfLocksHeld());
- tm.begin();
- cache.put(fqn, "k", "v");
- assertEquals(2, cache.getNumberOfLocksHeld());
- Thread.sleep(sleepTime);
- tm.rollback();
- assertEquals(0, cache.getNumberOfLocksHeld());
- // make sure the node was NOT added!!
- assertFalse(cache.exists(fqn));
- // even in a "deleted" form
- assertNull(cache.peek(fqn, true));
- }
-
- private void doTest(boolean commit, boolean writeLock) throws Exception
- {
- assertEquals(0, cache.getNumberOfLocksHeld());
- cache.put(fqn, "k", "v");//Executed in Not transactional context
- assertEquals(0, cache.getNumberOfLocksHeld());
- SeparateThread t = new SeparateThread(commit, writeLock);
- t.start();
- t.join();
- if (t.getException() != null)
- {
- throw t.getException();
- }
- assertEquals(0, cache.getNumberOfLocksHeld());
- assertEquals("v", cache.get(fqn, "k"));
- }
-
- public void testRollbackCreationInDifferentTxReadLock() throws Exception
- {
- doTest(false, false);
- }
-
- public void testCommitCreationInDifferentTxReadLock() throws Exception
- {
- doTest(true, false);
- }
-
- public void testRollbackCreationInDifferentTxWriteLock() throws Exception
- {
- doTest(false, true);
- }
-
- public void testCommitCreationInDifferentTxWriteLock() throws Exception
- {
- doTest(true, true);
- }
-
- public void testTxTimeoutAndPutAfter() throws Exception
- {
- assertEquals(0, cache.getNumberOfLocksHeld());
- tm.begin();
- cache.put(fqn, "k", "v");
- assertEquals(2, cache.getNumberOfLocksHeld());
- assertNotNull(tm.getTransaction());
- Thread.sleep(sleepTime);
- tm.rollback();
- assertNull(tm.getTransaction());
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- // make sure the node was NOT added!!
- assertFalse(cache.exists(fqn));
- // even in a "deleted" form
- assertNull(cache.peek(fqn, true));
-
- //Put not some data into cache. Because no transaction is used
- //no locks should be helds after this line.
- cache.put(fqn, "k", "v");
- assertEquals(0, cache.getNumberOfLocksHeld());
- }
-
- public void testTxTimeoutAndPutGetAfter() throws Exception
- {
- assertEquals(0, cache.getNumberOfLocksHeld());
- tm.begin();
- cache.put(fqn, "k", "v");
- assertEquals(2, cache.getNumberOfLocksHeld());
- assertNotNull(tm.getTransaction());
- Thread.sleep(sleepTime);
- tm.rollback();
- // make sure the node was NOT added!!
- assertFalse(cache.exists(fqn));
- // even in a "deleted" form
- assertNull(cache.peek(fqn, true));
- assertNull(tm.getTransaction());
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- //Put not some data into cache. Because no transaction is used
- //no locks should be helds after this line.
- cache.put(fqn, "k", "v");
- cache.get(fqn, "k");
-
- // Make sure no write lock is retained by the main thread. Test that another thread can read.
- SeparateThread t = new SeparateThread(false, false);
- t.start();
- t.join();
- if (t.getException() != null)
- {
- throw t.getException();
- }
- }
-
- private class SeparateThread extends Thread
- {
- Exception e = null;
- boolean commit, writeLock;
-
- public SeparateThread(boolean commit, boolean writeLock)
- {
- this.commit = commit;
- this.writeLock = writeLock;
- }
-
- public Exception getException()
- {
- return e;
- }
-
- public void run()
- {
- try
- {
- tm.begin();
- if (writeLock)
- {
- cache.put(fqn, "k", "v2");// obtain write lock on node
- }
- else
- {
- cache.get(fqn, "k");// obtain read lock on node
- }
-
- // sleep to ensure tx times out.
- sleep(2500);
-
- if (commit)
- {
- tm.commit();
- }
- else
- {
- tm.rollback();
- }
-
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- }
- catch (Exception e)
- {
- this.e = e;
- }
- }
- }
-
-}
Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTransactionalTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTransactionalTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTransactionalTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -1,200 +0,0 @@
-/*
- *
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.transaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.lock.IsolationLevel;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.fail;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.transaction.UserTransaction;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Unit test for local CacheSPI. Use locking and multiple threads to test
- * concurrent access to the tree.
- *
- * @version $Id$
- */
-@Test(groups = {"functional", "transaction"})
-public class ConcurrentTransactionalTest
-{
- private CacheSPI<Integer, String> cache;
- private Log logger_ = LogFactory.getLog(ConcurrentTransactionalTest.class);
- private static Throwable thread_ex = null;
- private static final int NUM = 10000;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
- }
-
- private void createCache(IsolationLevel level)
- {
- CacheFactory<Integer, String> factory = new DefaultCacheFactory<Integer, String>();
- Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
- conf.setCacheMode(Configuration.CacheMode.LOCAL);
- conf.setIsolationLevel(level);
- conf.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(conf);
- cache.put("/a/b/c", null);
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
- {
- cache.stop();
- thread_ex = null;
- TransactionSetup.cleanup();
- }
-
- public void testConcurrentAccessWithRWLock() throws Throwable
- {
- createCache(IsolationLevel.REPEATABLE_READ);
- work_();
- }
-
- public void testConcurrentAccessWithExclusiveLock() throws Throwable
- {
- createCache(IsolationLevel.SERIALIZABLE);
- work_();
- }
-
- private void work_() throws Throwable
- {
- Updater one, two;
- try
- {
- one = new Updater("Thread one");
- two = new Updater("Thread two");
- long current = System.currentTimeMillis();
- one.start();
- two.start();
- one.join();
- two.join();
- if (thread_ex != null)
- {
- throw thread_ex;
- }
-
- long now = System.currentTimeMillis();
- log("*** Time elapsed: " + (now - current));
-
- System.out.println("cache content: " + cache.toString());
- Set<Integer> keys = cache.getNode(Fqn.fromString("/a/b/c")).getKeys();
- System.out.println("number of keys=" + keys.size());
-
- if (keys.size() != NUM)
- {
- scanForNullValues(keys);
-
- try
- {
- System.out.println("size=" + keys.size());
- List<Integer> l = new LinkedList<Integer>(keys);
- Collections.sort(l);
- System.out.println("keys: " + l);
- for (int i = 0; i < NUM; i++)
- {
- if (!l.contains(new Integer(i)))
- {
- System.out.println("missing: " + i);
- }
- }
-
- LinkedList<Integer> duplicates = new LinkedList<Integer>();
- for (Integer integer : l)
- {
- if (duplicates.contains(integer))
- {
- System.out.println(integer + " is a duplicate");
- }
- else
- {
- duplicates.add(integer);
- }
- }
- }
- catch (Exception e1)
- {
- e1.printStackTrace();
- }
- }
-
- assertEquals(NUM, keys.size());
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail(e.toString());
- }
- }
-
- private void scanForNullValues(Set<Integer> keys)
- {
- for (Object o : keys)
- {
- if (o == null)
- {
- System.err.println("found a null value in keys");
- }
- }
- }
-
- private void log(String msg)
- {
- logger_.debug(" [" + Thread.currentThread() + "]: " + msg);
- }
-
- private class Updater extends Thread
- {
- private String val = null;
- private UserTransaction tx;
-
- public Updater(String name)
- {
- this.val = name;
- }
-
- public void run()
- {
- try
- {
- log("adding data");
- tx = TransactionSetup.getUserTransaction();
- for (int i = 0; i < NUM; i++)
- {
- log("adding data i=" + i);
- tx.begin();
- cache.put("/a/b/c", i, val);
- tx.commit();
- yield();
- }
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- thread_ex = t;
- }
- }
- }
-
-}
Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelNoneTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelNoneTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelNoneTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -1,102 +0,0 @@
-package org.jboss.cache.transaction;
-
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.config.Configuration;
-import org.jboss.cache.lock.IsolationLevel;
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertTrue;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.Test;
-
-import javax.transaction.NotSupportedException;
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-
-/**
- * Tests whether modifications within callbacks (TreeCacheListener) are handled correctly
- *
- * @author Bela Ban
- * @version $Id$
- */
-@Test(groups = {"functional", "transaction"})
-public class IsolationLevelNoneTest
-{
- CacheSPI<String, String> cache = null;
- final Fqn FQN = Fqn.fromString("/a/b/c");
- final String KEY = "key";
- final String VALUE = "value";
- TransactionManager tm;
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
- {
- if (cache != null)
- {
- cache.stop();
- cache.destroy();
- cache = null;
- }
- }
-
- public void testWithoutTransactions() throws Exception
- {
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache = (CacheSPI<String, String>) instance.createCache(false);
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
- cache.getConfiguration().setIsolationLevel(IsolationLevel.NONE);
- cache.start();
- cache.put(FQN, KEY, VALUE);
- cache.put(FQN + "/d", KEY, VALUE);
- Node node = cache.peek(FQN, false, false);
- assertTrue(node != null && node.getKeys().contains(KEY));
- assertEquals(VALUE, cache.get(FQN, KEY));
- assertEquals(0, cache.getNumberOfLocksHeld());
- }
-
- public void testWithTransactions() throws Exception
- {
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache = (CacheSPI<String, String>) instance.createCache(false);
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
- cache.getConfiguration().setIsolationLevel(IsolationLevel.NONE);
- cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache.start();
- tm = startTransaction();
- cache.put(FQN, KEY, VALUE);
- cache.put(FQN + "/d", KEY, VALUE);
- Node node = cache.peek(FQN, false, false);
- assertTrue(node != null && node.getKeys().contains(KEY));
- assertEquals(VALUE, cache.get(FQN, KEY));
- assertEquals(0, cache.getNumberOfLocksHeld());
- tm.commit();
- }
-
- public void testWithTransactionsRepeatableRead() throws Exception
- {
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache = (CacheSPI<String, String>) instance.createCache(false);
- cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
- cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
- cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache.start();
- tm = startTransaction();
- cache.put(FQN, KEY, VALUE);
- cache.put(FQN + "/d", KEY, VALUE);
- Node node = cache.peek(FQN, false, false);
- assertTrue(node != null && node.getKeys().contains(KEY));
- assertEquals(VALUE, cache.get(FQN, KEY));
- assertEquals(5, cache.getNumberOfLocksHeld());
- tm.commit();
- }
-
- private TransactionManager startTransaction() throws SystemException, NotSupportedException
- {
- TransactionManager mgr = cache.getTransactionManager();
- mgr.begin();
- return mgr;
- }
-}
Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/PrepareTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/PrepareTxTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/PrepareTxTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -1,154 +0,0 @@
-package org.jboss.cache.transaction;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import static org.testng.AssertJUnit.assertEquals;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.transaction.NotSupportedException;
-import javax.transaction.Synchronization;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-/**
- * Created by IntelliJ IDEA.
- * User: bela
- * Date: Jun 9, 2004
- * Time: 9:05:19 AM
- */
-@Test(groups = {"functional", "transaction"})
-public class PrepareTxTest
-{
- CacheSPI<String, String> cache;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
- CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
- cache = (CacheSPI<String, String>) instance.createCache(false);
- cache.getConfiguration().setCacheMode("local");
- cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- cache.create();
- cache.start();
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
- {
- cache.stop();
- cache.destroy();
- }
-
- /**
- * Tests cache modification <em>inside</em> the afterCompletion() callback. Reproduces a bug fixed in
- * connection with JBossCache being used as Hibernate's second level cache
- *
- * @throws Exception
- * @throws NotSupportedException
- */
- public void testCacheModificationInBeforeCompletionPhase() throws Exception
- {
- int numLocks = 0;
- TransactionManager mgr = cache.getTransactionManager();
- mgr.begin();
- Transaction tx = mgr.getTransaction();
-
- // this will cause the cache to register with TransactionManager for TX completion callbacks
- cache.put("/one/two/three", "key1", "val1");
- numLocks = cache.getNumberOfLocksHeld();
- assertEquals(4, numLocks);
-
- // we register *second*
- tx.registerSynchronization(new Synchronization()
- {
-
- public void beforeCompletion()
- {
- try
- {
- cache.put("/a/b/c", null);
- }
- catch (CacheException e)
- {
- e.printStackTrace();
- }
- }
-
- public void afterCompletion(int status)
- {
- }
- });
-
- mgr.commit();
- numLocks = cache.getNumberOfLocksHeld();
- assertEquals(0, numLocks);
-
- int num_local_txs, num_global_txs;
- TransactionTable tx_table = cache.getTransactionTable();
- num_local_txs = tx_table.getNumLocalTransactions();
- num_global_txs = tx_table.getNumGlobalTransactions();
- System.out.println("Number of Transactions: " + num_local_txs + "\nNumber of GlobalTransactions: " + num_global_txs + "\nTransactionTable:\n "
- + tx_table.toString(true));
- assertEquals(num_local_txs, num_global_txs);
- assertEquals(0, num_local_txs);
- }
-
- /**
- * Tests cache modification <em>inside</em> the afterCompletion() callback. Reproduces a bug fixed in
- * connection with JBossCache being used as Hibernate's second level cache
- *
- * @throws Exception
- * @throws NotSupportedException
- */
- public void testCacheModificationInAfterCompletionPhase() throws Exception
- {
- int numLocks = 0;
- TransactionManager mgr = cache.getTransactionManager();
- mgr.begin();
- Transaction tx = mgr.getTransaction();
-
- // this will cause the cache to register with TransactionManager for TX completion callbacks
- cache.put("/one/two/three", "key1", "val1");
- numLocks = cache.getNumberOfLocksHeld();
- assertEquals(4, numLocks);
-
- // we register *second*
- tx.registerSynchronization(new Synchronization()
- {
-
- public void beforeCompletion()
- {
- }
-
- public void afterCompletion(int status)
- {
- try
- {
- cache.put("/a/b/c", null);
- }
- catch (CacheException e)
- {
- e.printStackTrace();
- }
- }
- });
-
- mgr.commit();
- numLocks = cache.getNumberOfLocksHeld();
- assertEquals(0, numLocks);
-
- int num_local_txs, num_global_txs;
- TransactionTable tx_table = cache.getTransactionTable();
- num_local_txs = tx_table.getNumLocalTransactions();
- num_global_txs = tx_table.getNumGlobalTransactions();
- System.out.println("Number of Transactions: " + num_local_txs + "\nNumber of GlobalTransactions: " + num_global_txs + "\nTransactionTable:\n "
- + tx_table.toString(true));
- assertEquals(num_local_txs, num_global_txs);
- assertEquals(0, num_local_txs);
- }
-
-}
Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/StatusUnknownTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/StatusUnknownTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/StatusUnknownTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -1,162 +0,0 @@
-package org.jboss.cache.transaction;
-
-import org.jboss.cache.Cache;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-
-/**
- * This test checks how the cache behaves when a JTA STATUS_UNKNOWN is passed in to the cache during afterCompletion().
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- */
-@Test(groups = "functional")
-public class StatusUnknownTest
-{
- private Cache<String, String> cache;
- private TransactionManager tm;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
- cache = new DefaultCacheFactory<String, String>().createCache(false);
- cache.getConfiguration().setTransactionManagerLookupClass(HeuristicFailingDummyTransactionManagerLookup.class.getName());
- cache.start();
- tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown()
- {
- cache.stop();
- }
-
- public void testStatusUnknown() throws Exception
- {
- tm.begin();
- Fqn fqn = Fqn.fromString("/a/b/c");
-
- cache.put(fqn, "k", "v");
- assertEquals(4, ((CacheSPI) cache).getNumberOfLocksHeld());
- assertTrue(cache.getRoot().hasChild(fqn));
- tm.commit();
-
- assertEquals(0, ((CacheSPI) cache).getNumberOfLocksHeld());
- assertFalse(cache.getRoot().hasChild(fqn));
- }
-
- public static class HeuristicFailingDummyTransactionManager extends DummyTransactionManager
- {
- private static final long serialVersionUID = 6325631394461739211L;
-
- @Override
- public void begin() throws SystemException, NotSupportedException
- {
- super.begin();
-
- Transaction tx = new HeuristicFailingDummyTransaction(this);
- setTransaction(tx);
- }
-
- public static DummyTransactionManager getInstance()
- {
- if (instance == null)
- {
- instance = new HeuristicFailingDummyTransactionManager();
- try
- {
- Properties p = new Properties();
- p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
- Context ctx = new InitialContext(p);
- ctx.bind("java:/TransactionManager", instance);
- ctx.bind("UserTransaction", new DummyUserTransaction(instance));
- }
- catch (NamingException e)
- {
- log.error("binding of DummyTransactionManager failed", e);
- }
- }
- return instance;
- }
- }
-
- public static class HeuristicFailingDummyTransaction extends DummyTransaction
- {
- public HeuristicFailingDummyTransaction(DummyBaseTransactionManager mgr)
- {
- super(mgr);
- }
-
- @Override
- public void commit() throws RollbackException
- {
- try
- {
- notifyBeforeCompletion();
- notifyAfterCompletion(Status.STATUS_UNKNOWN);
- }
- finally
- {
- // Disassociate tx from thread.
- tm_.setTransaction(null);
- }
- }
-
- @Override
- protected void notifyAfterCompletion(int status)
- {
- List<Synchronization> tmp;
-
- synchronized (participants)
- {
- tmp = new LinkedList<Synchronization>(participants);
- }
-
- for (Synchronization s : tmp)
- {
- try
- {
- s.afterCompletion(status);
- }
- catch (Throwable t)
- {
- throw (RuntimeException) t;
- }
- }
-
- synchronized (participants)
- {
- participants.clear();
- }
- }
- }
-
- public static class HeuristicFailingDummyTransactionManagerLookup implements TransactionManagerLookup
- {
-
- public TransactionManager getTransactionManager() throws Exception
- {
- return HeuristicFailingDummyTransactionManager.getInstance();
- }
- }
-}
-
-
Deleted: core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -1,1068 +0,0 @@
-/*
- *
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-
-package org.jboss.cache.transaction;
-
-import org.jboss.cache.CacheException;
-import org.jboss.cache.CacheFactory;
-import org.jboss.cache.CacheSPI;
-import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Node;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.lock.IsolationLevel;
-import org.jboss.cache.lock.LockManager;
-import static org.jboss.cache.lock.LockType.READ;
-import static org.jboss.cache.lock.LockType.WRITE;
-import org.jboss.cache.util.CachePrinter;
-import org.jboss.cache.util.TestingUtil;
-import static org.testng.AssertJUnit.*;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Tests transactional access to a local CacheImpl.
- * Note: we use DummpyTranasctionManager to replace jta
- *
- * @version $Id$
- */
-@Test(groups = {"functional", "transaction"})
-public class TransactionTest
-{
- CacheSPI<String, Comparable> cache = null;
- UserTransaction tx = null;
- Exception exception;
- LockManager lockManager;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception
- {
-
- CacheFactory<String, Comparable> instance = new DefaultCacheFactory<String, Comparable>();
- cache = (CacheSPI<String, Comparable>) instance.createCache(false);
- cache.getConfiguration().setClusterName("test");
- cache.getConfiguration().setStateRetrievalTimeout(10000);
- cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
- cache.getConfiguration().setLockParentForChildInsertRemove(true);// this test case is written to assume this.
- cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
- tx = TransactionSetup.getUserTransaction();
-
- cache.create();
- cache.start();
- exception = null;
- lockManager = TestingUtil.extractLockManager(cache);
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception
- {
- if (cache != null)
- {
- cache.stop();
- cache = null;
- }
-
- // BW. kind of a hack to destroy jndi binding and thread local tx before next run.
- TransactionSetup.cleanup();
-
- if (tx != null)
- {
- try
- {
- tx.rollback();
- }
- catch (Throwable t)
- {
- // do nothing
- }
- tx = null;
- }
- }
-
- public void testPutTx() throws Exception
- {
- tx.begin();
- cache.put("/a/b/c", "age", 38);
- // the tx interceptor should know that we're in the same tx.
- assertEquals(cache.get("/a/b/c", "age"), 38);
-
- cache.put("/a/b/c", "age", 39);
- tx.commit();
-
- // This test is done outside the TX, it wouldn't work if someone else
- // modified "age". This works because we're the only TX running.
- assertEquals(cache.get("/a/b/c", "age"), 39);
- }
-
- public void testRollbackTx1()
- {
- try
- {
- tx.begin();
- cache.put("/a/b/c", "age", 38);
- cache.put("/a/b/c", "age", 39);
- tx.rollback();
-
- // This test is done outside the TX, it wouldn't work if someone else
- // modified "age". This works because we're the only TX running.
- assertNull(cache.get("/a/b/c", "age"));
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- public void testGetAfterRemovalRollback() throws Exception
- {
- assertEquals(0, cache.getNumberOfLocksHeld());
- cache.put("/a/b", null);
- assertEquals(0, cache.getNumberOfLocksHeld());
- assertTrue(cache.exists("/a/b"));
- tx.begin();
- cache.removeNode("/a/b");
- assertFalse(cache.exists("/a/b"));
- tx.rollback();
- assertTrue(cache.exists("/a/b"));
- assertEquals(0, cache.getNumberOfLocksHeld());
- // new tx in new thread
- Thread th = new Thread()
- {
- public void run()
- {
- try
- {
- cache.getTransactionManager().begin();
- assertNotNull(cache.getNode("/a/b"));
- cache.getTransactionManager().rollback();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail("Caught exception");
- }
- }
- };
-
- th.start();
- th.join();
-
- assertEquals(0, cache.getNumberOfLocksHeld());
- }
-
- public void testRollbackTx2()
- {
- try
- {
- tx.begin();
- cache.put("/a/b/c", "age", 38);
- cache.remove("/a/b/c", "age");
- tx.rollback();
-
- // This test is done outside the TX, it wouldn't work if someone else
- // modified "age". This works because we're the only TX running.
- assertNull(cache.get("/a/b/c", "age"));
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- public void testRollbackTx2a()
- {
- try
- {
- cache.put("/a/b/c", "age", 38);
- tx.begin();
- cache.remove("/a/b/c", "age");
- tx.rollback();
-
- // This test is done outside the TX, it wouldn't work if someone else
- // modified "age". This works because we're the only TX running.
- assertEquals(38, cache.get("/a/b/c", "age"));
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- public void testRollbackTx3()
- {
- try
- {
- java.util.Map<String, Comparable> map1 = new java.util.HashMap<String, Comparable>();
- map1.put("age", 38);
- java.util.Map<String, Comparable> map2 = new java.util.HashMap<String, Comparable>();
- map2.put("age", 39);
- tx.begin();
- cache.put("/a/b/c", map1);
- cache.put("/a/b/c", map2);
- tx.rollback();
-
- // This test is done outside the TX, it wouldn't work if someone else
- // modified "age". This works because we're the only TX running.
- assertNull(cache.get("/a/b/c", "age"));
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- public void testRollbackTx4()
- {
- try
- {
- Map<String, Comparable> map = new HashMap<String, Comparable>();
- map.put("age", 38);
- tx.begin();
- cache.put("/a/b/c", map);
- cache.removeNode("/a/b/c");
- tx.rollback();
-
- // This test is done outside the TX, it wouldn't work if someone else
- // modified "age". This works because we're the only TX running.
- assertNull(cache.get("/a/b/c", "age"));
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- public void testNodeCreationRollback()
- {
- try
- {
- tx.begin();
- System.out.println("initial state:\n" + cache);
- cache.put("/bela/ban", "key", "value");
- System.out.println("after put():\n" + cache);
- tx.rollback();
- System.out.println("after rollback():\n" + cache);
-
- assertNull("node should be not existent", cache.getNode("/bela/ban"));
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- public void testNodeCreationRollback2()
- {
- try
- {
- cache.put("/bela/ban", null);
- tx.begin();
- cache.put("/bela/ban/michelle", null);
- tx.rollback();
- assertNotNull("node should be not null", cache.getNode("/bela/ban"));
- assertNull("node should be not existent", cache.getNode("/bela/ban/michelle"));
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- public void testNodeDeletionRollback()
- {
- try
- {
- cache.put("/a/b/c", null);
- tx.begin();
- cache.removeNode("/a/b/c");
- assertNull(cache.getNode("/a/b/c"));
- cache.removeNode("/a/b");
- assertNull(cache.getNode("/a/b"));
- cache.removeNode("/a");
- assertNull(cache.getNode("/a"));
- tx.rollback();
- assertNotNull(cache.getNode("/a/b/c"));
- assertNotNull(cache.getNode("/a/b"));
- assertNotNull(cache.getNode("/a"));
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- public void testNodeDeletionRollback2() throws Exception
- {
- cache.put("/a/b/c", null);
- cache.put("/a/b/c1", null);
- cache.put("/a/b/c2", null);
- tx.begin();
- cache.removeNode("/a");
- assertNull(cache.getNode("/a/b/c"));
- assertNull(cache.getNode("/a/b/c1"));
- assertNull(cache.getNode("/a/b/c2"));
- assertNull(cache.getNode("/a/b"));
- assertNull(cache.getNode("/a"));
- Set children = cache.getChildrenNames(Fqn.fromString("/a/b"));
- assertTrue(children.isEmpty());
- children = cache.getChildrenNames("/a");
- assertTrue(children.isEmpty());
- tx.rollback();
- assertNotNull(cache.getNode("/a"));
- assertNotNull(cache.getNode("/a/b"));
- assertNotNull(cache.getNode("/a/b/c"));
- assertNotNull(cache.getNode("/a/b/c1"));
- assertNotNull(cache.getNode("/a/b/c2"));
- children = cache.getChildrenNames(Fqn.fromString("/a/b"));
- assertEquals(3, children.size());
- }
-
- public void testNodeCreation() throws Exception
- {
- GlobalTransaction gtx;
- cache.put("/a/b", null);
- tx.begin();
- gtx = cache.getCurrentTransaction();
- cache.put("/a/b/c", null);
- assertLocked(gtx, "/a", false);
- assertLocked(gtx, "/a/b", true);
- assertLocked(gtx, "/a/b/c", true);
- }
-
- public void testNodeCreation2() throws Exception
- {
- GlobalTransaction gtx;
- tx.begin();
- gtx = cache.getCurrentTransaction();
- cache.put("/a/b/c", null);
- assertLocked(gtx, "/a", true);
- assertLocked(gtx, "/a/b", true);
- assertLocked(gtx, "/a/b/c", true);
- }
-
- public void testNodeRemoval() throws SystemException, NotSupportedException
- {
- GlobalTransaction gtx;
- cache.put("/a/b/c", null);
- tx.begin();
- gtx = cache.getCurrentTransaction();
- cache.removeNode("/a/b/c");// need to remove the node, not just the data in the node.
- assertLocked(gtx, "/a", false);
- assertLocked(gtx, "/a/b", true);
- assertLocked(gtx, "/a/b/c", true);
- tx.rollback();
- }
-
- public void testNodeRemoval2() throws SystemException, NotSupportedException
- {
- GlobalTransaction gtx;
- cache.put("/a/b/c", null);
- tx.begin();
- gtx = cache.getCurrentTransaction();
- cache.removeNode("/a/b");// need to remove the node, not just the data in the node.
- assertLocked(gtx, "/a", true);
- assertLocked(gtx, "/a/b", true);
- assertLocked(gtx, "/a/b/c", true);
- tx.rollback();
- }
-
- public void testIntermediateNodeCreationOnWrite() throws Exception
- {
- cache.put("/a", null);
- tx.begin();
- cache.put("/a/b/c", null);
- // expecting WLs on /a, /a/b and /a/b/c.
- GlobalTransaction gtx = cache.getCurrentTransaction();
- assertLocked(gtx, "/a", true);
- assertLocked(gtx, "/a/b", true);
- assertLocked(gtx, "/a/b/c", true);
- tx.rollback();
- }
-
- public void testIntermediateNodeCreationOnRead() throws Exception
- {
- cache.put("/a", null);
- tx.begin();
- cache.getNode("/a/b/c");
-
- // expecting RLs on /, /a
- // /a/b, /a/b/c should NOT be created!
- GlobalTransaction gtx = cache.getCurrentTransaction();
- assertLocked(gtx, "/", false);
- assertLocked(gtx, "/a", false);
- assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b"), true));
- assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/b/c"), true));
- tx.rollback();
- assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b"), true));
- assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/b/c"), true));
-
- }
-
- public void testIntermediateNodeCreationOnRemove() throws Exception
- {
- cache.put("/a", null);
- tx.begin();
- cache.removeNode("/a/b/c");
-
- // expecting RLs on /, /a
- // /a/b, /a/b/c should NOT be created!
- GlobalTransaction gtx = cache.getCurrentTransaction();
- assertLocked(gtx, "/", false);
- assertLocked(gtx, "/a", true);
- assertLocked(gtx, "/a/b", true);
- assertLocked(gtx, "/a/b/c", true);
- assertNotNull("/a/b should exist", cache.peek(Fqn.fromString("/a/b"), true));
- assertNotNull("/a/b/c should exist", cache.peek(Fqn.fromString("/a/b/c"), true));
- assertNotNull("/a/b should NOT be visible", cache.exists(Fqn.fromString("/a/b")));
- assertNotNull("/a/b/c should NOT be visible", cache.exists(Fqn.fromString("/a/b/c")));
- tx.rollback();
- assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b"), true));
- assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/b/c"), true));
-
- }
-
- public void testNodeDeletionRollback3() throws Exception
- {
- GlobalTransaction gtx;
- cache.put("/a/b/c1", null);
-
- tx.begin();
- gtx = cache.getCurrentTransaction();
- cache.put("/a/b/c1", null);
- assertLocked(gtx, "/a", false);
- assertLocked(gtx, "/a/b", false);
- assertLocked(gtx, "/a/b/c1", true);
-
- cache.put("/a/b/c2", null);
- assertLocked(gtx, "/a/b", true);
- assertLocked(gtx, "/a/b/c2", true);
-
- cache.put("/a/b/c3", null);
- cache.put("/a/b/c1/one", null);
- assertLocked(gtx, "/a/b/c1", true);
- assertLocked(gtx, "/a/b/c1/one", true);
-
- cache.put("/a/b/c1/two", null);
- cache.put("/a/b/c1/one/1", null);
- assertLocked(gtx, "/a/b/c1", true);
- assertLocked(gtx, "/a/b/c1/one", true);
- assertLocked(gtx, "/a/b/c1/one/1", true);
-
- cache.put("/a/b/c1/two/2/3/4", null);
- assertLocked(gtx, "/a/b/c1", true);
- assertLocked(gtx, "/a/b/c1/two", true);
- assertLocked(gtx, "/a/b/c1/two/2", true);
- assertLocked(gtx, "/a/b/c1/two/2/3", true);
- assertLocked(gtx, "/a/b/c1/two/2/3/4", true);
-
- cache.removeNode("/a/b");
- tx.rollback();
- assertTrue(cache.getChildrenNames("/a/b/c1").isEmpty());
- Set cn = cache.getChildrenNames(Fqn.fromString("/a/b"));
- assertEquals(1, cn.size());
- assertEquals("c1", cn.iterator().next());
- }
-
- public void testDoubleLocks() throws Exception
- {
- tx.begin();
- GlobalTransaction gtx = cache.getCurrentTransaction();
- cache.put("/a/b/c", null);
- cache.put("/a/b/c", null);
-
- NodeSPI n = cache.getNode("/a");
- assert !lockManager.isLocked(n, READ);
- // make sure this is write locked.
- assertLocked(gtx, "/a", true);
-
- n = cache.getNode("/a/b");
- assert !lockManager.isLocked(n, READ);
- // make sure this is write locked.
- assertLocked(gtx, "/a/b", true);
-
- n = cache.getNode("/a/b/c");
- assert !lockManager.isLocked(n, READ);
- // make sure this is write locked.
- assertLocked(gtx, "/a/b/c", true);
-
- tx.rollback();
- assertEquals(0, cache.getNumberOfLocksHeld());
- }
-
- private void assertLocked(Object owner, String fqn, boolean writeLocked)
- {
- NodeSPI<String, Comparable> n = cache.peek(Fqn.fromString(fqn), true);
- if (owner == null) owner = Thread.currentThread();
- assertTrue("node " + fqn + " is not locked", lockManager.isLocked(n));
- if (writeLocked)
- {
- assertTrue("node " + fqn + " is not write-locked by owner " + owner + ". Lock details: " + lockManager.printLockInfo(n), lockManager.ownsLock(Fqn.fromString(fqn), WRITE, owner));
- }
- else
- {
- assertTrue("node " + fqn + " is not read-locked by owner " + owner + ". Lock details: " + lockManager.printLockInfo(n), lockManager.ownsLock(Fqn.fromString(fqn), READ, owner));
- }
- }
-
- public void testConcurrentNodeAccessOnRemovalWithTx() throws Exception
- {
- cache.put("/a/b/c", null);
- tx.begin();
- cache.removeNode("/a/b/c");
- // this node should now be locked.
- TransactionManager tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
- Transaction t = tm.suspend();
- // start a new tx
- tm.begin();
- try
- {
- cache.getNode("/a/b/c");// should fail
- fail("Should not be able to get a hold of /a/b/c until the deleting tx completes");
- }
- catch (Exception e)
- {
- // expected
- //cache.getTransactionManager().commit();
- tm.commit();
- }
-
- tm.resume(t);
- tx.rollback();
-
- assertNotNull(cache.getNode("/a/b/c"));
- assertEquals(0, cache.getNumberOfLocksHeld());
- }
-
- public void testConcurrentNodeAccessOnRemovalWithoutTx() throws Exception
- {
- cache.put("/a/b/c", null);
- tx.begin();
- cache.removeNode("/a/b/c");
- // this node should now be locked.
- Transaction t = cache.getTransactionManager().suspend();
- Thread th = new Thread()
- {
- public void run()
- {
- try
- {
- cache.getNode("/a/b/c");// should fail
-
- fail("Should not be able to get a hold of /a/b/c until the deleting tx completes");
- }
- catch (Exception e)
- {
- // expected
- }
- }
- };
-
- th.start();
- th.join();
-
- cache.getTransactionManager().resume(t);
- tx.rollback();
-
- assertNotNull(cache.getNode("/a/b/c"));
- assertEquals(0, cache.getNumberOfLocksHeld());
- }
-
- public void testRemove() throws CacheException, SystemException, NotSupportedException, HeuristicMixedException, HeuristicRollbackException, RollbackException
- {
- cache.put("/a/b/c", null);
- cache.put("/a/b/c/1", null);
- cache.put("/a/b/c/2", null);
- cache.put("/a/b/c/3", null);
- cache.put("/a/b/c/3/a/b/c", null);
-
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- tx.begin();
- cache.removeNode("/a/b/c");
- // this used to test for 2 locks held. After the fixes for JBCACHE-875 however, 2 more locks are acquired - for the root node as well as the deleted node.
- // and since we would lock all children of the deleted node as well, we have 10 locks here.
- assertEquals(10, cache.getNumberOfLocksHeld());
- tx.commit();
- assertEquals(0, cache.getNumberOfLocksHeld());
- }
-
- public void testRemoveAndRollback() throws CacheException, SystemException, NotSupportedException, HeuristicMixedException, HeuristicRollbackException,
- RollbackException
- {
- cache.put("/a/b/c", null);
- cache.put("/a/b/c/1", null);
- cache.put("/a/b/c/2", null);
- cache.put("/a/b/c/3", null);
- cache.put("/a/b/c/3/a/b/c", null);
-
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- tx.begin();
- cache.removeNode("/a/b/c");
- assertEquals(10, cache.getNumberOfLocksHeld());
- tx.rollback();
- assertEquals(0, cache.getNumberOfLocksHeld());
-
- assertTrue(cache.exists("/a/b/c"));
- assertTrue(cache.exists("/a/b/c/1"));
- assertTrue(cache.exists("/a/b/c/2"));
- assertTrue(cache.exists("/a/b/c/3"));
- assertTrue(cache.exists("/a/b/c/3/a"));
- assertTrue(cache.exists("/a/b/c/3/a/b"));
- assertTrue(cache.exists("/a/b/c/3/a/b/c"));
- }
-
- public void testRemoveKeyRollback() throws CacheException, SystemException, NotSupportedException
- {
- cache.put("/bela/ban", "name", "Bela");
- tx.begin();
- cache.remove("/bela/ban", "name");
- assertNull(cache.get("/bela/ban", "name"));
- tx.rollback();
- assertEquals("Bela", cache.get("/bela/ban", "name"));
- }
-
- public void testRemoveKeyRollback2()
- {
- try
- {
- Map<String, Comparable> m = new HashMap<String, Comparable>();
- m.put("name", "Bela");
- m.put("id", 322649);
- cache.put("/bela/ban", m);
- tx.begin();
- cache.remove("/bela/ban", "name");
- assertNull(cache.get("/bela/ban", "name"));
- tx.rollback();
- assertEquals("Bela", cache.get("/bela/ban", "name"));
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- public void testRemoveKeyRollback3()
- {
- try
- {
- cache.put("/bela/ban", "name", "Bela");
- tx.begin();
- cache.put("/bela/ban", "name", "Michelle");
- cache.remove("/bela/ban", "name");
- assertNull(cache.get("/bela/ban", "name"));
- tx.rollback();
- assertEquals("Bela", cache.get("/bela/ban", "name"));
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- public void testDoubleRemovalOfSameData() throws Exception
- {
- tx.begin();
- cache.put("/foo/1", "item", 1);
- assertEquals(cache.get("/foo/1", "item"), 1);
- cache.removeNode("/foo/1");
- assertNull(cache.get("/foo/1", "item"));
- cache.removeNode("/foo/1");
- assertNull(cache.get("/foo/1", "item"));
- tx.rollback();
- assertFalse(cache.exists("/foo/1"));
- assertNull(cache.get("/foo/1", "item"));
- }
-
- /**
- * put(Fqn, Map) with a previous null map
- */
- public void testPutDataRollback1()
- {
- try
- {
- cache.put("/bela/ban", null);// create a node /bela/ban with a null map
- tx.begin();
- Map<String, Comparable> m = new HashMap<String, Comparable>();
- m.put("name", "Bela");
- m.put("id", 322649);
- cache.put("/bela/ban", m);
- tx.rollback();
-
- Node n = cache.getNode("/bela/ban");
- if (n.getData() == null)
- return;
- assertEquals("map should be empty", 0, n.getData().size());
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- /**
- * put(Fqn, Map) with a previous non-null map
- */
- public void testputDataRollback2() throws Exception
- {
- Map<String, Comparable> m1, m2;
- m1 = new HashMap<String, Comparable>();
- m1.put("name", "Bela");
- m1.put("id", 322649);
- m2 = new HashMap<String, Comparable>();
- m2.put("other", "bla");
- m2.put("name", "Michelle");
-
- cache.put("/bela/ban", m1);
- tx.begin();
-
- cache.put("/bela/ban", m2);
- Map tmp = cache.getNode("/bela/ban").getData();
- assertEquals(3, tmp.size());
- assertEquals("Michelle", tmp.get("name"));
- assertEquals(tmp.get("id"), 322649);
- assertEquals("bla", tmp.get("other"));
- tx.rollback();
-
- tmp = cache.getNode("/bela/ban").getData();
- assertEquals(2, tmp.size());
- assertEquals("Bela", tmp.get("name"));
- assertEquals(tmp.get("id"), 322649);
- }
-
- public void testPutRollback()
- {
- try
- {
- cache.put("/bela/ban", null);// /bela/ban needs to exist
- tx.begin();
- cache.put("/bela/ban", "name", "Bela");
- assertEquals("Bela", cache.get("/bela/ban", "name"));
- tx.rollback();
- assertNull(cache.get("/bela/ban", "name"));
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- public void testPutRollback2()
- {
- try
- {
- cache.put("/bela/ban", "name", "Bela");// /bela/ban needs to exist
- tx.begin();
- cache.put("/bela/ban", "name", "Michelle");
- assertEquals("Michelle", cache.get("/bela/ban", "name"));
- tx.rollback();
- assertEquals("Bela", cache.get("/bela/ban", "name"));
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- fail(t.toString());
- }
- }
-
- public void testSimpleRollbackTransactions() throws Exception
- {
- final Fqn fqn = Fqn.fromString("/a/b/c");
- tx.begin();
- cache.put(fqn, "entry", "commit");
- tx.commit();
-
- tx.begin();
- cache.put(fqn, "entry", "rollback");
- cache.removeNode(fqn);
- tx.rollback();
- assertEquals("Node should keep the commited value", "commit", cache.getNode(fqn).get("entry"));
-
- tx.begin();
- cache.removeNode(fqn);
- cache.put(fqn, "entry", "rollback");
- tx.rollback();
-
- System.out.println("Cache: " + CachePrinter.printCacheDetails(cache));
-
- assertEquals("Node should keep the commited value", "commit", cache.getNode(fqn).get("entry"));// THIS FAILS
- }
-
- private TransactionManager startTransaction() throws Exception
- {
- TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
- mgr.begin();
- return mgr;
- }
-
- public void testConcurrentReadAndWriteAccess() throws Exception
- {
- cache.stop();
- cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
- cache.start();
-
- cache.put("/1/2/3/4", "foo", "bar");// no TX, no locks held after put() returns
-
- class Reader extends Thread
- {
- TransactionManager thread_tx;
-
- public Reader()
- {
- super("Reader");
- }
-
- public void run()
- {
- try
- {
- thread_tx = startTransaction();
- log("acquiring RL");
- cache.get("/1/2/3", "foo");// acquires RLs on all 3 nodes
- log("RL acquired successfully");
- sleep(2000);
- log("committing TX");
- thread_tx.commit();// releases RLs
- log("committed TX");
- }
- catch (Exception e)
- {
- exception = e;
- }
- }
- }
-
- class Writer extends Thread
- {
- TransactionManager thread_tx;
-
- public Writer()
- {
- super("Writer");
- }
-
- public void run()
- {
- try
- {
- sleep(500);// give the Reader a chance to acquire the RLs
- thread_tx = startTransaction();
- log("acquiring WL");
- cache.put("/1", "foo", "bar2");// needs to acquired a WL on /1
- log("acquired WL successfully");
- log("committing TX");
- thread_tx.commit();
- log("committed TX");
- }
- catch (Exception e)
- {
- exception = e;
- }
- }
- }
-
- Reader reader = new Reader();
- Writer writer = new Writer();
- reader.start();
- writer.start();
- reader.join();
- writer.join();
- if (exception != null)
- {
- throw exception;
- }
- }
-
- public void testRemoveAndGetInTx() throws Exception
- {
- Fqn A_B = Fqn.fromString("/a/b");
- Fqn A = Fqn.fromString("/a");
-
- cache.put(A_B, "k", "v");
-
- assertTrue(cache.exists(A_B));
- assertTrue(cache.exists(A));
-
- cache.getTransactionManager().begin();
- cache.removeNode(A);
- cache.get(A_B, "k");
- cache.getTransactionManager().commit();
- }
-
- public void testRemoveAndPutInTx() throws Exception
- {
- Fqn A_B = Fqn.fromString("/a/b");
- Fqn A = Fqn.fromString("/a");
-
- cache.put(A_B, "k", "v");
-
- assertTrue(cache.exists(A_B));
- assertTrue(cache.exists(A));
-
- cache.getTransactionManager().begin();
- cache.removeNode(A_B);
- cache.put(A_B, "k", "v2");
- cache.getTransactionManager().commit();
-
- assertTrue(cache.exists(A_B));
- assertTrue(cache.exists(A));
-
- assert cache.peek(A, true, true).isValid();
- assert cache.peek(A_B, true, true).isValid();
-
- assertEquals("v2", cache.get(A_B, "k"));
- }
-
- public void testRemoveParentAndPutInTx() throws Exception
- {
- Fqn A_B = Fqn.fromString("/a/b");
- Fqn A = Fqn.fromString("/a");
-
- cache.put(A_B, "k", "v");
-
- assertTrue(cache.exists(A_B));
- assertTrue(cache.exists(A));
-
- cache.getTransactionManager().begin();
- cache.removeNode(A);
- cache.put(A_B, "k", "v2");
- cache.getTransactionManager().commit();
-
- assertTrue(cache.exists(A_B));
- assertTrue(cache.exists(A));
-
- assertEquals("v2", cache.get(A_B, "k"));
- }
-
- public void testRemoveGrandParentAndPutInTx() throws Exception
- {
- Fqn A_B_C = Fqn.fromString("/a/b/c");
- Fqn A = Fqn.fromString("/a");
-
- cache.put(A_B_C, "k", "v");
-
- assertTrue(cache.exists(A_B_C));
- assertTrue(cache.exists(A));
-
- cache.getTransactionManager().begin();
- cache.removeNode(A);
- cache.put(A_B_C, "k", "v2");
- cache.getTransactionManager().commit();
-
- assertTrue(cache.exists(A_B_C));
- assertTrue(cache.exists(A));
-
- assertEquals("v2", cache.get(A_B_C, "k"));
- }
-
- public void testRootNodeRemoval() throws Exception
- {
- Fqn root = Fqn.ROOT;
- Fqn fqn = Fqn.fromElements(1);
- //put first time
- tx.begin();
- this.cache.put(fqn, "k", "v");
- tx.commit();
-
- //get works fine
- tx.begin();
- assertEquals("v", this.cache.get(fqn, "k"));
- tx.commit();
-
- //remove all
- tx.begin();
- this.cache.removeNode(root);
- tx.commit();
-
- //get returns null - ok
- //put - endless loop
- tx.begin();
- assertNull(this.cache.get(fqn, "k"));
- this.cache.put(fqn, "k", "v");
- tx.commit();
- }
-
- public void testNodeAdditionAfterRemoval() throws Exception
- {
- Fqn fqn = Fqn.fromString("/1/2/3/4");
- //put first time
- tx.begin();
- this.cache.put(fqn, "k", "v");
- tx.commit();
-
- //get works fine
- tx.begin();
- assertEquals("v", this.cache.get(fqn, "k"));
- tx.commit();
-
- //remove all
- tx.begin();
- this.cache.removeNode(Fqn.ROOT);
- tx.commit();
-
- //get returns null - ok
- //put - endless loop
- tx.begin();
- assertNull(this.cache.get(fqn, "k"));
- this.cache.put(fqn, "k", "v");
- tx.commit();
- }
-
- public void testRootNodeRemovalRollback() throws Exception
- {
- Fqn root = Fqn.ROOT;
- Fqn fqn = Fqn.fromRelativeElements(root, 1);
- //put first time
- tx.begin();
- this.cache.put(fqn, "k", "v");
- tx.commit();
-
- //get works fine
- tx.begin();
- assertEquals("v", this.cache.get(fqn, "k"));
- tx.commit();
-
- //remove all
- tx.begin();
- this.cache.removeNode(root);
- tx.rollback();
-
- assertEquals("v", this.cache.get(fqn, "k"));
- }
-
- private static void log(String msg)
- {
- System.out.println(Thread.currentThread().getName() + ": " + msg);
- }
-
-}
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/IsolationLevelTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/IsolationLevelTestBase.java 2008-08-23 12:40:58 UTC (rev 6610)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/isolationlevels/IsolationLevelTestBase.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -4,6 +4,7 @@
import org.jboss.cache.CacheFactory;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
import org.jboss.cache.lock.IsolationLevel;
import static org.jboss.cache.lock.IsolationLevel.*;
import org.jboss.cache.transaction.TransactionSetup;
@@ -40,7 +41,8 @@
{
CacheFactory<String, String> cf = new DefaultCacheFactory<String, String>();
cache = cf.createCache(false);
- cache.getConfiguration().setIsolationLevel(isolationLevel);
+ cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache.getConfiguration().setIsolationLevel(isolationLevel);
cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
// very short so the tests don't take ages
cache.getConfiguration().setLockAcquisitionTimeout(250);
Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AbortionTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AbortionTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AbortionTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -0,0 +1,204 @@
+/*
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.transaction.pessimistic;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
+import org.jboss.cache.transaction.NotifyingTransactionManager.Notification;
+import org.jboss.cache.transaction.NotifyingTransactionManager;
+import org.jboss.cache.transaction.DummyTransactionManager;
+import org.jboss.cache.transaction.TransactionContext;
+import org.jboss.cache.util.TestingUtil;
+import org.jgroups.JChannel;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.RollbackException;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+/**
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ */
+@Test(groups = {"functional"})
+public class AbortionTest
+{
+ private CacheSPI cache1, cache2, cache3;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ cache1 = initCache(false);
+ TestingUtil.sleepThread(1500); // to ensure cache1 is the coordinator
+ cache2 = initCache(false);
+ cache3 = initCache(true);
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ TestingUtil.killCaches(cache3, cache2, cache1);
+ }
+
+ private CacheSPI initCache(boolean notifying)
+ {
+ CacheSPI c = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(false);
+ c.getConfiguration().setCacheMode("REPL_SYNC");
+ c.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ c.getConfiguration().setClusterConfig(getJGroupsStack());
+ c.getConfiguration().setFetchInMemoryState(false);
+ if (!notifying)
+ {
+ c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.DummyTransactionManagerLookup");
+ }
+ else
+ {
+ c.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.transaction.NotifyingTransactionManager");
+ }
+ c.start();
+ return c;
+ }
+
+ // we need a 'special' stack that does not attempt redelivery since we kill a channel midway during a tx in this test.
+ private String getJGroupsStack()
+ {
+ return JChannel.DEFAULT_PROTOCOL_STACK;
+ }
+
+ private void destroyCache(CacheSPI c)
+ {
+ if (c != null)
+ {
+ c.stop();
+ c.destroy();
+ }
+ }
+
+ public void testSyncCaches() throws Exception
+ {
+ performTest(false, false);
+ }
+
+ public void testSyncCachesSyncCommitRollback() throws Exception
+ {
+ performTest(true, false);
+ }
+
+ /**
+ * Note that this tests a *remote* beforeCompletion abort - which is a part of the calling instance's afterCompletion.
+ *
+ * @throws Exception
+ */
+ public void testAbortBeforeCompletion() throws Exception
+ {
+ performTest(true, true);
+ }
+
+ private void performTest(boolean syncCommitRollback, boolean abortBeforeCompletion) throws Exception
+ {
+ cache1.getConfiguration().setSyncCommitPhase(syncCommitRollback);
+ cache1.getConfiguration().setSyncRollbackPhase(syncCommitRollback);
+ cache2.getConfiguration().setSyncCommitPhase(syncCommitRollback);
+ cache2.getConfiguration().setSyncRollbackPhase(syncCommitRollback);
+ cache3.getConfiguration().setSyncCommitPhase(syncCommitRollback);
+ cache3.getConfiguration().setSyncRollbackPhase(syncCommitRollback);
+
+ TransactionManager mgr1 = cache1.getTransactionManager();
+ TransactionManager mgr2 = cache2.getTransactionManager();
+ assertTrue(cache3.getTransactionManager() instanceof NotifyingTransactionManager);
+ NotifyingTransactionManager mgr3 = (NotifyingTransactionManager) cache3.getTransactionManager();
+ mgr3.setCache(cache3);
+
+ assertSame(mgr1, mgr2);
+ assertNotSame(mgr1, mgr3);
+ assertNotSame(mgr2, mgr3);
+
+ assertTrue(mgr1 instanceof DummyTransactionManager);
+ assertTrue(mgr2 instanceof DummyTransactionManager);
+
+ cache1.put("/test", "key", "value");
+
+ assertEquals("value", cache1.get("/test", "key"));
+ assertEquals("value", cache2.get("/test", "key"));
+ assertEquals("value", cache3.get("/test", "key"));
+
+ mgr3.setNotification(new TestNotification(abortBeforeCompletion));
+
+ mgr1.begin();
+ cache1.put("/test", "key", "value2");
+ mgr1.commit();
+
+ TestingUtil.sleepThread(5000);
+
+ // only test cache1 and cache2. Assume cache3 has crashed out.
+ assertEquals(0, cache1.getNumberOfLocksHeld());
+ assertEquals(0, cache2.getNumberOfLocksHeld());
+ assertEquals("put in transaction should NOT have been rolled back", "value2", cache1.get("/test", "key"));
+ assertEquals("put in transaction should NOT have been rolled back", "value2", cache2.get("/test", "key"));
+
+ }
+
+ class TestNotification implements Notification
+ {
+ boolean abortBeforeCompletion;
+
+ public TestNotification(boolean abortBeforeCompletion)
+ {
+ this.abortBeforeCompletion = abortBeforeCompletion;
+ }
+
+ public void notify(Transaction tx, TransactionContext transactionContext) throws SystemException, RollbackException
+ {
+ OrderedSynchronizationHandler osh = transactionContext.getOrderedSynchronizationHandler();
+
+ final Transaction finalTx = tx;
+ System.out.println("Notify called.");
+ // add an aborting sync handler.
+ Synchronization abort = new Synchronization()
+ {
+
+ public void beforeCompletion()
+ {
+ if (abortBeforeCompletion)
+ {
+ cache3.getConfiguration().getRuntimeConfig().getChannel().close();
+ System.out.println("Returning from abort.beforeCompletion");
+ try
+ {
+ finalTx.setRollbackOnly();
+ }
+ catch (SystemException e)
+ {
+ throw new RuntimeException("Unable to set rollback", e);
+ }
+ throw new RuntimeException("Dummy exception");
+ }
+ }
+
+ public void afterCompletion(int i)
+ {
+ if (!abortBeforeCompletion)
+ {
+ cache3.getConfiguration().getRuntimeConfig().getChannel().close();
+ System.out.println("Returning from abort.afterCompletion");
+ throw new RuntimeException("Dummy exception");
+ }
+ }
+ };
+
+ osh.registerAtHead(abort);
+ System.out.println("Added sync handler.");
+ }
+
+ }
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AbortionTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/transaction/AsyncRollbackTxTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -0,0 +1,240 @@
+package org.jboss.cache.transaction.pessimistic;
+
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.config.Configuration;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+
+/**
+ * Test behaviour of async rollback timeouted transaction
+ *
+ * @author <a href="mailto:jhalat@infovide.pl">Jacek Halat</a>
+ * @since 1.4.0
+ */
+@Test(groups = {"functional"})
+public class AsyncRollbackTxTest
+{
+ private CacheSPI<String, String> cache;
+ private TransactionManager tm;
+ private Fqn fqn = Fqn.fromString("/test");
+ // This sleep time (millis) should be longer than the transaction timeout time.
+ private long sleepTime = 2500;
+ // seconds
+ private int txTimeout = 2;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ Configuration c = new Configuration();
+ c.setTransactionManagerLookupClass("org.jboss.cache.transaction.AsyncRollbackTransactionManagerLookup");
+ CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache = (CacheSPI<String, String>) instance.createCache(c);
+ tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+ tm.setTransactionTimeout(txTimeout);
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown()
+ {
+ try
+ {
+ if (tm != null && tm.getTransaction() != null)
+ {
+ try
+ {
+ tm.rollback();
+ }
+ catch (SystemException e)
+ {
+ // do nothing
+ }
+ }
+ }
+ catch (SystemException e)
+ {
+ // do nothing
+ }
+ if (cache != null)
+ cache.stop();
+ cache = null;
+ tm = null;
+ }
+
+ public void testCommitCreationInSameTx() throws Exception
+ {
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ tm.begin();
+ cache.put(fqn, "k", "v");
+ assertEquals(2, cache.getNumberOfLocksHeld());
+ Thread.sleep(sleepTime);
+ tm.commit();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ }
+
+ public void testRollbackCreationInSameTx() throws Exception
+ {
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ tm.begin();
+ cache.put(fqn, "k", "v");
+ assertEquals(2, cache.getNumberOfLocksHeld());
+ Thread.sleep(sleepTime);
+ tm.rollback();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ // make sure the node was NOT added!!
+ assertFalse(cache.exists(fqn));
+ // even in a "deleted" form
+ assertNull(cache.peek(fqn, true));
+ }
+
+ private void doTest(boolean commit, boolean writeLock) throws Exception
+ {
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ cache.put(fqn, "k", "v");//Executed in Not transactional context
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ SeparateThread t = new SeparateThread(commit, writeLock);
+ t.start();
+ t.join();
+ if (t.getException() != null)
+ {
+ throw t.getException();
+ }
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ assertEquals("v", cache.get(fqn, "k"));
+ }
+
+ public void testRollbackCreationInDifferentTxReadLock() throws Exception
+ {
+ doTest(false, false);
+ }
+
+ public void testCommitCreationInDifferentTxReadLock() throws Exception
+ {
+ doTest(true, false);
+ }
+
+ public void testRollbackCreationInDifferentTxWriteLock() throws Exception
+ {
+ doTest(false, true);
+ }
+
+ public void testCommitCreationInDifferentTxWriteLock() throws Exception
+ {
+ doTest(true, true);
+ }
+
+ public void testTxTimeoutAndPutAfter() throws Exception
+ {
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ tm.begin();
+ cache.put(fqn, "k", "v");
+ assertEquals(2, cache.getNumberOfLocksHeld());
+ assertNotNull(tm.getTransaction());
+ Thread.sleep(sleepTime);
+ tm.rollback();
+ assertNull(tm.getTransaction());
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ // make sure the node was NOT added!!
+ assertFalse(cache.exists(fqn));
+ // even in a "deleted" form
+ assertNull(cache.peek(fqn, true));
+
+ //Put not some data into cache. Because no transaction is used
+ //no locks should be helds after this line.
+ cache.put(fqn, "k", "v");
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ }
+
+ public void testTxTimeoutAndPutGetAfter() throws Exception
+ {
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ tm.begin();
+ cache.put(fqn, "k", "v");
+ assertEquals(2, cache.getNumberOfLocksHeld());
+ assertNotNull(tm.getTransaction());
+ Thread.sleep(sleepTime);
+ tm.rollback();
+ // make sure the node was NOT added!!
+ assertFalse(cache.exists(fqn));
+ // even in a "deleted" form
+ assertNull(cache.peek(fqn, true));
+ assertNull(tm.getTransaction());
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ //Put not some data into cache. Because no transaction is used
+ //no locks should be helds after this line.
+ cache.put(fqn, "k", "v");
+ cache.get(fqn, "k");
+
+ // Make sure no write lock is retained by the main thread. Test that another thread can read.
+ SeparateThread t = new SeparateThread(false, false);
+ t.start();
+ t.join();
+ if (t.getException() != null)
+ {
+ throw t.getException();
+ }
+ }
+
+ private class SeparateThread extends Thread
+ {
+ Exception e = null;
+ boolean commit, writeLock;
+
+ public SeparateThread(boolean commit, boolean writeLock)
+ {
+ this.commit = commit;
+ this.writeLock = writeLock;
+ }
+
+ public Exception getException()
+ {
+ return e;
+ }
+
+ public void run()
+ {
+ try
+ {
+ tm.begin();
+ if (writeLock)
+ {
+ cache.put(fqn, "k", "v2");// obtain write lock on node
+ }
+ else
+ {
+ cache.get(fqn, "k");// obtain read lock on node
+ }
+
+ // sleep to ensure tx times out.
+ sleep(2500);
+
+ if (commit)
+ {
+ tm.commit();
+ }
+ else
+ {
+ tm.rollback();
+ }
+
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ }
+ catch (Exception e)
+ {
+ this.e = e;
+ }
+ }
+ }
+
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/AsyncRollbackTxTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/transaction/ConcurrentTransactionalTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -0,0 +1,202 @@
+/*
+ *
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.transaction.pessimistic;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.transaction.TransactionSetup;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
+import org.jboss.cache.lock.IsolationLevel;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.fail;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.UserTransaction;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Unit test for local CacheSPI. Use locking and multiple threads to test
+ * concurrent access to the tree.
+ *
+ * @version $Id$
+ */
+@Test(groups = {"functional", "transaction"})
+public class ConcurrentTransactionalTest
+{
+ private CacheSPI<Integer, String> cache;
+ private Log logger_ = LogFactory.getLog(ConcurrentTransactionalTest.class);
+ private static Throwable thread_ex = null;
+ private static final int NUM = 10000;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ }
+
+ private void createCache(IsolationLevel level)
+ {
+ CacheFactory<Integer, String> factory = new DefaultCacheFactory<Integer, String>();
+ Configuration conf = UnitTestCacheConfigurationFactory.createConfiguration(Configuration.CacheMode.LOCAL, true);
+ conf.setCacheMode(Configuration.CacheMode.LOCAL);
+ conf.setIsolationLevel(level);
+ conf.setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ conf.setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache = (CacheSPI) new DefaultCacheFactory<Object, Object>().createCache(conf);
+ cache.put("/a/b/c", null);
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ cache.stop();
+ thread_ex = null;
+ TransactionSetup.cleanup();
+ }
+
+ public void testConcurrentAccessWithRWLock() throws Throwable
+ {
+ createCache(IsolationLevel.REPEATABLE_READ);
+ work_();
+ }
+
+ public void testConcurrentAccessWithExclusiveLock() throws Throwable
+ {
+ createCache(IsolationLevel.SERIALIZABLE);
+ work_();
+ }
+
+ private void work_() throws Throwable
+ {
+ Updater one, two;
+ try
+ {
+ one = new Updater("Thread one");
+ two = new Updater("Thread two");
+ long current = System.currentTimeMillis();
+ one.start();
+ two.start();
+ one.join();
+ two.join();
+ if (thread_ex != null)
+ {
+ throw thread_ex;
+ }
+
+ long now = System.currentTimeMillis();
+ log("*** Time elapsed: " + (now - current));
+
+ System.out.println("cache content: " + cache.toString());
+ Set<Integer> keys = cache.getNode(Fqn.fromString("/a/b/c")).getKeys();
+ System.out.println("number of keys=" + keys.size());
+
+ if (keys.size() != NUM)
+ {
+ scanForNullValues(keys);
+
+ try
+ {
+ System.out.println("size=" + keys.size());
+ List<Integer> l = new LinkedList<Integer>(keys);
+ Collections.sort(l);
+ System.out.println("keys: " + l);
+ for (int i = 0; i < NUM; i++)
+ {
+ if (!l.contains(new Integer(i)))
+ {
+ System.out.println("missing: " + i);
+ }
+ }
+
+ LinkedList<Integer> duplicates = new LinkedList<Integer>();
+ for (Integer integer : l)
+ {
+ if (duplicates.contains(integer))
+ {
+ System.out.println(integer + " is a duplicate");
+ }
+ else
+ {
+ duplicates.add(integer);
+ }
+ }
+ }
+ catch (Exception e1)
+ {
+ e1.printStackTrace();
+ }
+ }
+
+ assertEquals(NUM, keys.size());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail(e.toString());
+ }
+ }
+
+ private void scanForNullValues(Set<Integer> keys)
+ {
+ for (Object o : keys)
+ {
+ if (o == null)
+ {
+ System.err.println("found a null value in keys");
+ }
+ }
+ }
+
+ private void log(String msg)
+ {
+ logger_.debug(" [" + Thread.currentThread() + "]: " + msg);
+ }
+
+ private class Updater extends Thread
+ {
+ private String val = null;
+ private UserTransaction tx;
+
+ public Updater(String name)
+ {
+ this.val = name;
+ }
+
+ public void run()
+ {
+ try
+ {
+ log("adding data");
+ tx = TransactionSetup.getUserTransaction();
+ for (int i = 0; i < NUM; i++)
+ {
+ log("adding data i=" + i);
+ tx.begin();
+ cache.put("/a/b/c", i, val);
+ tx.commit();
+ yield();
+ }
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ thread_ex = t;
+ }
+ }
+ }
+
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/ConcurrentTransactionalTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/IsolationLevelNoneTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/transaction/IsolationLevelNoneTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/IsolationLevelNoneTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/IsolationLevelNoneTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -0,0 +1,106 @@
+package org.jboss.cache.transaction.pessimistic;
+
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.transaction.TransactionSetup;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.lock.IsolationLevel;
+import static org.testng.AssertJUnit.assertEquals;
+import static org.testng.AssertJUnit.assertTrue;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.NotSupportedException;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+
+/**
+ * Tests whether modifications within callbacks (TreeCacheListener) are handled correctly
+ *
+ * @author Bela Ban
+ * @version $Id$
+ */
+@Test(groups = {"functional", "transaction"})
+public class IsolationLevelNoneTest
+{
+ CacheSPI<String, String> cache = null;
+ final Fqn FQN = Fqn.fromString("/a/b/c");
+ final String KEY = "key";
+ final String VALUE = "value";
+ TransactionManager tm;
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ if (cache != null)
+ {
+ cache.stop();
+ cache.destroy();
+ cache = null;
+ }
+ }
+
+ public void testWithoutTransactions() throws Exception
+ {
+ CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ cache = (CacheSPI<String, String>) instance.createCache(false);
+ cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+ cache.getConfiguration().setIsolationLevel(IsolationLevel.NONE);
+ cache.start();
+ cache.put(FQN, KEY, VALUE);
+ cache.put(FQN + "/d", KEY, VALUE);
+ Node node = cache.peek(FQN, false, false);
+ assertTrue(node != null && node.getKeys().contains(KEY));
+ assertEquals(VALUE, cache.get(FQN, KEY));
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ }
+
+ public void testWithTransactions() throws Exception
+ {
+ CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ cache = (CacheSPI<String, String>) instance.createCache(false);
+ cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+ cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache.getConfiguration().setIsolationLevel(IsolationLevel.NONE);
+ cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ cache.start();
+ tm = startTransaction();
+ cache.put(FQN, KEY, VALUE);
+ cache.put(FQN + "/d", KEY, VALUE);
+ Node node = cache.peek(FQN, false, false);
+ assertTrue(node != null && node.getKeys().contains(KEY));
+ assertEquals(VALUE, cache.get(FQN, KEY));
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ tm.commit();
+ }
+
+ public void testWithTransactionsRepeatableRead() throws Exception
+ {
+ CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ cache = (CacheSPI<String, String>) instance.createCache(false);
+ cache.getConfiguration().setCacheMode(Configuration.CacheMode.LOCAL);
+ cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ cache.start();
+ tm = startTransaction();
+ cache.put(FQN, KEY, VALUE);
+ cache.put(FQN + "/d", KEY, VALUE);
+ Node node = cache.peek(FQN, false, false);
+ assertTrue(node != null && node.getKeys().contains(KEY));
+ assertEquals(VALUE, cache.get(FQN, KEY));
+ assertEquals(5, cache.getNumberOfLocksHeld());
+ tm.commit();
+ }
+
+ private TransactionManager startTransaction() throws SystemException, NotSupportedException
+ {
+ TransactionManager mgr = cache.getTransactionManager();
+ mgr.begin();
+ return mgr;
+ }
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/IsolationLevelNoneTest.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PessimisticTransactionTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/transaction/TransactionTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PessimisticTransactionTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PessimisticTransactionTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -0,0 +1,1072 @@
+/*
+ *
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package org.jboss.cache.transaction.pessimistic;
+
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.transaction.TransactionSetup;
+import org.jboss.cache.transaction.GlobalTransaction;
+import org.jboss.cache.config.Configuration;
+import org.jboss.cache.lock.IsolationLevel;
+import org.jboss.cache.lock.LockManager;
+import static org.jboss.cache.lock.LockType.READ;
+import static org.jboss.cache.lock.LockType.WRITE;
+import org.jboss.cache.util.CachePrinter;
+import org.jboss.cache.util.TestingUtil;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Tests transactional access to a local CacheImpl.
+ * Note: we use DummpyTranasctionManager to replace jta
+ *
+ * @version $Id$
+ */
+@Test(groups = {"functional", "transaction"})
+public class PessimisticTransactionTest
+{
+ CacheSPI<String, Comparable> cache = null;
+ UserTransaction tx = null;
+ Exception exception;
+ LockManager lockManager;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+
+ CacheFactory<String, Comparable> instance = new DefaultCacheFactory<String, Comparable>();
+ cache = (CacheSPI<String, Comparable>) instance.createCache(false);
+ cache.getConfiguration().setClusterName("test");
+ cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache.getConfiguration().setStateRetrievalTimeout(10000);
+ cache.getConfiguration().setIsolationLevel(IsolationLevel.SERIALIZABLE);
+ cache.getConfiguration().setLockParentForChildInsertRemove(true);// this test case is written to assume this.
+ cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ tx = TransactionSetup.getUserTransaction();
+
+ cache.create();
+ cache.start();
+ exception = null;
+ lockManager = TestingUtil.extractLockManager(cache);
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ if (cache != null)
+ {
+ cache.stop();
+ cache = null;
+ }
+
+ // BW. kind of a hack to destroy jndi binding and thread local tx before next run.
+ TransactionSetup.cleanup();
+
+ if (tx != null)
+ {
+ try
+ {
+ tx.rollback();
+ }
+ catch (Throwable t)
+ {
+ // do nothing
+ }
+ tx = null;
+ }
+ }
+
+ public void testPutTx() throws Exception
+ {
+ tx.begin();
+ cache.put("/a/b/c", "age", 38);
+ // the tx interceptor should know that we're in the same tx.
+ assertEquals(cache.get("/a/b/c", "age"), 38);
+
+ cache.put("/a/b/c", "age", 39);
+ tx.commit();
+
+ // This test is done outside the TX, it wouldn't work if someone else
+ // modified "age". This works because we're the only TX running.
+ assertEquals(cache.get("/a/b/c", "age"), 39);
+ }
+
+ public void testRollbackTx1()
+ {
+ try
+ {
+ tx.begin();
+ cache.put("/a/b/c", "age", 38);
+ cache.put("/a/b/c", "age", 39);
+ tx.rollback();
+
+ // This test is done outside the TX, it wouldn't work if someone else
+ // modified "age". This works because we're the only TX running.
+ assertNull(cache.get("/a/b/c", "age"));
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ public void testGetAfterRemovalRollback() throws Exception
+ {
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ cache.put("/a/b", null);
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ assertTrue(cache.exists("/a/b"));
+ tx.begin();
+ cache.removeNode("/a/b");
+ assertFalse(cache.exists("/a/b"));
+ tx.rollback();
+ assertTrue(cache.exists("/a/b"));
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ // new tx in new thread
+ Thread th = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ cache.getTransactionManager().begin();
+ assertNotNull(cache.getNode("/a/b"));
+ cache.getTransactionManager().rollback();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Caught exception");
+ }
+ }
+ };
+
+ th.start();
+ th.join();
+
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ }
+
+ public void testRollbackTx2()
+ {
+ try
+ {
+ tx.begin();
+ cache.put("/a/b/c", "age", 38);
+ cache.remove("/a/b/c", "age");
+ tx.rollback();
+
+ // This test is done outside the TX, it wouldn't work if someone else
+ // modified "age". This works because we're the only TX running.
+ assertNull(cache.get("/a/b/c", "age"));
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ public void testRollbackTx2a()
+ {
+ try
+ {
+ cache.put("/a/b/c", "age", 38);
+ tx.begin();
+ cache.remove("/a/b/c", "age");
+ tx.rollback();
+
+ // This test is done outside the TX, it wouldn't work if someone else
+ // modified "age". This works because we're the only TX running.
+ assertEquals(38, cache.get("/a/b/c", "age"));
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ public void testRollbackTx3()
+ {
+ try
+ {
+ java.util.Map<String, Comparable> map1 = new java.util.HashMap<String, Comparable>();
+ map1.put("age", 38);
+ java.util.Map<String, Comparable> map2 = new java.util.HashMap<String, Comparable>();
+ map2.put("age", 39);
+ tx.begin();
+ cache.put("/a/b/c", map1);
+ cache.put("/a/b/c", map2);
+ tx.rollback();
+
+ // This test is done outside the TX, it wouldn't work if someone else
+ // modified "age". This works because we're the only TX running.
+ assertNull(cache.get("/a/b/c", "age"));
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ public void testRollbackTx4()
+ {
+ try
+ {
+ Map<String, Comparable> map = new HashMap<String, Comparable>();
+ map.put("age", 38);
+ tx.begin();
+ cache.put("/a/b/c", map);
+ cache.removeNode("/a/b/c");
+ tx.rollback();
+
+ // This test is done outside the TX, it wouldn't work if someone else
+ // modified "age". This works because we're the only TX running.
+ assertNull(cache.get("/a/b/c", "age"));
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ public void testNodeCreationRollback()
+ {
+ try
+ {
+ tx.begin();
+ System.out.println("initial state:\n" + cache);
+ cache.put("/bela/ban", "key", "value");
+ System.out.println("after put():\n" + cache);
+ tx.rollback();
+ System.out.println("after rollback():\n" + cache);
+
+ assertNull("node should be not existent", cache.getNode("/bela/ban"));
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ public void testNodeCreationRollback2()
+ {
+ try
+ {
+ cache.put("/bela/ban", null);
+ tx.begin();
+ cache.put("/bela/ban/michelle", null);
+ tx.rollback();
+ assertNotNull("node should be not null", cache.getNode("/bela/ban"));
+ assertNull("node should be not existent", cache.getNode("/bela/ban/michelle"));
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ public void testNodeDeletionRollback()
+ {
+ try
+ {
+ cache.put("/a/b/c", null);
+ tx.begin();
+ cache.removeNode("/a/b/c");
+ assertNull(cache.getNode("/a/b/c"));
+ cache.removeNode("/a/b");
+ assertNull(cache.getNode("/a/b"));
+ cache.removeNode("/a");
+ assertNull(cache.getNode("/a"));
+ tx.rollback();
+ assertNotNull(cache.getNode("/a/b/c"));
+ assertNotNull(cache.getNode("/a/b"));
+ assertNotNull(cache.getNode("/a"));
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ public void testNodeDeletionRollback2() throws Exception
+ {
+ cache.put("/a/b/c", null);
+ cache.put("/a/b/c1", null);
+ cache.put("/a/b/c2", null);
+ tx.begin();
+ cache.removeNode("/a");
+ assertNull(cache.getNode("/a/b/c"));
+ assertNull(cache.getNode("/a/b/c1"));
+ assertNull(cache.getNode("/a/b/c2"));
+ assertNull(cache.getNode("/a/b"));
+ assertNull(cache.getNode("/a"));
+ Set children = cache.getChildrenNames(Fqn.fromString("/a/b"));
+ assertTrue(children.isEmpty());
+ children = cache.getChildrenNames("/a");
+ assertTrue(children.isEmpty());
+ tx.rollback();
+ assertNotNull(cache.getNode("/a"));
+ assertNotNull(cache.getNode("/a/b"));
+ assertNotNull(cache.getNode("/a/b/c"));
+ assertNotNull(cache.getNode("/a/b/c1"));
+ assertNotNull(cache.getNode("/a/b/c2"));
+ children = cache.getChildrenNames(Fqn.fromString("/a/b"));
+ assertEquals(3, children.size());
+ }
+
+ public void testNodeCreation() throws Exception
+ {
+ GlobalTransaction gtx;
+ cache.put("/a/b", null);
+ tx.begin();
+ gtx = cache.getCurrentTransaction();
+ cache.put("/a/b/c", null);
+ assertLocked(gtx, "/a", false);
+ assertLocked(gtx, "/a/b", true);
+ assertLocked(gtx, "/a/b/c", true);
+ }
+
+ public void testNodeCreation2() throws Exception
+ {
+ GlobalTransaction gtx;
+ tx.begin();
+ gtx = cache.getCurrentTransaction();
+ cache.put("/a/b/c", null);
+ assertLocked(gtx, "/a", true);
+ assertLocked(gtx, "/a/b", true);
+ assertLocked(gtx, "/a/b/c", true);
+ }
+
+ public void testNodeRemoval() throws SystemException, NotSupportedException
+ {
+ GlobalTransaction gtx;
+ cache.put("/a/b/c", null);
+ tx.begin();
+ gtx = cache.getCurrentTransaction();
+ cache.removeNode("/a/b/c");// need to remove the node, not just the data in the node.
+ assertLocked(gtx, "/a", false);
+ assertLocked(gtx, "/a/b", true);
+ assertLocked(gtx, "/a/b/c", true);
+ tx.rollback();
+ }
+
+ public void testNodeRemoval2() throws SystemException, NotSupportedException
+ {
+ GlobalTransaction gtx;
+ cache.put("/a/b/c", null);
+ tx.begin();
+ gtx = cache.getCurrentTransaction();
+ cache.removeNode("/a/b");// need to remove the node, not just the data in the node.
+ assertLocked(gtx, "/a", true);
+ assertLocked(gtx, "/a/b", true);
+ assertLocked(gtx, "/a/b/c", true);
+ tx.rollback();
+ }
+
+ public void testIntermediateNodeCreationOnWrite() throws Exception
+ {
+ cache.put("/a", null);
+ tx.begin();
+ cache.put("/a/b/c", null);
+ // expecting WLs on /a, /a/b and /a/b/c.
+ GlobalTransaction gtx = cache.getCurrentTransaction();
+ assertLocked(gtx, "/a", true);
+ assertLocked(gtx, "/a/b", true);
+ assertLocked(gtx, "/a/b/c", true);
+ tx.rollback();
+ }
+
+ public void testIntermediateNodeCreationOnRead() throws Exception
+ {
+ cache.put("/a", null);
+ tx.begin();
+ cache.getNode("/a/b/c");
+
+ // expecting RLs on /, /a
+ // /a/b, /a/b/c should NOT be created!
+ GlobalTransaction gtx = cache.getCurrentTransaction();
+ assertLocked(gtx, "/", false);
+ assertLocked(gtx, "/a", false);
+ assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b"), true));
+ assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/b/c"), true));
+ tx.rollback();
+ assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b"), true));
+ assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/b/c"), true));
+
+ }
+
+ public void testIntermediateNodeCreationOnRemove() throws Exception
+ {
+ cache.put("/a", null);
+ tx.begin();
+ cache.removeNode("/a/b/c");
+
+ // expecting RLs on /, /a
+ // /a/b, /a/b/c should NOT be created!
+ GlobalTransaction gtx = cache.getCurrentTransaction();
+ assertLocked(gtx, "/", false);
+ assertLocked(gtx, "/a", true);
+ assertLocked(gtx, "/a/b", true);
+ assertLocked(gtx, "/a/b/c", true);
+ assertNotNull("/a/b should exist", cache.peek(Fqn.fromString("/a/b"), true));
+ assertNotNull("/a/b/c should exist", cache.peek(Fqn.fromString("/a/b/c"), true));
+ assertNotNull("/a/b should NOT be visible", cache.exists(Fqn.fromString("/a/b")));
+ assertNotNull("/a/b/c should NOT be visible", cache.exists(Fqn.fromString("/a/b/c")));
+ tx.rollback();
+ assertNull("/a/b should not exist", cache.peek(Fqn.fromString("/a/b"), true));
+ assertNull("/a/b/c should not exist", cache.peek(Fqn.fromString("/a/b/c"), true));
+
+ }
+
+ public void testNodeDeletionRollback3() throws Exception
+ {
+ GlobalTransaction gtx;
+ cache.put("/a/b/c1", null);
+
+ tx.begin();
+ gtx = cache.getCurrentTransaction();
+ cache.put("/a/b/c1", null);
+ assertLocked(gtx, "/a", false);
+ assertLocked(gtx, "/a/b", false);
+ assertLocked(gtx, "/a/b/c1", true);
+
+ cache.put("/a/b/c2", null);
+ assertLocked(gtx, "/a/b", true);
+ assertLocked(gtx, "/a/b/c2", true);
+
+ cache.put("/a/b/c3", null);
+ cache.put("/a/b/c1/one", null);
+ assertLocked(gtx, "/a/b/c1", true);
+ assertLocked(gtx, "/a/b/c1/one", true);
+
+ cache.put("/a/b/c1/two", null);
+ cache.put("/a/b/c1/one/1", null);
+ assertLocked(gtx, "/a/b/c1", true);
+ assertLocked(gtx, "/a/b/c1/one", true);
+ assertLocked(gtx, "/a/b/c1/one/1", true);
+
+ cache.put("/a/b/c1/two/2/3/4", null);
+ assertLocked(gtx, "/a/b/c1", true);
+ assertLocked(gtx, "/a/b/c1/two", true);
+ assertLocked(gtx, "/a/b/c1/two/2", true);
+ assertLocked(gtx, "/a/b/c1/two/2/3", true);
+ assertLocked(gtx, "/a/b/c1/two/2/3/4", true);
+
+ cache.removeNode("/a/b");
+ tx.rollback();
+ assertTrue(cache.getChildrenNames("/a/b/c1").isEmpty());
+ Set cn = cache.getChildrenNames(Fqn.fromString("/a/b"));
+ assertEquals(1, cn.size());
+ assertEquals("c1", cn.iterator().next());
+ }
+
+ public void testDoubleLocks() throws Exception
+ {
+ tx.begin();
+ GlobalTransaction gtx = cache.getCurrentTransaction();
+ cache.put("/a/b/c", null);
+ cache.put("/a/b/c", null);
+
+ NodeSPI n = cache.getNode("/a");
+ assert !lockManager.isLocked(n, READ);
+ // make sure this is write locked.
+ assertLocked(gtx, "/a", true);
+
+ n = cache.getNode("/a/b");
+ assert !lockManager.isLocked(n, READ);
+ // make sure this is write locked.
+ assertLocked(gtx, "/a/b", true);
+
+ n = cache.getNode("/a/b/c");
+ assert !lockManager.isLocked(n, READ);
+ // make sure this is write locked.
+ assertLocked(gtx, "/a/b/c", true);
+
+ tx.rollback();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ }
+
+ private void assertLocked(Object owner, String fqn, boolean writeLocked)
+ {
+ NodeSPI<String, Comparable> n = cache.peek(Fqn.fromString(fqn), true);
+ if (owner == null) owner = Thread.currentThread();
+ assertTrue("node " + fqn + " is not locked", lockManager.isLocked(n));
+ if (writeLocked)
+ {
+ assertTrue("node " + fqn + " is not write-locked by owner " + owner + ". Lock details: " + lockManager.printLockInfo(n), lockManager.ownsLock(Fqn.fromString(fqn), WRITE, owner));
+ }
+ else
+ {
+ assertTrue("node " + fqn + " is not read-locked by owner " + owner + ". Lock details: " + lockManager.printLockInfo(n), lockManager.ownsLock(Fqn.fromString(fqn), READ, owner));
+ }
+ }
+
+ public void testConcurrentNodeAccessOnRemovalWithTx() throws Exception
+ {
+ cache.put("/a/b/c", null);
+ tx.begin();
+ cache.removeNode("/a/b/c");
+ // this node should now be locked.
+ TransactionManager tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+ Transaction t = tm.suspend();
+ // start a new tx
+ tm.begin();
+ try
+ {
+ cache.getNode("/a/b/c");// should fail
+ fail("Should not be able to get a hold of /a/b/c until the deleting tx completes");
+ }
+ catch (Exception e)
+ {
+ // expected
+ //cache.getTransactionManager().commit();
+ tm.commit();
+ }
+
+ tm.resume(t);
+ tx.rollback();
+
+ assertNotNull(cache.getNode("/a/b/c"));
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ }
+
+ public void testConcurrentNodeAccessOnRemovalWithoutTx() throws Exception
+ {
+ cache.put("/a/b/c", null);
+ tx.begin();
+ cache.removeNode("/a/b/c");
+ // this node should now be locked.
+ Transaction t = cache.getTransactionManager().suspend();
+ Thread th = new Thread()
+ {
+ public void run()
+ {
+ try
+ {
+ cache.getNode("/a/b/c");// should fail
+
+ fail("Should not be able to get a hold of /a/b/c until the deleting tx completes");
+ }
+ catch (Exception e)
+ {
+ // expected
+ }
+ }
+ };
+
+ th.start();
+ th.join();
+
+ cache.getTransactionManager().resume(t);
+ tx.rollback();
+
+ assertNotNull(cache.getNode("/a/b/c"));
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ }
+
+ public void testRemove() throws CacheException, SystemException, NotSupportedException, HeuristicMixedException, HeuristicRollbackException, RollbackException
+ {
+ cache.put("/a/b/c", null);
+ cache.put("/a/b/c/1", null);
+ cache.put("/a/b/c/2", null);
+ cache.put("/a/b/c/3", null);
+ cache.put("/a/b/c/3/a/b/c", null);
+
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ tx.begin();
+ cache.removeNode("/a/b/c");
+ // this used to test for 2 locks held. After the fixes for JBCACHE-875 however, 2 more locks are acquired - for the root node as well as the deleted node.
+ // and since we would lock all children of the deleted node as well, we have 10 locks here.
+ assertEquals(10, cache.getNumberOfLocksHeld());
+ tx.commit();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+ }
+
+ public void testRemoveAndRollback() throws CacheException, SystemException, NotSupportedException, HeuristicMixedException, HeuristicRollbackException,
+ RollbackException
+ {
+ cache.put("/a/b/c", null);
+ cache.put("/a/b/c/1", null);
+ cache.put("/a/b/c/2", null);
+ cache.put("/a/b/c/3", null);
+ cache.put("/a/b/c/3/a/b/c", null);
+
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ tx.begin();
+ cache.removeNode("/a/b/c");
+ assertEquals(10, cache.getNumberOfLocksHeld());
+ tx.rollback();
+ assertEquals(0, cache.getNumberOfLocksHeld());
+
+ assertTrue(cache.exists("/a/b/c"));
+ assertTrue(cache.exists("/a/b/c/1"));
+ assertTrue(cache.exists("/a/b/c/2"));
+ assertTrue(cache.exists("/a/b/c/3"));
+ assertTrue(cache.exists("/a/b/c/3/a"));
+ assertTrue(cache.exists("/a/b/c/3/a/b"));
+ assertTrue(cache.exists("/a/b/c/3/a/b/c"));
+ }
+
+ public void testRemoveKeyRollback() throws CacheException, SystemException, NotSupportedException
+ {
+ cache.put("/bela/ban", "name", "Bela");
+ tx.begin();
+ cache.remove("/bela/ban", "name");
+ assertNull(cache.get("/bela/ban", "name"));
+ tx.rollback();
+ assertEquals("Bela", cache.get("/bela/ban", "name"));
+ }
+
+ public void testRemoveKeyRollback2()
+ {
+ try
+ {
+ Map<String, Comparable> m = new HashMap<String, Comparable>();
+ m.put("name", "Bela");
+ m.put("id", 322649);
+ cache.put("/bela/ban", m);
+ tx.begin();
+ cache.remove("/bela/ban", "name");
+ assertNull(cache.get("/bela/ban", "name"));
+ tx.rollback();
+ assertEquals("Bela", cache.get("/bela/ban", "name"));
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ public void testRemoveKeyRollback3()
+ {
+ try
+ {
+ cache.put("/bela/ban", "name", "Bela");
+ tx.begin();
+ cache.put("/bela/ban", "name", "Michelle");
+ cache.remove("/bela/ban", "name");
+ assertNull(cache.get("/bela/ban", "name"));
+ tx.rollback();
+ assertEquals("Bela", cache.get("/bela/ban", "name"));
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ public void testDoubleRemovalOfSameData() throws Exception
+ {
+ tx.begin();
+ cache.put("/foo/1", "item", 1);
+ assertEquals(cache.get("/foo/1", "item"), 1);
+ cache.removeNode("/foo/1");
+ assertNull(cache.get("/foo/1", "item"));
+ cache.removeNode("/foo/1");
+ assertNull(cache.get("/foo/1", "item"));
+ tx.rollback();
+ assertFalse(cache.exists("/foo/1"));
+ assertNull(cache.get("/foo/1", "item"));
+ }
+
+ /**
+ * put(Fqn, Map) with a previous null map
+ */
+ public void testPutDataRollback1()
+ {
+ try
+ {
+ cache.put("/bela/ban", null);// create a node /bela/ban with a null map
+ tx.begin();
+ Map<String, Comparable> m = new HashMap<String, Comparable>();
+ m.put("name", "Bela");
+ m.put("id", 322649);
+ cache.put("/bela/ban", m);
+ tx.rollback();
+
+ Node n = cache.getNode("/bela/ban");
+ if (n.getData() == null)
+ return;
+ assertEquals("map should be empty", 0, n.getData().size());
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ /**
+ * put(Fqn, Map) with a previous non-null map
+ */
+ public void testputDataRollback2() throws Exception
+ {
+ Map<String, Comparable> m1, m2;
+ m1 = new HashMap<String, Comparable>();
+ m1.put("name", "Bela");
+ m1.put("id", 322649);
+ m2 = new HashMap<String, Comparable>();
+ m2.put("other", "bla");
+ m2.put("name", "Michelle");
+
+ cache.put("/bela/ban", m1);
+ tx.begin();
+
+ cache.put("/bela/ban", m2);
+ Map tmp = cache.getNode("/bela/ban").getData();
+ assertEquals(3, tmp.size());
+ assertEquals("Michelle", tmp.get("name"));
+ assertEquals(tmp.get("id"), 322649);
+ assertEquals("bla", tmp.get("other"));
+ tx.rollback();
+
+ tmp = cache.getNode("/bela/ban").getData();
+ assertEquals(2, tmp.size());
+ assertEquals("Bela", tmp.get("name"));
+ assertEquals(tmp.get("id"), 322649);
+ }
+
+ public void testPutRollback()
+ {
+ try
+ {
+ cache.put("/bela/ban", null);// /bela/ban needs to exist
+ tx.begin();
+ cache.put("/bela/ban", "name", "Bela");
+ assertEquals("Bela", cache.get("/bela/ban", "name"));
+ tx.rollback();
+ assertNull(cache.get("/bela/ban", "name"));
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ public void testPutRollback2()
+ {
+ try
+ {
+ cache.put("/bela/ban", "name", "Bela");// /bela/ban needs to exist
+ tx.begin();
+ cache.put("/bela/ban", "name", "Michelle");
+ assertEquals("Michelle", cache.get("/bela/ban", "name"));
+ tx.rollback();
+ assertEquals("Bela", cache.get("/bela/ban", "name"));
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ fail(t.toString());
+ }
+ }
+
+ public void testSimpleRollbackTransactions() throws Exception
+ {
+ final Fqn fqn = Fqn.fromString("/a/b/c");
+ tx.begin();
+ cache.put(fqn, "entry", "commit");
+ tx.commit();
+
+ tx.begin();
+ cache.put(fqn, "entry", "rollback");
+ cache.removeNode(fqn);
+ tx.rollback();
+ assertEquals("Node should keep the commited value", "commit", cache.getNode(fqn).get("entry"));
+
+ tx.begin();
+ cache.removeNode(fqn);
+ cache.put(fqn, "entry", "rollback");
+ tx.rollback();
+
+ System.out.println("Cache: " + CachePrinter.printCacheDetails(cache));
+
+ assertEquals("Node should keep the commited value", "commit", cache.getNode(fqn).get("entry"));// THIS FAILS
+ }
+
+ private TransactionManager startTransaction() throws Exception
+ {
+ TransactionManager mgr = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+ mgr.begin();
+ return mgr;
+ }
+
+ public void testConcurrentReadAndWriteAccess() throws Exception
+ {
+ cache.stop();
+ cache.getConfiguration().setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ cache.start();
+
+ cache.put("/1/2/3/4", "foo", "bar");// no TX, no locks held after put() returns
+
+ class Reader extends Thread
+ {
+ TransactionManager thread_tx;
+
+ public Reader()
+ {
+ super("Reader");
+ }
+
+ public void run()
+ {
+ try
+ {
+ thread_tx = startTransaction();
+ log("acquiring RL");
+ cache.get("/1/2/3", "foo");// acquires RLs on all 3 nodes
+ log("RL acquired successfully");
+ sleep(2000);
+ log("committing TX");
+ thread_tx.commit();// releases RLs
+ log("committed TX");
+ }
+ catch (Exception e)
+ {
+ exception = e;
+ }
+ }
+ }
+
+ class Writer extends Thread
+ {
+ TransactionManager thread_tx;
+
+ public Writer()
+ {
+ super("Writer");
+ }
+
+ public void run()
+ {
+ try
+ {
+ sleep(500);// give the Reader a chance to acquire the RLs
+ thread_tx = startTransaction();
+ log("acquiring WL");
+ cache.put("/1", "foo", "bar2");// needs to acquired a WL on /1
+ log("acquired WL successfully");
+ log("committing TX");
+ thread_tx.commit();
+ log("committed TX");
+ }
+ catch (Exception e)
+ {
+ exception = e;
+ }
+ }
+ }
+
+ Reader reader = new Reader();
+ Writer writer = new Writer();
+ reader.start();
+ writer.start();
+ reader.join();
+ writer.join();
+ if (exception != null)
+ {
+ throw exception;
+ }
+ }
+
+ public void testRemoveAndGetInTx() throws Exception
+ {
+ Fqn A_B = Fqn.fromString("/a/b");
+ Fqn A = Fqn.fromString("/a");
+
+ cache.put(A_B, "k", "v");
+
+ assertTrue(cache.exists(A_B));
+ assertTrue(cache.exists(A));
+
+ cache.getTransactionManager().begin();
+ cache.removeNode(A);
+ cache.get(A_B, "k");
+ cache.getTransactionManager().commit();
+ }
+
+ public void testRemoveAndPutInTx() throws Exception
+ {
+ Fqn A_B = Fqn.fromString("/a/b");
+ Fqn A = Fqn.fromString("/a");
+
+ cache.put(A_B, "k", "v");
+
+ assertTrue(cache.exists(A_B));
+ assertTrue(cache.exists(A));
+
+ cache.getTransactionManager().begin();
+ cache.removeNode(A_B);
+ cache.put(A_B, "k", "v2");
+ cache.getTransactionManager().commit();
+
+ assertTrue(cache.exists(A_B));
+ assertTrue(cache.exists(A));
+
+ assert cache.peek(A, true, true).isValid();
+ assert cache.peek(A_B, true, true).isValid();
+
+ assertEquals("v2", cache.get(A_B, "k"));
+ }
+
+ public void testRemoveParentAndPutInTx() throws Exception
+ {
+ Fqn A_B = Fqn.fromString("/a/b");
+ Fqn A = Fqn.fromString("/a");
+
+ cache.put(A_B, "k", "v");
+
+ assertTrue(cache.exists(A_B));
+ assertTrue(cache.exists(A));
+
+ cache.getTransactionManager().begin();
+ cache.removeNode(A);
+ cache.put(A_B, "k", "v2");
+ cache.getTransactionManager().commit();
+
+ assertTrue(cache.exists(A_B));
+ assertTrue(cache.exists(A));
+
+ assertEquals("v2", cache.get(A_B, "k"));
+ }
+
+ public void testRemoveGrandParentAndPutInTx() throws Exception
+ {
+ Fqn A_B_C = Fqn.fromString("/a/b/c");
+ Fqn A = Fqn.fromString("/a");
+
+ cache.put(A_B_C, "k", "v");
+
+ assertTrue(cache.exists(A_B_C));
+ assertTrue(cache.exists(A));
+
+ cache.getTransactionManager().begin();
+ cache.removeNode(A);
+ cache.put(A_B_C, "k", "v2");
+ cache.getTransactionManager().commit();
+
+ assertTrue(cache.exists(A_B_C));
+ assertTrue(cache.exists(A));
+
+ assertEquals("v2", cache.get(A_B_C, "k"));
+ }
+
+ public void testRootNodeRemoval() throws Exception
+ {
+ Fqn root = Fqn.ROOT;
+ Fqn fqn = Fqn.fromElements(1);
+ //put first time
+ tx.begin();
+ this.cache.put(fqn, "k", "v");
+ tx.commit();
+
+ //get works fine
+ tx.begin();
+ assertEquals("v", this.cache.get(fqn, "k"));
+ tx.commit();
+
+ //remove all
+ tx.begin();
+ this.cache.removeNode(root);
+ tx.commit();
+
+ //get returns null - ok
+ //put - endless loop
+ tx.begin();
+ assertNull(this.cache.get(fqn, "k"));
+ this.cache.put(fqn, "k", "v");
+ tx.commit();
+ }
+
+ public void testNodeAdditionAfterRemoval() throws Exception
+ {
+ Fqn fqn = Fqn.fromString("/1/2/3/4");
+ //put first time
+ tx.begin();
+ this.cache.put(fqn, "k", "v");
+ tx.commit();
+
+ //get works fine
+ tx.begin();
+ assertEquals("v", this.cache.get(fqn, "k"));
+ tx.commit();
+
+ //remove all
+ tx.begin();
+ this.cache.removeNode(Fqn.ROOT);
+ tx.commit();
+
+ //get returns null - ok
+ //put - endless loop
+ tx.begin();
+ assertNull(this.cache.get(fqn, "k"));
+ this.cache.put(fqn, "k", "v");
+ tx.commit();
+ }
+
+ public void testRootNodeRemovalRollback() throws Exception
+ {
+ Fqn root = Fqn.ROOT;
+ Fqn fqn = Fqn.fromRelativeElements(root, 1);
+ //put first time
+ tx.begin();
+ this.cache.put(fqn, "k", "v");
+ tx.commit();
+
+ //get works fine
+ tx.begin();
+ assertEquals("v", this.cache.get(fqn, "k"));
+ tx.commit();
+
+ //remove all
+ tx.begin();
+ this.cache.removeNode(root);
+ tx.rollback();
+
+ assertEquals("v", this.cache.get(fqn, "k"));
+ }
+
+ private static void log(String msg)
+ {
+ System.out.println(Thread.currentThread().getName() + ": " + msg);
+ }
+
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PessimisticTransactionTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PrepareTxTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/transaction/PrepareTxTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PrepareTxTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PrepareTxTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -0,0 +1,158 @@
+package org.jboss.cache.transaction.pessimistic;
+
+import org.jboss.cache.CacheException;
+import org.jboss.cache.CacheFactory;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.transaction.TransactionSetup;
+import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.config.Configuration;
+import static org.testng.AssertJUnit.assertEquals;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.NotSupportedException;
+import javax.transaction.Synchronization;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: bela
+ * Date: Jun 9, 2004
+ * Time: 9:05:19 AM
+ */
+@Test(groups = {"functional", "transaction"})
+public class PrepareTxTest
+{
+ CacheSPI<String, String> cache;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ CacheFactory<String, String> instance = new DefaultCacheFactory<String, String>();
+ cache = (CacheSPI<String, String>) instance.createCache(false);
+ cache.getConfiguration().setCacheMode("local");
+ cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache.getConfiguration().setTransactionManagerLookupClass(TransactionSetup.getManagerLookup());
+ cache.create();
+ cache.start();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception
+ {
+ cache.stop();
+ cache.destroy();
+ }
+
+ /**
+ * Tests cache modification <em>inside</em> the afterCompletion() callback. Reproduces a bug fixed in
+ * connection with JBossCache being used as Hibernate's second level cache
+ *
+ * @throws Exception
+ * @throws NotSupportedException
+ */
+ public void testCacheModificationInBeforeCompletionPhase() throws Exception
+ {
+ int numLocks = 0;
+ TransactionManager mgr = cache.getTransactionManager();
+ mgr.begin();
+ Transaction tx = mgr.getTransaction();
+
+ // this will cause the cache to register with TransactionManager for TX completion callbacks
+ cache.put("/one/two/three", "key1", "val1");
+ numLocks = cache.getNumberOfLocksHeld();
+ assertEquals(4, numLocks);
+
+ // we register *second*
+ tx.registerSynchronization(new Synchronization()
+ {
+
+ public void beforeCompletion()
+ {
+ try
+ {
+ cache.put("/a/b/c", null);
+ }
+ catch (CacheException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void afterCompletion(int status)
+ {
+ }
+ });
+
+ mgr.commit();
+ numLocks = cache.getNumberOfLocksHeld();
+ assertEquals(0, numLocks);
+
+ int num_local_txs, num_global_txs;
+ TransactionTable tx_table = cache.getTransactionTable();
+ num_local_txs = tx_table.getNumLocalTransactions();
+ num_global_txs = tx_table.getNumGlobalTransactions();
+ System.out.println("Number of Transactions: " + num_local_txs + "\nNumber of GlobalTransactions: " + num_global_txs + "\nTransactionTable:\n "
+ + tx_table.toString(true));
+ assertEquals(num_local_txs, num_global_txs);
+ assertEquals(0, num_local_txs);
+ }
+
+ /**
+ * Tests cache modification <em>inside</em> the afterCompletion() callback. Reproduces a bug fixed in
+ * connection with JBossCache being used as Hibernate's second level cache
+ *
+ * @throws Exception
+ * @throws NotSupportedException
+ */
+ public void testCacheModificationInAfterCompletionPhase() throws Exception
+ {
+ int numLocks = 0;
+ TransactionManager mgr = cache.getTransactionManager();
+ mgr.begin();
+ Transaction tx = mgr.getTransaction();
+
+ // this will cause the cache to register with TransactionManager for TX completion callbacks
+ cache.put("/one/two/three", "key1", "val1");
+ numLocks = cache.getNumberOfLocksHeld();
+ assertEquals(4, numLocks);
+
+ // we register *second*
+ tx.registerSynchronization(new Synchronization()
+ {
+
+ public void beforeCompletion()
+ {
+ }
+
+ public void afterCompletion(int status)
+ {
+ try
+ {
+ cache.put("/a/b/c", null);
+ }
+ catch (CacheException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ });
+
+ mgr.commit();
+ numLocks = cache.getNumberOfLocksHeld();
+ assertEquals(0, numLocks);
+
+ int num_local_txs, num_global_txs;
+ TransactionTable tx_table = cache.getTransactionTable();
+ num_local_txs = tx_table.getNumLocalTransactions();
+ num_global_txs = tx_table.getNumGlobalTransactions();
+ System.out.println("Number of Transactions: " + num_local_txs + "\nNumber of GlobalTransactions: " + num_global_txs + "\nTransactionTable:\n "
+ + tx_table.toString(true));
+ assertEquals(num_local_txs, num_global_txs);
+ assertEquals(0, num_local_txs);
+ }
+
+}
Property changes on: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/PrepareTxTest.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Copied: core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/StatusUnknownTest.java (from rev 6585, core/trunk/src/test/java/org/jboss/cache/transaction/StatusUnknownTest.java)
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/StatusUnknownTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/pessimistic/StatusUnknownTest.java 2008-08-25 17:50:21 UTC (rev 6611)
@@ -0,0 +1,165 @@
+package org.jboss.cache.transaction.pessimistic;
+
+import org.jboss.cache.Cache;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.transaction.*;
+import org.jboss.cache.config.Configuration;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * This test checks how the cache behaves when a JTA STATUS_UNKNOWN is passed in to the cache during afterCompletion().
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ */
+@Test(groups = "functional")
+public class StatusUnknownTest
+{
+ private Cache<String, String> cache;
+ private TransactionManager tm;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception
+ {
+ cache = new DefaultCacheFactory<String, String>().createCache(false);
+ cache.getConfiguration().setNodeLockingScheme(Configuration.NodeLockingScheme.PESSIMISTIC);
+ cache.getConfiguration().setTransactionManagerLookupClass(HeuristicFailingDummyTransactionManagerLookup.class.getName());
+ cache.start();
+ tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown()
+ {
+ cache.stop();
+ }
+
+ public void testStatusUnknown() throws Exception
+ {
+ tm.begin();
+ Fqn fqn = Fqn.fromString("/a/b/c");
+
+ cache.put(fqn, "k", "v");
+ assertEquals(4, ((CacheSPI) cache).getNumberOfLocksHeld());
+ assertTrue(cache.getRoot().hasChild(fqn));
+ tm.commit();
+
+ assertEquals(0, ((CacheSPI) cache).getNumberOfLocksHeld());
+ assertFalse(cache.getRoot().hasChild(fqn));
+ }
+
+ public static class HeuristicFailingDummyTransactionManager extends DummyTransactionManager
+ {
+ private static final long serialVersionUID = 6325631394461739211L;
+
+ @Override
+ public void begin() throws SystemException, NotSupportedException
+ {
+ super.begin();
+
+ Transaction tx = new HeuristicFailingDummyTransaction(this);
+ setTransaction(tx);
+ }
+
+ public static DummyTransactionManager getInstance()
+ {
+ if (instance == null)
+ {
+ instance = new HeuristicFailingDummyTransactionManager();
+ try
+ {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.cache.transaction.DummyContextFactory");
+ Context ctx = new InitialContext(p);
+ ctx.bind("java:/TransactionManager", instance);
+ ctx.bind("UserTransaction", new DummyUserTransaction(instance));
+ }
+ catch (NamingException e)
+ {
+ log.error("binding of DummyTransactionManager failed", e);
+ }
+ }
+ return instance;
+ }
+ }
+
+ public static class HeuristicFailingDummyTransaction extends DummyTransaction
+ {
+ public HeuristicFailingDummyTransaction(DummyBaseTransactionManager mgr)
+ {
+ super(mgr);
+ }
+
+ @Override
+ public void commit() throws RollbackException
+ {
+ try
+ {
+ notifyBeforeCompletion();
+ notifyAfterCompletion(Status.STATUS_UNKNOWN);
+ }
+ finally
+ {
+ // Disassociate tx from thread.
+ tm_.setTransaction(null);
+ }
+ }
+
+ @Override
+ protected void notifyAfterCompletion(int status)
+ {
+ List<Synchronization> tmp;
+
+ synchronized (participants)
+ {
+ tmp = new LinkedList<Synchronization>(participants);
+ }
+
+ for (Synchronization s : tmp)
+ {
+ try
+ {
+ s.afterCompletion(status);
+ }
+ catch (Throwable t)
+ {
+ throw (RuntimeException) t;
+ }
+ }
+
+ synchronized (participants)
+ {
+ participants.clear();
+ }
+ }
+ }
+
+ public static class HeuristicFailingDummyTransactionManagerLookup implements TransactionManagerLookup
+ {
+
+ public TransactionManager getTransactionManager() throws Exception
+ {
+ return HeuristicFailingDummyTransactionManager.getInstance();
+ }
+ }
+}
+
+
16 years, 6 months