ignite-601
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/2d482d03 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/2d482d03 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/2d482d03 Branch: refs/heads/ignite-601 Commit: 2d482d03c7f724624b3e076a65ccd81adf387767 Parents: 865803b Author: sboikov <sboi...@apache.org> Authored: Thu Dec 27 19:37:11 2018 +0300 Committer: sboikov <sboi...@apache.org> Committed: Thu Dec 27 19:37:11 2018 +0300 ---------------------------------------------------------------------- .../distributed/near/GridNearCacheAdapter.java | 23 ------- .../distributed/GridCacheLockAbstractTest.java | 70 +++++++------------- ...achePartitionedNearDisabledLockSelfTest.java | 5 -- .../near/GridCacheNearMultiNodeSelfTest.java | 2 - .../near/GridCachePartitionedLockSelfTest.java | 5 -- .../Cache/CacheAbstractTest.cs | 2 +- .../Cache/CacheAbstractTransactionalTest.cs | 2 +- 7 files changed, 26 insertions(+), 83 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/2d482d03/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java index 086247c..34d7d61 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java @@ -56,7 +56,6 @@ 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.P1; -import org.apache.ignite.internal.util.typedef.internal.A; import org.apache.ignite.internal.util.typedef.internal.CU; import org.apache.ignite.internal.util.typedef.internal.S; import org.apache.ignite.lang.IgniteBiPredicate; @@ -185,28 +184,6 @@ public abstract class GridNearCacheAdapter<K, V> extends GridDistributedCacheAda } /** - * @param key Key. - * @return If near entry is locked. - */ - public boolean isLockedNearOnly(K key) { - return super.isLocked(key); - } - - /** - * @param keys Keys. - * @return If near entries for given keys are locked. - */ - public boolean isAllLockedNearOnly(Iterable<? extends K> keys) { - A.notNull(keys, "keys"); - - for (K key : keys) - if (!isLockedNearOnly(key)) - return false; - - return true; - } - - /** * @param tx Transaction. * @param keys Keys to load. * @param forcePrimary Force primary flag. http://git-wip-us.apache.org/repos/asf/ignite/blob/2d482d03/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 6d5ac30..3890133 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 @@ -33,6 +33,7 @@ import org.apache.ignite.cache.affinity.Affinity; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.internal.IgniteInternalFuture; +import org.apache.ignite.internal.util.lang.GridAbsPredicate; import org.apache.ignite.testframework.GridTestThread; import org.apache.ignite.testframework.GridTestUtils; import org.apache.ignite.testframework.MvccFeatureChecker; @@ -156,42 +157,6 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { } /** - * @return Partitioned flag. - */ - protected boolean isPartitioned() { - return false; - } - - /** - * @param k Key to check. - * @param idx Grid index. - * @return {@code True} if locked. - */ - private boolean locked(Integer k, int idx) { - if (isPartitioned()) - return near(idx).isLockedNearOnly(k); - - return jcache(idx).isLocalLocked(k, false); - } - - /** - * @param keys Keys to check. - * @param idx Grid index. - * @return {@code True} if locked. - */ - private boolean locked(Iterable<Integer> keys, int idx) { - if (isPartitioned()) - return near(idx).isAllLockedNearOnly(keys); - - for (Integer key : keys) { - if (!jcache(idx).isLocalLocked(key, true)) - return false; - } - - return true; - } - - /** * @throws Exception If test failed. */ @SuppressWarnings({"TooBroadScope"}) @@ -223,8 +188,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { info("Unlocked key: " + k); } - assert !locked(k, 1); - assert !cache1.isLocalLocked(k, true); + checkUnlocked(cache1, k); } /** @@ -257,7 +221,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { cache1.put(kv, Integer.toString(kv)); - info("Put " + kv + '=' + Integer.toString(kv) + " key pair into cache."); + info("Put " + kv + '=' + kv + " key pair into cache."); } finally { Thread.sleep(1000); @@ -269,8 +233,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { l2.await(); - assert !cache1.isLocalLocked(kv, true); - assert !locked(kv, 1); + checkUnlocked(cache1, kv); return null; } @@ -297,8 +260,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { info("Unlocked key in thread 2: " + kv); } - assert !locked(kv, 2); - assert !cache2.isLocalLocked(kv, true); + checkUnlocked(cache2, kv); Thread.sleep(1000); @@ -361,8 +323,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { l2.await(); - assert !locked(1, 1); - assert !cache1.isLocalLocked(1, true); + checkUnlocked(cache1, 1); return null; } @@ -458,7 +419,8 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { info("Unlocked entry for keys."); } - assert !locked(keys, 1); + for (Integer key : keys) + checkUnlocked(cache1, key); return null; } @@ -571,4 +533,20 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest { } } } + + /** + * @param cache Cache. + * @param key Key. + * @throws Exception If failed. + */ + protected void checkUnlocked(final IgniteCache<Integer, ?> cache, final Integer key) throws Exception { + GridTestUtils.waitForCondition(new GridAbsPredicate() { + @Override public boolean apply() { + return !cache.isLocalLocked(key, false); + } + }, 5000); + + assertFalse(cache.isLocalLocked(key, false)); + assertFalse(cache.isLocalLocked(key, true)); + } } http://git-wip-us.apache.org/repos/asf/ignite/blob/2d482d03/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java index ff738c6..320e00e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCachePartitionedNearDisabledLockSelfTest.java @@ -40,11 +40,6 @@ public class GridCachePartitionedNearDisabledLockSelfTest extends GridCacheParti } /** {@inheritDoc} */ - @Override protected boolean isPartitioned() { - return false; - } - - /** {@inheritDoc} */ @Test @Override public void testLockReentrancy() throws Throwable { fail("https://issues.apache.org/jira/browse/IGNITE-835"); http://git-wip-us.apache.org/repos/asf/ignite/blob/2d482d03/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 341abbf..d8d5e5e 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 @@ -733,7 +733,6 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest { assertNull(near(0).peekEx(key)); assertNull(near(1).peekEx(key)); - assertFalse(near(0).isLockedNearOnly(key)); assertFalse(cache.isLocalLocked(key, true)); } @@ -802,7 +801,6 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest { lock.unlock(); } - assertFalse(near(0).isLockedNearOnly(key)); assertFalse(near.isLocalLocked(key, true)); } http://git-wip-us.apache.org/repos/asf/ignite/blob/2d482d03/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java index 122dc76..c46c4a9 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedLockSelfTest.java @@ -44,9 +44,4 @@ public class GridCachePartitionedLockSelfTest extends GridCacheLockAbstractTest @Override protected CacheMode cacheMode() { return PARTITIONED; } - - /** {@inheritDoc} */ - @Override protected boolean isPartitioned() { - return true; - } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/2d482d03/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs index 3c74ce4..4f73662 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTest.cs @@ -2375,7 +2375,7 @@ namespace Apache.Ignite.Core.Tests.Cache Assert.AreEqual(expAge, person.Age); } - private static int GetPrimaryKeyForCache(ICache<int, int> cache) + protected static int GetPrimaryKeyForCache(ICache<int, int> cache) { return GetPrimaryKeysForCacheFrom(cache, 0).First(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/2d482d03/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTransactionalTest.cs ---------------------------------------------------------------------- diff --git a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTransactionalTest.cs b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTransactionalTest.cs index a70d9b7..83a3229 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTransactionalTest.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core.Tests/Cache/CacheAbstractTransactionalTest.cs @@ -42,7 +42,7 @@ namespace Apache.Ignite.Core.Tests.Cache { var cache = Cache(); - const int key = 7; + const int key = GetPrimaryKeyForCache(cache); Action<ICacheLock> checkLock = lck => {