ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [1/8] ignite git commit: IGNITE-3430 .NET: Enable TransactionScope API again, fix and improve tests
Date Mon, 06 Feb 2017 14:51:12 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-4475-async 5cf6dc4d9 -> 055295edd


IGNITE-3430 .NET: Enable TransactionScope API again, fix and improve tests

This closes #1487


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b0e104e8
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b0e104e8
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b0e104e8

Branch: refs/heads/ignite-4475-async
Commit: b0e104e87e40e6cd4164d96d17d757b822a50e9b
Parents: cfaa5cb
Author: Pavel Tupitsyn <ptupitsyn@apache.org>
Authored: Thu Feb 2 18:34:54 2017 +0300
Committer: Pavel Tupitsyn <ptupitsyn@apache.org>
Committed: Thu Feb 2 18:34:54 2017 +0300

----------------------------------------------------------------------
 .../Cache/CacheAbstractTransactionalTest.cs     | 105 ++++++++++---------
 .../Apache.Ignite.Core/Impl/Cache/CacheImpl.cs  |   9 +-
 2 files changed, 58 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b0e104e8/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTransactionalTest.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTransactionalTest.cs
b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTransactionalTest.cs
index 4bf38b9..2107399 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTransactionalTest.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTransactionalTest.cs
@@ -569,7 +569,6 @@ namespace Apache.Ignite.Core.Tests.Cache
         /// Test Ignite transaction enlistment in ambient <see cref="TransactionScope"/>.
         /// </summary>
         [Test]
-        [Ignore("IGNITE-3430")]
         public void TestTransactionScopeSingleCache()
         {
             var cache = Cache();
@@ -607,7 +606,6 @@ namespace Apache.Ignite.Core.Tests.Cache
         /// with multiple participating caches.
         /// </summary>
         [Test]
-        [Ignore("IGNITE-3430")]
         public void TestTransactionScopeMultiCache()
         {
             var cache1 = Cache();
@@ -648,7 +646,6 @@ namespace Apache.Ignite.Core.Tests.Cache
         /// when Ignite tx is started manually.
         /// </summary>
         [Test]
-        [Ignore("IGNITE-3430")]
         public void TestTransactionScopeWithManualIgniteTx()
         {
             var cache = Cache();
@@ -674,7 +671,6 @@ namespace Apache.Ignite.Core.Tests.Cache
         /// Test Ignite transaction with <see cref="TransactionScopeOption.Suppress"/>
option.
         /// </summary>
         [Test]
-        [Ignore("IGNITE-3430")]
         public void TestSuppressedTransactionScope()
         {
             var cache = Cache();
@@ -694,7 +690,6 @@ namespace Apache.Ignite.Core.Tests.Cache
         /// Test Ignite transaction enlistment in ambient <see cref="TransactionScope"/>
with nested scopes.
         /// </summary>
         [Test]
-        [Ignore("IGNITE-3430")]
         public void TestNestedTransactionScope()
         {
             var cache = Cache();
@@ -737,7 +732,6 @@ namespace Apache.Ignite.Core.Tests.Cache
         /// Test that ambient <see cref="TransactionScope"/> options propagate to Ignite
transaction.
         /// </summary>
         [Test]
-        [Ignore("IGNITE-3430")]
         public void TestTransactionScopeOptions()
         {
             var cache = Cache();
@@ -773,10 +767,9 @@ namespace Apache.Ignite.Core.Tests.Cache
         /// Tests all transactional operations with <see cref="TransactionScope"/>.
         /// </summary>
         [Test]
-        [Ignore("IGNITE-3430")]
         public void TestTransactionScopeAllOperations()
         {
-            for (var i = 0; i < 100; i++)
+            for (var i = 0; i < 10; i++)
             {
                 CheckTxOp((cache, key) => cache.Put(key, -5));
                 CheckTxOp((cache, key) => cache.PutAsync(key, -5).Wait());
@@ -792,7 +785,7 @@ namespace Apache.Ignite.Core.Tests.Cache
                 CheckTxOp((cache, key) =>
                 {
                     cache.Remove(key);
-                    cache.PutIfAbsentAsync(key, -10);
+                    cache.PutIfAbsentAsync(key, -10).Wait();
                 });
 
                 CheckTxOp((cache, key) => cache.GetAndPut(key, -9));
@@ -810,28 +803,28 @@ namespace Apache.Ignite.Core.Tests.Cache
                 });
 
                 CheckTxOp((cache, key) => cache.GetAndRemove(key));
-                CheckTxOp((cache, key) => cache.GetAndRemoveAsync(key));
+                CheckTxOp((cache, key) => cache.GetAndRemoveAsync(key).Wait());
 
                 CheckTxOp((cache, key) => cache.GetAndReplace(key, -11));
-                CheckTxOp((cache, key) => cache.GetAndReplaceAsync(key, -11));
+                CheckTxOp((cache, key) => cache.GetAndReplaceAsync(key, -11).Wait());
 
                 CheckTxOp((cache, key) => cache.Invoke(key, new AddProcessor(), 1));
-                CheckTxOp((cache, key) => cache.InvokeAsync(key, new AddProcessor(), 1));
+                CheckTxOp((cache, key) => cache.InvokeAsync(key, new AddProcessor(), 1).Wait());
 
                 CheckTxOp((cache, key) => cache.InvokeAll(new[] {key}, new AddProcessor(),
1));
-                CheckTxOp((cache, key) => cache.InvokeAllAsync(new[] {key}, new AddProcessor(),
1));
+                CheckTxOp((cache, key) => cache.InvokeAllAsync(new[] {key}, new AddProcessor(),
1).Wait());
 
                 CheckTxOp((cache, key) => cache.Remove(key));
-                CheckTxOp((cache, key) => cache.RemoveAsync(key));
+                CheckTxOp((cache, key) => cache.RemoveAsync(key).Wait());
 
                 CheckTxOp((cache, key) => cache.RemoveAll(new[] {key}));
                 CheckTxOp((cache, key) => cache.RemoveAllAsync(new[] {key}).Wait());
 
                 CheckTxOp((cache, key) => cache.Replace(key, 100));
-                CheckTxOp((cache, key) => cache.ReplaceAsync(key, 100));
+                CheckTxOp((cache, key) => cache.ReplaceAsync(key, 100).Wait());
 
                 CheckTxOp((cache, key) => cache.Replace(key, cache[key], 100));
-                CheckTxOp((cache, key) => cache.ReplaceAsync(key, cache[key], 100));
+                CheckTxOp((cache, key) => cache.ReplaceAsync(key, cache[key], 100).Wait());
             }
         }
 
@@ -840,50 +833,62 @@ namespace Apache.Ignite.Core.Tests.Cache
         /// </summary>
         private void CheckTxOp(Action<ICache<int, int>, int> act)
         {
-            var cache = Cache();
-
-            cache[1] = 1;
-            cache[2] = 2;
+            var isolationLevels = new[]
+            {
+                IsolationLevel.Serializable, IsolationLevel.RepeatableRead, IsolationLevel.ReadCommitted,
+                IsolationLevel.ReadUncommitted, IsolationLevel.Snapshot, IsolationLevel.Chaos
+            };
 
-            // Rollback.
-            using (new TransactionScope())
+            foreach (var isolationLevel in isolationLevels)
             {
-                act(cache, 1);
+                var txOpts = new TransactionOptions {IsolationLevel = isolationLevel};
+                const TransactionScopeOption scope = TransactionScopeOption.Required;
 
-                Assert.IsNotNull(cache.Ignite.GetTransactions().Tx, "Transaction has not
started.");
-            }
+                var cache = Cache();
 
-            Assert.AreEqual(1, cache[1]);
-            Assert.AreEqual(2, cache[2]);
+                cache[1] = 1;
+                cache[2] = 2;
 
-            using (new TransactionScope())
-            {
-                act(cache, 1);
-                act(cache, 2);
-            }
+                // Rollback.
+                using (new TransactionScope(scope, txOpts))
+                {
+                    act(cache, 1);
 
-            Assert.AreEqual(1, cache[1]);
-            Assert.AreEqual(2, cache[2]);
+                    Assert.IsNotNull(cache.Ignite.GetTransactions().Tx, "Transaction has
not started.");
+                }
 
-            // Commit.
-            using (var ts = new TransactionScope())
-            {
-                act(cache, 1);
-                ts.Complete();
-            }
+                Assert.AreEqual(1, cache[1]);
+                Assert.AreEqual(2, cache[2]);
 
-            Assert.IsTrue(!cache.ContainsKey(1) || cache[1] != 1);
-            Assert.AreEqual(2, cache[2]);
+                using (new TransactionScope(scope, txOpts))
+                {
+                    act(cache, 1);
+                    act(cache, 2);
+                }
 
-            using (var ts = new TransactionScope())
-            {
-                act(cache, 1);
-                act(cache, 2);
-                ts.Complete();
-            }
+                Assert.AreEqual(1, cache[1]);
+                Assert.AreEqual(2, cache[2]);
 
-            Assert.IsTrue(!cache.ContainsKey(1) || cache[1] != 1);
-            Assert.IsTrue(!cache.ContainsKey(2) || cache[2] != 2);
+                // Commit.
+                using (var ts = new TransactionScope(scope, txOpts))
+                {
+                    act(cache, 1);
+                    ts.Complete();
+                }
+
+                Assert.IsTrue(!cache.ContainsKey(1) || cache[1] != 1);
+                Assert.AreEqual(2, cache[2]);
+
+                using (var ts = new TransactionScope(scope, txOpts))
+                {
+                    act(cache, 1);
+                    act(cache, 2);
+                    ts.Complete();
+                }
+
+                Assert.IsTrue(!cache.ContainsKey(1) || cache[1] != 1);
+                Assert.IsTrue(!cache.ContainsKey(2) || cache[2] != 2);
+            }
         }
 
         [Serializable]

http://git-wip-us.apache.org/repos/asf/ignite/blob/b0e104e8/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
----------------------------------------------------------------------
diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
index cb6c8d5..a387e1b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Core/Impl/Cache/CacheImpl.cs
@@ -80,12 +80,9 @@ namespace Apache.Ignite.Core.Impl.Cache
             _flagKeepBinary = flagKeepBinary;
             _flagNoRetries = flagNoRetries;
 
-            // TransactionScope feature disabled: IGNITE-3430.
-            _txManager = null;
-
-            //_txManager = GetConfiguration().AtomicityMode == CacheAtomicityMode.Transactional
-            //    ? new CacheTransactionManager(grid.GetTransactions())
-            //    : null;
+            _txManager = GetConfiguration().AtomicityMode == CacheAtomicityMode.Transactional
+                ? new CacheTransactionManager(grid.GetTransactions())
+                : null;
         }
 
         /** <inheritDoc /> */


Mime
View raw message