You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2019/01/22 07:37:01 UTC

[ignite] 02/02: ignite-601

This is an automated email from the ASF dual-hosted git repository.

sboikov pushed a commit to branch ignite-601
in repository https://gitbox.apache.org/repos/asf/ignite.git

commit 7fb9ca06e88016aa70506be07db6e6fb2a5a9974
Author: sboikov <sb...@apache.org>
AuthorDate: Tue Jan 22 10:36:34 2019 +0300

    ignite-601
---
 .../processors/cache/local/GridLocalCache.java     | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java
index 3bdb44e..85fd309 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCache.java
@@ -28,6 +28,7 @@ import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
 import org.apache.ignite.internal.processors.cache.GridCacheEntryEx;
+import org.apache.ignite.internal.processors.cache.GridCacheEntryRemovedException;
 import org.apache.ignite.internal.processors.cache.GridCacheLocalConcurrentMap;
 import org.apache.ignite.internal.processors.cache.GridCacheMapEntry;
 import org.apache.ignite.internal.processors.cache.GridCacheMapEntryFactory;
@@ -38,6 +39,7 @@ import org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalEx;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.util.future.GridFinishedFuture;
 import org.apache.ignite.internal.util.typedef.F;
+import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.CU;
 import org.apache.ignite.transactions.TransactionIsolation;
 import org.jetbrains.annotations.Nullable;
@@ -255,4 +257,33 @@ public class GridLocalCache<K, V> extends GridCacheAdapter<K, V> {
 
         return true;
     }
+
+    /** {@inheritDoc} */
+    @Override public boolean isLockedByThread(K key) {
+        A.notNull(key, "key");
+
+        if (keyCheck)
+            validateCacheKey(key);
+
+        KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
+
+        while (true) {
+            try {
+                GridCacheEntryEx entry = peekEx(cacheKey);
+
+                if (entry != null) {
+                    boolean res = entry.lockedByThread();
+
+                    entry.touch();
+
+                    return res;
+                }
+
+                return false;
+            }
+            catch (GridCacheEntryRemovedException ignore) {
+                // No-op.
+            }
+        }
+    }
 }