IGNITE-59 Remove IgniteAsyncSupport from CacheLock.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/98c69556 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/98c69556 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/98c69556 Branch: refs/heads/ignite-99 Commit: 98c695560bbde607fb3ff75832cd5089dfe242a4 Parents: 1a2d2ca Author: sevdokimov <sevdoki...@gridgain.com> Authored: Wed Jan 21 15:03:11 2015 +0300 Committer: sevdokimov <sevdoki...@gridgain.com> Committed: Wed Jan 21 15:03:11 2015 +0300 ---------------------------------------------------------------------- .../java/org/apache/ignite/cache/CacheLock.java | 11 +- .../processors/cache/CacheLockAsyncImpl.java | 141 ----------------- .../processors/cache/CacheLockImpl.java | 31 +--- .../cache/GridCacheAbstractFullApiSelfTest.java | 20 +-- .../GridCacheMultiNodeLockAbstractTest.java | 150 +------------------ .../dht/GridCacheColocatedDebugTest.java | 9 +- .../near/GridCachePartitionedLockSelfTest.java | 10 -- ...idCachePartitionedMultiNodeLockSelfTest.java | 10 -- .../GridCacheLocalMultithreadedSelfTest.java | 119 --------------- 9 files changed, 20 insertions(+), 481 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/98c69556/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 index 82d6043..43aff7a 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/CacheLock.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheLock.java @@ -19,6 +19,7 @@ package org.apache.ignite.cache; import org.apache.ignite.*; import org.apache.ignite.lang.*; +import org.jetbrains.annotations.*; import java.util.concurrent.*; import java.util.concurrent.locks.*; @@ -26,7 +27,7 @@ import java.util.concurrent.locks.*; /** * Lock associated with some cache keys. */ -public interface CacheLock extends Lock, IgniteAsyncSupport { +public interface CacheLock extends Lock { /** * Checks if any node holds lock on at least one key associated with this {@code CacheLock}. * <p> @@ -57,6 +58,10 @@ public interface CacheLock extends Lock, IgniteAsyncSupport { @IgniteAsyncSupported @Override public boolean tryLock(long time, TimeUnit unit) throws InterruptedException; - /** {@inheritDoc} */ - @Override public CacheLock enableAsync(); + /** + * The method is unsupported. + * + * @return Nothing, this method is unsupported, {@link UnsupportedOperationException} will be thrown. + */ + @NotNull @Override public Condition newCondition(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/98c69556/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockAsyncImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockAsyncImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockAsyncImpl.java deleted file mode 100644 index 6eee3ae..0000000 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockAsyncImpl.java +++ /dev/null @@ -1,141 +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.internal.processors.cache; - -import org.apache.ignite.*; -import org.apache.ignite.cache.*; -import org.apache.ignite.lang.*; -import org.gridgain.grid.kernal.processors.cache.*; -import org.jetbrains.annotations.*; - -import javax.cache.*; -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.locks.*; - -/** - * - * @param <K> - */ -class CacheLockAsyncImpl<K> implements CacheLock { - /** */ - private final GridCacheProjectionEx<K, ?> delegate; - - /** */ - private final Collection<? extends K> keys; - - /** Future for previous asynchronous operation. */ - protected final ThreadLocal<IgniteFuture<?>> curFut = new ThreadLocal<>(); - - /** - * @param delegate Delegate. - * @param keys Keys. - */ - CacheLockAsyncImpl(GridCacheProjectionEx<K, ?> delegate, Collection<? extends K> keys) { - this.delegate = delegate; - this.keys = keys; - } - - /** {@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() { - IgniteFuture<Boolean> fut = delegate.lockAllAsync(keys, 0); - - curFut.set(fut); - } - - /** {@inheritDoc} */ - @Override public void lockInterruptibly() throws InterruptedException { - tryLock(-1, TimeUnit.MILLISECONDS); - } - - /** {@inheritDoc} */ - @Override public boolean tryLock() { - try { - return delegate.lockAll(keys, -1); - } - catch (IgniteCheckedException e) { - throw new CacheException(e.getMessage(), e); - } - } - - /** {@inheritDoc} */ - @Override public boolean tryLock(long time, TimeUnit unit) { - IgniteFuture<Boolean> fut = delegate.lockAllAsync(keys, time <= 0 ? -1 : unit.toMillis(time)); - - curFut.set(fut); - - return true; - } - - /** {@inheritDoc} */ - @Override public void unlock() { - try { - delegate.unlockAll(keys); - } - catch (IgniteCheckedException e) { - throw new CacheException(e.getMessage(), e); - } - } - - /** {@inheritDoc} */ - @NotNull @Override public Condition newCondition() { - throw new UnsupportedOperationException(); - } - - /** {@inheritDoc} */ - @Override public CacheLock enableAsync() { - return this; - } - - /** {@inheritDoc} */ - @Override public boolean isAsync() { - return true; - } - - /** {@inheritDoc} */ - @Override public <R> IgniteFuture<R> future() { - IgniteFuture<?> fut = curFut.get(); - - if (fut == null) - throw new IllegalStateException("Asynchronous operation not started."); - - curFut.set(null); - - return (IgniteFuture<R>)fut; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/98c69556/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 df40a23..43b9579 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 @@ -31,7 +31,6 @@ import java.util.concurrent.locks.*; /** * - * @param <K> */ class CacheLockImpl<K> implements CacheLock { /** */ @@ -40,9 +39,6 @@ class CacheLockImpl<K> implements CacheLock { /** */ private final Collection<? extends K> keys; - /** */ - private volatile CacheLockAsyncImpl<K> async; - /** * @param delegate Delegate. * @param keys Keys. @@ -84,7 +80,7 @@ class CacheLockImpl<K> implements CacheLock { /** {@inheritDoc} */ @Override public void lockInterruptibly() throws InterruptedException { - tryLock(-1, TimeUnit.MILLISECONDS); + tryLock(Long.MAX_VALUE, TimeUnit.MILLISECONDS); } /** {@inheritDoc} */ @@ -109,7 +105,7 @@ class CacheLockImpl<K> implements CacheLock { IgniteFuture<Boolean> fut = null; try { - fut = delegate.lockAllAsync(keys, time <= 0 ? -1 : unit.toMillis(time)); + fut = delegate.lockAllAsync(keys, unit.toMillis(time)); return fut.get(); } @@ -151,27 +147,4 @@ class CacheLockImpl<K> implements CacheLock { @NotNull @Override public Condition newCondition() { throw new UnsupportedOperationException(); } - - /** {@inheritDoc} */ - @Override public CacheLock enableAsync() { - CacheLockAsyncImpl<K> async = this.async; - - if (async == null) { - async = new CacheLockAsyncImpl<>(delegate, keys); - - this.async = async; - } - - return async; - } - - /** {@inheritDoc} */ - @Override public boolean isAsync() { - return false; - } - - /** {@inheritDoc} */ - @Override public <R> IgniteFuture<R> future() { - throw new IllegalStateException("Asynchronous mode is not enabled."); - } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/98c69556/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java index 7c615de..cf9c0d6 100644 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/GridCacheAbstractFullApiSelfTest.java @@ -3355,8 +3355,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assert !lock.isLocked(); - lock.enableAsync().lock(); - lock.enableAsync().future().get(); + lock.lock(); assert lock.isLocked(); @@ -3470,8 +3469,7 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract assert !cache.isLocked("key"); - lock.enableAsync().tryLock(1000, MILLISECONDS); - lock.enableAsync().future().get(); + lock.tryLock(1000, MILLISECONDS); assert cache.isLocked("key"); assert cache.isLockedByThread("key"); @@ -3482,22 +3480,12 @@ public abstract class GridCacheAbstractFullApiSelfTest extends GridCacheAbstract comp.call(new Callable<Boolean>() { @Override public Boolean call() throws Exception { - lock.enableAsync().tryLock(1000, MILLISECONDS); - - IgniteFuture<Boolean> f = lock.enableAsync().future(); - - try { - f.get(100); - - fail(); - } catch (IgniteFutureTimeoutException ex) { - info("Caught expected exception: " + ex); - } + assert !lock.tryLock(1000, MILLISECONDS); latch.countDown(); try { - assert f.get(); + assert lock.tryLock(); } finally { lock.unlock(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/98c69556/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java index 0b5b44e..dacf06b 100644 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheMultiNodeLockAbstractTest.java @@ -17,19 +17,17 @@ package org.gridgain.grid.kernal.processors.cache.distributed; -import com.google.common.collect.*; import org.apache.ignite.*; -import org.apache.ignite.cache.*; import org.apache.ignite.configuration.*; import org.apache.ignite.events.*; import org.apache.ignite.lang.*; +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.gridgain.grid.cache.*; import org.gridgain.grid.kernal.*; import org.gridgain.grid.kernal.processors.cache.distributed.dht.*; import org.gridgain.grid.kernal.processors.cache.distributed.near.*; -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.gridgain.testframework.*; import org.gridgain.testframework.junits.common.*; import org.jetbrains.annotations.*; @@ -374,67 +372,6 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr /** * @throws Exception If test fails. */ - public void testMultiNodeLockAsync() throws Exception { - IgniteCache<Integer, String> cache1 = ignite1.jcache(null); - IgniteCache<Integer, String> cache2 = ignite2.jcache(null); - - CacheLock lock1_1 = cache1.lock(1); - CacheLock lock2_1 = cache2.lock(1); - - lock1_1.enableAsync().lock(); - - assert lock1_1.enableAsync().<Boolean>future().get(); - - try { - assert cache1.isLocked(1); - assert cache1.isLockedByThread(1); - - assert cache2.isLocked(1); - assert !cache2.isLockedByThread(1); - - lock2_1.enableAsync().tryLock(-1, TimeUnit.MILLISECONDS); - - assert !lock2_1.enableAsync().<Boolean>future().get(); - } - finally { - lock1_1.unlock(); - } - - checkUnlocked(cache1, 1); - - lock2_1.lock(); - - CountDownLatch latch = new CountDownLatch(1); - - addListener(ignite1, new UnlockListener(latch, 1)); - - try { - assert cache1.isLocked(1); - assert !cache1.isLockedByThread(1); - - assert cache2.isLocked(1); - assert cache2.isLockedByThread(1); - - lock1_1.enableAsync().tryLock(-1, TimeUnit.MILLISECONDS); - - assert !lock1_1.enableAsync().<Boolean>future().get(); - } - finally { - lock2_1.unlock(); - } - - latch.await(); - - assert !cache1.isLocked(1); - assert !cache1.isLockedByThread(1); - - checkUnlocked(cache1, 1); - checkUnlocked(cache2, 1); - } - - /** - * @throws Exception If test fails. - */ public void testMultiNodeLockWithKeyLists() throws Exception { IgniteCache<Integer, String> cache1 = ignite1.jcache(null); IgniteCache<Integer, String> cache2 = ignite2.jcache(null); @@ -508,87 +445,6 @@ public abstract class GridCacheMultiNodeLockAbstractTest extends GridCommonAbstr } /** - * @throws Exception If test fails. - */ - public void testMultiNodeLockAsyncWithKeyLists() throws Exception { - IgniteCache<Integer, String> cache1 = ignite1.jcache(null); - IgniteCache<Integer, String> cache2 = ignite2.jcache(null); - - Collection<Integer> keys1 = Lists.newArrayList(1, 2, 3); - Collection<Integer> keys2 = Lists.newArrayList(2, 3, 4); - - CacheLock lock1_1 = cache1.lockAll(keys1); - CacheLock lock2_2 = cache2.lockAll(keys2); - - lock1_1.enableAsync().lock(); - - IgniteFuture<Boolean> f1 = lock1_1.enableAsync().future(); - - try { - assert f1.get(); - - checkLocked(cache1, keys1); - - checkRemoteLocked(cache2, keys1); - - lock2_2.enableAsync().tryLock(-1, TimeUnit.MILLISECONDS); - - IgniteFuture<Boolean> f2 = lock2_2.enableAsync().future(); - - assert !f2.get(); - - checkLocked(cache1, keys1); - - checkUnlocked(cache1, 4); - checkUnlocked(cache2, 4); - - checkRemoteLocked(cache2, keys1); - } - finally { - lock1_1.unlock(); - } - - checkUnlocked(cache1, keys1); - - CountDownLatch latch = new CountDownLatch(keys2.size()); - - addListener(ignite1, new UnlockListener(latch, keys2)); - - lock2_2.enableAsync().lock(); - - IgniteFuture<Boolean> f2 = lock2_2.enableAsync().future(); - - try { - assert f2.get(); - - checkLocked(cache2, keys2); - - checkRemoteLocked(cache1, keys2); - - checkUnlocked(cache1, 1); - - assert !cache1.lockAll(keys2).tryLock(); - - checkLocked(cache2, keys2); - - checkUnlocked(cache1, 1); - checkUnlocked(cache2 , 1); - - checkRemoteLocked(cache1, keys2); - } - finally { - lock2_2.unlock(); - } - - latch.await(); - - checkUnlocked(cache1, keys1); - checkUnlocked(cache2, keys1); - checkUnlocked(cache1, keys2); - checkUnlocked(cache2, keys2); - } - - /** * @throws IgniteCheckedException If test failed. */ public void testLockReentry() throws IgniteCheckedException { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/98c69556/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java index ffba769..d68ba4b 100644 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java @@ -400,20 +400,17 @@ public class GridCacheColocatedDebugTest extends GridCommonAbstractTest { CacheLock lock = g0.jcache(null).lock(key); - lock.enableAsync().lock(); - - IgniteFuture<Boolean> lockFut = lock.enableAsync().future(); + assert !lock.tryLock(); assert g0.cache(null).isLocked(key); - assert !lockFut.isDone() : "Key can not be locked by current thread."; assert !g0.cache(null).isLockedByThread(key) : "Key can not be locked by current thread."; unlockLatch.countDown(); unlockFut.get(); - assert lockFut.get(); + assert lock.tryLock(); - g0.cache(null).unlock(key); + lock.unlock(); } finally { stopAllGrids(); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/98c69556/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java index ec3069d..4179544 100644 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java @@ -86,15 +86,5 @@ public class GridCachePartitionedLockSelfTest extends GridCacheLockAbstractTest }, CacheException.class, "Locks are not supported"); CacheLock lock = g0.jcache(null).lock(1); - - lock.enableAsync().tryLock(Long.MAX_VALUE, TimeUnit.MILLISECONDS); - - final IgniteFuture<Boolean> lockFut1 = lock.enableAsync().future(); - - GridTestUtils.assertThrows(log, new Callable<Object>() { - @Override public Object call() throws Exception { - return lockFut1.get(); - } - }, IgniteCheckedException.class, "Locks are not supported"); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/98c69556/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java index d6cf5a8..7f04364 100644 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeLockSelfTest.java @@ -72,16 +72,6 @@ public class GridCachePartitionedMultiNodeLockSelfTest extends GridCacheMultiNod } /** {@inheritDoc} */ - @Override public void testMultiNodeLockAsync() throws Exception { - super.testMultiNodeLockAsync(); - } - - /** {@inheritDoc} */ - @Override public void testMultiNodeLockAsyncWithKeyLists() throws Exception { - super.testMultiNodeLockAsyncWithKeyLists(); - } - - /** {@inheritDoc} */ @Override public void testMultiNodeLockWithKeyLists() throws Exception { super.testMultiNodeLockWithKeyLists(); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/98c69556/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java index fc9db3d..f9c07d3 100644 --- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/local/GridCacheLocalMultithreadedSelfTest.java @@ -331,125 +331,6 @@ public class GridCacheLocalMultithreadedSelfTest extends GridCommonAbstractTest } /** - * @throws Exception If test failed. - */ - public void testLockOrder() throws Exception { - final CountDownLatch l1 = new CountDownLatch(1); - final CountDownLatch l2 = new CountDownLatch(1); - final CountDownLatch l3 = new CountDownLatch(1); - - Thread t1 = new GridTestThread(new Callable<Object>() { - /** {@inheritDoc} */ - @Override public Object call() throws Exception { - cache.lock(1).lock(); - - l1.countDown(); - - assert cache.isLocked(1); - assert cache.isLockedByThread(1); - - l2.await(); - - cache.lock(1).unlock(); - - l3.countDown(); - - assert !cache.isLockedByThread(1); - - return null; - } - }); - - Thread t2 = new Thread(new Runnable() { - /** {@inheritDoc} */ - @Override public void run() { - try { - l1.await(); - - CacheLock lock1 = cache.lock(1); - - lock1.enableAsync().lock(); - - IgniteFuture<Boolean> f1 = lock1.enableAsync().future(); - - try { - f1.get(100, TimeUnit.MILLISECONDS); - - assert false; - } - catch (IgniteFutureTimeoutException e) { - info("Correctly received timeout exception: " + e); - } - - CacheLock lock2 = cache.lock(2); - - lock2.enableAsync().lock(); - - IgniteFuture<Boolean> f2 = lock2.enableAsync().future(); - - try { - // Can't acquire f2 because f1 is held. - f2.get(100, TimeUnit.MILLISECONDS); - - // TODO uncomment after GG-3756 fix - //assert false; - } - catch (IgniteFutureTimeoutException e) { - info("Correctly received timeout exception: " + e); - } - - assert lock1.isLocked(); - assert !lock1.isLockedByThread(); - - // TODO uncomment after GG-3756 fix - //assert cache.isLocked(2); - //assert !cache.isLockedByThread(2); - - l2.countDown(); - - l3.await(); - - assert f1.get(); - - assert cache.isLocked(1); - assert cache.isLockedByThread(1); - - assert f2.get(); - - assert cache.isLocked(2); - assert cache.isLockedByThread(2); - - lock1.unlock(); - lock2.unlock(); - - assert !cache.isLocked(1); - assert !cache.isLockedByThread(1); - - assert !cache.isLocked(2); - assert !cache.isLockedByThread(2); - } - catch (Throwable e) { - error("Failed to acquire lock in thread: " + thread(), e); - - fail("Failed to acquire lock in thread: " + thread()); - } - } - }); - - t1.start(); - t2.start(); - - t1.join(); - t2.join(); - - assert !cache.isLocked(1); - assert !cache.isLockedByThread(1); - - assert !cache.isLocked(2); - assert !cache.isLockedByThread(2); - } - - /** * @return Formatted string for current thread. */ private String thread() {