ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [03/17] ignite git commit: ignite-971 Fix offheap to swap eviction.
Date Thu, 10 Sep 2015 12:04:38 GMT
ignite-971 Fix offheap to swap eviction.


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

Branch: refs/heads/ignite-1282
Commit: 4a3b0242c34e580054be2e23bc01560e96519b0b
Parents: 1b51ec3
Author: sboikov <sboikov@gridgain.com>
Authored: Thu Sep 10 10:42:01 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Thu Sep 10 10:42:01 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheMetricsImpl.java      |  2 +-
 .../processors/cache/GridCacheMapEntry.java     |  4 +--
 .../processors/cache/GridCacheSwapManager.java  |  9 ++----
 .../processors/cache/GridCacheUtils.java        |  6 ++--
 .../util/offheap/unsafe/GridUnsafeMap.java      | 33 ++++++++++++--------
 .../cache/GridCacheOffHeapAndSwapSelfTest.java  |  4 +++
 6 files changed, 33 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/4a3b0242/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
index 1554e07..dfa0217 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
@@ -843,7 +843,7 @@ public class CacheMetricsImpl implements CacheMetrics {
         offHeapEvicts.incrementAndGet();
 
         if (delegate != null)
-            delegate.onOffHeapRemove();
+            delegate.onOffHeapEvict();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a3b0242/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 3fc1b2e..bdf6057 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -3681,7 +3681,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter
impleme
             if (F.isEmptyOrNulls(filter)) {
                 synchronized (this) {
                     if (obsoleteVersionExtras() != null)
-                        return false;
+                        return true;
 
                     CacheObject prev = saveValueForIndexUnlocked();
 
@@ -3725,7 +3725,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter
impleme
 
                     synchronized (this) {
                         if (obsoleteVersionExtras() != null)
-                            return false;
+                            return true;
 
                         if (!v.equals(ver))
                             // Version has changed since entry passed the filter. Do it again.

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a3b0242/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index 53b0421..851c827 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -1059,7 +1059,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
 
         checkIteratorQueue();
 
-        boolean rmv = offheap.removex(spaceName, part, key, key.valueBytes(cctx.cacheObjectContext()),
+        return offheap.removex(spaceName, part, key, key.valueBytes(cctx.cacheObjectContext()),
             new IgniteBiPredicate<Long, Integer>() {
                 @Override public boolean apply(Long ptr, Integer len) {
                     GridCacheVersion ver0 = GridCacheOffheapSwapEntry.version(ptr);
@@ -1068,11 +1068,6 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
                 }
             }
         );
-
-        if (rmv && cctx.config().isStatisticsEnabled())
-            cctx.cache().metrics0().onOffHeapRemove();
-
-        return rmv;
     }
 
     /**
@@ -1355,7 +1350,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
      */
     public void clearOffHeap() {
         if (offheapEnabled)
-            clearOffHeap();
+            initOffHeap();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a3b0242/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 919bce6..2d5698a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -1032,9 +1032,11 @@ public class GridCacheUtils {
         ctx.swap().unwindOffheapEvicts();
 
         if (ctx.isNear()) {
-            ctx.near().dht().context().evicts().unwind();
+            GridCacheContext dhtCtx = ctx.near().dht().context();
 
-            ctx.swap().unwindOffheapEvicts();
+            dhtCtx.evicts().unwind();
+
+            dhtCtx.swap().unwindOffheapEvicts();
         }
 
         ctx.ttl().expire();

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a3b0242/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
index ed13fe1..d0435e4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/offheap/unsafe/GridUnsafeMap.java
@@ -1022,12 +1022,26 @@ public class GridUnsafeMap implements GridOffHeapMap {
                         }
 
                         if (cur != 0) {
-                            long a;
+                            long qAddr0 = Entry.queueAddress(cur, mem);
 
-                            assert qAddr == (a = Entry.queueAddress(cur, mem)) : "Queue node
address mismatch " +
-                                "[qAddr=" + qAddr + ", entryQueueAddr=" + a + ']';
+                            assert qAddr == qAddr0 : "Queue node address mismatch " +
+                                "[qAddr=" + qAddr + ", entryQueueAddr=" + qAddr + ']';
+
+                            if (evictLsnr != null) {
+                                keyBytes = Entry.readKeyBytes(cur, mem);
+
+                                int keyLen = Entry.readKeyLength(cur, mem);
+                                int valLen = Entry.readValueLength(cur, mem);
+
+                                valBytes = mem.readBytes(cur + HEADER + keyLen, valLen);
+                            }
 
                             if (rmvEvicted) {
+                                long a;
+
+                                assert qAddr == (a = Entry.queueAddress(cur, mem)) : "Queue
node address mismatch " +
+                                    "[qAddr=" + qAddr + ", entryQueueAddr=" + a + ']';
+
                                 long next = Entry.nextAddress(cur, mem);
 
                                 if (prev != 0)
@@ -1047,18 +1061,11 @@ public class GridUnsafeMap implements GridOffHeapMap {
                                 totalCnt.decrement();
                             }
                             else {
-                                if (qAddr != 0) {
-                                    boolean clear = Entry.clearQueueAddress(cur, qAddr, mem);
+                                boolean clear = Entry.clearQueueAddress(cur, qAddr, mem);
 
-                                    assert clear;
-                                }
+                                assert clear;
 
-                                keyBytes = Entry.readKeyBytes(cur, mem);
-
-                                int keyLen = Entry.readKeyLength(cur, mem);
-                                int valLen = Entry.readValueLength(cur, mem);
-
-                                valBytes = mem.readBytes(cur + HEADER + keyLen, valLen);
+                                relSize = Entry.size(cur, mem);
                             }
                         }
                     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/4a3b0242/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapAndSwapSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapAndSwapSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapAndSwapSelfTest.java
index 8f453a5..eb0880a 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapAndSwapSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheOffHeapAndSwapSelfTest.java
@@ -249,6 +249,10 @@ public class GridCacheOffHeapAndSwapSelfTest extends GridCommonAbstractTest
{
             assertEquals(ENTRY_CNT - i - 1, cache.localSize(CachePeekMode.ONHEAP));
         }
 
+        log.info("Cache size [onheap=" + cache.localSize(CachePeekMode.ONHEAP) +
+            ", offheap=" + cache.localSize(CachePeekMode.OFFHEAP) +
+            ", swap=" + cache.localSize(CachePeekMode.SWAP) + ']');
+
         // Ensure that part of entries located in off-heap memory and part is swapped.
         assertEquals(0, cache.localSize(CachePeekMode.ONHEAP));
         assertTrue(cache.localSize(CachePeekMode.OFFHEAP) > 0);


Mime
View raw message