ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [02/12] incubator-ignite git commit: # ignite-58
Date Thu, 05 Feb 2015 10:20:13 GMT
# ignite-58


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

Branch: refs/heads/sprint-1
Commit: d126ec4ed2004f6629d0a0dc5ff37a5cff2597b9
Parents: 6de2ced
Author: sboikov <semen.boikov@inria.fr>
Authored: Thu Feb 5 07:32:24 2015 +0300
Committer: sboikov <semen.boikov@inria.fr>
Committed: Thu Feb 5 07:32:24 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheAdapter.java      |  3 +-
 .../cache/IgniteCachePeekAbstractTest.java      | 48 ++++++++++++++++----
 2 files changed, 42 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d126ec4e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 0b3372c..2cd1737 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -812,7 +812,8 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
             V val = null;
 
             if (heap) {
-                GridCacheEntryEx<K, V> e = peekEx(key);
+                GridCacheEntryEx<K, V> e = nearKey ? peekEx(key) :
+                    (ctx.isNear() ? ctx.near().dht().peekEx(key) : peekEx(key));
 
                 if (e != null) {
                     val = e.peek(heap, offheap, swap, topVer);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/d126ec4e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java
index f8aaaca..cd97c75 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCachePeekAbstractTest.java
@@ -22,6 +22,7 @@ import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.affinity.*;
 import org.apache.ignite.cache.eviction.fifo.*;
 import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
 import org.apache.ignite.spi.*;
 import org.apache.ignite.spi.swapspace.inmemory.*;
 
@@ -78,6 +79,8 @@ public abstract class IgniteCachePeekAbstractTest extends IgniteCacheAbstractTes
      * @throws Exception If failed.
      */
     public void testLocalPeek() throws Exception {
+        checkAffinity();
+
         checkStorage();
     }
 
@@ -157,27 +160,56 @@ public abstract class IgniteCachePeekAbstractTest extends IgniteCacheAbstractTes
 
         assertTrue(swapKeys.size() + HEAP_ENTRIES < 100);
 
-        List<Integer> offheapKeys = new ArrayList<>(keys);
+        Set<Integer> offheapKeys = new HashSet<>();
+
+        GridCacheAdapter<Integer, String> internalCache =
+            ((IgniteKernal)ignite(0)).context().cache().<Integer, String>internalCache();
+
+        Iterator<Map.Entry<Integer, String>> offheapIt =
+            internalCache.context().near().dht().context().swap().lazyOffHeapIterator();
+
+        while (offheapIt.hasNext()) {
+            Map.Entry<Integer, String> e = offheapIt.next();
+
+            assertTrue(offheapKeys.add(e.getKey()));
+
+            assertFalse(swapKeys.contains(e.getKey()));
+        }
+
+        assertFalse(offheapKeys.isEmpty());
+
+        Set<Integer> heapKeys = new HashSet<>(keys);
+
+        heapKeys.removeAll(offheapKeys);
+        heapKeys.removeAll(swapKeys);
+
+        assertFalse(heapKeys.isEmpty());
+
+        log.info("Keys [swap=" + swapKeys.size() +
+            ", offheap=" + offheapKeys.size() +
+            ", heap=" + heapKeys.size() + ']');
+
+        assertEquals(100, swapKeys.size() + offheapKeys.size() + heapKeys.size());
 
         for (Integer key : swapKeys) {
             assertEquals(val, cache0.localPeek(key, SWAP));
 
             assertNull(cache0.localPeek(key, ONHEAP));
             assertNull(cache0.localPeek(key, OFFHEAP));
-
-            offheapKeys.remove(key);
         }
 
-        for (int i = 0; i < HEAP_ENTRIES; i++) {
-            Integer key = keys.get(keys.size() - i - 1);
+        for (Integer key : offheapKeys) {
+            assertEquals(val, cache0.localPeek(key, OFFHEAP));
 
-            assertFalse(swapKeys.contains(key));
+            assertNull(cache0.localPeek(key, ONHEAP));
+            assertNull(cache0.localPeek(key, SWAP));
+        }
+
+        for (Integer key : heapKeys) {
             assertEquals(val, cache0.localPeek(key, ONHEAP));
 
             assertNull(cache0.localPeek(key, SWAP));
             assertNull(cache0.localPeek(key, OFFHEAP));
-
-            offheapKeys.remove(key);
         }
     }
 }
\ No newline at end of file


Mime
View raw message