ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [10/45] ignite git commit: ignite-1349 Cleanup thread local context for system pool threads.
Date Tue, 08 Sep 2015 17:09:00 GMT
ignite-1349 Cleanup thread local context for system pool threads.


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

Branch: refs/heads/ignite-264
Commit: bbfee45418587b6f04e2a6141ae275f133f65d05
Parents: 18b5be3
Author: sboikov <sboikov@gridgain.com>
Authored: Tue Sep 8 09:56:48 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Tue Sep 8 09:56:48 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      | 11 +++++++-
 .../cache/GridCacheMvccCandidate.java           |  6 ++--
 .../cache/GridCacheSharedContext.java           |  7 +++++
 .../distributed/dht/GridDhtTxPrepareFuture.java |  3 ++
 .../colocated/GridDhtColocatedLockFuture.java   | 14 ++++++++--
 .../distributed/near/GridNearLockFuture.java    | 14 ++++++++--
 .../near/GridNearOptimisticTxPrepareFuture.java |  7 ++++-
 .../processors/cache/GridCacheMvccSelfTest.java | 29 +++++++-------------
 .../IgniteCacheFailoverTestSuite2.java          |  3 ++
 9 files changed, 67 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bbfee454/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 68749b9..79c5e4b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -4235,6 +4235,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
 
                                         throw e1;
                                     }
+                                    finally {
+                                        ctx.shared().txContextReset();
+                                    }
                                 }
                             });
                         }
@@ -4245,7 +4248,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
                 return f;
             }
 
-            IgniteInternalFuture<T> f = op.op(tx).chain(new CX1<IgniteInternalFuture<T>,
T>() {
+            final IgniteInternalFuture<T> f = op.op(tx).chain(new CX1<IgniteInternalFuture<T>,
T>() {
                 @Override public T applyx(IgniteInternalFuture<T> tFut) throws IgniteCheckedException
{
                     try {
                         return tFut.get();
@@ -4255,6 +4258,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
 
                         throw e1;
                     }
+                    finally {
+                        ctx.shared().txContextReset();
+                    }
                 }
             });
 
@@ -4881,6 +4887,9 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K,
V
                                         catch (IgniteCheckedException e) {
                                             onDone(e);
                                         }
+                                        finally {
+                                            ctx.shared().txContextReset();
+                                        }
                                     }
                                 });
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbfee454/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
index 0e75d3b..2df103d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
@@ -523,14 +523,16 @@ public class GridCacheMvccCandidate implements Externalizable,
     /**
      * @return Lock that comes before in the same thread, possibly <tt>null</tt>.
      */
-    public GridCacheMvccCandidate previous() {
+    @Nullable public GridCacheMvccCandidate previous() {
         return prev;
     }
 
     /**
-     * @param prev Lock that comes before in the same thread, possibly <tt>null</tt>.
+     * @param prev Lock that comes before in the same thread.
      */
     public void previous(GridCacheMvccCandidate prev) {
+        assert threadId == prev.threadId;
+
         this.prev = prev;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbfee454/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
index beffdd1..90e0921 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
@@ -678,4 +678,11 @@ public class GridCacheSharedContext<K, V> {
 
         return mgr;
     }
+
+    /**
+     * Reset thread-local context for transactional cache.
+     */
+    public void txContextReset() {
+        mvccMgr.contextReset();
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbfee454/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
index f1771d4..6e8460f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxPrepareFuture.java
@@ -537,6 +537,9 @@ public final class GridDhtTxPrepareFuture extends GridCompoundFuture<IgniteInter
                         catch (IgniteCheckedException e) {
                             onError(e);
                         }
+                        finally {
+                            cctx.txContextReset();
+                        }
                     }
                 });
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbfee454/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
index ce547b6..f7093b8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedLockFuture.java
@@ -635,7 +635,12 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
             else {
                 fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>()
{
                     @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion>
t) {
-                        mapOnTopology(remap, c);
+                        try {
+                            mapOnTopology(remap, c);
+                        }
+                        finally {
+                            cctx.shared().txContextReset();
+                        }
                     }
                 });
             }
@@ -1312,7 +1317,12 @@ public final class GridDhtColocatedLockFuture extends GridCompoundIdentityFuture
                     if (affFut != null && !affFut.isDone()) {
                         affFut.listen(new CI1<IgniteInternalFuture<?>>() {
                             @Override public void apply(IgniteInternalFuture<?> fut)
{
-                                remap();
+                                try {
+                                    remap();
+                                }
+                                finally {
+                                    cctx.shared().txContextReset();
+                                }
                             }
                         });
                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbfee454/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
index 629dbb7..26276f0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearLockFuture.java
@@ -769,7 +769,12 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
             else {
                 fut.listen(new CI1<IgniteInternalFuture<AffinityTopologyVersion>>()
{
                     @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion>
t) {
-                        mapOnTopology(remap);
+                        try {
+                            mapOnTopology(remap);
+                        }
+                        finally {
+                            cctx.shared().txContextReset();
+                        }
                     }
                 });
             }
@@ -1420,7 +1425,12 @@ public final class GridNearLockFuture extends GridCompoundIdentityFuture<Boolean
                     if (affFut != null && !affFut.isDone()) {
                         affFut.listen(new CI1<IgniteInternalFuture<?>>() {
                             @Override public void apply(IgniteInternalFuture<?> fut)
{
-                                remap();
+                                try {
+                                    remap();
+                                }
+                                finally {
+                                    cctx.shared().txContextReset();
+                                }
                             }
                         });
                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbfee454/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
index e825e70..529f29c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearOptimisticTxPrepareFuture.java
@@ -324,7 +324,12 @@ public class GridNearOptimisticTxPrepareFuture extends GridNearTxPrepareFutureAd
                 @Override public void apply(IgniteInternalFuture<AffinityTopologyVersion>
t) {
                     cctx.kernalContext().closure().runLocalSafe(new GridPlainRunnable() {
                         @Override public void run() {
-                            prepareOnTopology(remap, c);
+                            try {
+                                prepareOnTopology(remap, c);
+                            }
+                            finally {
+                                cctx.txContextReset();
+                            }
                         }
                     });
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbfee454/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
index c1bf2f1..f2bb8fa 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMvccSelfTest.java
@@ -1349,14 +1349,20 @@ public class GridCacheMvccSelfTest extends GridCommonAbstractTest
{
 
         ctx.mvcc().addNext(ctx, c1);
 
+        ctx.mvcc().contextReset();
+
         GridCacheMvccCandidate c2 = entry.addLocal(2, ver2, 0, true, false);
 
         ctx.mvcc().addNext(ctx, c2);
 
+        ctx.mvcc().contextReset();
+
         GridCacheMvccCandidate c3 = entry.addLocal(3, ver3, 0, true, true);
 
         ctx.mvcc().addNext(ctx, c3);
 
+        ctx.mvcc().contextReset();
+
         checkLocal(entry.candidate(ver1), ver1, false, false, false);
         checkLocal(entry.candidate(ver2), ver2, false, false, false);
         checkLocal(entry.candidate(ver3), ver3, false, false, false);
@@ -1371,9 +1377,7 @@ public class GridCacheMvccSelfTest extends GridCommonAbstractTest {
         entry.removeLock(ver2);
 
         assert c3 != null;
-        assert c3.previous() == c2;
         assert c2 != null;
-        assert c2.previous() == c1;
 
         checkLocal(c2, ver2, false, false, false, true);
 
@@ -1382,9 +1386,6 @@ public class GridCacheMvccSelfTest extends GridCommonAbstractTest {
 
         entry.removeLock(ver1);
 
-        assert c3.previous() == c2;
-        assert c2.previous() == c1;
-
         checkLocal(entry.candidate(ver3), ver3, true, true, false);
 
         GridCacheMvccCandidate c4 = entry.addLocal(4, ver4, 0, true, true);
@@ -1392,7 +1393,6 @@ public class GridCacheMvccSelfTest extends GridCommonAbstractTest {
         ctx.mvcc().addNext(ctx, c4);
 
         assert c4 != null;
-        assert c4.previous() == c3;
     }
 
     /**
@@ -1624,6 +1624,7 @@ public class GridCacheMvccSelfTest extends GridCommonAbstractTest {
     /**
      * Links candidates.
      *
+     * @param ctx Cache context.
      * @param cands Candidates.
      * @throws Exception If failed.
      */
@@ -1670,9 +1671,8 @@ public class GridCacheMvccSelfTest extends GridCommonAbstractTest {
 
         StringBuilder buf = new StringBuilder(eol);
 
-        for (Object obj : objs) {
+        for (Object obj : objs)
             buf.append(obj.toString()).append(eol);
-        }
 
         return buf.toString();
     }
@@ -1686,9 +1686,8 @@ public class GridCacheMvccSelfTest extends GridCommonAbstractTest {
 
         StringBuilder buf = new StringBuilder(eol);
 
-        for (Object obj : objs) {
+        for (Object obj : objs)
             buf.append(obj.toString()).append(eol);
-        }
 
         return buf.toString();
     }
@@ -1834,20 +1833,12 @@ public class GridCacheMvccSelfTest extends GridCommonAbstractTest
{
     }
 
     /**
-     * @return Empty collection.
-     */
-    private Collection<GridCacheVersion> empty() {
-        return Collections.emptyList();
-    }
-
-    /**
      * @param cands Candidates to print.
      */
     private void info(Iterable<GridCacheMvccCandidate> cands) {
         info("Collection of candidates: ");
 
-        for (GridCacheMvccCandidate c : cands) {
+        for (GridCacheMvccCandidate c : cands)
             info(">>> " + c);
-        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/bbfee454/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java
index 20cc6b6..60ada78 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheFailoverTestSuite2.java
@@ -22,6 +22,7 @@ import org.apache.ignite.internal.processors.cache.CacheGetFromJobTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheAsyncOperationsFailoverAtomicTest;
 import org.apache.ignite.internal.processors.cache.distributed.CacheAsyncOperationsFailoverTxTest;
 import org.apache.ignite.internal.processors.cache.distributed.CachePutAllFailoverAtomicTest;
+import org.apache.ignite.internal.processors.cache.distributed.CachePutAllFailoverTxTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridCacheColocatedFailoverSelfTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.IgniteCacheCrossCacheTxFailoverTest;
 import org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridCacheAtomicFailoverSelfTest;
@@ -57,7 +58,9 @@ public class IgniteCacheFailoverTestSuite2 {
 
         suite.addTestSuite(CacheAsyncOperationsFailoverAtomicTest.class);
         suite.addTestSuite(CacheAsyncOperationsFailoverTxTest.class);
+
         suite.addTestSuite(CachePutAllFailoverAtomicTest.class);
+        suite.addTestSuite(CachePutAllFailoverTxTest.class);
 
         return suite;
     }


Mime
View raw message