ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-5075
Date Tue, 16 May 2017 11:32:06 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-5075 e84d4a2d1 -> 3f6a79f77


ignite-5075


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

Branch: refs/heads/ignite-5075
Commit: 3f6a79f7719189eeb3f4fe5169f9f1f346293508
Parents: e84d4a2
Author: sboikov <sboikov@gridgain.com>
Authored: Tue May 16 14:31:59 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Tue May 16 14:31:59 2017 +0300

----------------------------------------------------------------------
 .../cache/IgniteCacheOffheapManagerImpl.java    |  1 +
 .../processors/cache/IgniteCacheGroupsTest.java | 96 +++++++++++++++++---
 2 files changed, 83 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3f6a79f7/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
index 471f073..9553491 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManagerImpl.java
@@ -1159,6 +1159,7 @@ public class IgniteCacheOffheapManagerImpl implements IgniteCacheOffheapManager
         }
 
         /**
+         * @param cctx Cache context.
          * @param newRow New row.
          * @param oldRow Old row if available.
          * @throws IgniteCheckedException If failed.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3f6a79f7/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
index 9fb72d7..8ff45f2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheGroupsTest.java
@@ -168,7 +168,7 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
             for (int i = 0; i < srvs; i++) {
                 checkCacheGroup(i, GROUP1, true);
 
-                //checkCache(i, "cache2");
+                checkCache(i, "cache2");
             }
 
             srv0.destroyCache("cache2");
@@ -262,14 +262,52 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
-    public void _testCacheApiTx() throws Exception {
+    public void testCacheApiTxPartitioned() throws Exception {
+        cacheApiTest(PARTITIONED, TRANSACTIONAL);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCacheApiTxReplicated() throws Exception {
+        cacheApiTest(REPLICATED, TRANSACTIONAL);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCacheApiAtomicPartitioned() throws Exception {
+        cacheApiTest(PARTITIONED, ATOMIC);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testCacheApiAtomicReplicated() throws Exception {
+        cacheApiTest(REPLICATED, ATOMIC);
+    }
+
+    /**
+     * @param cacheMode Cache mode.
+     * @param atomicityMode Atomicity mode.
+     * @throws Exception If failed.
+     */
+    private void cacheApiTest(CacheMode cacheMode, CacheAtomicityMode atomicityMode) throws
Exception {
         startGridsMultiThreaded(4);
 
         client = true;
 
         startGrid(4);
 
-        cacheApiTest(PARTITIONED, TRANSACTIONAL, 2, false);
+        int[] backups = cacheMode == REPLICATED ? new int[]{Integer.MAX_VALUE} : new int[]{0,
1, 2, 3};
+
+        for (int backups0 : backups)
+            cacheApiTest(cacheMode, atomicityMode, backups0, false);
+
+        int backups0 = cacheMode == REPLICATED ? Integer.MAX_VALUE :
+            backups[ThreadLocalRandom.current().nextInt(backups.length)];
+
+        cacheApiTest(cacheMode, atomicityMode, backups0, true);
     }
 
     /**
@@ -282,27 +320,57 @@ public class IgniteCacheGroupsTest extends GridCommonAbstractTest {
         for (int i = 0; i < 2; i++)
             ignite(0).createCache(cacheConfiguration(GROUP1, "cache-" + i, cacheMode, atomicityMode,
backups, heapCache));
 
-        for (Ignite node : Ignition.allGrids()) {
-            for (int i = 0; i < 2; i++) {
-                IgniteCache cache = node.cache("cache-" + i);
-
-                log.info("Test cache [node=" + node.name() + ", cache=" + cache.getName()
+
-                    ", mode=" + cacheMode + ", atomicity=" + atomicityMode + ", backups="
+ backups + ']');
-
-                cacheApiTest(cache);
+        try {
+            for (Ignite node : Ignition.allGrids()) {
+                for (int i = 0; i < 2; i++) {
+                    IgniteCache cache = node.cache("cache-" + i);
+
+                    log.info("Test cache [node=" + node.name() +
+                        ", cache=" + cache.getName() +
+                        ", mode=" + cacheMode +
+                        ", atomicity=" + atomicityMode +
+                        ", backups=" + backups +
+                        ", heapCache=" + heapCache +
+                        ']');
+
+                    cacheApiTest(cache);
+                }
             }
         }
+        finally {
+            for (int i = 0; i < 2; i++)
+                ignite(0).destroyCache("cache-" + i);
+        }
     }
 
     /**
      * @param cache Cache.
      */
     private void cacheApiTest(IgniteCache cache) {
-        int key = 1;
+        ThreadLocalRandom rnd = ThreadLocalRandom.current();
 
-        cache.put(key, 1);
+        for (int i = 0; i < 10; i++) {
+            Integer key = rnd.nextInt(10_000);
+
+            assertNull(cache.get(key));
+            assertFalse(cache.containsKey(key));
+
+            Integer val = key + 1;
+
+            cache.put(key, val);
+
+            assertEquals(val, cache.get(key));
+            assertTrue(cache.containsKey(key));
+
+            cache.remove(key);
+
+            assertNull(cache.get(key));
+            assertFalse(cache.containsKey(key));
+        }
+
+        cache.clear();
 
-        cache.remove(key);
+        cache.removeAll();
     }
 
     /**


Mime
View raw message