geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dschnei...@apache.org
Subject [1/2] incubator-geode git commit: made release method default on interfaces got rid of instanceof on release call
Date Wed, 09 Nov 2016 23:55:51 GMT
Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-1895 [created] 2f9ea5e8f


made release method default on interfaces
got rid of instanceof on release call


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

Branch: refs/heads/feature/GEODE-1895
Commit: 34ba0f38ad494a7539486c34fedd7ae5daaba39f
Parents: 7973d57
Author: Darrel Schneider <dschneider@pivotal.io>
Authored: Wed Nov 9 11:26:11 2016 -0800
Committer: Darrel Schneider <dschneider@pivotal.io>
Committed: Wed Nov 9 15:50:36 2016 -0800

----------------------------------------------------------------------
 .../apache/geode/internal/cache/AbstractDiskRegion.java  | 11 +++--------
 .../apache/geode/internal/cache/OffHeapRegionEntry.java  | 11 +++++++++--
 .../org/apache/geode/internal/cache/RegionEntry.java     |  9 ++++++++-
 3 files changed, 20 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/34ba0f38/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractDiskRegion.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractDiskRegion.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractDiskRegion.java
index 554455d..0bf5842 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractDiskRegion.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/AbstractDiskRegion.java
@@ -580,19 +580,14 @@ public abstract class AbstractDiskRegion implements DiskRegionView {
     if (isReadyForRecovery()) {
       ds.updateDiskRegion(this);
       this.entriesMapIncompatible = false;
-      if (this.entries != null) {
+      if (this.entries != null && region.getOffHeap()) {
         CustomEntryConcurrentHashMap<Object, Object> other =
             ((AbstractRegionMap) this.entries)._getMap();
         Iterator<Map.Entry<Object, Object>> it = other.entrySetWithReusableEntries().iterator();
         while (it.hasNext()) {
           Map.Entry<Object, Object> me = it.next();
-          RegionEntry oldRe = (RegionEntry) me.getValue();
-          if (oldRe instanceof OffHeapRegionEntry) {
-            ((OffHeapRegionEntry) oldRe).release();
-          } else {
-            // no need to keep iterating; they are all either off heap or on heap.
-            break;
-          }
+          OffHeapRegionEntry oldRe = (OffHeapRegionEntry) me.getValue();
+          oldRe.release();
         }
       }
       this.entries = null;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/34ba0f38/geode-core/src/main/java/org/apache/geode/internal/cache/OffHeapRegionEntry.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/OffHeapRegionEntry.java
b/geode-core/src/main/java/org/apache/geode/internal/cache/OffHeapRegionEntry.java
index 34109f4..83b298a 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/OffHeapRegionEntry.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/OffHeapRegionEntry.java
@@ -15,14 +15,15 @@
 
 package org.apache.geode.internal.cache;
 
-import org.apache.geode.internal.offheap.Releasable;
+import org.apache.geode.internal.offheap.OffHeapRegionEntryHelper;
+import org.apache.geode.internal.offheap.annotations.Released;
 
 /**
  * Any RegionEntry that is stored off heap must implement this interface.
  * 
  *
  */
-public interface OffHeapRegionEntry extends RegionEntry, Releasable {
+public interface OffHeapRegionEntry extends RegionEntry {
   /**
    * OFF_HEAP_FIELD_READER
    * 
@@ -38,4 +39,10 @@ public interface OffHeapRegionEntry extends RegionEntry, Releasable {
    * @return newAddr OFF_HEAP_ADDRESS
    */
   public boolean setAddress(long expectedAddr, long newAddr);
+  
+  @Override
+  @Released
+  default public void release() {
+    OffHeapRegionEntryHelper.releaseEntry(this);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/34ba0f38/geode-core/src/main/java/org/apache/geode/internal/cache/RegionEntry.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/RegionEntry.java b/geode-core/src/main/java/org/apache/geode/internal/cache/RegionEntry.java
index 3448d1f..202d006 100644
--- a/geode-core/src/main/java/org/apache/geode/internal/cache/RegionEntry.java
+++ b/geode-core/src/main/java/org/apache/geode/internal/cache/RegionEntry.java
@@ -29,6 +29,7 @@ import org.apache.geode.internal.cache.lru.NewLRUClockHand;
 import org.apache.geode.internal.cache.versions.VersionSource;
 import org.apache.geode.internal.cache.versions.VersionStamp;
 import org.apache.geode.internal.cache.versions.VersionTag;
+import org.apache.geode.internal.offheap.Releasable;
 import org.apache.geode.internal.offheap.StoredObject;
 import org.apache.geode.internal.offheap.annotations.Released;
 import org.apache.geode.internal.offheap.annotations.Retained;
@@ -51,7 +52,7 @@ import org.apache.geode.internal.offheap.annotations.Unretained;
  *        volatile long id; DiskStatsLRUEntry extends StatsLRUEntry private volatile long
id;
  *
  */
-public interface RegionEntry {
+public interface RegionEntry extends Releasable {
   // Our RegionEntry does not need to keep a reference to the key.
   // It is being referenced by the Map.Entry whose value field
   // references this RegionEntry.
@@ -459,4 +460,10 @@ public interface RegionEntry {
   @Retained(ABSTRACT_REGION_ENTRY_PREPARE_VALUE_FOR_CACHE)
   public Object prepareValueForCache(RegionEntryContext r, Object val, EntryEventImpl event,
       boolean isEntryUpdate);
+  
+  @Override
+  default public void release() {
+    // nothing needed by default
+  }
+
 }


Mime
View raw message