JBoss Cache SVN: r6039 - in core/trunk/src: test/java/org/jboss/cache/api/pfer and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-25 11:34:48 -0400 (Wed, 25 Jun 2008)
New Revision: 6039
Modified:
core/trunk/src/main/java/org/jboss/cache/optimistic/TransactionWorkspace.java
core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ChildMapLazyLoadingTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedOptimisticCreateIfNotExistsInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
Log:
Renamed TransactionEntry to TransactionContext
Modified: core/trunk/src/main/java/org/jboss/cache/optimistic/TransactionWorkspace.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/optimistic/TransactionWorkspace.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/main/java/org/jboss/cache/optimistic/TransactionWorkspace.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -15,7 +15,7 @@
* Used to contain a copy of the tree being worked on within the scope of a given transaction.
* Maintains {@link WorkspaceNode}s rather than conventional
* <p/>
- * Also see {@link org.jboss.cache.transaction.OptimisticTransactionEntry}, which creates and maintains
+ * Also see {@link org.jboss.cache.transaction.OptimisticTransactionContext}, which creates and maintains
* an instance of TransactionWorkspace for each
* transaction running.
*
Modified: core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/api/pfer/PutForExternalReadTestBase.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -9,10 +9,7 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.RPCManager;
-import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.util.internals.ReplicationListener;
import org.jboss.cache.commands.ReplicableCommand;
-import org.jboss.cache.commands.write.*;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.Configuration.CacheMode;
import org.jboss.cache.factories.ComponentRegistry;
@@ -20,7 +17,9 @@
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.internals.ReplicationListener;
import org.jgroups.Address;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -454,7 +453,7 @@
try
{
GlobalTransaction gtx = cs.getTransactionTable().get(cs.getTransactionManager().getTransaction());
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) cs.getTransactionTable().get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) cs.getTransactionTable().get(gtx);
return entry.getTransactionWorkSpace();
}
catch (SystemException e)
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AbstractOptimisticTestCase.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -7,13 +7,13 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.VersionedDataCommand;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
+import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
import org.jboss.cache.factories.UnitTestCacheConfigurationFactory;
-import org.jboss.cache.config.parsing.XmlConfigurationParserOld;
import org.jboss.cache.interceptors.CacheMgmtInterceptor;
import org.jboss.cache.interceptors.CallInterceptor;
import org.jboss.cache.interceptors.NotificationInterceptor;
@@ -28,7 +28,7 @@
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.TransactionSetup;
-import org.jboss.cache.config.parsing.XmlConfigHelper;
+import org.jboss.cache.util.TestingUtil;
import org.jgroups.Address;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -95,7 +95,7 @@
cache.getInvocationContext().setTransaction(tx);
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
cache.getInvocationContext().setGlobalTransaction(gtx);
- cache.getInvocationContext().setTransactionEntry(cache.getTransactionTable().get(gtx));
+ cache.getInvocationContext().setTransactionContext(cache.getTransactionTable().get(gtx));
}
protected CacheLoaderConfig getCacheLoaderConfig(boolean shared, boolean passivation) throws Exception
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/AsyncFullStackInterceptorTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -3,15 +3,14 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
import org.jboss.cache.commands.write.RemoveNodeCommand;
-import org.jboss.cache.commands.write.PutKeyValueCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.lock.LockManager;
-import org.jboss.cache.util.TestingUtil;
-import org.jboss.cache.util.internals.ReplicationListener;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
+import org.jboss.cache.util.internals.ReplicationListener;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
@@ -332,7 +331,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
assertNull(mgr.getTransaction());
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -17,7 +17,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.invocation.NodeInvocationDelegate;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.TestingUtil;
import org.jgroups.Address;
@@ -211,7 +211,7 @@
GlobalTransaction gtx = c.getCurrentTransaction(tx, true);
TransactionTable table = c.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertNotNull(mgr.getTransaction());
ReversibleCommand command = entry.getModifications().get(0);
mgr.commit();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ChildMapLazyLoadingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ChildMapLazyLoadingTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ChildMapLazyLoadingTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -7,7 +7,7 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.transaction.DummyTransactionManagerLookup;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -205,7 +205,7 @@
{
Transaction tx = cache.getTransactionManager().getTransaction();
GlobalTransaction gtx = cache.getTransactionTable().get(tx);
- OptimisticTransactionEntry te = (OptimisticTransactionEntry) cache.getTransactionTable().get(gtx);
+ OptimisticTransactionContext te = (OptimisticTransactionContext) cache.getTransactionTable().get(gtx);
TransactionWorkspace tw = te.getTransactionWorkSpace();
return tw.getNode(fqn);
}
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/FullStackInterceptorTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -7,10 +7,10 @@
import org.jboss.cache.config.Configuration;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.lock.LockManager;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
@@ -433,7 +433,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table
.get(gtx);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetChildrenNamesTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -2,15 +2,15 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.factories.ComponentRegistry;
import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -76,7 +76,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -119,7 +119,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
//assert we can see this with a key value get in the transaction
assertEquals(0, cache.getRoot().getChildrenNames().size());
@@ -149,7 +149,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeyValTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -2,14 +2,14 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -70,7 +70,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -123,7 +123,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -161,7 +161,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -215,7 +215,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -223,7 +223,7 @@
//resume the suspended transaction
GlobalTransaction gtx2 = table.get(tx2);
- OptimisticTransactionEntry entry2 = (OptimisticTransactionEntry) table.get(gtx2);
+ OptimisticTransactionContext entry2 = (OptimisticTransactionContext) table.get(gtx2);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace2 = entry2.getTransactionWorkSpace();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorGetKeysTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -2,14 +2,14 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -69,7 +69,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -113,7 +113,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
//assert we can see this with a key value get in the transaction
assertEquals(0, cache.getRoot().getKeys().size());
@@ -142,7 +142,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
//assert we can see this with a key value get in the transaction
assertEquals(1, cache.getNode("/one/two").getKeys().size());
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorKeyValTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -2,14 +2,14 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -69,7 +69,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -108,7 +108,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -143,7 +143,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -180,7 +180,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -226,7 +226,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -234,7 +234,7 @@
//resume the suspended transaction
GlobalTransaction gtx2 = table.get(tx2);
- OptimisticTransactionEntry entry2 = (OptimisticTransactionEntry) table.get(gtx2);
+ OptimisticTransactionContext entry2 = (OptimisticTransactionContext) table.get(gtx2);
@SuppressWarnings("unchecked")
TransactionWorkspace<Object, Object> workspace2 = entry2.getTransactionWorkSpace();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutEraseTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -2,14 +2,14 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -73,7 +73,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
@@ -110,7 +110,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
@@ -144,7 +144,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorPutMapTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -6,10 +6,10 @@
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.SamplePojo;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -73,7 +73,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
@@ -114,7 +114,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
@@ -153,7 +153,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveDataTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -2,14 +2,14 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -70,7 +70,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
@@ -104,7 +104,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
@@ -140,7 +140,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
@@ -178,7 +178,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
assertEquals(1, workspace.getNode(Fqn.fromString("/one/two")).getMergedData().size());
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveKeyValTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -8,14 +8,14 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
import org.jboss.cache.interceptors.OptimisticNodeInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -76,7 +76,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
@@ -110,7 +110,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
@@ -146,7 +146,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/NodeInterceptorRemoveNodeTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -13,7 +13,7 @@
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.interceptors.CallInterceptor;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -75,7 +75,7 @@
TransactionTable table = cache.getTransactionTable();
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
mgr.commit();
@@ -114,7 +114,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace<?, ?> workspace = entry.getTransactionWorkSpace();
@@ -153,7 +153,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace<?, ?> workspace = entry.getTransactionWorkSpace();
@@ -192,7 +192,7 @@
TransactionTable table = cache.getTransactionTable();
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
@@ -248,7 +248,7 @@
TransactionTable table = cache.getTransactionTable();
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
@@ -308,7 +308,7 @@
TransactionTable table = cache.getTransactionTable();
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace workspace = entry.getTransactionWorkSpace();
@@ -369,7 +369,7 @@
TransactionTable table = cache.getTransactionTable();
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace<?, ?> workspace = entry.getTransactionWorkSpace();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticCreateIfNotExistsInterceptorTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -12,11 +12,11 @@
import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.SamplePojo;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
@@ -35,7 +35,7 @@
protected Transaction tx;
protected GlobalTransaction gtx;
protected TransactionTable table;
- protected OptimisticTransactionEntry entry;
+ protected OptimisticTransactionContext entry;
protected TransactionWorkspace workspace;
protected void setupTransactionsInInvocationCtx(CacheSPI cache) throws Exception
@@ -50,7 +50,7 @@
// create a globalTransaction
gtx = cache.getCurrentTransaction();
tx = txManager.getTransaction();
- entry = (OptimisticTransactionEntry) table.get(gtx);
+ entry = (OptimisticTransactionContext) table.get(gtx);
workspace = entry.getTransactionWorkSpace();
setupTransactions(cache, tx);
@@ -117,7 +117,7 @@
// we should now remove stuff from the InvocationCtx
cache.getInvocationContext().setGlobalTransaction(null);
cache.getInvocationContext().setTransaction(null);
- cache.getInvocationContext().setTransactionEntry(null);
+ cache.getInvocationContext().setTransactionContext(null);
try
{
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -15,7 +15,7 @@
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.TestingUtil;
import org.jgroups.Address;
@@ -133,7 +133,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertNotNull(mgr.getTransaction());
mgr.commit();
@@ -198,7 +198,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertNotNull(mgr.getTransaction());
mgr.commit();
@@ -276,7 +276,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertNotNull(mgr.getTransaction());
mgr.commit();
@@ -335,7 +335,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertNotNull(mgr.getTransaction());
mgr.commit();
@@ -388,7 +388,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertNotNull(mgr.getTransaction());
mgr.commit();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedOptimisticCreateIfNotExistsInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedOptimisticCreateIfNotExistsInterceptorTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ThreadedOptimisticCreateIfNotExistsInterceptorTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -8,12 +8,12 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.Fqn;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.interceptors.OptimisticCreateIfNotExistsInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.DummyTransactionManager;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
+import org.jboss.cache.util.TestingUtil;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
import org.testng.annotations.Test;
@@ -76,7 +76,7 @@
cache.put("/one/two", "key2", pojo);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) cache.getTransactionTable().get(cache.getCurrentTransaction());
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) cache.getTransactionTable().get(cache.getCurrentTransaction());
assertEquals(3, entry.getTransactionWorkSpace().getNodes().size());
assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/")) != null);
assertTrue(entry.getTransactionWorkSpace().getNode(Fqn.fromString("/one")) != null);
@@ -136,7 +136,7 @@
setTransactionsInInvocationCtx(mgr, cache);
cache.put("/one", "key1", pojo);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) cache.getTransactionTable().get(cache.getCurrentTransaction());
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) cache.getTransactionTable().get(cache.getCurrentTransaction());
randomSleep(minSleep, maxSleep);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -13,7 +13,7 @@
import org.jboss.cache.commands.tx.RollbackCommand;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionSetup;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.TestingUtil;
@@ -286,7 +286,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertNotNull(mgr.getTransaction());
ReversibleCommand command = entry.getModifications().get(0);
mgr.commit();
@@ -355,7 +355,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertEquals(tx, mgr.getTransaction());
//now send the remote prepare
@@ -438,7 +438,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertEquals(tx, mgr.getTransaction());
//now send the remote prepare
@@ -526,7 +526,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertEquals(tx, mgr.getTransaction());
//now send the remote prepare
@@ -613,7 +613,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertNotNull(mgr.getTransaction());
ReversibleCommand command = entry.getModifications().get(0);
mgr.commit();
@@ -705,7 +705,7 @@
GlobalTransaction gtx = cache.getCurrentTransaction(tx, true);
TransactionTable table = cache.getTransactionTable();
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
assertNotNull(mgr.getTransaction());
ReversibleCommand command = entry.getModifications().get(0);
mgr.commit();
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java 2008-06-25 15:33:13 UTC (rev 6038)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java 2008-06-25 15:34:48 UTC (rev 6039)
@@ -21,7 +21,7 @@
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.SamplePojo;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.CachePrinter;
import org.jboss.cache.util.TestingUtil;
@@ -95,7 +95,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -145,7 +145,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -193,7 +193,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -270,7 +270,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
@SuppressWarnings("unchecked") TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
@@ -349,7 +349,7 @@
GlobalTransaction gtx = table.get(tx);
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) table.get(gtx);
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) table.get(gtx);
TransactionWorkspace<Object, Object> workspace = entry.getTransactionWorkSpace();
16 years, 4 months
JBoss Cache SVN: r6038 - in core/trunk/src: main/java/org/jboss/cache/interceptors and 6 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-25 11:33:13 -0400 (Wed, 25 Jun 2008)
New Revision: 6038
Added:
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
Removed:
core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
Modified:
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.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/CacheLoaderInterceptor.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/InvalidationInterceptor.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/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/lock/LockUtil.java
core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java
core/trunk/src/test/java/org/jboss/cache/transaction/NotifyingTransactionManager.java
Log:
Renamed TransactionEntry to TransactionContext
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -13,7 +13,7 @@
import org.jboss.cache.lock.NodeLock;
import org.jboss.cache.marshall.MethodCall;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.Transaction;
@@ -37,7 +37,7 @@
private Transaction transaction;
private GlobalTransaction globalTransaction;
- private TransactionEntry transactionEntry;
+ private TransactionContext transactionContext;
private Option optionOverrides;
// defaults to true.
private boolean originLocal = true;
@@ -109,20 +109,20 @@
* @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
*/
- public TransactionEntry getTransactionEntry()
+ public TransactionContext getTransactionContext()
{
- return transactionEntry;
+ return transactionContext;
}
/**
* Sets the transaction entry to be associated with the current thread.
*
- * @param transactionEntry transaction entry to set
+ * @param transactionContext transaction entry to set
* @since 2.2.0
*/
- public void setTransactionEntry(TransactionEntry transactionEntry)
+ public void setTransactionContext(TransactionContext transactionContext)
{
- this.transactionEntry = transactionEntry;
+ this.transactionContext = transactionContext;
}
/**
@@ -187,7 +187,7 @@
/**
* 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, these locks are retrieved from the {@link org.jboss.cache.transaction.TransactionEntry} rather than
+ * Note that if a transaction is in scope, these locks are retrieved from the {@link org.jboss.cache.transaction.TransactionContext} rather than
* this {@link org.jboss.cache.InvocationContext}. Retrieving locks from here will ensure they are retrieved from the appropriate
* scope.
* <p/>
@@ -201,14 +201,14 @@
public List getLocks()
{
// first check transactional scope
- if (transactionEntry != null) return transactionEntry.getLocks();
+ if (transactionContext != null) return transactionContext.getLocks();
return Collections.unmodifiableList(new ArrayList(invocationLocks));
}
/**
* Adds a List of locks to the currently maintained collection of locks acquired.
* <p/>
- * Note that if a transaction is in scope, these locks are recorded on the {@link org.jboss.cache.transaction.TransactionEntry} rather than
+ * Note that if a transaction is in scope, these locks are recorded on the {@link org.jboss.cache.transaction.TransactionContext} rather than
* this {@link org.jboss.cache.InvocationContext}. Adding locks here will ensure they are promoted to the appropriate
* scope.
* <p/>
@@ -222,9 +222,9 @@
public void addAllLocks(List locks)
{
// first check transactional scope
- if (transactionEntry != null)
+ if (transactionContext != null)
{
- transactionEntry.addAllLocks(locks);
+ transactionContext.addAllLocks(locks);
}
else
{
@@ -237,7 +237,7 @@
/**
* Adds a lock to the currently maintained collection of locks acquired.
* <p/>
- * Note that if a transaction is in scope, this lock is recorded on the {@link org.jboss.cache.transaction.TransactionEntry} rather than
+ * Note that if a transaction is in scope, this lock is recorded on the {@link org.jboss.cache.transaction.TransactionContext} rather than
* this {@link org.jboss.cache.InvocationContext}. Adding a lock here will ensure it is promoted to the appropriate
* scope.
* <p/>
@@ -251,9 +251,9 @@
public void addLock(Object lock)
{
// first check transactional scope
- if (transactionEntry != null)
+ if (transactionContext != null)
{
- transactionEntry.addLock(lock);
+ transactionContext.addLock(lock);
}
else
{
@@ -266,7 +266,7 @@
/**
* Removes a lock from the currently maintained collection of locks acquired.
* <p/>
- * Note that if a transaction is in scope, this lock is removed from the {@link org.jboss.cache.transaction.TransactionEntry} rather than
+ * Note that if a transaction is in scope, this lock is removed from the {@link org.jboss.cache.transaction.TransactionContext} rather than
* this {@link org.jboss.cache.InvocationContext}. Removing a lock here will ensure it is removed in the appropriate
* scope.
* <p/>
@@ -280,9 +280,9 @@
public void removeLock(Object lock)
{
// first check transactional scope
- if (transactionEntry != null)
+ if (transactionContext != null)
{
- transactionEntry.removeLock(lock);
+ transactionContext.removeLock(lock);
}
else
{
@@ -294,7 +294,7 @@
/**
* Clears all locks from the currently maintained collection of locks acquired.
* <p/>
- * Note that if a transaction is in scope, locks are cleared from the {@link org.jboss.cache.transaction.TransactionEntry} rather than
+ * Note that if a transaction is in scope, locks are cleared from the {@link org.jboss.cache.transaction.TransactionContext} rather than
* this {@link org.jboss.cache.InvocationContext}. Clearing locks here will ensure they are cleared in the appropriate
* scope.
* <p/>
@@ -305,9 +305,9 @@
public void clearLocks()
{
// first check transactional scope
- if (transactionEntry != null)
+ if (transactionContext != null)
{
- transactionEntry.clearLocks();
+ transactionContext.clearLocks();
}
else
{
@@ -397,7 +397,7 @@
copy.optionOverrides = optionOverrides == null ? null : optionOverrides.copy();
copy.originLocal = originLocal;
copy.transaction = transaction;
- copy.transactionEntry = transactionEntry;
+ copy.transactionContext = transactionContext;
copy.txHasMods = txHasMods;
return null;
}
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -281,7 +281,7 @@
if (gtx != null)
{
CreateNodeCommand createNodeCommand = commandsFactory.buildCreateNodeCommand(child_fqn);
- ctx.getTransactionEntry().addModification(createNodeCommand);
+ ctx.getTransactionContext().addModification(createNodeCommand);
}
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ActivationInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -21,7 +21,7 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
@@ -290,14 +290,14 @@
private void prepareCacheLoader(InvocationContext ctx) throws Throwable
{
GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry == null)
+ TransactionContext tCtx = ctx.getTransactionContext();
+ if (tCtx == null)
{
- throw new Exception("entry for transaction " + gtx + " not found in transaction table");
+ throw new Exception("tCtx for transaction " + gtx + " not found in transaction table");
}
List<Modification> cacheLoaderModifications = new ArrayList<Modification>();
- builder.visitCollection(ctx, entry.getModifications());
+ builder.visitCollection(ctx, tCtx.getModifications());
if (cacheLoaderModifications.size() > 0)
{
loader.prepare(gtx, cacheLoaderModifications, false);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseRpcInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -15,7 +15,7 @@
import org.jboss.cache.factories.annotations.Start;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import org.jgroups.Address;
@@ -106,11 +106,11 @@
Transaction tx = ctx.getTransaction();
if (tx != null)
{
- TransactionEntry te = ctx.getTransactionEntry();
- if (te != null)
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext != null)
{
- if (te.isForceAsyncReplication()) sync = false;
- else if (te.isForceSyncReplication()) sync = true;
+ if (transactionContext.isForceAsyncReplication()) sync = false;
+ else if (transactionContext.isForceSyncReplication()) sync = true;
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/BaseTransactionalContextInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -5,7 +5,7 @@
import org.jboss.cache.factories.annotations.Inject;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.Status;
@@ -32,18 +32,18 @@
protected void copyInvocationScopeOptionsToTxScope(InvocationContext ctx)
{
- // notify the transaction entry that this override is in place.
- TransactionEntry entry = txTable.get(ctx.getGlobalTransaction());
- if (entry != null)
+ // notify the transaction tCtx that this override is in place.
+ TransactionContext tCtx = txTable.get(ctx.getGlobalTransaction());
+ if (tCtx != null)
{
Option txScopeOption = new Option();
txScopeOption.setCacheModeLocal(ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isCacheModeLocal());
txScopeOption.setSkipCacheStatusCheck(ctx.getOptionOverrides() != null && ctx.getOptionOverrides().isSkipCacheStatusCheck());
- entry.setOption(txScopeOption);
+ tCtx.setOption(txScopeOption);
}
}
- protected void setTransactionalContext(Transaction tx, GlobalTransaction gtx, TransactionEntry entry, InvocationContext ctx)
+ protected void setTransactionalContext(Transaction tx, GlobalTransaction gtx, TransactionContext tCtx, InvocationContext ctx)
{
if (trace)
{
@@ -52,21 +52,21 @@
}
ctx.setTransaction(tx);
ctx.setGlobalTransaction(gtx);
- if (entry == null)
+ if (tCtx == null)
{
if (gtx != null)
{
- ctx.setTransactionEntry(txTable.get(gtx));
+ ctx.setTransactionContext(txTable.get(gtx));
}
else if (tx == null)
{
- // then nullify the transaction entry as well
- ctx.setTransactionEntry(null);
+ // then nullify the transaction tCtx as well
+ ctx.setTransactionContext(null);
}
}
else
{
- ctx.setTransactionEntry(entry);
+ ctx.setTransactionContext(tCtx);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheLoaderInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -30,7 +30,7 @@
import org.jboss.cache.lock.LockType;
import org.jboss.cache.lock.TimeoutException;
import org.jboss.cache.notifications.Notifier;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import java.util.Collections;
@@ -93,7 +93,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, false, true, false, ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, false, true, false, ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -103,7 +103,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, useCacheStore, !useCacheStore, ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, useCacheStore, !useCacheStore, ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -121,9 +121,9 @@
{
if (command.getTo() != null)
{
- loadIfNeeded(ctx, command.getTo(), null, false, false, true, ctx.getTransactionEntry(), false, true, false);
+ loadIfNeeded(ctx, command.getTo(), null, false, false, true, ctx.getTransactionContext(), false, true, false);
}
- loadIfNeeded(ctx, command.getFqn(), null, false, false, true, ctx.getTransactionEntry(), true, true, false);
+ loadIfNeeded(ctx, command.getFqn(), null, false, false, true, ctx.getTransactionContext(), true, true, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -133,7 +133,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, true, ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, true, ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -144,7 +144,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, false, false, true, ctx.getTransactionEntry(), false, false, !usingOptimisticInvalidation);
+ loadIfNeeded(ctx, command.getFqn(), null, false, false, true, ctx.getTransactionContext(), false, false, !usingOptimisticInvalidation);
}
return invokeNextInterceptor(ctx, command);
}
@@ -155,7 +155,7 @@
Fqn fqn = command.getFqn();
if (fqn != null)
{
- loadIfNeeded(ctx, fqn, null, false, false, false, ctx.getTransactionEntry(), false, false, true);
+ loadIfNeeded(ctx, fqn, null, false, false, false, ctx.getTransactionContext(), false, false, true);
NodeSPI n = dataContainer.peek(fqn, true, true);
loadChildren(fqn, n, false, false, ctx);
}
@@ -168,7 +168,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, true, false, true, ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, true, false, true, ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -178,7 +178,7 @@
{
if (command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, true, false, true, ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, true, false, true, ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -190,7 +190,7 @@
if (trace) log.trace("Removing temporarily created nodes from treecache");
// this needs to be done in reverse order.
- List list = ctx.getTransactionEntry().getDummyNodesCreatedByCacheLoader();
+ List list = ctx.getTransactionContext().getDummyNodesCreatedByCacheLoader();
if (list != null && list.size() > 0)
{
ListIterator i = list.listIterator(list.size());
@@ -215,7 +215,7 @@
{
if (configuration.isNodeLockingOptimistic() && command.getFqn() != null)
{
- loadIfNeeded(ctx, command.getFqn(), null, false, false, false, ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), null, false, false, false, ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -225,7 +225,7 @@
{
if (command.getFqn() != null && !useCacheStore)
{
- loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, false, ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, command.getFqn(), command.getKey(), false, false, false, ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
@@ -236,12 +236,12 @@
Fqn fqn = command.getFqn();
if (fqn != null && !useCacheStore)
{
- loadIfNeeded(ctx, fqn, null, false, true, false, ctx.getTransactionEntry(), false, false, false);
+ loadIfNeeded(ctx, fqn, null, false, true, false, ctx.getTransactionContext(), false, false, false);
}
return invokeNextInterceptor(ctx, command);
}
- private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean allKeys, boolean initNode, boolean acquireLock, TransactionEntry entry, boolean recursive, boolean isMove, boolean bypassLoadingData) throws Throwable
+ private void loadIfNeeded(InvocationContext ctx, Fqn fqn, Object key, boolean allKeys, boolean initNode, boolean acquireLock, TransactionContext transactionContext, boolean recursive, boolean isMove, boolean bypassLoadingData) throws Throwable
{
NodeSPI n = dataContainer.peek(fqn, true, true);
Object lockOwner = lockManager.getLockOwner(ctx);
@@ -269,7 +269,7 @@
{
if (initNode)
{
- n = createTempNode(fqn, entry);
+ n = createTempNode(fqn, transactionContext);
}
// Only attempt to acquire this lock if we need to - i.e., if
@@ -297,12 +297,12 @@
if (n == null && loader.exists(fqn))
{
// just create a dummy node in memory
- n = createTempNode(fqn, entry);
+ n = createTempNode(fqn, transactionContext);
}
}
else
{
- n = loadNode(ctx, fqn, n, entry);
+ n = loadNode(ctx, fqn, n, transactionContext);
}
}
}
@@ -470,10 +470,10 @@
*/
private boolean wasRemovedInTx(Fqn fqn, InvocationContext ctx)
{
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry == null) return false;
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext == null) return false;
- for (ReversibleCommand txCacheCommand : entry.getModifications())
+ for (ReversibleCommand txCacheCommand : transactionContext.getModifications())
{
if (txCacheCommand instanceof RemoveNodeCommand && fqn.isChildOrEquals(txCacheCommand.getFqn())) return true;
}
@@ -485,7 +485,7 @@
* If it doesn't exist on disk but in memory, clears the
* uninitialized flag, otherwise returns null.
*/
- private NodeSPI loadNode(InvocationContext ctx, Fqn fqn, NodeSPI n, TransactionEntry entry) throws Exception
+ private NodeSPI loadNode(InvocationContext ctx, Fqn fqn, NodeSPI n, TransactionContext transactionContext) throws Exception
{
if (trace) log.trace("loadNode " + fqn);
Map nodeData = loadData(fqn);
@@ -499,7 +499,7 @@
notifier.notifyNodeActivated(fqn, true, Collections.emptyMap(), ctx);
}
- n = createNodes(fqn, entry);
+ n = createNodes(fqn, transactionContext);
// n.clearDataDirect();
n.setInternalState(nodeData);
@@ -523,9 +523,9 @@
/**
* Creates a new memory node in preparation for storage.
*/
- private NodeSPI createTempNode(Fqn fqn, TransactionEntry entry) throws Exception
+ private NodeSPI createTempNode(Fqn fqn, TransactionContext transactionContext) throws Exception
{
- NodeSPI n = createNodes(fqn, entry);
+ NodeSPI n = createNodes(fqn, transactionContext);
n.setDataLoaded(false);
if (trace)
{
@@ -535,7 +535,7 @@
}
@SuppressWarnings("unchecked")
- private NodeSPI createNodes(Fqn fqn, TransactionEntry entry) throws Exception
+ private NodeSPI createNodes(Fqn fqn, TransactionContext transactionContext) throws Exception
{
Object[] results = dataContainer.createNodes(fqn);
List<NodeSPI> createdNodes = (List<NodeSPI>) results[0];
@@ -544,9 +544,9 @@
for (NodeSPI node : createdNodes)
{
node.setDataLoaded(false);
- if (entry != null)
+ if (transactionContext != null)
{
- entry.loadUninitialisedNode(node.getFqn());
+ transactionContext.loadUninitialisedNode(node.getFqn());
}
lastCreated = node;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CacheStoreInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -27,7 +27,7 @@
import org.jboss.cache.loader.CacheLoader;
import org.jboss.cache.loader.CacheLoaderManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
@@ -182,7 +182,7 @@
if (inTransaction())
{
if (trace) log.trace("transactional so don't put stuff in the cloader yet.");
- prepareCacheLoader(command.getGlobalTransaction(), ctx.getTransactionEntry(), command.isOnePhaseCommit());
+ prepareCacheLoader(command.getGlobalTransaction(), ctx.getTransactionContext(), command.isOnePhaseCommit());
}
return invokeNextInterceptor(ctx, command);
}
@@ -333,13 +333,13 @@
return retval;
}
- private void prepareCacheLoader(GlobalTransaction gtx, TransactionEntry entry, boolean onePhase) throws Throwable
+ private void prepareCacheLoader(GlobalTransaction gtx, TransactionContext transactionContext, boolean onePhase) throws Throwable
{
- if (entry == null)
+ if (transactionContext == null)
{
- throw new Exception("entry for transaction " + gtx + " not found in transaction table");
+ throw new Exception("transactionContext for transaction " + gtx + " not found in transaction table");
}
- List<ReversibleCommand> modifications = entry.getModifications();
+ List<ReversibleCommand> modifications = transactionContext.getModifications();
if (modifications.size() == 0)
{
if (trace) log.trace("Transaction has not logged any modifications!");
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/CallInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -8,11 +8,11 @@
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
+import org.jboss.cache.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.annotations.Inject;
@@ -171,7 +171,7 @@
}
else
{
- ctx.getTransactionEntry().addModification(command);
+ ctx.getTransactionContext().addModification(command);
}
}
return result;
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/InvalidationInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -15,7 +15,15 @@
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
import org.jboss.cache.commands.tx.PrepareCommand;
import org.jboss.cache.commands.tx.RollbackCommand;
-import org.jboss.cache.commands.write.*;
+import org.jboss.cache.commands.write.ClearDataCommand;
+import org.jboss.cache.commands.write.InvalidateCommand;
+import org.jboss.cache.commands.write.MoveCommand;
+import org.jboss.cache.commands.write.OptimisticInvalidateCommand;
+import org.jboss.cache.commands.write.PutDataMapCommand;
+import org.jboss.cache.commands.write.PutForExternalReadCommand;
+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.config.Option;
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.factories.annotations.Inject;
@@ -25,8 +33,8 @@
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.SystemException;
@@ -81,7 +89,7 @@
public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
{
// these are always local more, as far as invalidation is concerned
- if (ctx.getTransaction() != null) ctx.getTransactionEntry().addLocalModification(command);
+ if (ctx.getTransaction() != null) ctx.getTransactionContext().addLocalModification(command);
return invokeNextInterceptor(ctx, command);
}
@@ -125,16 +133,17 @@
if (trace) log.trace("Entering InvalidationInterceptor's prepare phase");
// fetch the modifications before the transaction is committed (and thus removed from the txTable)
GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry == null) throw new IllegalStateException("cannot find transaction entry for " + gtx);
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext == null)
+ throw new IllegalStateException("cannot find transaction transactionContext for " + gtx);
- if (entry.hasModifications())
+ if (transactionContext.hasModifications())
{
List<ReversibleCommand> mods;
- if (entry.hasLocalModifications())
+ if (transactionContext.hasLocalModifications())
{
mods = new ArrayList<ReversibleCommand>(command.getModifications());
- mods.removeAll(entry.getLocalModifications());
+ mods.removeAll(transactionContext.getLocalModifications());
}
else
{
@@ -159,13 +168,14 @@
{
// here we just record the modifications but actually do the invalidate in commit.
GlobalTransaction gtx = ctx.getGlobalTransaction();
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry == null) throw new IllegalStateException("cannot find transaction entry for " + gtx);
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext == null)
+ throw new IllegalStateException("cannot find transaction transactionContext for " + gtx);
- if (entry.hasModifications())
+ if (transactionContext.hasModifications())
{
- List<ReversibleCommand> mods = new ArrayList<ReversibleCommand>(entry.getModifications());
- if (entry.hasLocalModifications()) mods.removeAll(entry.getLocalModifications());
+ List<ReversibleCommand> mods = new ArrayList<ReversibleCommand>(transactionContext.getModifications());
+ if (transactionContext.hasLocalModifications()) mods.removeAll(transactionContext.getLocalModifications());
txMods.put(gtx, mods);
}
}
@@ -229,7 +239,7 @@
}
else
{
- if (isLocalModeForced(ctx)) ctx.getTransactionEntry().addLocalModification((ReversibleCommand) command);
+ if (isLocalModeForced(ctx)) ctx.getTransactionContext().addLocalModification((ReversibleCommand) command);
}
}
return retval;
@@ -396,7 +406,7 @@
protected TransactionWorkspace getWorkspace(InvocationContext ctx)
{
- OptimisticTransactionEntry entry = (OptimisticTransactionEntry) ctx.getTransactionEntry();
+ OptimisticTransactionContext entry = (OptimisticTransactionContext) ctx.getTransactionContext();
return entry.getTransactionWorkSpace();
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -19,7 +19,7 @@
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.Transaction;
@@ -47,15 +47,15 @@
protected TransactionWorkspace getTransactionWorkspace(InvocationContext ctx) throws CacheException
{
- OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry) ctx.getTransactionEntry();
+ OptimisticTransactionContext transactionContext = (OptimisticTransactionContext) ctx.getTransactionContext();
- if (transactionEntry == null)
+ if (transactionContext == null)
{
throw new CacheException("Unable to map global transaction " + ctx.getGlobalTransaction() + " to transaction entry when trying to retrieve transaction workspace.");
}
// try and get the workspace from the transaction
- return transactionEntry.getTransactionWorkSpace();
+ return transactionContext.getTransactionWorkSpace();
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticLockingInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -19,7 +19,7 @@
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
/**
* Locks nodes during transaction boundaries. Only affects prepare/commit/rollback method calls; other method calls
@@ -30,14 +30,11 @@
*/
public class OptimisticLockingInterceptor extends OptimisticInterceptor
{
- private long lockAcquisitionTimeout;
-
@Start
private void init()
{
if (txManager == null)
log.fatal("No transaction manager lookup class has been defined. Transactions cannot be used and thus OPTIMISTIC locking cannot be used! Expect errors!!");
- lockAcquisitionTimeout = configuration.getLockAcquisitionTimeout();
}
@Override
@@ -125,8 +122,8 @@
{
try
{
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry != null)
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext != null)
{
lockManager.unlock(ctx);
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticNodeInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -346,7 +346,7 @@
private void addToModificationList(ReversibleCommand command, InvocationContext ctx)
{
Option opt = ctx.getOptionOverrides();
- ctx.getTransactionEntry().addModification(command);
+ ctx.getTransactionContext().addModification(command);
if (log.isDebugEnabled()) log.debug("Adding command " + command + " to modification list");
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -33,8 +33,8 @@
import org.jboss.cache.optimistic.TransactionWorkspace;
import org.jboss.cache.optimistic.WorkspaceNode;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
import java.util.ArrayList;
@@ -75,11 +75,11 @@
if (!skipReplicationOfTransactionMethod(ctx))
{
GlobalTransaction gtx = getGlobalTransaction(ctx);
- TransactionEntry te = ctx.getTransactionEntry();
- if (te.hasLocalModifications())
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext.hasLocalModifications())
{
OptimisticPrepareCommand replicablePrepareCommand = command.copy(); // makre sure we remove any "local" transactions
- replicablePrepareCommand.removeModifications(te.getLocalModifications());
+ replicablePrepareCommand.removeModifications(transactionContext.getLocalModifications());
command = replicablePrepareCommand;
}
@@ -147,14 +147,14 @@
@Override
public Object visitPutForExternalReadCommand(InvocationContext ctx, PutForExternalReadCommand command) throws Throwable
{
- ctx.getTransactionEntry().setForceAsyncReplication(true);
+ ctx.getTransactionContext().setForceAsyncReplication(true);
return handleDefault(ctx, command);
}
public Object handleDefault(InvocationContext ctx, VisitableCommand command) throws Throwable
{
if (isLocalModeForced(ctx) && command instanceof ReversibleCommand)
- ctx.getTransactionEntry().addLocalModification((ReversibleCommand) command);
+ ctx.getTransactionContext().addLocalModification((ReversibleCommand) command);
return invokeNextInterceptor(ctx, command);
}
@@ -378,13 +378,13 @@
protected TransactionWorkspace getTransactionWorkspace(InvocationContext ctx) throws CacheException
{
- OptimisticTransactionEntry transactionEntry = (OptimisticTransactionEntry) ctx.getTransactionEntry();
- if (transactionEntry == null)
+ OptimisticTransactionContext transactionContext = (OptimisticTransactionContext) ctx.getTransactionContext();
+ if (transactionContext == null)
{
throw new CacheException("unable to map global transaction " + ctx + " to transaction entry");
}
// try and get the workspace from the transaction
- return transactionEntry.getTransactionWorkSpace();
+ return transactionContext.getTransactionWorkSpace();
}
}
\ No newline at end of file
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -13,8 +13,8 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Option;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
+import org.jboss.cache.transaction.TransactionContext;
import javax.transaction.Transaction;
import java.util.List;
@@ -99,13 +99,13 @@
if (optionOverride != null
&& (optionOverride.isForceAsynchronous() || optionOverride.isForceSynchronous()))
{
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry != null)
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext != null)
{
if (optionOverride.isForceAsynchronous())
- entry.setForceAsyncReplication(true);
+ transactionContext.setForceAsyncReplication(true);
else
- entry.setForceSyncReplication(true);
+ transactionContext.setForceSyncReplication(true);
}
}
}
@@ -143,17 +143,17 @@
protected void cleanupStaleLocks(InvocationContext ctx) throws Throwable
{
super.cleanupStaleLocks(ctx);
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry != null)
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext != null)
{
- ((OptimisticTransactionEntry) entry).getTransactionWorkSpace().clearNodes();
+ ((OptimisticTransactionContext) transactionContext).getTransactionWorkSpace().clearNodes();
}
}
@Override
- protected TransactionEntry createNewTransactionEntry(Transaction tx) throws Exception
+ protected TransactionContext createNewTransactionContext(Transaction tx) throws Exception
{
- return new OptimisticTransactionEntry(tx);
+ return new OptimisticTransactionContext(tx);
}
private class ModificationsReplayVisitor extends AbstractVisitor
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/PessimisticLockInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -37,7 +37,7 @@
import org.jboss.cache.lock.LockUtil;
import org.jboss.cache.lock.PessimisticNodeBasedLockManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import java.util.LinkedList;
import java.util.List;
@@ -125,7 +125,7 @@
if (!command.isOnePhaseCommit()) return invokeNextInterceptor(ctx, command);
// commit propagated up from the tx interceptor
- commit(ctx.getTransactionEntry(), ctx.getGlobalTransaction());
+ commit(ctx.getTransactionContext(), ctx.getGlobalTransaction());
Object retVal = invokeNextInterceptor(ctx, command);
lockManager.unlock(ctx);
return retVal;
@@ -134,7 +134,7 @@
@Override
protected Object handleCommitCommand(InvocationContext ctx, CommitCommand command) throws Throwable
{
- commit(ctx.getTransactionEntry(), command.getGlobalTransaction());
+ commit(ctx.getTransactionContext(), command.getGlobalTransaction());
if (trace) log.trace("bypassed locking as method commit() doesn't require locking");
Object retVal = invokeNextInterceptor(ctx, command);
lockManager.unlock(ctx);
@@ -144,23 +144,23 @@
@Override
protected Object handleRollbackCommand(InvocationContext ctx, RollbackCommand command) throws Throwable
{
- TransactionEntry entry = ctx.getTransactionEntry();
+ TransactionContext transactionContext = ctx.getTransactionContext();
if (trace)
{
log.trace("called to rollback cache with GlobalTransaction=" + command.getGlobalTransaction());
}
- if (entry == null)
+ if (transactionContext == null)
{
- log.error("entry for transaction " + command.getGlobalTransaction() + " not found (transaction has possibly already been rolled back)");
+ log.error("transactionContext for transaction " + command.getGlobalTransaction() + " not found (transaction has possibly already been rolled back)");
}
else
{
- for (Fqn fqn : entry.getRemovedNodes())
+ for (Fqn fqn : transactionContext.getRemovedNodes())
{
dataContainer.removeFromDataStructure(fqn, false);
}
// 1. Revert the modifications by running the undo-op list in reverse. This *cannot* throw any exceptions !
- entry.undoOperations();
+ transactionContext.undoOperations();
}
if (trace)
{
@@ -183,7 +183,7 @@
lockManager.lockPessimistically(ctx, command.getFqn(), WRITE, false, false, true, false, null, false);
if (ctx.getGlobalTransaction() != null)
{
- ctx.getTransactionEntry().addRemovedNode(command.getFqn());
+ ctx.getTransactionContext().addRemovedNode(command.getFqn());
}
lockManager.lockAllAndRecord(dataContainer.peek(command.getFqn(), true, false), WRITE, ctx);
}
@@ -215,19 +215,19 @@
// we need to mark new nodes created as deleted since they are only created to form a path to the node being removed, to
// create a lock.
boolean created = lockManager.lockPessimistically(ctx, command.getFqn(), WRITE, true, false, true, true, createdNodes, true);
- TransactionEntry entry = null;
+ TransactionContext transactionContext = null;
if (ctx.getGlobalTransaction() != null)
{
- entry = ctx.getTransactionEntry();
- entry.addRemovedNode(command.getFqn());
+ transactionContext = ctx.getTransactionContext();
+ transactionContext.addRemovedNode(command.getFqn());
for (NodeSPI nodeSPI : createdNodes)
{
- entry.addRemovedNode(nodeSPI.getFqn());
+ transactionContext.addRemovedNode(nodeSPI.getFqn());
nodeSPI.markAsDeleted(true);
}
}
- lockAllForRemoval(dataContainer.peek(command.getFqn(), false, false), ctx, entry);
+ lockAllForRemoval(dataContainer.peek(command.getFqn(), false, false), ctx, transactionContext);
if (!createdNodes.isEmpty())
{
@@ -256,19 +256,19 @@
/**
* Acquires write locks on the node and all child nodes, adding children to the list of removed nodes in the context.
*
- * @param node node to inspect
- * @param ctx invocation context
- * @param entry transaction entry
+ * @param node node to inspect
+ * @param ctx invocation context
+ * @param transactionContext transaction entry
* @throws InterruptedException in the event of interruption
*/
- public void lockAllForRemoval(NodeSPI node, InvocationContext ctx, TransactionEntry entry) throws InterruptedException
+ public void lockAllForRemoval(NodeSPI node, InvocationContext ctx, TransactionContext transactionContext) throws InterruptedException
{
if (node == null) return;
// lock node
lockManager.lockAndRecord(node, WRITE, ctx);
// add to deleted list
- if (entry != null) entry.addRemovedNode(node.getFqn());
+ if (transactionContext != null) transactionContext.addRemovedNode(node.getFqn());
// now children.
Map<Object, NodeSPI> children = node.getChildrenMapDirect();
@@ -277,7 +277,7 @@
for (NodeSPI child : children.values())
{
// lock child.
- lockAllForRemoval(child, ctx, entry);
+ lockAllForRemoval(child, ctx, transactionContext);
}
}
}
@@ -340,16 +340,16 @@
/**
* Remove all locks held by <tt>tx</tt>, remove the transaction from the transaction table
*/
- private void commit(TransactionEntry entry, GlobalTransaction gtx)
+ private void commit(TransactionContext transactionContext, GlobalTransaction gtx)
{
if (trace) log.trace("committing cache with gtx " + gtx);
- if (entry == null)
+ if (transactionContext == null)
{
- log.error("entry for transaction " + gtx + " not found (maybe already committed)");
+ log.error("transactionContext for transaction " + gtx + " not found (maybe already committed)");
return;
}
// first remove nodes that should be deleted.
- for (Fqn fqn : entry.getRemovedNodes())
+ for (Fqn fqn : transactionContext.getRemovedNodes())
{
dataContainer.removeFromDataStructure(fqn, false);
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -15,7 +15,7 @@
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
/**
* Takes care of replicating modifications to other nodes in a cluster. Also
@@ -40,11 +40,11 @@
public Object visitPrepareCommand(InvocationContext ctx, PrepareCommand command) throws Throwable
{
Object retVal = invokeNextInterceptor(ctx, command);
- TransactionEntry te = ctx.getTransactionEntry();
- if (te.hasLocalModifications())
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext.hasLocalModifications())
{
PrepareCommand replicablePrepareCommand = command.copy(); // makre sure we remove any "local" transactions
- replicablePrepareCommand.removeModifications(te.getLocalModifications());
+ replicablePrepareCommand.removeModifications(transactionContext.getLocalModifications());
command = replicablePrepareCommand;
}
@@ -70,8 +70,8 @@
if (isTransactionalAndLocal(ctx))
{
Object returnValue = invokeNextInterceptor(ctx, command);
- ctx.getTransactionEntry().setForceAsyncReplication(true);
- if (local) ctx.getTransactionEntry().addLocalModification(command);
+ ctx.getTransactionContext().setForceAsyncReplication(true);
+ if (local) ctx.getTransactionContext().addLocalModification(command);
return returnValue;
}
else
@@ -140,7 +140,7 @@
}
else
{
- if (local) ctx.getTransactionEntry().addLocalModification((ReversibleCommand) command);
+ if (local) ctx.getTransactionContext().addLocalModification((ReversibleCommand) command);
}
return returnValue;
}
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/TxInterceptor.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -33,7 +33,7 @@
import org.jboss.cache.lock.LockManager;
import org.jboss.cache.notifications.Notifier;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.concurrent.ConcurrentHashSet;
@@ -359,22 +359,22 @@
// at this point we have a non-null ltx
// Asssociate the local TX with the global TX. Create new
- // entry for TX in txTable, the modifications
- // below will need this entry to add their modifications
+ // transactionContext for TX in txTable, the modifications
+ // below will need this transactionContext to add their modifications
// under the GlobalTx key
- TransactionEntry entry = txTable.get(gtx);
- if (entry == null)
+ TransactionContext transactionContext = txTable.get(gtx);
+ if (transactionContext == null)
{
- // create a new transaction entry
- if (log.isDebugEnabled()) log.debug("creating new tx entry");
- entry = createNewTransactionEntry(ltx);
- txTable.put(gtx, entry);
+ // create a new transaction transactionContext
+ if (log.isDebugEnabled()) log.debug("creating new tx transactionContext");
+ transactionContext = createNewTransactionContext(ltx);
+ txTable.put(gtx, transactionContext);
}
- setTransactionalContext(ltx, gtx, entry, ctx);
+ setTransactionalContext(ltx, gtx, transactionContext, ctx);
// register a sync handler for this tx.
- registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx, entry), ctx);
+ registerHandler(ltx, new RemoteSynchronizationHandler(gtx, ltx, transactionContext), ctx);
success = false;
@@ -448,9 +448,9 @@
return retval;
}
- protected TransactionEntry createNewTransactionEntry(Transaction tx) throws Exception
+ protected TransactionContext createNewTransactionContext(Transaction tx) throws Exception
{
- return new TransactionEntry(tx);
+ return new TransactionContext(tx);
}
private ReplicableCommand attachGlobalTransaction(InvocationContext ctx, Transaction tx, VisitableCommand command) throws Throwable
@@ -599,8 +599,8 @@
protected void cleanupStaleLocks(InvocationContext ctx) throws Throwable
{
- TransactionEntry entry = ctx.getTransactionEntry();
- if (entry != null) lockManager.unlock(ctx);
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ if (transactionContext != null) lockManager.unlock(ctx);
}
/**
@@ -736,16 +736,16 @@
if (TransactionTable.isValid(tx) && transactions.add(tx))
{
gtx = txTable.getCurrentTransaction(tx, true);
- TransactionEntry entry;
+ TransactionContext transactionContext;
if (ctx.getGlobalTransaction() == null)
{
ctx.setGlobalTransaction(gtx);
- entry = txTable.get(gtx);
- ctx.setTransactionEntry(entry);
+ transactionContext = txTable.get(gtx);
+ ctx.setTransactionContext(transactionContext);
}
else
{
- entry = ctx.getTransactionEntry();
+ transactionContext = ctx.getTransactionContext();
}
if (gtx.isRemote())
{
@@ -757,7 +757,7 @@
if (trace) log.trace("Registering sync handler for tx " + tx + ", gtx " + gtx);
// see the comment in the LocalSyncHandler for the last isOriginLocal param.
- LocalSynchronizationHandler myHandler = new LocalSynchronizationHandler(gtx, tx, entry, !ctx.isOriginLocal());
+ LocalSynchronizationHandler myHandler = new LocalSynchronizationHandler(gtx, tx, transactionContext, !ctx.isOriginLocal());
registerHandler(tx, myHandler, ctx);
}
}
@@ -781,7 +781,7 @@
*/
private void registerHandler(Transaction tx, Synchronization handler, InvocationContext ctx) throws Exception
{
- OrderedSynchronizationHandler orderedHandler = ctx.getTransactionEntry().getOrderedSynchronizationHandler(); //OrderedSynchronizationHandler.getInstance(tx);
+ OrderedSynchronizationHandler orderedHandler = ctx.getTransactionContext().getOrderedSynchronizationHandler(); //OrderedSynchronizationHandler.getInstance(tx);
if (trace) log.trace("registering for TX completion: SynchronizationHandler(" + handler + ")");
@@ -893,31 +893,32 @@
Transaction tx = null;
GlobalTransaction gtx = null;
List<ReversibleCommand> modifications = null;
- TransactionEntry entry = null;
+ TransactionContext transactionContext = null;
protected InvocationContext ctx; // the context for this call.
- RemoteSynchronizationHandler(GlobalTransaction gtx, Transaction tx, TransactionEntry entry)
+ RemoteSynchronizationHandler(GlobalTransaction gtx, Transaction tx, TransactionContext entry)
{
this.gtx = gtx;
this.tx = tx;
- this.entry = entry;
+ this.transactionContext = entry;
}
public void beforeCompletion()
{
if (trace) log.trace("Running beforeCompletion on gtx " + gtx);
- if (entry == null)
+ if (transactionContext == null)
{
log.error("Transaction has a null transaction entry - beforeCompletion() will fail.");
throw new IllegalStateException("cannot find transaction entry for " + gtx);
}
- modifications = entry.getModifications();
+ modifications = transactionContext.getModifications();
ctx = invocationContextContainer.get();
- setTransactionalContext(tx, gtx, entry, ctx);
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
- if (ctx.isOptionsUninitialised() && entry.getOption() != null) ctx.setOptionOverrides(entry.getOption());
+ if (ctx.isOptionsUninitialised() && transactionContext.getOption() != null)
+ ctx.setOptionOverrides(transactionContext.getOption());
assertCanContinue();
@@ -932,12 +933,12 @@
if (ctx == null)
{
ctx = invocationContextContainer.get();
- setTransactionalContext(tx, gtx, entry, ctx);
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
- if (ctx.isOptionsUninitialised() && entry != null && entry.getOption() != null)
+ if (ctx.isOptionsUninitialised() && transactionContext != null && transactionContext.getOption() != null)
{
// use the options from the transaction entry instead
- ctx.setOptionOverrides(entry.getOption());
+ ctx.setOptionOverrides(transactionContext.getOption());
}
}
@@ -957,11 +958,11 @@
if (trace) log.trace("calling aftercompletion for " + gtx);
// set any transaction wide options as current for this thread.
- if (entry != null)
+ if (transactionContext != null)
{
// this should ideally be set in beforeCompletion(), after compacting the list.
- if (modifications == null) modifications = entry.getModifications();
- ctx.setOptionOverrides(entry.getOption());
+ if (modifications == null) modifications = transactionContext.getModifications();
+ ctx.setOptionOverrides(transactionContext.getOption());
}
if (tx != null) transactions.remove(tx);
@@ -1017,8 +1018,8 @@
tx = null;
gtx = null;
modifications = null;
- if (entry != null) entry.reset();
- entry = null;
+ if (transactionContext != null) transactionContext.reset();
+ transactionContext = null;
}
@Override
@@ -1059,9 +1060,9 @@
* @param tx
* @param remoteLocal
*/
- LocalSynchronizationHandler(GlobalTransaction gtx, Transaction tx, TransactionEntry entry, boolean remoteLocal)
+ LocalSynchronizationHandler(GlobalTransaction gtx, Transaction tx, TransactionContext transactionContext, boolean remoteLocal)
{
- super(gtx, tx, entry);
+ super(gtx, tx, transactionContext);
this.remoteLocal = remoteLocal;
}
@@ -1072,8 +1073,8 @@
ctx.setOriginLocal(!remoteLocal); // this is the LOCAL sync handler after all!
// fetch the modifications before the transaction is committed
// (and thus removed from the txTable)
- setTransactionalContext(tx, gtx, entry, ctx);
- if (!entry.hasModifications())
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
+ if (!transactionContext.hasModifications())
{
if (trace) log.trace("No modifications in this tx. Skipping beforeCompletion()");
modifications = Collections.emptyList();
@@ -1082,7 +1083,7 @@
// set any transaction wide options as current for this thread, caching original options that would then be reset
originalOptions = ctx.getOptionOverrides();
- transactionalOptions = entry.getOption();
+ transactionalOptions = transactionContext.getOption();
ctx.setOptionOverrides(transactionalOptions);
try
@@ -1139,7 +1140,7 @@
// could happen if a rollback is called and beforeCompletion() doesn't get called.
if (ctx == null) ctx = invocationContextContainer.get();
ctx.setLocalRollbackOnly(localRollbackOnly);
- setTransactionalContext(tx, gtx, entry, ctx);
+ setTransactionalContext(tx, gtx, transactionContext, ctx);
ctx.setOptionOverrides(transactionalOptions);
try
{
Modified: core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/lock/LockUtil.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -9,7 +9,7 @@
import org.jboss.cache.factories.CommandsFactory;
import org.jboss.cache.statetransfer.StateTransferManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import javax.transaction.Status;
@@ -216,15 +216,15 @@
if (ctx.getGlobalTransaction() != null) //if no tx then reverse remove does not make sense
{
Fqn fqn = childNode.getFqn();
- TransactionEntry entry = ctx.getTransactionEntry();
- boolean needToReverseRemove = reverseRemoveCheck && childNode.isDeleted() && entry != null && entry.getRemovedNodes().contains(fqn);
+ TransactionContext transactionContext = ctx.getTransactionContext();
+ boolean needToReverseRemove = reverseRemoveCheck && childNode.isDeleted() && transactionContext != null && transactionContext.getRemovedNodes().contains(fqn);
if (!needToReverseRemove) return;
childNode.markAsDeleted(false);
//if we'll rollback the tx data should be added to the node again
Map oldData = new HashMap(childNode.getDataDirect());
PutDataMapCommand command = commandsFactory.buildPutDataMapCommand(ctx.getGlobalTransaction(), fqn, oldData);
// txTable.get(gtx).addUndoOperation(command); --- now need to make sure this is added to the normal mods list instead
- entry.addModification(command);
+ transactionContext.addModification(command);
//we're prepared for rollback, now reset the node
childNode.clearDataDirect();
if (createdNodes != null)
Copied: core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java (from rev 6034, core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -0,0 +1,57 @@
+/*
+ * 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.optimistic.TransactionWorkspace;
+import org.jboss.cache.optimistic.TransactionWorkspaceImpl;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+
+/**
+ * Subclasses the {@link TransactionContext} class to add a {@link TransactionWorkspace}. Used with optimistic locking
+ * where each call is assigned a trasnaction and a transaction workspace.
+ *
+ * @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>
+ */
+
+public class OptimisticTransactionContext extends TransactionContext
+{
+ private TransactionWorkspace transactionWorkSpace = new TransactionWorkspaceImpl();
+
+ public OptimisticTransactionContext(Transaction tx) throws SystemException, RollbackException
+ {
+ super(tx);
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer(super.toString());
+ sb.append("\nworkspace: ").append(transactionWorkSpace);
+ return sb.toString();
+ }
+
+ /**
+ * @return Returns the transactionWorkSpace.
+ */
+ public TransactionWorkspace getTransactionWorkSpace()
+ {
+ return transactionWorkSpace;
+ }
+
+ /**
+ * @param transactionWorkSpace The transactionWorkSpace to set.
+ */
+ public void setTransactionWorkSpace(TransactionWorkspace transactionWorkSpace)
+ {
+ this.transactionWorkSpace = transactionWorkSpace;
+ }
+
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionContext.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/OptimisticTransactionEntry.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -1,57 +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.optimistic.TransactionWorkspace;
-import org.jboss.cache.optimistic.TransactionWorkspaceImpl;
-
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-
-/**
- * Subclasses the {@link TransactionEntry} class to add a {@link TransactionWorkspace}. Used with optimistic locking
- * where each call is assigned a trasnaction and a transaction workspace.
- *
- * @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>
- */
-
-public class OptimisticTransactionEntry extends TransactionEntry
-{
- private TransactionWorkspace transactionWorkSpace = new TransactionWorkspaceImpl();
-
- public OptimisticTransactionEntry(Transaction tx) throws SystemException, RollbackException
- {
- super(tx);
- }
-
- @Override
- public String toString()
- {
- StringBuffer sb = new StringBuffer(super.toString());
- sb.append("\nworkspace: ").append(transactionWorkSpace);
- return sb.toString();
- }
-
- /**
- * @return Returns the transactionWorkSpace.
- */
- public TransactionWorkspace getTransactionWorkSpace()
- {
- return transactionWorkSpace;
- }
-
- /**
- * @param transactionWorkSpace The transactionWorkSpace to set.
- */
- public void setTransactionWorkSpace(TransactionWorkspace transactionWorkSpace)
- {
- this.transactionWorkSpace = transactionWorkSpace;
- }
-
-}
Copied: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java (from rev 6034, core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java)
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -0,0 +1,462 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.cache.transaction;
+
+
+import net.jcip.annotations.ThreadSafe;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.commands.ReversibleCommand;
+import org.jboss.cache.config.Option;
+import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
+import org.jboss.cache.lock.NodeLock;
+
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+
+/**
+ * Information associated with a {@link GlobalTransaction} about the transaction state.
+ * <p/>
+ * A TransactionContext maintains:
+ * <ul>
+ * <li>Handle to the local Transaction</li>
+ * <li>List of {@link org.jboss.cache.commands.ReversibleCommand}s that make up this transaction</li>
+ * <li>List of locks acquired</li>
+ * <li>Any transaction-scope options</li>
+ * </ul>
+ *
+ * @author <a href="mailto:bela@jboss.org">Bela Ban</a>
+ * @author Manik Surtani
+ * @version $Revision$
+ */
+@ThreadSafe
+public class TransactionContext
+{
+
+ private static final Log log = LogFactory.getLog(TransactionContext.class);
+ private static final boolean trace = log.isTraceEnabled();
+
+ /**
+ * Local transaction
+ */
+ private Transaction ltx = null;
+ private Option option;
+ private OrderedSynchronizationHandler orderedSynchronizationHandler;
+
+ private boolean forceAsyncReplication = false;
+ private boolean forceSyncReplication = false;
+
+ /**
+ * List<ReversibleCommand> of modifications ({@link ReversibleCommand}). They will be replicated on TX commit
+ */
+ private List<ReversibleCommand> modificationList;
+ /**
+ * A list of modifications that have been encountered with a LOCAL mode option. These will be removed from the modification list during replication.
+ */
+ private List<ReversibleCommand> localModifications;
+
+ /**
+ * LinkedHashSet of locks acquired by the transaction. We use a LinkedHashSet because we need efficient Set semantics
+ * but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
+ * <p/>
+ * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy Opt/Pess locking (NodeLocks held here).
+ * once we drop support for opt/pess locks we can genericise this to contain Fqns. - Manik Surtani, June 2008
+ */
+ private LinkedHashSet transactionLocks;
+ private final Map<Fqn, NodeSPI> lookedUpNodes = new HashMap<Fqn, NodeSPI>();
+
+
+ /**
+ * A list of dummy uninitialised nodes created by the cache loader interceptor to load data for a
+ * given node in this tx.
+ */
+ private List<Fqn> dummyNodesCreatedByCacheLoader;
+
+ /**
+ * List<Fqn> of nodes that have been removed by the transaction
+ */
+ private final List<Fqn> removedNodes = new LinkedList<Fqn>();
+
+ public TransactionContext(Transaction tx) throws SystemException, RollbackException
+ {
+ ltx = tx;
+ orderedSynchronizationHandler = new OrderedSynchronizationHandler(tx);
+ }
+
+ /**
+ * Adds a modification to the modification list.
+ */
+ public void addModification(ReversibleCommand command)
+ {
+ if (command == null) return;
+ if (modificationList == null) modificationList = new LinkedList<ReversibleCommand>();
+ modificationList.add(command);
+ }
+
+ /**
+ * Returns all modifications.
+ */
+ public List<ReversibleCommand> getModifications()
+ {
+ if (modificationList == null) return Collections.emptyList();
+ return modificationList;
+ }
+
+ /**
+ * Adds a modification to the local modification list.
+ */
+ public void addLocalModification(ReversibleCommand command)
+ {
+ if (command == null) return;
+ if (localModifications == null) localModifications = new LinkedList<ReversibleCommand>();
+ localModifications.add(command);
+ }
+
+ /**
+ * Returns all modifications that have been invoked with the LOCAL cache mode option. These will also be in the standard modification list.
+ */
+ public List<ReversibleCommand> getLocalModifications()
+ {
+ if (localModifications == null) return Collections.emptyList();
+ return localModifications;
+ }
+
+
+ /**
+ * Adds the node that has been removed.
+ *
+ * @param fqn
+ */
+ public void addRemovedNode(Fqn fqn)
+ {
+ removedNodes.add(fqn);
+ }
+
+ /**
+ * Gets the list of removed nodes.
+ */
+ public List<Fqn> getRemovedNodes()
+ {
+ return new ArrayList<Fqn>(removedNodes);
+ }
+
+ /**
+ * Sets the local transaction for this entry.
+ */
+ public void setTransaction(Transaction tx)
+ {
+ ltx = tx;
+ }
+
+ /**
+ * Returns a local transaction associated with this TransactionEntry
+ */
+ public Transaction getTransaction()
+ {
+ return ltx;
+ }
+
+ /**
+ * 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.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 Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link 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
+ * @see org.jboss.cache.InvocationContext#addLock(Object)
+ */
+ @SuppressWarnings("unchecked")
+ public void addLock(Object lock)
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (transactionLocks == null) transactionLocks = new LinkedHashSet(5);
+ transactionLocks.add(lock);
+ }
+
+ /**
+ * 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.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 Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link 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
+ * @see org.jboss.cache.InvocationContext#removeLock(Object)
+ */
+ @SuppressWarnings("unchecked")
+ public void removeLock(Object lock)
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (transactionLocks != null) transactionLocks.remove(lock);
+ }
+
+ /**
+ * 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.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 Fqn}s as locks)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link NodeLock} as locks). Once support for
+ * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
+ *
+ * @see org.jboss.cache.InvocationContext#clearLocks()
+ */
+ public void clearLocks()
+ {
+ if (transactionLocks != null) transactionLocks.clear();
+ }
+
+
+ /**
+ * 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.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)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link 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 newLocks locks to add
+ * @see org.jboss.cache.InvocationContext#addAllLocks(java.util.List)
+ */
+ @SuppressWarnings("unchecked")
+ public void addAllLocks(List newLocks)
+ {
+ // no need to worry about concurrency here - a context is only valid for a single thread.
+ if (transactionLocks == null) transactionLocks = new LinkedHashSet(5);
+ transactionLocks.addAll(newLocks);
+ }
+
+ /**
+ * 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.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)
+ * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link 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.
+ * @see org.jboss.cache.InvocationContext#getLocks()
+ */
+ @SuppressWarnings("unchecked")
+ public List getLocks()
+ {
+ return Collections.unmodifiableList(new ArrayList(transactionLocks));
+ }
+
+
+ /**
+ * Gets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
+ * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * a transactional context.
+ *
+ * @return true if the forceAsyncReplication flag is set to true.
+ */
+ public boolean isForceAsyncReplication()
+ {
+ return forceAsyncReplication;
+ }
+
+ /**
+ * Sets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
+ * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * a transactional context. Also used by OptimisticReplicationInterceptor when dealing
+ * with {@link org.jboss.cache.config.Option#setForceAsynchronous(boolean)} in a
+ * non-transactional context (i.e. with an implicit transaction).
+ *
+ * @param forceAsyncReplication value of forceAsyncReplication
+ */
+ public void setForceAsyncReplication(boolean forceAsyncReplication)
+ {
+ this.forceAsyncReplication = forceAsyncReplication;
+ if (forceAsyncReplication)
+ {
+ forceSyncReplication = false;
+ }
+ }
+
+ /**
+ * Gets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
+ * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * a transactional context.
+ *
+ * @return true if the forceAsyncReplication flag is set to true.
+ */
+ public boolean isForceSyncReplication()
+ {
+ return forceSyncReplication;
+ }
+
+ /**
+ * Sets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
+ * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
+ * a transactional context.
+ *
+ * @param forceSyncReplication value of forceSyncReplication
+ */
+ public void setForceSyncReplication(boolean forceSyncReplication)
+ {
+ this.forceSyncReplication = forceSyncReplication;
+ if (forceSyncReplication)
+ {
+ forceAsyncReplication = false;
+ }
+ }
+
+
+ /**
+ * Posts all undo operations to the CacheImpl.
+ */
+ public void undoOperations()
+ {
+ if (modificationList == null)
+ {
+ if (trace) log.trace("Modification list is null, no modifications in this transaction!");
+ return;
+ }
+
+ if (trace) log.trace("undoOperations " + modificationList);
+
+ ArrayList<ReversibleCommand> copy;
+// synchronized (modificationList)
+// {
+ // no need to sync? Only one thread would access a transaction at any given time?
+ copy = new ArrayList<ReversibleCommand>(modificationList);
+// }
+ for (ListIterator i = copy.listIterator(copy.size()); i.hasPrevious();)
+ {
+ Object undoOp = i.previous();
+ ReversibleCommand txCommand = (ReversibleCommand) undoOp;
+ if (log.isDebugEnabled()) log.debug("Calling rollback() on command " + undoOp);
+ txCommand.rollback();
+ }
+ }
+
+ /**
+ * Returns debug information about this transaction.
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append("TransactionEntry\nmodificationList: ").append(modificationList);
+ return sb.toString();
+ }
+
+ public void loadUninitialisedNode(Fqn fqn)
+ {
+ if (dummyNodesCreatedByCacheLoader == null)
+ dummyNodesCreatedByCacheLoader = new LinkedList<Fqn>();
+ dummyNodesCreatedByCacheLoader.add(fqn);
+ }
+
+ public List<Fqn> getDummyNodesCreatedByCacheLoader()
+ {
+ return dummyNodesCreatedByCacheLoader;
+ }
+
+ /**
+ * Sets a transaction-scope option override
+ *
+ * @param o
+ */
+ public void setOption(Option o)
+ {
+ this.option = o;
+ }
+
+ /**
+ * Retrieves a transaction scope option override
+ */
+ public Option getOption()
+ {
+ return this.option;
+ }
+
+ public OrderedSynchronizationHandler getOrderedSynchronizationHandler()
+ {
+ return orderedSynchronizationHandler;
+ }
+
+ public void setOrderedSynchronizationHandler(OrderedSynchronizationHandler orderedSynchronizationHandler)
+ {
+ this.orderedSynchronizationHandler = orderedSynchronizationHandler;
+ }
+
+ /**
+ * Returns true if modifications were registered to either modificationList or to class loader modifications list.
+ */
+ public boolean hasModifications()
+ {
+ return modificationList != null && !modificationList.isEmpty();
+ }
+
+ /**
+ * @return true if any modifications have been invoked with cache mode being LOCAL.
+ */
+ public boolean hasLocalModifications()
+ {
+ return localModifications != null && !localModifications.isEmpty();
+ }
+
+ public NodeSPI lookUpNode(Fqn fqn)
+ {
+ return lookedUpNodes.get(fqn);
+ }
+
+ public void putLookedUpNode(Fqn f, NodeSPI n)
+ {
+ lookedUpNodes.put(f, n);
+ }
+
+ public void clearLookedUpNodes()
+ {
+ lookedUpNodes.clear();
+ }
+
+ public Map<Fqn, NodeSPI> getLookedUpNodes()
+ {
+ return lookedUpNodes;
+ }
+
+
+ /**
+ * Cleans up internal state
+ */
+ public void reset()
+ {
+ orderedSynchronizationHandler = null;
+ if (modificationList != null) modificationList = null;
+ if (localModifications != null) localModifications = null;
+ option = null;
+ transactionLocks.clear();
+ if (dummyNodesCreatedByCacheLoader != null) dummyNodesCreatedByCacheLoader.clear();
+ removedNodes.clear();
+ }
+}
Property changes on: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionContext.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionEntry.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -1,465 +0,0 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.cache.transaction;
-
-
-import net.jcip.annotations.ThreadSafe;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.Fqn;
-import org.jboss.cache.Modification;
-import org.jboss.cache.NodeSPI;
-import org.jboss.cache.commands.ReversibleCommand;
-import org.jboss.cache.config.Option;
-import org.jboss.cache.interceptors.OrderedSynchronizationHandler;
-import org.jboss.cache.lock.IdentityLock;
-import org.jboss.cache.lock.NodeLock;
-
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
-import javax.transaction.Transaction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-/**
- * Information associated with a {@link GlobalTransaction} about the transaction state.
- * <p/>
- * A TransactionEntry maintains:
- * <ul>
- * <li>Handle to local Transactions: there can be more than 1 local TX associated with a GlobalTransaction
- * <li>List of modifications ({@link Modification})
- * <li>List of nodes that were created as part of lock acquisition. These nodes can be
- * safely deleted when a transaction is rolled back
- * <li>List of locks ({@link IdentityLock}) that have been acquired by
- * this transaction so far
- * </ul>
- *
- * @author <a href="mailto:bela@jboss.org">Bela Ban</a> Apr 14, 2003
- * @version $Revision$
- */
-@ThreadSafe
-public class TransactionEntry
-{
-
- private static final Log log = LogFactory.getLog(TransactionEntry.class);
- private static final boolean trace = log.isTraceEnabled();
-
- /**
- * Local transaction
- */
- private Transaction ltx = null;
- private Option option;
- private OrderedSynchronizationHandler orderedSynchronizationHandler;
-
- private boolean forceAsyncReplication = false;
- private boolean forceSyncReplication = false;
-
- /**
- * List<ReversibleCommand> of modifications ({@link ReversibleCommand}). They will be replicated on TX commit
- */
- private List<ReversibleCommand> modificationList;
- /**
- * A list of modifications that have been encountered with a LOCAL mode option. These will be removed from the modification list during replication.
- */
- private List<ReversibleCommand> localModifications;
-
- /**
- * LinkedHashSet of locks acquired by the transaction. We use a LinkedHashSet because we need efficient Set semantics
- * but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
- * <p/>
- * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy Opt/Pess locking (NodeLocks held here).
- * once we drop support for opt/pess locks we can genericise this to contain Fqns. - Manik Surtani, June 2008
- */
- private LinkedHashSet transactionLocks;
- private final Map<Fqn, NodeSPI> lookedUpNodes = new HashMap<Fqn, NodeSPI>();
-
-
- /**
- * A list of dummy uninitialised nodes created by the cache loader interceptor to load data for a
- * given node in this tx.
- */
- private List<Fqn> dummyNodesCreatedByCacheLoader;
-
- /**
- * List<Fqn> of nodes that have been removed by the transaction
- */
- private final List<Fqn> removedNodes = new LinkedList<Fqn>();
-
- public TransactionEntry(Transaction tx) throws SystemException, RollbackException
- {
- ltx = tx;
- orderedSynchronizationHandler = new OrderedSynchronizationHandler(tx);
- }
-
- /**
- * Adds a modification to the modification list.
- */
- public void addModification(ReversibleCommand command)
- {
- if (command == null) return;
- if (modificationList == null) modificationList = new LinkedList<ReversibleCommand>();
- modificationList.add(command);
- }
-
- /**
- * Returns all modifications.
- */
- public List<ReversibleCommand> getModifications()
- {
- if (modificationList == null) return Collections.emptyList();
- return modificationList;
- }
-
- /**
- * Adds a modification to the local modification list.
- */
- public void addLocalModification(ReversibleCommand command)
- {
- if (command == null) return;
- if (localModifications == null) localModifications = new LinkedList<ReversibleCommand>();
- localModifications.add(command);
- }
-
- /**
- * Returns all modifications that have been invoked with the LOCAL cache mode option. These will also be in the standard modification list.
- */
- public List<ReversibleCommand> getLocalModifications()
- {
- if (localModifications == null) return Collections.emptyList();
- return localModifications;
- }
-
-
- /**
- * Adds the node that has been removed.
- *
- * @param fqn
- */
- public void addRemovedNode(Fqn fqn)
- {
- removedNodes.add(fqn);
- }
-
- /**
- * Gets the list of removed nodes.
- */
- public List<Fqn> getRemovedNodes()
- {
- return new ArrayList<Fqn>(removedNodes);
- }
-
- /**
- * Sets the local transaction for this entry.
- */
- public void setTransaction(Transaction tx)
- {
- ltx = tx;
- }
-
- /**
- * Returns a local transaction associated with this TransactionEntry
- */
- public Transaction getTransaction()
- {
- return ltx;
- }
-
- /**
- * 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.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 Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link 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
- * @see org.jboss.cache.InvocationContext#addLock(Object)
- */
- @SuppressWarnings("unchecked")
- public void addLock(Object lock)
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (transactionLocks == null) transactionLocks = new LinkedHashSet(5);
- transactionLocks.add(lock);
- }
-
- /**
- * 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.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 Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link 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
- * @see org.jboss.cache.InvocationContext#removeLock(Object)
- */
- @SuppressWarnings("unchecked")
- public void removeLock(Object lock)
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (transactionLocks != null) transactionLocks.remove(lock);
- }
-
- /**
- * 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.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 Fqn}s as locks)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link NodeLock} as locks). Once support for
- * legacy node locking schemes are dropped, this method will be more strongly typed to accept {@link Fqn}.
- *
- * @see org.jboss.cache.InvocationContext#clearLocks()
- */
- public void clearLocks()
- {
- if (transactionLocks != null) transactionLocks.clear();
- }
-
-
- /**
- * 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.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)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link 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 newLocks locks to add
- * @see org.jboss.cache.InvocationContext#addAllLocks(java.util.List)
- */
- @SuppressWarnings("unchecked")
- public void addAllLocks(List newLocks)
- {
- // no need to worry about concurrency here - a context is only valid for a single thread.
- if (transactionLocks == null) transactionLocks = new LinkedHashSet(5);
- transactionLocks.addAll(newLocks);
- }
-
- /**
- * 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.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)
- * as well as legacy Optimistic and Pessimistic Locking schemes (which use {@link 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.
- * @see org.jboss.cache.InvocationContext#getLocks()
- */
- @SuppressWarnings("unchecked")
- public List getLocks()
- {
- return Collections.unmodifiableList(new ArrayList(transactionLocks));
- }
-
-
- /**
- * Gets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
- * a transactional context.
- *
- * @return true if the forceAsyncReplication flag is set to true.
- */
- public boolean isForceAsyncReplication()
- {
- return forceAsyncReplication;
- }
-
- /**
- * Sets the value of the forceAsyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
- * a transactional context. Also used by OptimisticReplicationInterceptor when dealing
- * with {@link org.jboss.cache.config.Option#setForceAsynchronous(boolean)} in a
- * non-transactional context (i.e. with an implicit transaction).
- *
- * @param forceAsyncReplication value of forceAsyncReplication
- */
- public void setForceAsyncReplication(boolean forceAsyncReplication)
- {
- this.forceAsyncReplication = forceAsyncReplication;
- if (forceAsyncReplication)
- {
- forceSyncReplication = false;
- }
- }
-
- /**
- * Gets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
- * a transactional context.
- *
- * @return true if the forceAsyncReplication flag is set to true.
- */
- public boolean isForceSyncReplication()
- {
- return forceSyncReplication;
- }
-
- /**
- * Sets the value of the forceSyncReplication flag. Used by ReplicationInterceptor and OptimisticReplicationInterceptor
- * when dealing with {@link org.jboss.cache.Cache#putForExternalRead(org.jboss.cache.Fqn,Object,Object)} within
- * a transactional context.
- *
- * @param forceSyncReplication value of forceSyncReplication
- */
- public void setForceSyncReplication(boolean forceSyncReplication)
- {
- this.forceSyncReplication = forceSyncReplication;
- if (forceSyncReplication)
- {
- forceAsyncReplication = false;
- }
- }
-
-
- /**
- * Posts all undo operations to the CacheImpl.
- */
- public void undoOperations()
- {
- if (modificationList == null)
- {
- if (trace) log.trace("Modification list is null, no modifications in this transaction!");
- return;
- }
-
- if (trace) log.trace("undoOperations " + modificationList);
-
- ArrayList<ReversibleCommand> copy;
-// synchronized (modificationList)
-// {
- // no need to sync? Only one thread would access a transaction at any given time?
- copy = new ArrayList<ReversibleCommand>(modificationList);
-// }
- for (ListIterator i = copy.listIterator(copy.size()); i.hasPrevious();)
- {
- Object undoOp = i.previous();
- ReversibleCommand txCommand = (ReversibleCommand) undoOp;
- if (log.isDebugEnabled()) log.debug("Calling rollback() on command " + undoOp);
- txCommand.rollback();
- }
- }
-
- /**
- * Returns debug information about this transaction.
- */
- @Override
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
- sb.append("TransactionEntry\nmodificationList: ").append(modificationList);
- return sb.toString();
- }
-
- public void loadUninitialisedNode(Fqn fqn)
- {
- if (dummyNodesCreatedByCacheLoader == null)
- dummyNodesCreatedByCacheLoader = new LinkedList<Fqn>();
- dummyNodesCreatedByCacheLoader.add(fqn);
- }
-
- public List<Fqn> getDummyNodesCreatedByCacheLoader()
- {
- return dummyNodesCreatedByCacheLoader;
- }
-
- /**
- * Sets a transaction-scope option override
- *
- * @param o
- */
- public void setOption(Option o)
- {
- this.option = o;
- }
-
- /**
- * Retrieves a transaction scope option override
- */
- public Option getOption()
- {
- return this.option;
- }
-
- public OrderedSynchronizationHandler getOrderedSynchronizationHandler()
- {
- return orderedSynchronizationHandler;
- }
-
- public void setOrderedSynchronizationHandler(OrderedSynchronizationHandler orderedSynchronizationHandler)
- {
- this.orderedSynchronizationHandler = orderedSynchronizationHandler;
- }
-
- /**
- * Returns true if modifications were registered to either modificationList or to class loader modifications list.
- */
- public boolean hasModifications()
- {
- return modificationList != null && !modificationList.isEmpty();
- }
-
- /**
- * @return true if any modifications have been invoked with cache mode being LOCAL.
- */
- public boolean hasLocalModifications()
- {
- return localModifications != null && !localModifications.isEmpty();
- }
-
- public NodeSPI lookUpNode(Fqn fqn)
- {
- return lookedUpNodes.get(fqn);
- }
-
- public void putLookedUpNode(Fqn f, NodeSPI n)
- {
- lookedUpNodes.put(f, n);
- }
-
- public void clearLookedUpNodes()
- {
- lookedUpNodes.clear();
- }
-
- public Map<Fqn, NodeSPI> getLookedUpNodes()
- {
- return lookedUpNodes;
- }
-
-
- /**
- * Cleans up internal state
- */
- public void reset()
- {
- orderedSynchronizationHandler = null;
- if (modificationList != null) modificationList = null;
- if (localModifications != null) localModifications = null;
- option = null;
- transactionLocks.clear();
- if (dummyNodesCreatedByCacheLoader != null) dummyNodesCreatedByCacheLoader.clear();
- removedNodes.clear();
- }
-}
Modified: core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/main/java/org/jboss/cache/transaction/TransactionTable.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -26,7 +26,7 @@
/**
* Maintains the mapping between a local {@link Transaction} and a {@link GlobalTransaction}.
- * Also stores {@link TransactionEntry} instances under a given transaction.
+ * Also stores {@link TransactionContext} instances under a given transaction.
*
* @author <a href="mailto:bela@jboss.org">Bela Ban</a> Apr 14, 2003
* @version $Revision$
@@ -47,7 +47,7 @@
/**
* Mappings between GlobalTransactions and modifications.
*/
- protected final Map<GlobalTransaction, TransactionEntry> gtx2EntryMap = new ConcurrentHashMap<GlobalTransaction, TransactionEntry>();
+ protected final Map<GlobalTransaction, TransactionContext> gtx2ContextMap = new ConcurrentHashMap<GlobalTransaction, TransactionContext>();
protected final Map<GlobalTransaction, Transaction> gtx2TxMap = new ConcurrentHashMap<GlobalTransaction, Transaction>();
@@ -85,7 +85,7 @@
*/
public int getNumGlobalTransactions()
{
- return gtx2EntryMap.size();
+ return gtx2ContextMap.size();
}
/**
@@ -152,32 +152,32 @@
* Returns the local transaction entry for the global transaction.
* Returns null if tx is null or it was not found.
*/
- public TransactionEntry get(GlobalTransaction gtx)
+ public TransactionContext get(GlobalTransaction gtx)
{
- return gtx != null ? gtx2EntryMap.get(gtx) : null;
+ return gtx != null ? gtx2ContextMap.get(gtx) : null;
}
/**
- * Associates the global transaction with a transaction entry.
+ * Associates the global transaction with a transaction context.
*/
- public void put(GlobalTransaction tx, TransactionEntry entry)
+ public void put(GlobalTransaction tx, TransactionContext transactionContext)
{
if (tx == null)
{
log.error("key (GlobalTransaction) is null");
return;
}
- gtx2EntryMap.put(tx, entry);
+ gtx2ContextMap.put(tx, transactionContext);
}
/**
* Removes a global transation, returns the old transaction entry.
*/
- public TransactionEntry remove(GlobalTransaction tx)
+ public TransactionContext remove(GlobalTransaction tx)
{
if (tx == null) return null;
gtx2TxMap.remove(tx);
- return gtx2EntryMap.remove(tx);
+ return gtx2ContextMap.remove(tx);
}
/**
@@ -193,7 +193,7 @@
public void remove(GlobalTransaction gtx, Transaction tx)
{
gtx2TxMap.remove(gtx);
- gtx2EntryMap.remove(gtx);
+ gtx2ContextMap.remove(gtx);
tx2gtxMap.remove(tx);
}
@@ -205,7 +205,7 @@
{
StringBuffer sb = new StringBuffer();
sb.append(tx2gtxMap.size()).append(" mappings, ");
- sb.append(gtx2EntryMap.size()).append(" transactions");
+ sb.append(gtx2ContextMap.size()).append(" transactions");
return sb.toString();
}
@@ -218,16 +218,16 @@
return toString();
StringBuffer sb = new StringBuffer();
sb.append("LocalTransactions: ").append(tx2gtxMap.size()).append("\n");
- sb.append("GlobalTransactions: ").append(gtx2EntryMap.size()).append("\n");
+ sb.append("GlobalTransactions: ").append(gtx2ContextMap.size()).append("\n");
sb.append("tx2gtxMap:\n");
for (Map.Entry<Transaction, GlobalTransaction> entry : tx2gtxMap.entrySet())
{
sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
}
sb.append("gtx2EntryMap:\n");
- for (Map.Entry<GlobalTransaction, TransactionEntry> entry : gtx2EntryMap.entrySet())
+ for (Map.Entry<GlobalTransaction, TransactionContext> transactionContextEntry : gtx2ContextMap.entrySet())
{
- sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
+ sb.append(transactionContextEntry.getKey()).append(": ").append(transactionContextEntry.getValue()).append("\n");
}
return sb.toString();
}
@@ -398,17 +398,17 @@
Address addr = rpcManager.getLocalAddress();
gtx = GlobalTransaction.create(addr);
put(tx, gtx);
- TransactionEntry ent;
+ TransactionContext transactionContext;
try
{
- ent = isOptimisticLocking ? new OptimisticTransactionEntry(tx) : new TransactionEntry(tx);
+ transactionContext = isOptimisticLocking ? new OptimisticTransactionContext(tx) : new TransactionContext(tx);
}
catch (Exception e)
{
throw new CacheException("Unable to create a transaction entry!", e);
}
- put(gtx, ent);
+ put(gtx, transactionContext);
if (trace)
{
log.trace("created new GTX: " + gtx + ", local TX=" + tx);
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeAPITest.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -9,7 +9,7 @@
import org.jboss.cache.interceptors.PessimisticLockInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.optimistic.TransactionWorkspace;
-import org.jboss.cache.transaction.OptimisticTransactionEntry;
+import org.jboss.cache.transaction.OptimisticTransactionContext;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -323,7 +323,7 @@
@SuppressWarnings("unchecked")
private TransactionWorkspace<Object, Object> getTransactionWorkspace() throws Exception
{
- return ((OptimisticTransactionEntry) cache.getTransactionTable().get(cache.getTransactionTable().get(tm.getTransaction()))).getTransactionWorkSpace();
+ return ((OptimisticTransactionContext) cache.getTransactionTable().get(cache.getTransactionTable().get(tm.getTransaction()))).getTransactionWorkSpace();
}
public void testGetChildAPI()
Modified: core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/test/java/org/jboss/cache/invocationcontext/TransactionTest.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -4,7 +4,7 @@
import org.jboss.cache.DefaultCacheFactory;
import org.jboss.cache.Fqn;
import org.jboss.cache.config.Configuration.CacheMode;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.jboss.cache.transaction.TransactionTable;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -123,7 +123,7 @@
assertNotNull("Gtx should have been set up by now", cache.getInvocationContext().getGlobalTransaction());
Transaction tx = tm.getTransaction();
- TransactionEntry entry = tt.get(tt.get(tx));
+ TransactionContext transactionContext = tt.get(tt.get(tx));
if (commit)
{
@@ -139,10 +139,10 @@
assertEquals("Method call should have been scrubbed", null, cache.getInvocationContext().getMethodCall());
assertEquals("Cache command should have been scrubbed", null, cache.getInvocationContext().getCommand());
- // check that the transaction entry hasn't leaked stuff.
- assert entry.getModifications().isEmpty() : "Should have scrubbed modifications in transaction entry";
- assert entry.getLocks().isEmpty() : "Should have scrubbed modifications in transaction entry";
- assert entry.getOrderedSynchronizationHandler() == null : "Should have removed the ordered sync handler";
+ // check that the transaction transactionContext hasn't leaked stuff.
+ assert transactionContext.getModifications().isEmpty() : "Should have scrubbed modifications in transaction transactionContext";
+ assert transactionContext.getLocks().isEmpty() : "Should have scrubbed modifications in transaction transactionContext";
+ assert transactionContext.getOrderedSynchronizationHandler() == null : "Should have removed the ordered sync handler";
}
private void setUpOnePhaseCache()
Modified: core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/test/java/org/jboss/cache/lock/AbstractLockManagerRecordingTest.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -10,7 +10,7 @@
import org.jboss.cache.transaction.DummyTransaction;
import org.jboss.cache.transaction.DummyTransactionManager;
import org.jboss.cache.transaction.GlobalTransaction;
-import org.jboss.cache.transaction.TransactionEntry;
+import org.jboss.cache.transaction.TransactionContext;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
@@ -52,12 +52,12 @@
InvocationContext ctx = icc.get();
ctx.setGlobalTransaction(new GlobalTransaction());
ctx.setTransaction(new DummyTransaction(DummyTransactionManager.getInstance()));
- ctx.setTransactionEntry(new TransactionEntry(ctx.getTransaction()));
+ ctx.setTransactionContext(new TransactionContext(ctx.getTransaction()));
// lock and record.
lm.lockAndRecord(node, WRITE, ctx);
assert ctx.getLocks().contains(fqnBasedLocking ? fqn : node.getLock());
- assert ctx.getTransactionEntry().getLocks().size() == 1;
+ assert ctx.getTransactionContext().getLocks().size() == 1;
assert lm.isLocked(node) : "Should be locked";
lm.unlock(ctx);
assert !lm.isLocked(node) : "Should not be locked";
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/AbortionTest.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -8,9 +8,9 @@
import org.jboss.cache.CacheSPI;
import org.jboss.cache.DefaultCacheFactory;
-import org.jboss.cache.util.TestingUtil;
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;
@@ -152,9 +152,9 @@
this.abortBeforeCompletion = abortBeforeCompletion;
}
- public void notify(Transaction tx, TransactionEntry entry) throws SystemException, RollbackException
+ public void notify(Transaction tx, TransactionContext transactionContext) throws SystemException, RollbackException
{
- OrderedSynchronizationHandler osh = entry.getOrderedSynchronizationHandler();
+ OrderedSynchronizationHandler osh = transactionContext.getOrderedSynchronizationHandler();
final Transaction finalTx = tx;
System.out.println("Notify called.");
Modified: core/trunk/src/test/java/org/jboss/cache/transaction/NotifyingTransactionManager.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/transaction/NotifyingTransactionManager.java 2008-06-25 15:10:47 UTC (rev 6037)
+++ core/trunk/src/test/java/org/jboss/cache/transaction/NotifyingTransactionManager.java 2008-06-25 15:33:13 UTC (rev 6038)
@@ -66,7 +66,7 @@
public interface Notification
{
- public void notify(Transaction tx, TransactionEntry entry) throws SystemException, RollbackException;
+ public void notify(Transaction tx, TransactionContext transactionContext) throws SystemException, RollbackException;
}
public CacheSPI getCache()
16 years, 4 months
JBoss Cache SVN: r6037 - core/trunk/src/test/java/org/jboss/cache/optimistic.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-25 11:10:47 -0400 (Wed, 25 Jun 2008)
New Revision: 6037
Modified:
core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
Log:
Removed unnecessary param
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java 2008-06-25 15:09:36 UTC (rev 6036)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/CacheTest.java 2008-06-25 15:10:47 UTC (rev 6037)
@@ -10,7 +10,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.VersionedNode;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
@@ -20,6 +19,7 @@
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.OptimisticTransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import org.jgroups.Address;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -30,7 +30,6 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.CountDownLatch;
@@ -98,7 +97,7 @@
try
{
latch.await();
- for (int i=0;i<5; i++)
+ for (int i = 0; i < 5; i++)
{
c.put("/a", "k", "v");
}
@@ -226,7 +225,7 @@
//call our remote method
List<ReversibleCommand> cacheCommands = injectDataVersion(entry.getModifications());
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, cacheCommands, (Map) null, (Address) remoteGtx.getAddress(), false);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, cacheCommands, (Address) remoteGtx.getAddress(), false);
TestingUtil.replicateCommand(c, prepareCommand);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2008-06-25 15:09:36 UTC (rev 6036)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/OptimisticReplicationInterceptorTest.java 2008-06-25 15:10:47 UTC (rev 6037)
@@ -7,7 +7,6 @@
package org.jboss.cache.optimistic;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
@@ -18,6 +17,7 @@
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.OptimisticTransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import org.jgroups.Address;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -33,7 +33,6 @@
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
/**
* @author xenephon
@@ -147,7 +146,7 @@
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand optimisticPrepareCommand = new OptimisticPrepareCommand(remoteGtx, null, (Map) null, (Address) remoteGtx.getAddress(), false);
+ OptimisticPrepareCommand optimisticPrepareCommand = new OptimisticPrepareCommand(remoteGtx, null, (Address) remoteGtx.getAddress(), false);
try
{
TestingUtil.replicateCommand(cache, optimisticPrepareCommand); //getInvocationDelegate(cache)._replicate(prepareMethod);
@@ -211,7 +210,7 @@
ReversibleCommand command = entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, null, null, (Address) remoteGtx.getAddress(), false);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, null, (Address) remoteGtx.getAddress(), false);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -400,7 +399,7 @@
//hack the method call to make it have the remote globalTransaction
ReversibleCommand command = entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, null, (Map) null, (Address) remoteGtx.getAddress(), false);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, null, (Address) remoteGtx.getAddress(), false);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2008-06-25 15:09:36 UTC (rev 6036)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/TxInterceptorTest.java 2008-06-25 15:10:47 UTC (rev 6037)
@@ -7,7 +7,6 @@
package org.jboss.cache.optimistic;
import org.jboss.cache.CacheSPI;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.tx.CommitCommand;
import org.jboss.cache.commands.tx.OptimisticPrepareCommand;
@@ -17,6 +16,7 @@
import org.jboss.cache.transaction.OptimisticTransactionEntry;
import org.jboss.cache.transaction.TransactionSetup;
import org.jboss.cache.transaction.TransactionTable;
+import org.jboss.cache.util.TestingUtil;
import org.jgroups.Address;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.Test;
@@ -24,7 +24,6 @@
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.util.List;
-import java.util.Map;
@Test(groups = {"functional", "transaction"})
public class TxInterceptorTest extends AbstractOptimisticTestCase
@@ -309,7 +308,7 @@
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Address) remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -368,7 +367,7 @@
ReversibleCommand command = entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Address) remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -451,7 +450,7 @@
ReversibleCommand command = entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Address) remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -539,7 +538,7 @@
ReversibleCommand command = entry.getModifications().get(0);
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Address) remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -638,7 +637,7 @@
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Address) remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -722,7 +721,7 @@
command.setGlobalTransaction(remoteGtx);
//call our remote method
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Map) null, (Address) remoteGtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(remoteGtx, injectDataVersion(entry.getModifications()), (Address) remoteGtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
Modified: core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java 2008-06-25 15:09:36 UTC (rev 6036)
+++ core/trunk/src/test/java/org/jboss/cache/optimistic/ValidatorInterceptorTest.java 2008-06-25 15:10:47 UTC (rev 6037)
@@ -20,11 +20,11 @@
import org.jboss.cache.interceptors.OptimisticValidatorInterceptor;
import org.jboss.cache.interceptors.base.CommandInterceptor;
import org.jboss.cache.loader.SamplePojo;
-import org.jboss.cache.util.TestingUtil;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jboss.cache.transaction.OptimisticTransactionEntry;
import org.jboss.cache.transaction.TransactionTable;
import org.jboss.cache.util.CachePrinter;
+import org.jboss.cache.util.TestingUtil;
import org.jgroups.Address;
import static org.testng.AssertJUnit.*;
import org.testng.annotations.AfterMethod;
@@ -108,7 +108,7 @@
assertTrue(!cache.exists("/one/two"));
assertEquals(null, dummy.getCalledCommand());
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
//now let us do a prepare
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -161,7 +161,7 @@
//lets change one of the underlying version numbers
workspace.getNode(Fqn.fromString("/one/two")).getNode().setVersion(new DefaultDataVersion(2));
//now let us do a prepare
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -208,7 +208,7 @@
//lets change one of the underlying version numbers
//now let us do a prepare
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -285,7 +285,7 @@
//lets change one of the underlying version numbers
//now let us do a prepare
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
try
{
TestingUtil.replicateCommand(cache, prepareCommand);
@@ -364,7 +364,7 @@
//lets change one of the underlying version numbers
//now let us do a prepare
- OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Map) null, (Address) gtx.getAddress(), Boolean.FALSE);
+ OptimisticPrepareCommand prepareCommand = new OptimisticPrepareCommand(gtx, entry.getModifications(), (Address) gtx.getAddress(), Boolean.FALSE);
try
{
16 years, 4 months
JBoss Cache SVN: r6036 - in core/trunk/src/main/java/org/jboss/cache: buddyreplication and 7 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-25 11:09:36 -0400 (Wed, 25 Jun 2008)
New Revision: 6036
Modified:
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.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/eviction/EvictedEventNode.java
core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.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/ReplicationInterceptor.java
core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
core/trunk/src/main/java/org/jboss/cache/mvcc/InternalNode.java
Log:
War against cloning
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -731,17 +731,16 @@
setFlag(LOCK_FOR_CHILD_INSERT_REMOVE, lockForChildInsertRemove);
}
- public InternalNode clone()
+ public InternalNode copy()
{
- try
- {
- return (InternalNode) super.clone();
- }
- catch (CloneNotSupportedException e)
- {
- // do nothing
- return null;
- }
+ UnversionedNode n = new UnversionedNode(fqn.getLastElement(), fqn, data, cache);
+ n.children = children;
+ n.commandsFactory = commandsFactory;
+ n.delegate = delegate;
+ n.flags.clear();
+ n.flags.addAll(flags);
+ n.lockStrategyFactory = lockStrategyFactory;
+ return n;
}
public void setInternalState(Map state)
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/BuddyManager.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -698,7 +698,7 @@
public ReplicateCommand transformReplicateCommand(ReplicateCommand rc)
{
- ReplicateCommand clone = rc.clone();
+ ReplicateCommand clone = rc.copy();
if (rc.isSingleCommand())
{
clone.setSingleModification(transformFqns((VisitableCommand) rc.getSingleModification()));
Modified: core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/buddyreplication/Fqn2BuddyFqnVisitor.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -184,7 +184,7 @@
public Object visitOptimisticPrepareCommand(InvocationContext ctx, OptimisticPrepareCommand command) throws Throwable
{
List<ReversibleCommand> transformed = transformBatch(command.getModifications());
- return factory.buildOptimisticPrepareCommand(command.getGlobalTransaction(), transformed, command.getData(), command.getLocalAddress(), command.isOnePhaseCommit());
+ return factory.buildOptimisticPrepareCommand(command.getGlobalTransaction(), transformed, command.getLocalAddress(), command.isOnePhaseCommit());
}
@Override
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-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/commands/remote/ReplicateCommand.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -9,6 +9,7 @@
import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.interceptors.InterceptorChain;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -224,24 +225,17 @@
}
/**
- * Clones this replicate command, but with an empty modification list.
+ * Creates a copy of this command, amking a deep copy of any collections but everything else copied shallow.
*
- * @return a clone
+ * @return a copy
*/
- @Override
- public ReplicateCommand clone()
+ public ReplicateCommand copy()
{
- ReplicateCommand clone = null;
- try
- {
- clone = (ReplicateCommand) super.clone();
- clone.initialize(invoker);
- }
- catch (CloneNotSupportedException e)
- {
- // should never get here
- }
-
+ ReplicateCommand clone;
+ clone = new ReplicateCommand();
+ clone.invoker = invoker;
+ clone.modifications = modifications == null ? null : new ArrayList<ReplicableCommand>(modifications);
+ clone.singleModification = singleModification;
return clone;
}
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-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/OptimisticPrepareCommand.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -6,8 +6,8 @@
import org.jboss.cache.transaction.GlobalTransaction;
import org.jgroups.Address;
+import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
/**
* An optimistic version of {@link PrepareCommand}.
@@ -18,12 +18,10 @@
public class OptimisticPrepareCommand extends PrepareCommand
{
public static final int METHOD_ID = 18;
- private Map data;
- public OptimisticPrepareCommand(GlobalTransaction gtx, List<ReversibleCommand> modifications, Map data, Address address, boolean onePhaseCommit)
+ public OptimisticPrepareCommand(GlobalTransaction gtx, List<ReversibleCommand> modifications, Address address, boolean onePhaseCommit)
{
super(gtx, modifications, address, onePhaseCommit);
- this.data = data;
}
public OptimisticPrepareCommand()
@@ -36,11 +34,6 @@
return visitor.visitOptimisticPrepareCommand(ctx, this);
}
- public Map getData()
- {
- return data;
- }
-
@Override
public int getCommandId()
{
@@ -50,13 +43,24 @@
@Override
public Object[] getParameters()
{
- return new Object[]{globalTransaction, modifications, data, localAddress, onePhaseCommit};
+ // the null is needed for wire-level compat with pre-command versions
+ return new Object[]{globalTransaction, modifications, null, localAddress, onePhaseCommit};
}
+ /**
+ * A shallow copy of all fields except collections.
+ *
+ * @return a copy of this command
+ */
@Override
- public OptimisticPrepareCommand clone() throws CloneNotSupportedException
+ public OptimisticPrepareCommand copy()
{
- return (OptimisticPrepareCommand) super.clone();
+ OptimisticPrepareCommand copy = new OptimisticPrepareCommand();
+ copy.globalTransaction = globalTransaction;
+ copy.localAddress = localAddress;
+ copy.modifications = modifications == null ? null : new ArrayList<ReversibleCommand>(modifications);
+ copy.onePhaseCommit = onePhaseCommit;
+ return copy;
}
@Override
@@ -65,38 +69,15 @@
{
globalTransaction = (GlobalTransaction) args[0];
modifications = (List<ReversibleCommand>) args[1];
- data = (Map) args[2];
+ //args[2] is probably null.
localAddress = (Address) args[3];
onePhaseCommit = (Boolean) args[4];
}
@Override
- public boolean equals(Object o)
- {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- if (!super.equals(o)) return false;
-
- OptimisticPrepareCommand that = (OptimisticPrepareCommand) o;
-
- if (data != null ? !data.equals(that.data) : that.data != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = super.hashCode();
- result = 31 * result + (data != null ? data.hashCode() : 0);
- return result;
- }
-
- @Override
public String toString()
{
return "OptimisticPrepareCommand{" +
- "data=" + data +
"modifications=" + modifications +
", localAddress=" + localAddress +
", onePhaseCommit=" + onePhaseCommit +
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-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/commands/tx/PrepareCommand.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -1,12 +1,13 @@
package org.jboss.cache.commands.tx;
import org.jboss.cache.InvocationContext;
+import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.commands.ReversibleCommand;
import org.jboss.cache.commands.Visitor;
-import org.jboss.cache.commands.ReplicableCommand;
import org.jboss.cache.transaction.GlobalTransaction;
import org.jgroups.Address;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -118,10 +119,14 @@
return result;
}
- @Override
- public PrepareCommand clone() throws CloneNotSupportedException
+ public PrepareCommand copy()
{
- return (PrepareCommand) super.clone();
+ PrepareCommand copy = new PrepareCommand();
+ copy.globalTransaction = globalTransaction;
+ copy.localAddress = localAddress;
+ copy.modifications = modifications == null ? null : new ArrayList<ReversibleCommand>(modifications);
+ copy.onePhaseCommit = onePhaseCommit;
+ return copy;
}
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/eviction/EvictedEventNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/eviction/EvictedEventNode.java 2008-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/eviction/EvictedEventNode.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -15,9 +15,9 @@
* @author Daniel Huang (dhuang(a)jboss.org)
* @see org.jboss.cache.Region
*/
-public class EvictedEventNode implements Cloneable
+public class EvictedEventNode
{
- private Fqn fqn_;
+ private Fqn fqn;
private NodeEventType type;
private int elementDifference;
@@ -64,12 +64,12 @@
public Fqn getFqn()
{
- return fqn_;
+ return fqn;
}
public void setFqn(Fqn fqn)
{
- this.fqn_ = fqn;
+ this.fqn = fqn;
}
public void setEventType(NodeEventType event)
@@ -85,21 +85,18 @@
@Override
public String toString()
{
- return "EvictedEN[fqn=" + fqn_ + " event=" + type + " diff=" + elementDifference + "]";
+ return "EvictedEventNode[fqn=" + fqn + " event=" + type + " diff=" + elementDifference + "]";
}
- public EvictedEventNode clone(Fqn cloneFqn)
+ /**
+ * Copies this evicted event node to create a new one with the same values, except with a new Fqn root.
+ *
+ * @param newRoot new Fqn root to use
+ * @return a new EvictedEventNode instance
+ * @see org.jboss.cache.Region#copy(org.jboss.cache.Fqn)
+ */
+ public EvictedEventNode copy(Fqn newRoot)
{
- EvictedEventNode clone = null;
- try
- {
- clone = (EvictedEventNode) super.clone();
- clone.setFqn(Fqn.fromRelativeFqn(cloneFqn, fqn_));
- }
- catch (CloneNotSupportedException e)
- {
- // should never get here
- }
- return clone;
+ return new EvictedEventNode(Fqn.fromRelativeFqn(newRoot, fqn), type, elementDifference);
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java 2008-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/factories/CommandsFactory.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -253,9 +253,9 @@
return new RollbackCommand(gtx);
}
- public OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, List<ReversibleCommand> modifications, Map data, Address address, boolean onePhaseCommit)
+ public OptimisticPrepareCommand buildOptimisticPrepareCommand(GlobalTransaction gtx, List<ReversibleCommand> modifications, Address address, boolean onePhaseCommit)
{
- return new OptimisticPrepareCommand(gtx, modifications, data, address, onePhaseCommit);
+ return new OptimisticPrepareCommand(gtx, modifications, address, onePhaseCommit);
}
public AnnounceBuddyPoolNameCommand buildAnnounceBuddyPoolNameCommand(Address address, String buddyPoolName)
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticReplicationInterceptor.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -18,12 +18,12 @@
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.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.CreateNodeCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.factories.CommandsFactory;
@@ -78,7 +78,7 @@
TransactionEntry te = ctx.getTransactionEntry();
if (te.hasLocalModifications())
{
- OptimisticPrepareCommand replicablePrepareCommand = command.clone(); // makre sure we remove any "local" transactions
+ OptimisticPrepareCommand replicablePrepareCommand = command.copy(); // makre sure we remove any "local" transactions
replicablePrepareCommand.removeModifications(te.getLocalModifications());
command = replicablePrepareCommand;
}
@@ -182,7 +182,7 @@
// visit all elements in the collection and apply the DataVersionPopulator to ensure all commands have data versions set.
populator.visitCollection(null, command.getModifications());
- ReplicableCommand toBroadcast = commandsFactory.buildOptimisticPrepareCommand(gtx, populator.versionedCommands, command.getData(), command.getLocalAddress(), command.isOnePhaseCommit());
+ ReplicableCommand toBroadcast = commandsFactory.buildOptimisticPrepareCommand(gtx, populator.versionedCommands, command.getLocalAddress(), command.isOnePhaseCommit());
//record the things we have possibly sent
broadcastTxs.add(gtx);
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java 2008-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticTxInterceptor.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -114,7 +114,7 @@
protected PrepareCommand buildPrepareCommand(GlobalTransaction gtx, List modifications, boolean onePhaseCommit)
{
// optimistic locking NEVER does one-phase prepares.
- return commandsFactory.buildOptimisticPrepareCommand(gtx, modifications, null, rpcManager.getLocalAddress(), false);
+ return commandsFactory.buildOptimisticPrepareCommand(gtx, modifications, rpcManager.getLocalAddress(), false);
}
/**
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/ReplicationInterceptor.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -6,11 +6,11 @@
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.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.MoveCommand;
import org.jboss.cache.commands.write.PutDataMapCommand;
import org.jboss.cache.commands.write.PutForExternalReadCommand;
import org.jboss.cache.commands.write.PutKeyValueCommand;
-import org.jboss.cache.commands.write.ClearDataCommand;
import org.jboss.cache.commands.write.RemoveKeyCommand;
import org.jboss.cache.commands.write.RemoveNodeCommand;
import org.jboss.cache.config.Configuration;
@@ -43,7 +43,7 @@
TransactionEntry te = ctx.getTransactionEntry();
if (te.hasLocalModifications())
{
- PrepareCommand replicablePrepareCommand = command.clone(); // makre sure we remove any "local" transactions
+ PrepareCommand replicablePrepareCommand = command.copy(); // makre sure we remove any "local" transactions
replicablePrepareCommand.removeModifications(te.getLocalModifications());
command = replicablePrepareCommand;
}
Modified: core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/invocation/NodeInvocationDelegate.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -6,9 +6,9 @@
import org.jboss.cache.Node;
import org.jboss.cache.NodeNotValidException;
import org.jboss.cache.NodeSPI;
-import org.jboss.cache.UnversionedNode;
import org.jboss.cache.config.Option;
import org.jboss.cache.lock.NodeLock;
+import org.jboss.cache.mvcc.InternalNode;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -27,10 +27,10 @@
@SuppressWarnings("unchecked")
public class NodeInvocationDelegate<K, V> extends AbstractInvocationDelegate implements NodeSPI<K, V>
{
- private final UnversionedNode node;
+ protected InternalNode node;
private CacheSPI<K, V> spi;
- public NodeInvocationDelegate(UnversionedNode node)
+ public NodeInvocationDelegate(InternalNode node)
{
this.node = node;
}
@@ -278,16 +278,7 @@
// TODO: Revisit. Is this really threadsafe? See comment in putIfAbsent() - same solution should be applied here too.
assertValid();
Fqn nf = Fqn.fromRelativeFqn(getFqn(), f);
- Option o1;
- try
- {
- o1 = spi.getInvocationContext().getOptionOverrides().clone();
- }
- catch (CloneNotSupportedException e)
- {
- // should never happen
- throw new RuntimeException(e);
- }
+ Option o1 = spi.getInvocationContext().getOptionOverrides().copy();
Node<K, V> child = getChild(f);
if (child == null)
Modified: core/trunk/src/main/java/org/jboss/cache/mvcc/InternalNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/InternalNode.java 2008-06-25 14:15:51 UTC (rev 6035)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/InternalNode.java 2008-06-25 15:09:36 UTC (rev 6036)
@@ -109,7 +109,7 @@
boolean isResident();
- InternalNode clone();
+ InternalNode copy();
NodeLock getLock();
16 years, 4 months
JBoss Cache SVN: r6035 - in core/trunk/src/main/java/org/jboss/cache: commands and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-25 10:15:51 -0400 (Wed, 25 Jun 2008)
New Revision: 6035
Modified:
core/trunk/src/main/java/org/jboss/cache/Fqn.java
core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
core/trunk/src/main/java/org/jboss/cache/Region.java
core/trunk/src/main/java/org/jboss/cache/RegionImpl.java
core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java
core/trunk/src/main/java/org/jboss/cache/config/Option.java
Log:
Removed dependence on Cloneable where possible.
Modified: core/trunk/src/main/java/org/jboss/cache/Fqn.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-06-25 13:48:34 UTC (rev 6034)
+++ core/trunk/src/main/java/org/jboss/cache/Fqn.java 2008-06-25 14:15:51 UTC (rev 6035)
@@ -82,7 +82,7 @@
* @version $Revision$
*/
@Immutable
-public class Fqn<E> implements Cloneable, Externalizable, Comparable<Fqn<?>>
+public class Fqn<E> implements Externalizable, Comparable<Fqn<?>>
{
/**
* Separator between FQN elements.
@@ -429,24 +429,6 @@
}
/**
- * Clones the Fqn.
- */
- @Override
- @SuppressWarnings("unchecked")
- public Fqn<E> clone() throws CloneNotSupportedException
- {
- try
- {
- return (Fqn<E>) super.clone();
- }
- catch (CloneNotSupportedException e)
- {
- log.error("Unable to clone Fqn " + this, e);
- return null;
- }
- }
-
- /**
* Returns true if obj is a Fqn with the same elements.
*/
@Override
Modified: core/trunk/src/main/java/org/jboss/cache/InvocationContext.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-06-25 13:48:34 UTC (rev 6034)
+++ core/trunk/src/main/java/org/jboss/cache/InvocationContext.java 2008-06-25 14:15:51 UTC (rev 6035)
@@ -379,17 +379,26 @@
/**
* 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 template passed in.
+ * 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 TransactionEntry, if any, is maintained.
*
- * @param template template to copy
* @return a new InvocationContext
*/
- public static InvocationContext copy(InvocationContext template)
+ @SuppressWarnings("unchecked")
+ public InvocationContext copy()
{
- // TODO: Remove all use of cloning and replace with copy factory methods.
-// InvocationContext clone = (InvocationContext) super.clone();
-// clone.setOptionOverrides(getOptionOverrides().clone());
-// return clone;
+ InvocationContext copy = new InvocationContext();
+ copy.command = command;
+ copy.globalTransaction = globalTransaction;
+ copy.invocationLocks = invocationLocks == null ? null : new LinkedHashSet(invocationLocks);
+ copy.localRollbackOnly = localRollbackOnly;
+ copy.lookedUpNodes.putAll(lookedUpNodes);
+ copy.optionOverrides = optionOverrides == null ? null : optionOverrides.copy();
+ copy.originLocal = originLocal;
+ copy.transaction = transaction;
+ copy.transactionEntry = transactionEntry;
+ copy.txHasMods = txHasMods;
return null;
}
Modified: core/trunk/src/main/java/org/jboss/cache/Region.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/Region.java 2008-06-25 13:48:34 UTC (rev 6034)
+++ core/trunk/src/main/java/org/jboss/cache/Region.java 2008-06-25 14:15:51 UTC (rev 6035)
@@ -31,7 +31,7 @@
* @see org.jboss.cache.RegionManager
* @since 2.0.0
*/
-public interface Region extends Comparable<Region>, Cloneable
+public interface Region extends Comparable<Region>
{
/**
@@ -214,6 +214,12 @@
*/
Status getStatus();
- Region clone(Fqn cloneFqn);
-
+ /**
+ * copies the region - including eviction queue events - to a new Region instance, attached to a new Fqn root.
+ * Typically used with Buddy Replication where region roots need to be adjusted.
+ *
+ * @param newRoot new root for the region - e.g., a buddy backup root.
+ * @return a new Region instance.
+ */
+ Region copy(Fqn newRoot);
}
Modified: core/trunk/src/main/java/org/jboss/cache/RegionImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/RegionImpl.java 2008-06-25 13:48:34 UTC (rev 6034)
+++ core/trunk/src/main/java/org/jboss/cache/RegionImpl.java 2008-06-25 14:15:51 UTC (rev 6035)
@@ -279,28 +279,18 @@
}
}
- public RegionImpl clone(Fqn newRoot)
+ public Region copy(Fqn newRoot)
{
- RegionImpl clone = null;
- try
+ RegionImpl clone;
+ clone = new RegionImpl(policy, configuration, Fqn.fromRelativeFqn(newRoot, fqn), regionManager);
+ clone.status = status;
+ // we also need to copy all of the eviction event nodes to the clone's queue
+ clone.createQueue();
+ for (EvictedEventNode een : this.nodeEventQueue)
{
- clone = (RegionImpl) super.clone();
- clone.policy = policy;
- clone.configuration = configuration;
- clone.status = status;
- clone.fqn = Fqn.fromRelativeFqn(newRoot, fqn);
- // we also need to copy all of the eviction event nodes to the clone's queue
- clone.createQueue();
- for (EvictedEventNode een : this.nodeEventQueue)
- {
- EvictedEventNode cloneEEN = een.clone(newRoot);
- clone.putNodeEvent(cloneEEN);
- }
+ EvictedEventNode cloneEEN = een.copy(newRoot);
+ clone.putNodeEvent(cloneEEN);
}
- catch (CloneNotSupportedException e)
- {
- // problems cloning? Should never get here.
- }
return clone;
}
}
Modified: core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java 2008-06-25 13:48:34 UTC (rev 6034)
+++ core/trunk/src/main/java/org/jboss/cache/commands/ReplicableCommand.java 2008-06-25 14:15:51 UTC (rev 6035)
@@ -10,7 +10,7 @@
* @author Manik Surtani
* @since 2.2.0
*/
-public interface ReplicableCommand extends Cloneable
+public interface ReplicableCommand
{
/**
* Performs the primary function of the command. Please see specific implementation classes for details on what is
Modified: core/trunk/src/main/java/org/jboss/cache/config/Option.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/config/Option.java 2008-06-25 13:48:34 UTC (rev 6034)
+++ core/trunk/src/main/java/org/jboss/cache/config/Option.java 2008-06-25 14:15:51 UTC (rev 6035)
@@ -251,13 +251,34 @@
'}';
}
+ /**
+ * @see #copy()
+ * @deprecated this method may disappear in future, please use copy() instead.
+ */
@Override
+ @Deprecated
public Option clone() throws CloneNotSupportedException
{
return (Option) super.clone();
}
+ /**
+ * @return a new Option instance with all fields shallow-copied.
+ */
+ public Option copy()
+ {
+ try
+ {
+ return (Option) super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ // should never happen
+ return null;
+ }
+ }
+
@Override
public boolean equals(Object o)
{
16 years, 4 months
JBoss Cache SVN: r6034 - core/trunk/src/main/java/org/jboss/cache/lock.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-25 09:48:34 -0400 (Wed, 25 Jun 2008)
New Revision: 6034
Modified:
core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java
core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
Log:
Updated to use new context APIs
Modified: core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java 2008-06-25 13:44:32 UTC (rev 6033)
+++ core/trunk/src/main/java/org/jboss/cache/lock/NodeBasedLockManager.java 2008-06-25 13:48:34 UTC (rev 6034)
@@ -104,14 +104,7 @@
NodeLock lock = acquireLock(node, lockType, getLockOwner(ctx), ctx.getContextLockAcquisitionTimeout(lockAcquisitionTimeout));
if (lock != null)
{
- if (ctx.getTransactionEntry() != null)
- {
- ctx.getTransactionEntry().addLock(lock);
- }
- else
- {
- ctx.addLock(lock);
- }
+ ctx.addLock(lock);
return true;
}
else
@@ -208,14 +201,7 @@
if (locks.size() > 0)
{
- if (ctx.getGlobalTransaction() != null)
- {
- ctx.getTransactionEntry().addAllLocks(locks);
- }
- else
- {
- ctx.addAllLocks(locks);
- }
+ ctx.addAllLocks(locks);
}
return true;
Modified: core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2008-06-25 13:44:32 UTC (rev 6033)
+++ core/trunk/src/main/java/org/jboss/cache/lock/PessimisticNodeBasedLockManager.java 2008-06-25 13:48:34 UTC (rev 6034)
@@ -237,17 +237,7 @@
{
NodeLock lock = node.getLock();
boolean acquired = lock.acquire(owner, lockTimeout, lockType);
- if (acquired)
- {
- // Record the lock for release on method return or tx commit/rollback
- if (gtx != null)
- {
- ctx.getTransactionEntry().addLock(lock);
- }
- else
- {
- ctx.addLock(lock);
- }
- }
+ // Record the lock for release on method return or tx commit/rollback
+ if (acquired) ctx.addLock(lock);
}
}
16 years, 4 months
JBoss Cache SVN: r6033 - core/trunk/src/main/java/org/jboss/cache/lock.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-25 09:44:32 -0400 (Wed, 25 Jun 2008)
New Revision: 6033
Modified:
core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java
core/trunk/src/main/java/org/jboss/cache/lock/NodeLock.java
Log:
Added deprecation
Modified: core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java 2008-06-25 13:32:44 UTC (rev 6032)
+++ core/trunk/src/main/java/org/jboss/cache/lock/IdentityLock.java 2008-06-25 13:44:32 UTC (rev 6033)
@@ -60,8 +60,9 @@
*
* @author <a href="mailto:bela@jboss.org">Bela Ban</a> Apr 11, 2003
* @author Ben Wang July 2003
- * @version $Revision$
+ * @deprecated will be removed when we drop support for Pessimistic Locking and Optimistic Locking
*/
+@Deprecated
@SuppressWarnings("deprecation")
public class IdentityLock implements NodeLock
{
Modified: core/trunk/src/main/java/org/jboss/cache/lock/NodeLock.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/lock/NodeLock.java 2008-06-25 13:32:44 UTC (rev 6032)
+++ core/trunk/src/main/java/org/jboss/cache/lock/NodeLock.java 2008-06-25 13:44:32 UTC (rev 6033)
@@ -8,7 +8,11 @@
/**
* Interface for a lock for nodes.
+ * <p/>
+ *
+ * @deprecated will be removed when we drop support for Pessimistic Locking and Optimistic Locking
*/
+@Deprecated
public interface NodeLock
{
16 years, 4 months
JBoss Cache SVN: r6032 - in core/trunk/src/test/java/org/jboss/cache: api and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-25 09:32:44 -0400 (Wed, 25 Jun 2008)
New Revision: 6032
Modified:
core/trunk/src/test/java/org/jboss/cache/FqnTest.java
core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.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/lock/ReentrantWriterPreferenceReadWriteLockTest.java
core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java
Log:
Updated tests
Modified: core/trunk/src/test/java/org/jboss/cache/FqnTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/FqnTest.java 2008-06-25 13:29:24 UTC (rev 6031)
+++ core/trunk/src/test/java/org/jboss/cache/FqnTest.java 2008-06-25 13:32:44 UTC (rev 6032)
@@ -216,14 +216,6 @@
assert !fqn.equals(null);
}
- public void testClone() throws CloneNotSupportedException
- {
- Fqn<String> fqn1 = Fqn.fromString("/a/b/c");
- Fqn<String> fqn2 = fqn1.clone();
- assert fqn1.equals(fqn2);
- assert fqn1.hashCode() == fqn2.hashCode();
- }
-
public void testNullElements() throws CloneNotSupportedException
{
Fqn<Object> fqn0 = Fqn.fromElements((Object) null);
@@ -235,7 +227,6 @@
Fqn fqn2 = Fqn.fromElements("NULL", null, 0);
assert fqn1.hashCode() == fqn2.hashCode();
assert fqn1.equals(fqn2);
- assert fqn1.equals(fqn1.clone());
}
public void testIteration()
@@ -320,18 +311,6 @@
assert object.toString().equals(objectFqn.getLastElementAsString());
}
- public void testCloningString() throws CloneNotSupportedException
- {
- Fqn<String> f = Fqn.fromString("/a/b/c");
- assert f.equals(f.clone());
- }
-
- public void testCloningOtherTypes() throws CloneNotSupportedException
- {
- Fqn f = Fqn.fromElements("blah", 10, Boolean.TRUE);
- assert f.equals(f.clone());
- }
-
public void testRemovalNonString() throws Exception
{
Fqn f = Fqn.fromElements("test", 1);
Modified: core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-06-25 13:29:24 UTC (rev 6031)
+++ core/trunk/src/test/java/org/jboss/cache/api/NodeMoveAPITest.java 2008-06-25 13:32:44 UTC (rev 6032)
@@ -2,7 +2,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.jboss.cache.*;
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.DefaultCacheFactory;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeNotExistsException;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.config.Configuration;
import org.jboss.cache.config.parsing.CacheLoadersElementParser;
@@ -324,7 +328,7 @@
log.info("nodeD get child E ");
nodeE = nodeD.getChild(E);
- Fqn old_C = C.clone();
+ Fqn old_C = C;
Fqn old_D = Fqn.fromRelativeFqn(old_C, D);
Fqn old_E = Fqn.fromRelativeFqn(old_D, E);
@@ -529,14 +533,14 @@
protected CacheLoaderConfig getSingleCacheLoaderConfig(boolean passivation, String preload, String cacheloaderClass, String properties, boolean async, boolean fetchPersistentState, boolean shared, boolean purgeOnStartup) throws Exception
{
String xml =
- " <cacheLoaders passivation=\"" + passivation + "\" shared=\"" + shared + "\">\n" +
+ " <cacheLoaders passivation=\"" + passivation + "\" shared=\"" + shared + "\">\n" +
" <preload>\n" +
" <node fqn=\"" + preload + "\"/>\n" +
" </preload>\n" +
" <cacheLoader class=\"" + cacheloaderClass + "\" async=\"" + async + "\" fetchPersistentState=\"" + fetchPersistentState + "\"\n" +
" purgeOnStartup=\"" + purgeOnStartup + "\">\n" +
" <properties>\n" +
- properties +
+ properties +
" </properties>\n" +
" </cacheLoader>\n" +
" </cacheLoaders>";
Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-06-25 13:29:24 UTC (rev 6031)
+++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTest.java 2008-06-25 13:32:44 UTC (rev 6032)
@@ -135,15 +135,8 @@
private void assertInvocationContextInitState(Cache c)
{
InvocationContext ctx = c.getInvocationContext();
- InvocationContext control = null;
- try
- {
- control = ctx.clone();
- }
- catch (CloneNotSupportedException e)
- {
- throw new RuntimeException(e);
- }
+ InvocationContext control;
+ control = InvocationContext.copy(ctx);
control.reset();
control.setOptionOverrides(new Option());
Modified: core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java 2008-06-25 13:29:24 UTC (rev 6031)
+++ core/trunk/src/test/java/org/jboss/cache/api/SyncReplTxTest.java 2008-06-25 13:32:44 UTC (rev 6032)
@@ -149,15 +149,8 @@
private void assertInvocationContextInitState(Cache<Object, Object> c)
{
InvocationContext ctx = c.getInvocationContext();
- InvocationContext control = null;
- try
- {
- control = ctx.clone();
- }
- catch (CloneNotSupportedException e)
- {
- throw new RuntimeException(e);
- }
+ InvocationContext control;
+ control = InvocationContext.copy(ctx);
control.reset();
control.setOptionOverrides(new Option());
Modified: core/trunk/src/test/java/org/jboss/cache/lock/ReentrantWriterPreferenceReadWriteLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/ReentrantWriterPreferenceReadWriteLockTest.java 2008-06-25 13:29:24 UTC (rev 6031)
+++ core/trunk/src/test/java/org/jboss/cache/lock/ReentrantWriterPreferenceReadWriteLockTest.java 2008-06-25 13:32:44 UTC (rev 6032)
@@ -8,6 +8,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Tests ReentrantWriterPreferenceReadWriteLock
Modified: core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2008-06-25 13:29:24 UTC (rev 6031)
+++ core/trunk/src/test/java/org/jboss/cache/replicated/SyncReplTest.java 2008-06-25 13:32:44 UTC (rev 6032)
@@ -141,15 +141,8 @@
private void assertInvocationContextInitState(Cache c)
{
InvocationContext ctx = c.getInvocationContext();
- InvocationContext control = null;
- try
- {
- control = ctx.clone();
- }
- catch (CloneNotSupportedException e)
- {
- throw new RuntimeException(e);
- }
+ InvocationContext control;
+ control = InvocationContext.copy(ctx);
control.reset();
control.setOptionOverrides(new Option());
16 years, 4 months
JBoss Cache SVN: r6031 - in core/trunk/src/main/java/org/jboss/cache: mvcc and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-25 09:29:24 -0400 (Wed, 25 Jun 2008)
New Revision: 6031
Added:
core/trunk/src/main/java/org/jboss/cache/mvcc/
core/trunk/src/main/java/org/jboss/cache/mvcc/InternalNode.java
Modified:
core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
Log:
Added an InternalNode interface to UnversionedNode
Added new constructor for UnversionedNode to aid unit testing
Modified: core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-06-25 13:25:40 UTC (rev 6030)
+++ core/trunk/src/main/java/org/jboss/cache/UnversionedNode.java 2008-06-25 13:29:24 UTC (rev 6031)
@@ -14,6 +14,7 @@
import org.jboss.cache.lock.IdentityLock;
import org.jboss.cache.lock.LockStrategyFactory;
import org.jboss.cache.marshall.MarshalledValue;
+import org.jboss.cache.mvcc.InternalNode;
import org.jboss.cache.optimistic.DataVersion;
import org.jboss.cache.transaction.GlobalTransaction;
@@ -32,7 +33,7 @@
* @since 2.0.0
*/
@SuppressWarnings("unchecked")
-public class UnversionedNode<K, V> extends AbstractNode<K, V>
+public class UnversionedNode<K, V> extends AbstractNode<K, V> implements InternalNode<K, V>
{
/**
* Debug log.
@@ -70,8 +71,16 @@
}
/**
+ * Constructs a new node a given Fqn
+ */
+ public UnversionedNode(Fqn fqn)
+ {
+ this.fqn = fqn;
+ initFlags();
+ }
+
+ /**
* Constructs a new node with a name, etc.
- *
*/
protected UnversionedNode(Object childName, Fqn fqn, Map data, CacheSPI cache)
{
@@ -722,6 +731,19 @@
setFlag(LOCK_FOR_CHILD_INSERT_REMOVE, lockForChildInsertRemove);
}
+ public InternalNode clone()
+ {
+ try
+ {
+ return (InternalNode) super.clone();
+ }
+ catch (CloneNotSupportedException e)
+ {
+ // do nothing
+ return null;
+ }
+ }
+
public void setInternalState(Map state)
{
// don't bother doing anything here
Added: core/trunk/src/main/java/org/jboss/cache/mvcc/InternalNode.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/mvcc/InternalNode.java (rev 0)
+++ core/trunk/src/main/java/org/jboss/cache/mvcc/InternalNode.java 2008-06-25 13:29:24 UTC (rev 6031)
@@ -0,0 +1,119 @@
+package org.jboss.cache.mvcc;
+
+import org.jboss.cache.CacheSPI;
+import org.jboss.cache.Fqn;
+import org.jboss.cache.Node;
+import org.jboss.cache.NodeSPI;
+import org.jboss.cache.lock.NodeLock;
+import org.jboss.cache.optimistic.DataVersion;
+import org.jboss.cache.transaction.GlobalTransaction;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * // TODO Document this
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 3.0
+ */
+public interface InternalNode<K, V>
+{
+ NodeSPI getParent();
+
+ CacheSPI getCache();
+
+ boolean isChildrenLoaded();
+
+ void setChildrenLoaded(boolean flag);
+
+ Object getDirect(Object key);
+
+ Map getDataDirect();
+
+ Object putDirect(Object key, Object value);
+
+ NodeSPI getOrCreateChild(Object child_name, GlobalTransaction gtx, boolean notify);
+
+ Object removeDirect(Object key);
+
+ void addChildDirect(NodeSPI child);
+
+ NodeSPI addChildDirect(Fqn f);
+
+ NodeSPI addChildDirect(Fqn f, boolean notify);
+
+ NodeSPI addChildDirect(Object o, boolean notify);
+
+ void clearDataDirect();
+
+ NodeSPI getChildDirect(Fqn fqn);
+
+ Set<Object> getChildrenNamesDirect();
+
+ Set<Object> getKeysDirect();
+
+ boolean removeChildDirect(Object childName);
+
+ boolean removeChildDirect(Fqn f);
+
+ Map<Object, Node<K, V>> getChildrenMapDirect();
+
+ void setChildrenMapDirect(Map<Object, Node<K, V>> children);
+
+ void putAllDirect(Map data);
+
+ void removeChildrenDirect();
+
+ void setVersion(DataVersion version);
+
+ DataVersion getVersion();
+
+ Fqn getFqn();
+
+ void setFqn(Fqn fqn);
+
+ NodeSPI getChildDirect(Object childName);
+
+ Set<NodeSPI> getChildrenDirect();
+
+ boolean hasChildrenDirect();
+
+ Set<NodeSPI> getChildrenDirect(boolean includeMarkedForRemoval);
+
+ boolean isDataLoaded();
+
+ void setDataLoaded(boolean dataLoaded);
+
+ boolean isValid();
+
+ void setValid(boolean valid, boolean recursive);
+
+ boolean isLockForChildInsertRemove();
+
+ void setLockForChildInsertRemove(boolean lockForChildInsertRemove);
+
+ void setInternalState(Map state);
+
+ Map getInternalState(boolean onlyInternalState);
+
+ void releaseObjectReferences(boolean recursive);
+
+ boolean isDeleted();
+
+ void markAsDeleted(boolean marker);
+
+ void markAsDeleted(boolean marker, boolean recursive);
+
+ void setResident(boolean resident);
+
+ boolean isResident();
+
+ InternalNode clone();
+
+ NodeLock getLock();
+
+ void addChild(Object nodeName, Node<K, V> nodeToAdd);
+
+ void printDetails(StringBuffer sb, int indent);
+}
16 years, 4 months
JBoss Cache SVN: r6030 - core/trunk/src/main/java/org/jboss/cache/interceptors.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2008-06-25 09:25:40 -0400 (Wed, 25 Jun 2008)
New Revision: 6030
Modified:
core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
Log:
Catch interruptedException
Modified: core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-06-25 13:24:47 UTC (rev 6029)
+++ core/trunk/src/main/java/org/jboss/cache/interceptors/OptimisticInterceptor.java 2008-06-25 13:25:40 UTC (rev 6030)
@@ -111,7 +111,16 @@
@SuppressWarnings("unchecked")
protected WorkspaceNode lockAndCreateWorkspaceNode(NodeFactory nodeFactory, NodeSPI node, TransactionWorkspace workspace, GlobalTransaction gtx, long timeout)
{
- boolean locked = lockManager.lock(node, READ, gtx, timeout);
+ boolean locked = false;
+ try
+ {
+ locked = lockManager.lock(node, READ, gtx, timeout);
+ }
+ catch (InterruptedException e)
+ {
+ // test if we acquired the lock
+ locked = lockManager.getReadOwners(node).contains(gtx);
+ }
if (!locked)
throw new TimeoutException("Unable to lock node " + node.getFqn() + " after timeout " + timeout + " for copying into workspace");
16 years, 4 months