ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [07/15] incubator-ignite git commit: IGNITE-59 Support lock, lockAll: Fix tests.
Date Mon, 19 Jan 2015 11:36:05 GMT
IGNITE-59 Support lock, lockAll: Fix tests.


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

Branch: refs/heads/ignite-49
Commit: eec3b6c71c7bc285440422b13b6d5a44a6fd3d24
Parents: 2d69d23
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Thu Jan 15 19:09:14 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Fri Jan 16 15:45:41 2015 +0300

----------------------------------------------------------------------
 .../distributed/GridCacheLockAbstractTest.java  | 31 +++++++-------------
 .../near/GridCachePartitionedLockSelfTest.java  |  6 ++--
 2 files changed, 15 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eec3b6c7/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheLockAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheLockAbstractTest.java
b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheLockAbstractTest.java
index fd77a1d..639534b 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheLockAbstractTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheLockAbstractTest.java
@@ -49,10 +49,10 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest
{
     private static Ignite ignite2;
 
     /** (for convenience). */
-    private static GridCache<Integer, String> cache1;
+    private static IgniteCache<Integer, String> cache1;
 
     /** (for convenience). */
-    private static GridCache<Integer, String> cache2;
+    private static IgniteCache<Integer, String> cache2;
 
     /** Ip-finder. */
     private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
@@ -104,8 +104,8 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest
{
         ignite1 = startGrid(1);
         ignite2 = startGrid(2);
 
-        cache1 = ignite1.cache(null);
-        cache2 = ignite2.cache(null);
+        cache1 = ignite1.jcache(null);
+        cache2 = ignite2.jcache(null);
     }
 
     /** {@inheritDoc} */
@@ -127,8 +127,8 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest
{
 
         cache2.flagsOn(GridCacheFlag.SYNC_COMMIT).removeAll();
 
-        assert cache1.isEmpty() : "Cache is not empty: " + cache1.entrySet();
-        assert cache2.isEmpty() : "Cache is not empty: " + cache2.entrySet();
+        assert cache1.size() == 0 : "Cache is not empty: " + cache1;
+        assert cache2.size() == 0 : "Cache is not empty: " + cache2;
     }
 
     /**
@@ -172,9 +172,6 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest
{
      */
     @SuppressWarnings({"TooBroadScope"})
     public void testLockSingleThread() throws Exception {
-        final IgniteCache<Integer, String> cache1 = ignite1.jcache(null);
-        final IgniteCache<Integer, String> cache2 = ignite1.jcache(null);
-
         int k = 1;
         String v = String.valueOf(k);
 
@@ -208,9 +205,6 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest
{
      */
     @SuppressWarnings({"TooBroadScope"})
     public void testLock() throws Exception {
-        final IgniteCache<Integer, String> cache1 = ignite1.jcache(null);
-        final IgniteCache<Integer, String> cache2 = ignite1.jcache(null);
-
         final int kv = 1;
 
         final CountDownLatch l1 = new CountDownLatch(1);
@@ -299,9 +293,6 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest
{
      * @throws Exception If test failed.
      */
     public void testLockAndPut() throws Exception {
-        final IgniteCache<Integer, String> cache1 = ignite1.jcache(null);
-        final IgniteCache<Integer, String> cache2 = ignite1.jcache(null);
-
         final CountDownLatch l1 = new CountDownLatch(1);
         final CountDownLatch l2 = new CountDownLatch(1);
 
@@ -388,7 +379,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest
{
     public void testLockTimeoutTwoThreads() throws Exception {
         int keyCnt = 1;
 
-        final Collection<Integer> keys = new ArrayList<>(keyCnt);
+        final Set<Integer> keys = new HashSet<>();
 
         for (int i = 1; i <= keyCnt; i++)
             keys.add(i);
@@ -400,7 +391,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest
{
                 @Nullable @Override public Object call() throws Exception {
                     info("Before lock for keys.");
 
-                    assert cache1.lockAll(keys, 0);
+                    cache1.lockAll(keys).lock();
 
                     info("After lock for keys.");
 
@@ -428,7 +419,7 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest
{
 
                         info("Before unlock keys in thread 1: " + keys);
 
-                        cache1.unlockAll(keys);
+                        cache1.lockAll(keys).unlock();
 
                         info("Unlocked entry for keys.");
                     }
@@ -448,11 +439,11 @@ public abstract class GridCacheLockAbstractTest extends GridCommonAbstractTest
{
 
                         // This call should not acquire the lock since
                         // other thread is holding it.
-                        assert !cache1.lockAll(keys, -1);
+                        assert !cache1.lockAll(keys).tryLock();
 
                         info("Before unlock keys in thread 2: " + keys);
 
-                        cache1.unlockAll(keys);
+                        cache1.lockAll(keys).unlock();
 
                         // The keys should still be locked.
                         for (Integer key : keys)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/eec3b6c7/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 26edf39..24d84ea 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
@@ -70,15 +70,17 @@ public class GridCachePartitionedLockSelfTest extends GridCacheLockAbstractTest
 
         final Ignite g0 = G.start(cfg);
 
+        final IgniteCache<Object, Object> cache = g0.jcache(null);
+
         GridTestUtils.assertThrows(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
-                return g0.jcache(null).lock(1).tryLock(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
+                return cache.lock(1).tryLock(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
             }
         }, IgniteCheckedException.class, "Locks are not supported");
 
         GridTestUtils.assertThrows(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
-                return g0.cache(null).lockAll(Arrays.asList(1), Long.MAX_VALUE);
+                return cache.lockAll(Collections.singleton(1)).tryLock(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
             }
         }, IgniteCheckedException.class, "Locks are not supported");
 


Mime
View raw message