geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [02/50] [abbrv] incubator-geode git commit: GEODE-1169 Free offheap memory for recovered region entries when there is a configuration change.
Date Tue, 12 Apr 2016 17:42:52 GMT
GEODE-1169 Free offheap memory for recovered region entries when there is a configuration change.


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

Branch: refs/heads/feature/GEODE-1162
Commit: 36f3f8da042f286c5f3c8d2a06cb640c8081564d
Parents: e7b7360
Author: eshu <eshu@pivotal.io>
Authored: Tue Apr 5 16:34:09 2016 -0700
Committer: eshu <eshu@pivotal.io>
Committed: Tue Apr 5 16:34:09 2016 -0700

----------------------------------------------------------------------
 .../internal/cache/AbstractRegionMap.java       |  5 +--
 .../internal/offheap/OffHeapRegionBase.java     | 33 ++++++++++++++++++++
 2 files changed, 36 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/36f3f8da/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
index 7b9dce7..1cb7a20 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/AbstractRegionMap.java
@@ -678,8 +678,9 @@ public abstract class AbstractRegionMap implements RegionMap {
           incEntryCount(1);
           lruEntryUpdate(newRe);
         } finally {
-          if (OffHeapHelper.release(value)) {
-            ((OffHeapRegionEntry)oldRe).release();
+          OffHeapHelper.release(value);
+          if (oldRe instanceof OffHeapRegionEntry) {
+            ((OffHeapRegionEntry) oldRe).release();
           }
         }
         lruUpdateCallback();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/36f3f8da/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
index a820619..f3b0c33 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/internal/offheap/OffHeapRegionBase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.fail;
 
 import java.io.Serializable;
 import java.util.Arrays;
+import java.util.List;
 import java.util.Properties;
 
 import org.junit.Test;
@@ -620,4 +621,36 @@ public abstract class OffHeapRegionBase {
       closeCache(gfc, false);
     }
   }
+
+  @Test
+  public void testPersistentCompressorChange() {
+    GemFireCacheImpl gfc = createCache(true);
+    Region<Object, Object> r = null;
+    String value = "value1";
+    String key = "key";
+
+    try {
+      r = gfc.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT).setOffHeap(true).setCompressor(new
SnappyCompressor()).create("region1");
+      r.put(key, value);
+    } finally {
+      closeCache(gfc, false);
+    }
+
+    gfc = createCache(true);
+    try {
+      r = gfc.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT).setOffHeap(true).setCompressor(null).create("region1");
+      assertEquals(true, r.containsKey(key));
+      MemoryAllocatorImpl mai = MemoryAllocatorImpl.getAllocator();
+      List<OffHeapStoredObject> orphans = mai.getLostChunks();
+      if (orphans.size() >0) {
+        fail("expected no orphan detected, but gets orphan size " + orphans.size());
+      }
+      assertEquals(value, r.get(key));
+    } finally {
+      if (r !=null && !r.isDestroyed()) {
+        r.destroyRegion();
+      }
+      closeCache(gfc, false);
+    }
+  }
 }


Mime
View raw message