ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject [07/15] incubator-ignite git commit: # IGNITE-56 Revert GridCachePartitionedReloadAllAbstractSelfTest test.
Date Mon, 09 Feb 2015 00:02:06 GMT
# IGNITE-56 Revert GridCachePartitionedReloadAllAbstractSelfTest test.


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

Branch: refs/heads/ignite-sql-tests
Commit: 068931b378a49c9a3b2f93d92321182ffe758a38
Parents: db5e5d3
Author: sevdokimov <sergey.evdokimov@jetbrains.com>
Authored: Mon Feb 9 00:28:14 2015 +0300
Committer: sevdokimov <sergey.evdokimov@jetbrains.com>
Committed: Mon Feb 9 00:28:14 2015 +0300

----------------------------------------------------------------------
 ...chePartitionedReloadAllAbstractSelfTest.java | 56 +++++++++++++-------
 1 file changed, 38 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/068931b3/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
index 1797eee..eb1900e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCachePartitionedReloadAllAbstractSelfTest.java
@@ -19,7 +19,6 @@ package org.apache.ignite.internal.processors.cache.distributed;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
-import org.apache.ignite.cache.affinity.*;
 import org.apache.ignite.cache.store.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.util.typedef.*;
@@ -56,7 +55,7 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends
Grid
     private final Map<Integer, String> map = new ConcurrentHashMap8<>();
 
     /** Collection of caches, one per grid node. */
-    private List<IgniteCache<Integer, String>> caches;
+    private List<GridCache<Integer, String>> caches;
 
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
@@ -130,7 +129,7 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends
Grid
         caches = new ArrayList<>(GRID_CNT);
 
         for (int i = 0; i < GRID_CNT; i++)
-            caches.add(startGrid(i).<Integer, String>jcache(null));
+            caches.add(startGrid(i).<Integer, String>cache(null));
 
         awaitPartitionMapExchange();
     }
@@ -156,14 +155,14 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest
extends Grid
 
             @Override public void loadCache(IgniteBiInClosure<Integer, String> c,
                 Object... args) {
-                X.println("Loading all on: " + caches.indexOf(g.<Integer, String>jcache(null)));
+                X.println("Loading all on: " + caches.indexOf(g.<Integer, String>cache(null)));
 
                 for (Map.Entry<Integer, String> e : map.entrySet())
                     c.apply(e.getKey(), e.getValue());
             }
 
             @Override public String load(Integer key) {
-                X.println("Loading on: " + caches.indexOf(g.<Integer, String>jcache(null))
+ " key=" + key);
+                X.println("Loading on: " + caches.indexOf(g.<Integer, String>cache(null))
+ " key=" + key);
 
                 return map.get(key);
             }
@@ -186,8 +185,8 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest extends
Grid
      */
     public void testReloadAll() throws Exception {
         // Fill caches with values.
-        for (IgniteCache<Integer, String> cache : caches) {
-            Iterable<Integer> keys = primaryKeys(cache, 100);
+        for (GridCache<Integer, String> cache : caches) {
+            Iterable<Integer> keys = primaryKeysForCache(cache, 100);
 
             info("Values [cache=" + caches.indexOf(cache) + ", size=" + F.size(keys.iterator())
+  ", keys=" + keys + "]");
 
@@ -195,33 +194,54 @@ public abstract class GridCachePartitionedReloadAllAbstractSelfTest
extends Grid
                 map.put(key, "val" + key);
         }
 
-        Collection<IgniteCache<Integer, String>> emptyCaches = new ArrayList<>(caches);
+        Collection<GridCache<Integer, String>> emptyCaches = new ArrayList<>(caches);
 
-        for (IgniteCache<Integer, String> cache : caches) {
+        for (GridCache<Integer, String> cache : caches) {
             info("Reloading cache: " + caches.indexOf(cache));
 
             // Check data is reloaded only on the nodes on which reloadAll() has been called.
             if (!nearEnabled()) {
-                for (IgniteCache<Integer, String> eCache : emptyCaches)
+                for (GridCache<Integer, String> eCache : emptyCaches)
                     assertEquals("Non-null values found in cache [cache=" + caches.indexOf(eCache)
+
-                        ", size=" + eCache.size() + ", size=" + eCache.size() + "]",
+                        ", size=" + eCache.size() + ", size=" + eCache.size() +
+                        ", entrySetSize=" + eCache.entrySet().size() + "]",
                         0, eCache.size());
             }
 
-            loadAll(cache, map.keySet(), true);
+            cache.reloadAll(map.keySet());
 
             for (Integer key : map.keySet()) {
-                CacheAffinity<Integer> affinity = affinity(cache);
+                CacheEntry entry = cache.entry(key);
 
-                if (affinity.isPrimary(localNode(cache), key)
-                    || affinity.isBackup(localNode(cache), key)
-                    || nearEnabled())
-                    assertEquals(map.get(key), cache.localPeek(key, CachePeekMode.ONHEAP));
+                if (entry.primary() || entry.backup() || nearEnabled())
+                    assertEquals(map.get(key), cache.peek(key));
                 else
-                    assertNull(cache.localPeek(key, CachePeekMode.ONHEAP));
+                    assertNull(cache.peek(key));
             }
 
             emptyCaches.remove(cache);
         }
     }
+
+    /**
+     * Create list of keys for which the given cache is primary.
+     *
+     * @param cache Cache.
+     * @param cnt Keys count.
+     * @return Collection of keys for which given cache is primary.
+     */
+    private Iterable<Integer> primaryKeysForCache(CacheProjection<Integer,String>
cache, int cnt) {
+        Collection<Integer> found = new ArrayList<>(cnt);
+
+        for (int i = 0; i < 10000; i++) {
+            if (cache.entry(i).primary()) {
+                found.add(i);
+
+                if (found.size() == cnt)
+                    return found;
+            }
+        }
+
+        throw new IllegalStateException("Unable to find " + cnt + " keys as primary for cache.");
+    }
 }


Mime
View raw message