ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject [01/22] incubator-ignite git commit: Remove CacheLock class, merge IgniteCache.isLocked(key) and IgniteCache.isLockedByThread(key) to IgniteCache.isLocalLocked(key, boolean).
Date Wed, 28 Jan 2015 10:18:49 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/sprint-1 237465ed5 -> 0e110c0c1


Remove CacheLock class, merge IgniteCache.isLocked(key) and IgniteCache.isLockedByThread(key) to IgniteCache.isLocalLocked(key, boolean).


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

Branch: refs/heads/sprint-1
Commit: b9c6f3b6ebe67e14f7866a6759d18c36e1b5f974
Parents: 15cbff4
Author: Sergey Evdokimov <sergey.evdokimov@jetbrains.com>
Authored: Fri Jan 23 18:51:00 2015 +0300
Committer: Sergey Evdokimov <sergey.evdokimov@jetbrains.com>
Committed: Fri Jan 23 18:51:00 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/IgniteCache.java     |  38 +++----
 .../java/org/apache/ignite/cache/CacheLock.java |  57 ----------
 .../processors/cache/CacheLockImpl.java         |  22 +---
 .../processors/cache/IgniteCacheProxy.java      |  21 +---
 .../cache/GridCacheAbstractFullApiSelfTest.java |  66 +++++------
 .../cache/GridCacheBasicApiAbstractTest.java    | 110 +++++++++----------
 .../GridCacheOffHeapTieredAbstractSelfTest.java |   4 +-
 .../distributed/GridCacheLockAbstractTest.java  |  26 ++---
 .../GridCacheMultiNodeLockAbstractTest.java     |  56 +++++-----
 .../dht/GridCacheColocatedDebugTest.java        |  19 ++--
 .../near/GridCacheNearMultiNodeSelfTest.java    |  14 +--
 .../near/GridCacheNearOneNodeSelfTest.java      |  24 ++--
 .../cache/local/GridCacheLocalLockSelfTest.java |  52 ++++-----
 .../GridCacheLocalMultithreadedSelfTest.java    |  52 ++++-----
 .../tcp/GridCacheDhtLockBackupSelfTest.java     |   8 +-
 15 files changed, 239 insertions(+), 330 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
index d99ccc6..1b3640c 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java
@@ -29,6 +29,7 @@ import javax.cache.expiry.*;
 import javax.cache.processor.*;
 import java.util.*;
 import java.util.concurrent.*;
+import java.util.concurrent.locks.*;
 
 /**
  * Main entry point for all <b>Data Grid APIs.</b> You can get a named cache by calling {@link Ignite#cache(String)}
@@ -158,48 +159,43 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS
     @Nullable public V getAndPutIfAbsent(K key, V val) throws CacheException;
 
     /**
-     * Return a {@link CacheLock} instance associated with passed key.
+     * Creates a {@link Lock} instance associated with passed key.
      * This method does not acquire lock immediately, you have to call appropriate method on returned instance.
+     * Returned lock does not support {@link Lock#newCondition()} method,
+     * other methods defined in {@link Lock} are supported.
      *
      * @param key Key for lock.
      * @return New lock instance associated with passed key.
-     * @see CacheLock#lock()
-     * @see CacheLock#tryLock(long, TimeUnit)
+     * @see Lock#lock()
+     * @see Lock#tryLock(long, TimeUnit)
      */
-    public CacheLock lock(K key);
+    public Lock lock(K key);
 
     /**
-     * Return a {@link CacheLock} instance associated with passed keys.
+     * Creates a {@link Lock} instance associated with passed keys.
      * This method does not acquire lock immediately, you have to call appropriate method on returned instance.
+     * Returned lock does not support {@link Lock#newCondition()} method,
+     * other methods defined in {@link Lock} are supported.
      *
      * @param keys Keys for lock.
      * @return New lock instance associated with passed key.
-     * @see CacheLock#lock()
-     * @see CacheLock#tryLock(long, TimeUnit)
+     * @see Lock#lock()
+     * @see Lock#tryLock(long, TimeUnit)
      */
-    public CacheLock lockAll(Collection<? extends K> keys);
+    public Lock lockAll(Collection<? extends K> keys);
 
     /**
-     * Checks if any node owns a lock for this key.
+     * Checks if specified key is locked.
      * <p>
      * This is a local in-VM operation and does not involve any network trips
      * or access to persistent storage in any way.
      *
      * @param key Key to check.
+     * @param byCurrThread If {@code true} method will check that current thread owns a lock on this key, other vise
+     *     will check that any thread on any node owns a lock on this key.
      * @return {@code True} if lock is owned by some node.
      */
-    public boolean isLocked(K key);
-
-    /**
-     * Checks if current thread owns a lock on this key.
-     * <p>
-     * This is a local in-VM operation and does not involve any network trips
-     * or access to persistent storage in any way.
-     *
-     * @param key Key to check.
-     * @return {@code True} if key is locked by current thread.
-     */
-    public boolean isLockedByThread(K key);
+    public boolean isLocalLocked(K key, boolean byCurrThread);
 
     public QueryCursor<Entry<K, V>> query(QueryPredicate<K, V> filter);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/main/java/org/apache/ignite/cache/CacheLock.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheLock.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheLock.java
deleted file mode 100644
index 96e44d6..0000000
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheLock.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache;
-
-import org.apache.ignite.*;
-import org.jetbrains.annotations.*;
-
-import java.util.concurrent.locks.*;
-
-/**
- * Lock associated with some cache keys.
- */
-public interface CacheLock extends Lock {
-    /**
-     * Checks if any node holds lock on at least one key associated with this {@code CacheLock}.
-     * <p>
-     * This is a local in-VM operation and does not involve any network trips
-     * or access to persistent storage in any way.
-     *
-     * @return {@code True} if lock is owned by some node.
-     * @see {@link IgniteCache#isLocked(Object)}
-     */
-    public boolean isLocked();
-
-    /**
-     * Checks if current thread holds lock on at least one key associated with this {@code CacheLock}.
-     * <p>
-     * This is a local in-VM operation and does not involve any network trips
-     * or access to persistent storage in any way.
-     *
-     * @return {@code True} if key is locked by current thread.
-     * @see {@link IgniteCache#isLockedByThread(Object)}
-     */
-    public boolean isLockedByThread();
-
-    /**
-     * The method is not supported, {@link UnsupportedOperationException} will be thrown.
-     *
-     * @return This method is not supported, {@link UnsupportedOperationException} will be thrown.
-     */
-    @NotNull @Override public Condition newCondition();
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java
index 9071c00..9bd4ea9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockImpl.java
@@ -30,7 +30,7 @@ import java.util.concurrent.locks.*;
 /**
  *
  */
-class CacheLockImpl<K> implements CacheLock {
+class CacheLockImpl<K> implements Lock {
     /** */
     private final GridCacheProjectionEx<K, ?> delegate;
 
@@ -47,26 +47,6 @@ class CacheLockImpl<K> implements CacheLock {
     }
 
     /** {@inheritDoc} */
-    @Override public boolean isLocked() {
-        for (K key : keys) {
-            if (!delegate.isLocked(key))
-                return false;
-        }
-
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isLockedByThread() {
-        for (K key : keys) {
-            if (!delegate.isLockedByThread(key))
-                return false;
-        }
-
-        return true;
-    }
-
-    /** {@inheritDoc} */
     @Override public void lock() {
         try {
             delegate.lockAll(keys, 0);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
index b9265a5..0d171ef 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheProxy.java
@@ -36,6 +36,7 @@ import javax.cache.processor.*;
 import java.io.*;
 import java.util.*;
 import java.util.concurrent.*;
+import java.util.concurrent.locks.*;
 
 /**
  * Cache proxy.
@@ -177,33 +178,21 @@ public class IgniteCacheProxy<K, V> extends IgniteAsyncSupportAdapter implements
     }
 
     /** {@inheritDoc} */
-    @Override public CacheLock lock(K key) throws CacheException {
+    @Override public Lock lock(K key) throws CacheException {
         return lockAll(Collections.<K>singleton(key));
     }
 
     /** {@inheritDoc} */
-    @Override public CacheLock lockAll(final Collection<? extends K> keys) {
+    @Override public Lock lockAll(final Collection<? extends K> keys) {
         return new CacheLockImpl<K>(delegate, keys);
     }
 
     /** {@inheritDoc} */
-    @Override public boolean isLocked(K key) {
+    @Override public boolean isLocalLocked(K key, boolean byCurrThread) {
         GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
 
         try {
-            return delegate.isLocked(key);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isLockedByThread(K key) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.isLockedByThread(key);
+            return byCurrThread ? delegate.isLockedByThread(key) : delegate.isLocked(key);
         }
         finally {
             gate.leave(prev);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index 7c6af95..7deaffe 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -3318,25 +3318,25 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
 
             cache.put(key, 1);
 
-            assert !cache.isLocked(key);
+            assert !cache.isLocalLocked(key, false);
 
             cache.lock(key).lock();
 
             lockCnt.await();
 
-            assert cache.isLocked(key);
+            assert cache.isLocalLocked(key, false);
 
             cache.lock(key).unlock();
 
             unlockCnt.await();
 
             for (int i = 0; i < 100; i++)
-                if (cache.isLocked(key))
+                if (cache.isLocalLocked(key, false))
                     Thread.sleep(10);
                 else
                     break;
 
-            assert !cache.isLocked(key);
+            assert !cache.isLocalLocked(key, false);
         }
     }
 
@@ -3348,25 +3348,25 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
         if (lockingEnabled()) {
             IgniteCache<String, Integer> cache = jcache();
 
-            CacheLock lock = cache.lock("key");
+            Lock lock = cache.lock("key");
 
             cache.put("key", 1);
 
-            assert !lock.isLocked();
+            assert !cache.isLocalLocked("key", false);
 
             lock.lock();
 
-            assert lock.isLocked();
+            assert cache.isLocalLocked("key", false);
 
             lock.unlock();
 
             for (int i = 0; i < 100; i++)
-                if (lock.isLocked())
+                if (cache.isLocalLocked("key", false))
                     Thread.sleep(10);
                 else
                     break;
 
-            assert !cache.isLocked("key");
+            assert !cache.isLocalLocked("key", false);
         }
     }
 
@@ -3407,14 +3407,14 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
         if (lockingEnabled()) {
             jcache().put("key", 1);
 
-            assert !jcache().isLocked("key");
+            assert !jcache().isLocalLocked("key", false);
 
             final Lock lock = jcache().lock("key");
 
             lock.tryLock(2000, MILLISECONDS);
 
-            assert jcache().isLocked("key");
-            assert jcache().isLockedByThread("key");
+            assert jcache().isLocalLocked("key", false);
+            assert jcache().isLocalLocked("key", true);
 
             assert !forLocal(dfltIgnite).call(new Callable<Boolean>() {
                 @Override public Boolean call() throws InterruptedException {
@@ -3464,14 +3464,14 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
 
             cache.put("key", 1);
 
-            final CacheLock lock = cache.lock("key");
+            final Lock lock = cache.lock("key");
 
-            assert !cache.isLocked("key");
+            assert !cache.isLocalLocked("key", false);
 
             lock.tryLock(1000, MILLISECONDS);
 
-            assert cache.isLocked("key");
-            assert cache.isLockedByThread("key");
+            assert cache.isLocalLocked("key", false);
+            assert cache.isLocalLocked("key", true);
 
             final CountDownLatch latch = new CountDownLatch(1);
 
@@ -3499,21 +3499,21 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
                 // Let another thread start.
             latch.await();
 
-            assert cache.isLocked("key");
-            assert cache.isLockedByThread("key");
+            assert cache.isLocalLocked("key", false);
+            assert cache.isLocalLocked("key", true);
 
             lock.unlock();
 
             assert f.get();
 
             for (int i = 0; i < 100; i++)
-                if (cache.isLocked("key") || cache.isLockedByThread("key"))
+                if (cache.isLocalLocked("key", false) || cache.isLocalLocked("key", true))
                     Thread.sleep(10);
                 else
                     break;
 
-            assert !cache.isLocked("key");
-            assert !cache.isLockedByThread("key");
+            assert !cache.isLocalLocked("key", false);
+            assert !cache.isLocalLocked("key", true);
         }
     }
 
@@ -3701,42 +3701,42 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract
             cache.put("key1", 1);
             cache.put("key2", 2);
 
-            assert !cache.isLocked("key1");
-            assert !cache.isLocked("key2");
+            assert !cache.isLocalLocked("key1", false);
+            assert !cache.isLocalLocked("key2", false);
 
             cache.lockAll(ImmutableSet.of("key1", "key2")).lock();
 
-            assert cache.isLocked("key1");
-            assert cache.isLocked("key2");
+            assert cache.isLocalLocked("key1", false);
+            assert cache.isLocalLocked("key2", false);
 
             cache.lockAll(ImmutableSet.of("key1", "key2")).unlock();
 
             for (int i = 0; i < 100; i++)
-                if (cache.isLocked("key1") || cache.isLocked("key2"))
+                if (cache.isLocalLocked("key1", false) || cache.isLocalLocked("key2", false))
                     Thread.sleep(10);
                 else
                     break;
 
-            assert !cache.isLocked("key1");
-            assert !cache.isLocked("key2");
+            assert !cache.isLocalLocked("key1", false);
+            assert !cache.isLocalLocked("key2", false);
 
             Lock lock = cache.lockAll(ImmutableSet.of("key1", "key2"));
 
             lock.lock();
 
-            assert cache.isLocked("key1");
-            assert cache.isLocked("key2");
+            assert cache.isLocalLocked("key1", false);
+            assert cache.isLocalLocked("key2", false);
 
             lock.unlock();
 
             for (int i = 0; i < 100; i++)
-                if (cache.isLocked("key1") || cache.isLocked("key2"))
+                if (cache.isLocalLocked("key1", false) || cache.isLocalLocked("key2", false))
                     Thread.sleep(10);
                 else
                     break;
 
-            assert !cache.isLocked("key1");
-            assert !cache.isLocked("key2");
+            assert !cache.isLocalLocked("key1", false);
+            assert !cache.isLocalLocked("key2", false);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
index b892230..3e07da5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheBasicApiAbstractTest.java
@@ -88,11 +88,11 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
 
         assert lock.tryLock();
 
-        assert cache.isLocked(1);
+        assert cache.isLocalLocked(1, false);
 
         lock.unlock();
 
-        assert !cache.isLocked(1);
+        assert !cache.isLocalLocked(1, false);
     }
 
     /**
@@ -106,20 +106,20 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
         lock.lock();
 
         try {
-            assert cache.isLockedByThread(1);
+            assert cache.isLocalLocked(1, true);
 
             lock.lock();
 
             lock.unlock();
 
-            assert cache.isLockedByThread(1);
+            assert cache.isLocalLocked(1, true);
         }
         finally {
             lock.unlock();
         }
 
-        assert !cache.isLockedByThread(1);
-        assert !cache.isLocked(1);
+        assert !cache.isLocalLocked(1, true);
+        assert !cache.isLocalLocked(1, false);
     }
 
     /**
@@ -133,33 +133,33 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
 
         lock.lock();
 
-        assert cache.isLocked(1);
-        assert cache.isLockedByThread(1);
+        assert cache.isLocalLocked(1, false);
+        assert cache.isLocalLocked(1, true);
 
         lock.lock();
 
-        assert cache.isLocked(1);
-        assert cache.isLockedByThread(1);
+        assert cache.isLocalLocked(1, false);
+        assert cache.isLocalLocked(1, true);
 
         lock.lock();
 
-        assert cache.isLocked(1);
-        assert cache.isLockedByThread(1);
+        assert cache.isLocalLocked(1, false);
+        assert cache.isLocalLocked(1, true);
 
         lock.unlock();
 
-        assert cache.isLocked(1);
-        assert cache.isLockedByThread(1);
+        assert cache.isLocalLocked(1, false);
+        assert cache.isLocalLocked(1, true);
 
         lock.unlock();
 
-        assert cache.isLocked(1);
-        assert cache.isLockedByThread(1);
+        assert cache.isLocalLocked(1, false);
+        assert cache.isLocalLocked(1, true);
 
         lock.unlock();
 
-        assert !cache.isLocked(1);
-        assert !cache.isLockedByThread(1);
+        assert !cache.isLocalLocked(1, false);
+        assert !cache.isLocalLocked(1, true);
     }
 
     /**
@@ -174,12 +174,12 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
 
         Thread t = new Thread(new Runnable() {
             @Override public void run() {
-                assertFalse(cache.lock(1).isLockedByThread());
+                assertFalse(cache.isLocalLocked(1, true));
 
                 cache.lock(1).lock();
 
                 try {
-                    assertTrue(cache.lock(1).isLockedByThread());
+                    assertTrue(cache.isLocalLocked(1, true));
                 }
                 finally {
                     cache.lock(1).unlock();
@@ -235,8 +235,8 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
 
         cache.lock(2).unlock();
 
-        assertFalse(cache.lock(1).isLocked());
-        assertFalse(cache.lock(2).isLocked());
+        assertFalse(cache.isLocalLocked(1, false));
+        assertFalse(cache.isLocalLocked(2, false));
 
         assertTrue(isOk.get());
     }
@@ -256,13 +256,13 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
             assert cache.getAndPut(key, "1") == null;
             assert "1".equals(cache.get(key));
 
-            assert cache.isLocked(key);
-            assert cache.isLockedByThread(key);
+            assert cache.isLocalLocked(key, false);
+            assert cache.isLocalLocked(key, true);
 
             cache.lock(key).lock();
 
-            assert cache.isLocked(key);
-            assert cache.isLockedByThread(key);
+            assert cache.isLocalLocked(key, false);
+            assert cache.isLocalLocked(key, true);
 
             try {
                 assert "1".equals(cache.getAndRemove(key));
@@ -271,14 +271,14 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
                 cache.lock(key).unlock();
             }
 
-            assert cache.isLocked(key);
-            assert cache.isLockedByThread(key);
+            assert cache.isLocalLocked(key, false);
+            assert cache.isLocalLocked(key, true);
         }
         finally {
             cache.lock(key).unlock();
 
-            assert !cache.isLocked(key);
-            assert !cache.isLockedByThread(key);
+            assert !cache.isLocalLocked(key, false);
+            assert !cache.isLocalLocked(key, true);
         }
     }
 
@@ -302,8 +302,8 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
                 info("After lock for key 1");
 
                 try {
-                    assert cache.isLocked(1);
-                    assert cache.isLockedByThread(1);
+                    assert cache.isLocalLocked(1, false);
+                    assert cache.isLocalLocked(1, true);
 
                     l1.countDown();
 
@@ -347,10 +347,10 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
 
                 assert !cache.lock(1).tryLock();
 
-                if (!cache.isLocked(1))
+                if (!cache.isLocalLocked(1, false))
                     throw new IllegalArgumentException();
 
-                assert !cache.isLockedByThread(1);
+                assert !cache.isLocalLocked(1, true);
 
                 info("Tried to lock cache for key1");
 
@@ -365,8 +365,8 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
                 try {
                     info("Locked cache for key 1");
 
-                    assert cache.isLocked(1);
-                    assert cache.isLockedByThread(1);
+                    assert cache.isLocalLocked(1, false);
+                    assert cache.isLocalLocked(1, true);
 
                     info("Checked that cache is locked for key 1");
                 }
@@ -376,8 +376,8 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
                     info("Unlocked cache for key 1");
                 }
 
-                assert !cache.isLocked(1);
-                assert !cache.isLockedByThread(1);
+                assert !cache.isLocalLocked(1, false);
+                assert !cache.isLocalLocked(1, true);
 
                 return null;
             }
@@ -392,7 +392,7 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
         t1.checkError();
         t2.checkError();
 
-        assert !cache.isLocked(1);
+        assert !cache.isLocalLocked(1, false);
     }
 
     /**
@@ -485,7 +485,7 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
             info("Stop latch wait 1");
 
             assert cache.containsKey(key);
-            assert cache.isLockedByThread(key);
+            assert cache.isLocalLocked(key, true);
 
             latch = new CountDownLatch(2);
 
@@ -501,7 +501,7 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
             info("Stop latch wait 2");
 
             assert cache.containsKey(key);
-            assert cache.isLockedByThread(key);
+            assert cache.isLocalLocked(key, true);
 
             latch = new CountDownLatch(1);
 
@@ -515,7 +515,7 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
 
             info("Stop latch wait 3");
 
-            assert cache.isLocked(key);
+            assert cache.isLocalLocked(key, false);
         }
         finally {
             cache.lock(key).unlock();
@@ -524,7 +524,7 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
         }
 
         // Entry should be evicted since allowEmptyEntries is false.
-        assert !cache.isLocked(key);
+        assert !cache.isLocalLocked(key, false);
     }
 
     /**
@@ -539,23 +539,23 @@ public abstract class GridCacheBasicApiAbstractTest extends GridCommonAbstractTe
 
         cache.lockAll(keys).lock();
 
-        assert cache.isLocked(1);
-        assert cache.isLocked(2);
-        assert cache.isLocked(3);
+        assert cache.isLocalLocked(1, false);
+        assert cache.isLocalLocked(2, false);
+        assert cache.isLocalLocked(3, false);
 
-        assert cache.isLockedByThread(1);
-        assert cache.isLockedByThread(2);
-        assert cache.isLockedByThread(3);
+        assert cache.isLocalLocked(1, true);
+        assert cache.isLocalLocked(2, true);
+        assert cache.isLocalLocked(3, true);
 
         cache.lockAll(keys).unlock();
 
-        assert !cache.isLocked(1);
-        assert !cache.isLocked(2);
-        assert !cache.isLocked(3);
+        assert !cache.isLocalLocked(1, false);
+        assert !cache.isLocalLocked(2, false);
+        assert !cache.isLocalLocked(3, false);
 
-        assert !cache.isLockedByThread(1);
-        assert !cache.isLockedByThread(2);
-        assert !cache.isLockedByThread(3);
+        assert !cache.isLocalLocked(1, true);
+        assert !cache.isLocalLocked(2, true);
+        assert !cache.isLocalLocked(3, true);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java
index bed5ffb..e89d26a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapTieredAbstractSelfTest.java
@@ -533,11 +533,11 @@ public abstract class GridCacheOffHeapTieredAbstractSelfTest extends GridCacheAb
 
         c.lock(key).lock();
 
-        assertTrue(c.isLocked(key));
+        assertTrue(c.isLocalLocked(key, false));
 
         c.lock(key).unlock();
 
-        assertFalse(c.isLocked(key));
+        assertFalse(c.isLocalLocked(key, false));
 
         assertNull(c.localPeek(key));
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java
index 9cf3c0d..0863092 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheLockAbstractTest.java
@@ -181,8 +181,8 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest {
         info("After lock for key: " + k);
 
         try {
-            assert cache1.isLocked(k);
-            assert cache1.isLockedByThread(k);
+            assert cache1.isLocalLocked(k, false);
+            assert cache1.isLocalLocked(k, true);
 
             // Put to cache.
             cache1.put(k, v);
@@ -196,7 +196,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest {
         }
 
         assert !locked(k, 1);
-        assert !cache1.isLockedByThread(k);
+        assert !cache1.isLocalLocked(k, true);
     }
 
     /**
@@ -218,8 +218,8 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest {
                 info("After lock for key: " + kv);
 
                 try {
-                    assert cache1.isLocked(kv);
-                    assert cache1.isLockedByThread(kv);
+                    assert cache1.isLocalLocked(kv, false);
+                    assert cache1.isLocalLocked(kv, true);
 
                     l1.countDown();
 
@@ -239,7 +239,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest {
 
                 l2.await();
 
-                assert !cache1.isLockedByThread(kv);
+                assert !cache1.isLocalLocked(kv, true);
                 assert !locked(kv, 1);
 
                 return null;
@@ -268,7 +268,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest {
                 }
 
                 assert !locked(kv, 2);
-                assert !cache2.isLockedByThread(kv);
+                assert !cache2.isLocalLocked(kv, true);
 
                 Thread.sleep(1000);
 
@@ -302,8 +302,8 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest {
                 info("Locked cache key: 1");
 
                 try {
-                    assert cache1.isLocked(1);
-                    assert cache1.isLockedByThread(1);
+                    assert cache1.isLocalLocked(1, false);
+                    assert cache1.isLocalLocked(1, true);
 
                     info("Verified that cache key is locked: 1");
 
@@ -329,7 +329,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest {
                 l2.await();
 
                 assert !locked(1, 1);
-                assert !cache1.isLockedByThread(1);
+                assert !cache1.isLocalLocked(1, true);
 
                 return null;
             }
@@ -396,8 +396,8 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest {
 
                     try {
                         for (Integer key : keys) {
-                            assert cache1.isLocked(key);
-                            assert cache1.isLockedByThread(key);
+                            assert cache1.isLocalLocked(key, false);
+                            assert cache1.isLocalLocked(key, true);
                         }
 
                         l1.countDown();
@@ -446,7 +446,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest {
 
                         // The keys should still be locked.
                         for (Integer key : keys)
-                            assert cache1.isLocked(key);
+                            assert cache1.isLocalLocked(key, false);
                     }
                     finally {
                         l2.countDown();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
index 0e689af..e9d0e3c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java
@@ -147,8 +147,8 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
      * @param key Key.
      */
     private void checkLocked(IgniteCache<Integer,String> cache, Integer key) {
-        assert cache.isLocked(key);
-        assert cache.isLockedByThread(key);
+        assert cache.isLocalLocked(key, false);
+        assert cache.isLocalLocked(key, true);
     }
 
     /**
@@ -165,8 +165,8 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
      * @param key Key.
      */
     private void checkRemoteLocked(IgniteCache<Integer,String> cache, Integer key) {
-        assert cache.isLocked(key);
-        assert !cache.isLockedByThread(key);
+        assert cache.isLocalLocked(key, false);
+        assert !cache.isLocalLocked(key, true);
     }
 
     /**
@@ -199,11 +199,11 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
      */
     @SuppressWarnings({"BusyWait"})
     private void checkUnlocked(IgniteCache<Integer,String> cache, Integer key) {
-        assert !cache.isLockedByThread(key);
+        assert !cache.isLocalLocked(key, true);
 
         if (partitioned()) {
             for(int i = 0; i < 200; i++)
-                if (cache.isLocked(key)) {
+                if (cache.isLocalLocked(key, false)) {
                     try {
                         Thread.sleep(10);
                     }
@@ -215,7 +215,7 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
                     return;
         }
 
-        assertFalse("Key locked [key=" + key + ", entries=" + entries(key) + "]", cache.isLocked(key));
+        assertFalse("Key locked [key=" + key + ", entries=" + entries(key) + "]", cache.isLocalLocked(key, false));
     }
 
     /**
@@ -285,8 +285,8 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
 
         cache.lock(1).lock();
 
-        assert cache.isLocked(1);
-        assert cache.isLockedByThread(1);
+        assert cache.isLocalLocked(1, false);
+        assert cache.isLocalLocked(1, true);
 
         cache.lockAll(Collections.singleton(1)).unlock();
 
@@ -323,17 +323,17 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
 
         cache1.lock(1).lock();
 
-        assert cache1.isLocked(1) : entries(1);
-        assert cache1.isLockedByThread(1);
+        assert cache1.isLocalLocked(1, false) : entries(1);
+        assert cache1.isLocalLocked(1, true);
 
-        assert cache2.isLocked(1) : entries(1);
-        assert !cache2.isLockedByThread(1);
+        assert cache2.isLocalLocked(1, false) : entries(1);
+        assert !cache2.isLocalLocked(1, true);
 
         try {
             assert !cache2.lock(1).tryLock();
 
-            assert cache2.isLocked(1) : entries(1);
-            assert !cache2.isLockedByThread(1);
+            assert cache2.isLocalLocked(1, false) : entries(1);
+            assert !cache2.isLocalLocked(1, true);
         }
         finally {
             cache1.lock(1).unlock();
@@ -343,11 +343,11 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
 
         cache2.lock(1).lock();
 
-        assert cache2.isLocked(1) : entries(1);
-        assert cache2.isLockedByThread(1);
+        assert cache2.isLocalLocked(1, false) : entries(1);
+        assert cache2.isLocalLocked(1, true);
 
-        assert cache1.isLocked(1) : entries(1);
-        assert !cache1.isLockedByThread(1);
+        assert cache1.isLocalLocked(1, false) : entries(1);
+        assert !cache1.isLocalLocked(1, true);
 
         CountDownLatch latch = new CountDownLatch(1);
 
@@ -356,8 +356,8 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
         try {
             assert !cache1.lock(1).tryLock();
 
-            assert cache1.isLocked(1) : entries(1);
-            assert !cache1.isLockedByThread(1);
+            assert cache1.isLocalLocked(1, false) : entries(1);
+            assert !cache1.isLocalLocked(1, true);
         }
         finally {
             cache2.lockAll(Collections.singleton(1)).unlock();
@@ -389,15 +389,15 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
         try {
             assert !cache2.lockAll(keys2).tryLock();
 
-            assert cache2.isLocked(2);
-            assert cache2.isLocked(3);
+            assert cache2.isLocalLocked(2, false);
+            assert cache2.isLocalLocked(3, false);
 
             checkUnlocked(cache1, 4);
             checkUnlocked(cache2, 4);
 
-            assert !cache2.isLockedByThread(2);
-            assert !cache2.isLockedByThread(3);
-            assert !cache2.isLockedByThread(4);
+            assert !cache2.isLocalLocked(2, true);
+            assert !cache2.isLocalLocked(3, true);
+            assert !cache2.isLocalLocked(4, true);
         }
         finally {
             cache1.lockAll(keys1).unlock();
@@ -526,8 +526,8 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr
                     info("Unlocked entry for key 1.");
                 }
 
-                assert !cache.isLockedByThread(1);
-                assert !cache.isLockedByThread(2);
+                assert !cache.isLocalLocked(1, true);
+                assert !cache.isLocalLocked(2, true);
 
                 return null;
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
index f6a3526..1f8e401 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
@@ -24,25 +24,26 @@ import org.apache.ignite.cache.store.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.cache.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
-import org.apache.ignite.transactions.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.testframework.junits.common.*;
+import org.apache.ignite.transactions.*;
 
 import javax.cache.configuration.*;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
+import java.util.concurrent.locks.*;
 
-import static org.apache.ignite.cache.CacheMode.*;
 import static org.apache.ignite.cache.CacheDistributionMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
 import static org.apache.ignite.transactions.IgniteTxConcurrency.*;
 import static org.apache.ignite.transactions.IgniteTxIsolation.*;
-import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
 
 /**
  * Tests for colocated cache.
@@ -378,7 +379,7 @@ public class GridCacheColocatedDebugTest extends GridCommonAbstractTest {
             IgniteFuture<?> unlockFut = multithreadedAsync(new Runnable() {
                 @Override public void run() {
                     try {
-                        CacheLock lock = g0.jcache(null).lock(key);
+                        Lock lock = g0.jcache(null).lock(key);
 
                         lock.lock();
 
@@ -400,10 +401,10 @@ public class GridCacheColocatedDebugTest extends GridCommonAbstractTest {
 
             U.await(lockLatch);
 
-            assert g0.jcache(null).isLocked(key);
-            assert !g0.jcache(null).isLockedByThread(key) : "Key can not be locked by current thread.";
+            assert g0.jcache(null).isLocalLocked(key, false);
+            assert !g0.jcache(null).isLocalLocked(key, true) : "Key can not be locked by current thread.";
 
-            CacheLock lock = g0.jcache(null).lock(key);
+            Lock lock = g0.jcache(null).lock(key);
 
             assert !lock.tryLock();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
index bf766e3..97e4764 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
@@ -760,8 +760,8 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest {
             assertEquals(val, near.localPeek(key));
             assertEquals(val, dht(primaryGrid(key)).peek(key));
 
-            assertTrue(near.isLocked(key));
-            assertTrue(near.isLockedByThread(key));
+            assertTrue(near.isLocalLocked(key, false));
+            assertTrue(near.isLocalLocked(key, true));
 
             near.lock(key).lock(); // Reentry.
 
@@ -772,15 +772,15 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest {
                 assertNull(near.localPeek(key));
                 assertNull(dht(primaryGrid(key)).peek(key));
 
-                assertTrue(near.isLocked(key));
-                assertTrue(near.isLockedByThread(key));
+                assertTrue(near.isLocalLocked(key, false));
+                assertTrue(near.isLocalLocked(key, true));
             }
             finally {
                 near.lock(key).unlock();
             }
 
-            assertTrue(near.isLocked(key));
-            assertTrue(near.isLockedByThread(key));
+            assertTrue(near.isLocalLocked(key, false));
+            assertTrue(near.isLocalLocked(key, true));
         }
         catch (Throwable t) {
             error("Test failed.", t);
@@ -792,7 +792,7 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest {
         }
 
         assertFalse(near(0).isLockedNearOnly(key));
-        assertFalse(near.isLockedByThread(key));
+        assertFalse(near.isLocalLocked(key, true));
     }
 
     /** @throws Exception If failed. */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
index 6f78d1e..c7427e6 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
@@ -224,15 +224,15 @@ public class GridCacheNearOneNodeSelfTest extends GridCommonAbstractTest {
             assertNull(near.localPeek(1));
             assertNull(dht().peek(1));
 
-            assertTrue(near.isLocked(1));
-            assertTrue(near.isLockedByThread(1));
+            assertTrue(near.isLocalLocked(1, false));
+            assertTrue(near.isLocalLocked(1, true));
         }
         finally {
             near.lock(1).unlock();
         }
 
-        assertFalse(near.isLocked(1));
-        assertFalse(near.isLockedByThread(1));
+        assertFalse(near.isLocalLocked(1, false));
+        assertFalse(near.isLocalLocked(1, true));
     }
 
     /** @throws Exception If failed. */
@@ -247,8 +247,8 @@ public class GridCacheNearOneNodeSelfTest extends GridCommonAbstractTest {
             assertEquals("1", near.localPeek(1));
             assertEquals("1", dht().peek(1));
 
-            assertTrue(near.isLocked(1));
-            assertTrue(near.isLockedByThread(1));
+            assertTrue(near.isLocalLocked(1, false));
+            assertTrue(near.isLocalLocked(1, true));
 
             near.lock(1).lock(); // Reentry.
 
@@ -259,22 +259,22 @@ public class GridCacheNearOneNodeSelfTest extends GridCommonAbstractTest {
                 assertNull(near.localPeek(1));
                 assertNull(dht().peek(1));
 
-                assertTrue(near.isLocked(1));
-                assertTrue(near.isLockedByThread(1));
+                assertTrue(near.isLocalLocked(1, false));
+                assertTrue(near.isLocalLocked(1, true));
             }
             finally {
                 near.lock(1).unlock();
             }
 
-            assertTrue(near.isLocked(1));
-            assertTrue(near.isLockedByThread(1));
+            assertTrue(near.isLocalLocked(1, false));
+            assertTrue(near.isLocalLocked(1, true));
         }
         finally {
             near.lock(1).unlock();
         }
 
-        assertFalse(near.isLocked(1));
-        assertFalse(near.isLockedByThread(1));
+        assertFalse(near.isLocalLocked(1, false));
+        assertFalse(near.isLocalLocked(1, true));
     }
 
     /** @throws Exception If failed. */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLockSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLockSelfTest.java
index 2b121d3..af0f865 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLockSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalLockSelfTest.java
@@ -80,13 +80,13 @@ public class GridCacheLocalLockSelfTest extends GridCommonAbstractTest {
     public void testLockReentry() throws IgniteCheckedException {
         IgniteCache<Integer, String> cache = ignite.jcache(null);
 
-        assert !cache.isLocked(1);
-        assert !cache.isLockedByThread(1);
+        assert !cache.isLocalLocked(1, false);
+        assert !cache.isLocalLocked(1, true);
 
         cache.lock(1).lock();
 
-        assert cache.isLocked(1);
-        assert cache.isLockedByThread(1);
+        assert cache.isLocalLocked(1, false);
+        assert cache.isLocalLocked(1, true);
 
         try {
             assert cache.get(1) == null;
@@ -96,8 +96,8 @@ public class GridCacheLocalLockSelfTest extends GridCommonAbstractTest {
             // Reentry.
             cache.lock(1).lock();
 
-            assert cache.isLocked(1);
-            assert cache.isLockedByThread(1);
+            assert cache.isLocalLocked(1, false);
+            assert cache.isLocalLocked(1, true);
 
             try {
                 assert "1".equals(cache.getAndRemove(1));
@@ -106,15 +106,15 @@ public class GridCacheLocalLockSelfTest extends GridCommonAbstractTest {
                 cache.lock(1).unlock();
             }
 
-            assert cache.isLocked(1);
-            assert cache.isLockedByThread(1);
+            assert cache.isLocalLocked(1, false);
+            assert cache.isLocalLocked(1, true);
         }
         finally {
             cache.lock(1).unlock();
         }
 
-        assert !cache.isLocked(1);
-        assert !cache.isLockedByThread(1);
+        assert !cache.isLocalLocked(1, false);
+        assert !cache.isLocalLocked(1, true);
     }
 
     /**
@@ -137,8 +137,8 @@ public class GridCacheLocalLockSelfTest extends GridCommonAbstractTest {
                 info("After lock for key 1");
 
                 try {
-                    assert cache.isLocked(1);
-                    assert cache.isLockedByThread(1);
+                    assert cache.isLocalLocked(1, false);
+                    assert cache.isLocalLocked(1, true);
 
                     latch1.countDown();
 
@@ -175,8 +175,8 @@ public class GridCacheLocalLockSelfTest extends GridCommonAbstractTest {
 
                 assert !cache.lock(1).tryLock();
 
-                assert cache.isLocked(1);
-                assert !cache.isLockedByThread(1);
+                assert cache.isLocalLocked(1, false);
+                assert !cache.isLocalLocked(1, true);
 
                 info("Tried to lock cache for key1");
 
@@ -188,8 +188,8 @@ public class GridCacheLocalLockSelfTest extends GridCommonAbstractTest {
 
                 assert cache.lock(1).tryLock();
 
-                assert cache.isLocked(1);
-                assert cache.isLockedByThread(1);
+                assert cache.isLocalLocked(1, false);
+                assert cache.isLocalLocked(1, true);
 
                 try {
                     info("Locked cache for key 1");
@@ -202,8 +202,8 @@ public class GridCacheLocalLockSelfTest extends GridCommonAbstractTest {
 
                     info("Removed value for key 1");
 
-                    assert cache.isLocked(1);
-                    assert cache.isLockedByThread(1);
+                    assert cache.isLocalLocked(1, false);
+                    assert cache.isLocalLocked(1, true);
 
                     info("Checked that cache is locked for key 1");
                 }
@@ -213,8 +213,8 @@ public class GridCacheLocalLockSelfTest extends GridCommonAbstractTest {
                     info("Unlocked cache for key 1");
                 }
 
-                assert !cache.isLocked(1);
-                assert !cache.isLockedByThread(1);
+                assert !cache.isLocalLocked(1, false);
+                assert !cache.isLocalLocked(1, true);
 
                 return null;
             }
@@ -229,8 +229,8 @@ public class GridCacheLocalLockSelfTest extends GridCommonAbstractTest {
         t1.checkError();
         t2.checkError();
 
-        assert !cache.isLockedByThread(1);
-        assert !cache.isLocked(1);
+        assert !cache.isLocalLocked(1, true);
+        assert !cache.isLocalLocked(1, false);
     }
 
     /**
@@ -248,8 +248,8 @@ public class GridCacheLocalLockSelfTest extends GridCommonAbstractTest {
                 info("Locked cache key: 1");
 
                 try {
-                    assert cache.isLockedByThread(1);
-                    assert cache.isLocked(1);
+                    assert cache.isLocalLocked(1, true);
+                    assert cache.isLocalLocked(1, false);
 
                     info("Verified that cache key is locked: 1");
 
@@ -309,7 +309,7 @@ public class GridCacheLocalLockSelfTest extends GridCommonAbstractTest {
         t1.checkError();
         t2.checkError();
 
-        assert !cache.isLockedByThread(1);
-        assert !cache.isLocked(1);
+        assert !cache.isLocalLocked(1, true);
+        assert !cache.isLocalLocked(1, false);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java
index 7d2860c..5cf7ce0 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java
@@ -169,12 +169,12 @@ public class GridCacheLocalMultithreadedSelfTest extends GridCommonAbstractTest
         GridTestThread t1 = new GridTestThread(new Callable<Object>() {
             /** {@inheritDoc} */
             @Override public Object call() throws Exception {
-                assert !cache.isLocked(1);
+                assert !cache.isLocalLocked(1, false);
 
                 cache.lock(1).lock();
 
-                assert cache.isLockedByThread(1);
-                assert cache.isLocked(1);
+                assert cache.isLocalLocked(1, true);
+                assert cache.isLocalLocked(1, false);
 
                 l1.countDown();
 
@@ -182,8 +182,8 @@ public class GridCacheLocalMultithreadedSelfTest extends GridCommonAbstractTest
 
                 cache.lock(1).unlock();
 
-                assert !cache.isLockedByThread(1);
-                assert !cache.isLocked(1);
+                assert !cache.isLocalLocked(1, true);
+                assert !cache.isLocalLocked(1, false);
 
                 return null;
             }
@@ -194,13 +194,13 @@ public class GridCacheLocalMultithreadedSelfTest extends GridCommonAbstractTest
             @Override public Object call() throws Exception {
                 l1.await();
 
-                assert cache.isLocked(1);
-                assert !cache.isLockedByThread(1);
+                assert cache.isLocalLocked(1, false);
+                assert !cache.isLocalLocked(1, true);
 
                 assert !cache.lock(1).tryLock(100L, TimeUnit.MILLISECONDS);
 
-                assert cache.isLocked(1);
-                assert !cache.isLockedByThread(1);
+                assert cache.isLocalLocked(1, false);
+                assert !cache.isLocalLocked(1, true);
 
                 l2.countDown();
 
@@ -219,8 +219,8 @@ public class GridCacheLocalMultithreadedSelfTest extends GridCommonAbstractTest
         t1.checkError();
         t2.checkError();
 
-        assert !cache.isLocked(1);
-        assert !cache.isLockedByThread(1);
+        assert !cache.isLocalLocked(1, false);
+        assert !cache.isLocalLocked(1, true);
     }
 
     /**
@@ -241,15 +241,15 @@ public class GridCacheLocalMultithreadedSelfTest extends GridCommonAbstractTest
             @Override public Object call() throws Exception {
                 int idx = cnt.incrementAndGet();
 
-                assert !cache.isLocked(1);
+                assert !cache.isLocalLocked(1, false);
 
                 Collections.addAll(keys1, idx, idx + 1, idx + 2, idx + 3);
 
                 cache.lockAll(keys1).lock();
 
                 for (Integer key : keys1) {
-                    assert cache.isLocked(key) : "Failed to acquire lock for key: " + key;
-                    assert cache.isLockedByThread(key) : "Failed to acquire lock for key: " + key;
+                    assert cache.isLocalLocked(key, false) : "Failed to acquire lock for key: " + key;
+                    assert cache.isLocalLocked(key, true) : "Failed to acquire lock for key: " + key;
                 }
 
                 l1.countDown();
@@ -259,8 +259,8 @@ public class GridCacheLocalMultithreadedSelfTest extends GridCommonAbstractTest
                 cache.lockAll(keys1).unlock();
 
                 for (Integer key : keys1) {
-                    assert !cache.isLocked(key);
-                    assert !cache.isLockedByThread(key);
+                    assert !cache.isLocalLocked(key, false);
+                    assert !cache.isLocalLocked(key, true);
                 }
 
                 l3.countDown();
@@ -279,20 +279,20 @@ public class GridCacheLocalMultithreadedSelfTest extends GridCommonAbstractTest
                 l1.await();
 
                 for (Integer key : keys1) {
-                    assert cache.isLocked(key);
-                    assert !cache.isLockedByThread(key);
+                    assert cache.isLocalLocked(key, false);
+                    assert !cache.isLocalLocked(key, true);
                 }
 
                 // Lock won't be acquired due to timeout.
                 assert !cache.lockAll(keys2).tryLock(100, TimeUnit.MILLISECONDS);
 
                 for (Integer key : keys2) {
-                    boolean locked = cache.isLocked(key);
+                    boolean locked = cache.isLocalLocked(key, false);
 
                     assert locked == keys1.contains(key) : "Lock failure for key [key=" + key +
                         ", locked=" + locked + ", keys1=" + keys1 + ']';
 
-                    assert !cache.isLockedByThread(key);
+                    assert !cache.isLocalLocked(key, true);
                 }
 
                 l2.countDown();
@@ -300,8 +300,8 @@ public class GridCacheLocalMultithreadedSelfTest extends GridCommonAbstractTest
                 l3.await();
 
                 for (Integer key : keys2) {
-                    assert !cache.isLocked(key);
-                    assert !cache.isLockedByThread(key);
+                    assert !cache.isLocalLocked(key, false);
+                    assert !cache.isLocalLocked(key, true);
                 }
 
                 return null;
@@ -318,13 +318,13 @@ public class GridCacheLocalMultithreadedSelfTest extends GridCommonAbstractTest
         t2.checkError();
 
         for (Integer key : keys1) {
-            assert !cache.isLocked(key);
-            assert !cache.isLockedByThread(key);
+            assert !cache.isLocalLocked(key, false);
+            assert !cache.isLocalLocked(key, true);
         }
 
         for (Integer key : keys2) {
-            assert !cache.isLocked(key);
-            assert !cache.isLockedByThread(key);
+            assert !cache.isLocalLocked(key, false);
+            assert !cache.isLocalLocked(key, true);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b9c6f3b6/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java
index 9af89ca..2b976ef 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/communication/tcp/GridCacheDhtLockBackupSelfTest.java
@@ -130,8 +130,8 @@ public class GridCacheDhtLockBackupSelfTest extends GridCommonAbstractTest {
                 info("After lock for key: " + kv);
 
                 try {
-                    assert cache1.isLocked(kv);
-                    assert cache1.isLockedByThread(kv);
+                    assert cache1.isLocalLocked(kv, false);
+                    assert cache1.isLocalLocked(kv, true);
 
                     l1.countDown();
 
@@ -149,7 +149,7 @@ public class GridCacheDhtLockBackupSelfTest extends GridCommonAbstractTest {
                     info("Unlocked key in thread 1: " + kv);
                 }
 
-                assert !cache1.isLockedByThread(kv);
+                assert !cache1.isLocalLocked(kv, true);
 
                 return null;
             }
@@ -175,7 +175,7 @@ public class GridCacheDhtLockBackupSelfTest extends GridCommonAbstractTest {
                     info("Unlocked key in thread 2: " + kv);
                 }
 
-                assert !cache2.isLockedByThread(kv);
+                assert !cache2.isLocalLocked(kv, true);
 
                 return null;
             }


Mime
View raw message