From 13befedff91b3c48ac9a98010741f752a887e5e0 Mon Sep 17 00:00:00 2001 From: Alexey Goncharuk Date: Fri, 31 Jul 2015 17:34:34 -0700 Subject: [PATCH] # ignite-1159 --- .../processors/cache/GridCacheMvccManager.java | 73 ++++------------------ .../processors/cache/GridCacheMvccSelfTest.java | 1 - 2 files changed, 13 insertions(+), 61 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java index a0d9051..6a8c6fe 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccManager.java @@ -51,9 +51,9 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter { private static final int MAX_REMOVED_LOCKS = 10240; /** Pending locks per thread. */ - private final ThreadLocal> pending = - new ThreadLocal>() { - @Override protected Queue initialValue() { + private final ThreadLocal> pending = + new ThreadLocal>() { + @Override protected LinkedList initialValue() { return new LinkedList<>(); } }; @@ -708,35 +708,6 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter { } /** - * Unlinks a lock candidate. - * - * @param cand Lock candidate to unlink. - */ - private void unlink(GridCacheMvccCandidate cand) { - GridCacheMvccCandidate next = cand.next(); - - if (next != null) { - GridCacheMvccCandidate prev = cand.previous(); - - next.previous(prev); - - if (prev != null) - prev.next(next); - } - - /* - * Note that we specifically don't set links from passed in - * candidate to null because it is possible in some race - * cases that it will get traversed. However, it should - * still become available for GC and should not cause - * an issue. - */ - - if (log.isDebugEnabled()) - log.debug("Unlinked lock candidate: " + cand); - } - - /** * * @param cand Cache lock candidate to add. * @return {@code True} if added as a result of this operation, @@ -751,43 +722,25 @@ public class GridCacheMvccManager extends GridCacheSharedManagerAdapter { if (cacheCtx.isNear() || cand.singleImplicit()) return true; - Queue queue = pending.get(); - - boolean add = true; + LinkedList queue = pending.get(); GridCacheMvccCandidate prev = null; - for (Iterator it = queue.iterator(); it.hasNext(); ) { - GridCacheMvccCandidate c = it.next(); - - if (c.equals(cand)) - add = false; - - if (c.used()) { - it.remove(); + if (!queue.isEmpty()) + prev = queue.getLast(); - unlink(c); + queue.add(cand); - continue; - } + if (prev != null) { + prev.next(cand); - prev = c; + cand.previous(prev); } - if (add) { - queue.add(cand); - - if (prev != null) { - prev.next(cand); - - cand.previous(prev); - } - - if (log.isDebugEnabled()) - log.debug("Linked new candidate: " + cand); - } + if (log.isDebugEnabled()) + log.debug("Linked new candidate: " + cand); - return add; + return true; } /** 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 be7e3c9..2a4365d 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 @@ -1387,7 +1387,6 @@ public class GridCacheMvccSelfTest extends GridCommonAbstractTest { ctx.mvcc().addNext(ctx, c4); - assert c3.previous() == null; assert c4 != null; assert c4.previous() == c3; } -- 1.9.5 (Apple Git-50.3)