mnemonic-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject incubator-mnemonic git commit: MNEMONIC-381: Support reclaim context
Date Wed, 04 Oct 2017 21:21:11 GMT
Repository: incubator-mnemonic
Updated Branches:
  refs/heads/master d78454b06 -> e93965705


MNEMONIC-381: Support reclaim context


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

Branch: refs/heads/master
Commit: e93965705cd15295598433214400d3da572588e1
Parents: d78454b
Author: Wang, Gang(Gary) <gang1.wang@intel.com>
Authored: Wed Oct 4 13:45:22 2017 -0700
Committer: Wang, Gang(Gary) <gang1.wang@intel.com>
Committed: Wed Oct 4 13:45:22 2017 -0700

----------------------------------------------------------------------
 .../mnemonic/collections/DurableArrayImpl.java  |   9 +-
 .../collections/DurableHashMapImpl.java         |   8 +-
 .../collections/DurableHashSetImpl.java         |   8 +-
 .../mnemonic/collections/DurableTreeImpl.java   |   6 +
 .../java/org/apache/mnemonic/Allocatable.java   |  26 ++++
 .../mnemonic/AnnotatedDurableEntityClass.java   | 148 ++++++++++---------
 .../org/apache/mnemonic/CommonAllocator.java    |  29 ++++
 .../main/java/org/apache/mnemonic/Durable.java  |   9 ++
 .../java/org/apache/mnemonic/DurableBuffer.java |   7 +
 .../java/org/apache/mnemonic/DurableChunk.java  |   7 +
 .../java/org/apache/mnemonic/GenericField.java  |  14 +-
 .../org/apache/mnemonic/MemBufferHolder.java    |  13 ++
 .../org/apache/mnemonic/MemChunkHolder.java     |  12 ++
 .../java/org/apache/mnemonic/MemHolder.java     |   8 +
 14 files changed, 226 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableArrayImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableArrayImpl.java
b/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableArrayImpl.java
index d0c01b3..705c8a2 100644
--- a/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableArrayImpl.java
+++ b/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableArrayImpl.java
@@ -29,6 +29,8 @@ import org.apache.mnemonic.RetrieveDurableEntityError;
 import org.apache.mnemonic.Utils;
 
 import java.util.NoSuchElementException;
+
+import org.flowcomputing.commons.resgc.ReclaimContext;
 import sun.misc.Unsafe;
 import java.util.Iterator;
 
@@ -186,7 +188,12 @@ public class DurableArrayImpl<A extends RestorableAllocator<A>,
E>
 
   @Override
   public void registerAutoReclaim() {
-    holder.registerAutoReclaim();
+    this.registerAutoReclaim(null);
+  }
+
+  @Override
+  public void registerAutoReclaim(ReclaimContext rctx) {
+    holder.registerAutoReclaim(rctx);
     autoReclaim = true;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashMapImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashMapImpl.java
b/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashMapImpl.java
index ca2a287..0c20245 100644
--- a/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashMapImpl.java
+++ b/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashMapImpl.java
@@ -31,6 +31,7 @@ import org.apache.mnemonic.ParameterHolder;
 
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.commons.lang3.ArrayUtils;
+import org.flowcomputing.commons.resgc.ReclaimContext;
 import sun.misc.Unsafe;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
@@ -434,7 +435,12 @@ public class DurableHashMapImpl<A extends RestorableAllocator<A>,
K, V>
 
   @Override
   public void registerAutoReclaim() {
-    holder.registerAutoReclaim();
+    this.registerAutoReclaim(null);
+  }
+
+  @Override
+  public void registerAutoReclaim(ReclaimContext rctx) {
+    holder.registerAutoReclaim(rctx);
     autoReclaim = true;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashSetImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashSetImpl.java
b/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashSetImpl.java
index fa0bec5..11fb695 100644
--- a/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashSetImpl.java
+++ b/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableHashSetImpl.java
@@ -27,6 +27,7 @@ import org.apache.mnemonic.RetrieveDurableEntityError;
 import org.apache.mnemonic.Utils;
 
 import org.apache.commons.lang3.ArrayUtils;
+import org.flowcomputing.commons.resgc.ReclaimContext;
 import sun.misc.Unsafe;
 import java.util.Iterator;
 
@@ -135,7 +136,12 @@ public class DurableHashSetImpl<A extends RestorableAllocator<A>,
E>
 
   @Override
   public void registerAutoReclaim() {
-    map.registerAutoReclaim();
+    this.registerAutoReclaim(null);
+  }
+
+  @Override
+  public void registerAutoReclaim(ReclaimContext rctx) {
+    map.registerAutoReclaim(rctx);
     autoReclaim = true;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableTreeImpl.java
----------------------------------------------------------------------
diff --git a/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableTreeImpl.java
b/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableTreeImpl.java
index b345e9f..df70ff4 100644
--- a/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableTreeImpl.java
+++ b/mnemonic-collections/src/main/java/org/apache/mnemonic/collections/DurableTreeImpl.java
@@ -27,6 +27,7 @@ import org.apache.mnemonic.RestoreDurableEntityError;
 import org.apache.mnemonic.RetrieveDurableEntityError;
 import org.apache.mnemonic.Utils;
 
+import org.flowcomputing.commons.resgc.ReclaimContext;
 import sun.misc.Unsafe;
 
 @SuppressWarnings("restriction")
@@ -545,6 +546,11 @@ public class DurableTreeImpl<A extends RestorableAllocator<A>,
E extends Compara
 
   @Override
   public void registerAutoReclaim() {
+    this.registerAutoReclaim(null);
+  }
+
+  @Override
+  public void registerAutoReclaim(ReclaimContext rctx) {
     autoReclaim = true;
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-core/src/main/java/org/apache/mnemonic/Allocatable.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/Allocatable.java b/mnemonic-core/src/main/java/org/apache/mnemonic/Allocatable.java
index 2fec5c8..9b81c2d 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/Allocatable.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/Allocatable.java
@@ -17,6 +17,10 @@
 
 package org.apache.mnemonic;
 
+import org.flowcomputing.commons.resgc.ReclaimContext;
+
+import java.nio.ByteBuffer;
+
 /**
  * an interface to allocate memory resources from any underlying memory kind of
  * storage.
@@ -75,7 +79,18 @@ public interface Allocatable<A extends CommonAllocator<A>>
{
    *
    * @param mholder
    *          specify a chunk holder to register
+   *
+   * @param rctx
+   *          specify a reclaim context
    */
+  void registerChunkAutoReclaim(MemChunkHolder<A> mholder, ReclaimContext<Long>
rctx);
+
+    /**
+     * register a memory chunk for auto-reclaim
+     *
+     * @param mholder
+     *          specify a chunk holder to register
+     */
   void registerChunkAutoReclaim(MemChunkHolder<A> mholder);
 
   /**
@@ -83,6 +98,17 @@ public interface Allocatable<A extends CommonAllocator<A>>
{
    *
    * @param mholder
    *          specify a buffer holder to register
+   *
+   * @param rctx
+   *          specify a reclaim context
+   */
+  void registerBufferAutoReclaim(MemBufferHolder<A> mholder, ReclaimContext<ByteBuffer>
rctx);
+
+  /**
+   * register a memory buffer for auto-reclaim
+   *
+   * @param mholder
+   *          specify a buffer holder to register
    */
   void registerBufferAutoReclaim(MemBufferHolder<A> mholder);
 

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-core/src/main/java/org/apache/mnemonic/AnnotatedDurableEntityClass.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/AnnotatedDurableEntityClass.java
b/mnemonic-core/src/main/java/org/apache/mnemonic/AnnotatedDurableEntityClass.java
index 6717ba9..87b45f4 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/AnnotatedDurableEntityClass.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/AnnotatedDurableEntityClass.java
@@ -113,7 +113,7 @@ public class AnnotatedDurableEntityClass {
   private Map<String, FieldInfo> m_dynfieldsinfo = new HashMap<String, FieldInfo>();
   private Map<String, FieldInfo> m_fieldsinfo = new HashMap<String, FieldInfo>();
 
-  private Map<String, MethodInfo> m_durablemtdinfo = new HashMap<String, MethodInfo>();
+  private Map<String, List<MethodInfo>> m_durablemtdinfo = new HashMap<String,
List<MethodInfo>>();
   private Map<String, MethodInfo> m_entitymtdinfo = new HashMap<String, MethodInfo>();
 
   private long computeTypeSize(TypeName tname) throws AnnotationProcessingException {
@@ -182,15 +182,15 @@ public class AnnotatedDurableEntityClass {
     m_factoryname = String.format("%s%s", m_elem.getSimpleName(), cFACTORYNAMESUFFIX);
     m_entityname = String.format("%s%s_%s", cPMEMNAMEPREFIX, m_elem.getSimpleName(), Utils.genRandomString());
 
-    m_durablemtdinfo.put("cancelAutoReclaim", new MethodInfo());
-    m_durablemtdinfo.put("registerAutoReclaim", new MethodInfo());
-    m_durablemtdinfo.put("getHandler", new MethodInfo());
-    m_durablemtdinfo.put("autoReclaim", new MethodInfo());
-    m_durablemtdinfo.put("destroy", new MethodInfo());
-    m_durablemtdinfo.put("sync", new MethodInfo());
-    m_durablemtdinfo.put("persist", new MethodInfo());
-    m_durablemtdinfo.put("flush", new MethodInfo());
-    m_durablemtdinfo.put("getNativeFieldInfo", new MethodInfo());
+    m_durablemtdinfo.put("cancelAutoReclaim", new ArrayList<MethodInfo>());
+    m_durablemtdinfo.put("registerAutoReclaim", new ArrayList<MethodInfo>());
+    m_durablemtdinfo.put("getHandler", new ArrayList<MethodInfo>());
+    m_durablemtdinfo.put("autoReclaim", new ArrayList<MethodInfo>());
+    m_durablemtdinfo.put("destroy", new ArrayList<MethodInfo>());
+    m_durablemtdinfo.put("sync", new ArrayList<MethodInfo>());
+    m_durablemtdinfo.put("persist", new ArrayList<MethodInfo>());
+    m_durablemtdinfo.put("flush", new ArrayList<MethodInfo>());
+    m_durablemtdinfo.put("getNativeFieldInfo", new ArrayList<MethodInfo>());
 
     m_entitymtdinfo.put("initializeDurableEntity", new MethodInfo());
     m_entitymtdinfo.put("createDurableEntity", new MethodInfo());
@@ -327,7 +327,8 @@ public class AnnotatedDurableEntityClass {
         methodname = elem.getSimpleName().toString();
         if (m_durablemtdinfo.containsKey(methodname)) {
           // System.err.printf("**++++++++++ %s ======\n", methodname);
-          methodinfo = m_durablemtdinfo.get(methodname);
+          methodinfo = new MethodInfo();
+          m_durablemtdinfo.get(methodname).add(methodinfo);
           methodinfo.elem = (ExecutableElement) elem;
           methodinfo.specbuilder = MethodSpec.overriding(methodinfo.elem);
         }
@@ -713,74 +714,79 @@ public class AnnotatedDurableEntityClass {
   }
 
   protected void buildDurableMethodSpecs(TypeSpec.Builder typespecbuilder) throws AnnotationProcessingException
{
-    MethodInfo methodinfo;
     CodeBlock.Builder code;
     FieldInfo dynfieldinfo;
     String holdername = m_fieldsinfo.get("holder").name;
     String allocname = m_fieldsinfo.get("allocator").name;
     String autoreclaimname = m_fieldsinfo.get("autoreclaim").name;
     for (String name : m_durablemtdinfo.keySet()) {
-      methodinfo = m_durablemtdinfo.get(name);
-      code = CodeBlock.builder();
-      switch (name) {
-      case "cancelAutoReclaim":
-        code.addStatement("$1N.cancelAutoReclaim()", holdername);
-        for (String fname : m_dynfieldsinfo.keySet()) {
-          dynfieldinfo = m_dynfieldsinfo.get(fname);
-          if (!isUnboxPrimitive(dynfieldinfo.type)) {
-            code.beginControlFlow("if (null != $1N)", dynfieldinfo.name);
-            code.addStatement("$1N.cancelAutoReclaim()", dynfieldinfo.name);
-            code.endControlFlow();
-          }
+      for (MethodInfo methodinfo : m_durablemtdinfo.get(name)) {
+        code = CodeBlock.builder();
+        switch (name) {
+          case "cancelAutoReclaim":
+            code.addStatement("$1N.cancelAutoReclaim()", holdername);
+            for (String fname : m_dynfieldsinfo.keySet()) {
+              dynfieldinfo = m_dynfieldsinfo.get(fname);
+              if (!isUnboxPrimitive(dynfieldinfo.type)) {
+                code.beginControlFlow("if (null != $1N)", dynfieldinfo.name);
+                code.addStatement("$1N.cancelAutoReclaim()", dynfieldinfo.name);
+                code.endControlFlow();
+              }
+            }
+            code.addStatement("$1N = false", autoreclaimname);
+            break;
+          case "registerAutoReclaim":
+            if (methodinfo.elem.asType().toString().contains("ReclaimContext")) {
+              VariableElement arg0 = methodinfo.elem.getParameters().get(0);
+              code.addStatement("$1N.registerAutoReclaim($2L)", holdername, arg0);
+              for (String fname : m_dynfieldsinfo.keySet()) {
+                dynfieldinfo = m_dynfieldsinfo.get(fname);
+                if (!isUnboxPrimitive(dynfieldinfo.type)) {
+                  code.beginControlFlow("if (null != $1N)", dynfieldinfo.name);
+                  code.addStatement("$1N.registerAutoReclaim($2L)", dynfieldinfo.name, arg0);
+                  code.endControlFlow();
+                }
+              }
+              code.addStatement("$1N = true", autoreclaimname);
+            } else {
+              code.addStatement("this.registerAutoReclaim(null)");
+            }
+            break;
+          case "getHandler":
+            code.addStatement("return $1N.getChunkHandler($2N)", allocname, holdername);
+            break;
+          case "autoReclaim":
+            code.addStatement("return $1N", autoreclaimname);
+            break;
+          case "sync":
+            code.addStatement("$1N.sync()", holdername);
+            break;
+          case "persist":
+            code.addStatement("$1N.persist()", holdername);
+            break;
+          case "flush":
+            code.addStatement("$1N.flush()", holdername);
+            break;
+          case "destroy":
+            for (String fname : m_dynfieldsinfo.keySet()) {
+              dynfieldinfo = m_dynfieldsinfo.get(fname);
+              if (!isUnboxPrimitive(dynfieldinfo.type)) {
+                code.beginControlFlow("if (null != $1N)", dynfieldinfo.name);
+                code.addStatement("$1N.destroy()", dynfieldinfo.name);
+                code.addStatement("$1N = null", dynfieldinfo.name);
+                code.endControlFlow();
+              }
+            }
+            code.addStatement("$1N.destroy()", holdername);
+            break;
+          case "getNativeFieldInfo":
+            code.addStatement("return $1N", m_fieldsinfo.get("nfieldinfo").name);
+            break;
+          default:
+            throw new AnnotationProcessingException(null, "Method %s is not supported.",
name);
         }
-        code.addStatement("$1N = false", autoreclaimname);
-        break;
-      case "registerAutoReclaim":
-        code.addStatement("$1N.registerAutoReclaim()", holdername);
-        for (String fname : m_dynfieldsinfo.keySet()) {
-          dynfieldinfo = m_dynfieldsinfo.get(fname);
-          if (!isUnboxPrimitive(dynfieldinfo.type)) {
-            code.beginControlFlow("if (null != $1N)", dynfieldinfo.name);
-            code.addStatement("$1N.registerAutoReclaim()", dynfieldinfo.name);
-            code.endControlFlow();
-          }
-        }
-        code.addStatement("$1N = true", autoreclaimname);
-        break;
-      case "getHandler":
-        code.addStatement("return $1N.getChunkHandler($2N)", allocname, holdername);
-        break;
-      case "autoReclaim":
-        code.addStatement("return $1N", autoreclaimname);
-        break;
-      case "sync":
-        code.addStatement("$1N.sync()", holdername);
-        break;
-      case "persist":
-        code.addStatement("$1N.persist()", holdername);
-        break;
-      case "flush":
-        code.addStatement("$1N.flush()", holdername);
-        break;
-      case "destroy":
-        for (String fname : m_dynfieldsinfo.keySet()) {
-          dynfieldinfo = m_dynfieldsinfo.get(fname);
-          if (!isUnboxPrimitive(dynfieldinfo.type)) {
-            code.beginControlFlow("if (null != $1N)", dynfieldinfo.name);
-            code.addStatement("$1N.destroy()", dynfieldinfo.name);
-            code.addStatement("$1N = null", dynfieldinfo.name);
-            code.endControlFlow();
-          }
-        }
-        code.addStatement("$1N.destroy()", holdername);
-        break;
-      case "getNativeFieldInfo":
-        code.addStatement("return $1N", m_fieldsinfo.get("nfieldinfo").name);
-        break;
-      default:
-        throw new AnnotationProcessingException(null, "Method %s is not supported.", name);
+        typespecbuilder.addMethod(methodinfo.specbuilder.addCode(code.build()).build());
       }
-      typespecbuilder.addMethod(methodinfo.specbuilder.addCode(code.build()).build());
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-core/src/main/java/org/apache/mnemonic/CommonAllocator.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/CommonAllocator.java b/mnemonic-core/src/main/java/org/apache/mnemonic/CommonAllocator.java
index 6738568..fed34d5 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/CommonAllocator.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/CommonAllocator.java
@@ -18,6 +18,7 @@
 package org.apache.mnemonic;
 
 import org.apache.mnemonic.service.memory.MemoryServiceFeature;
+import org.flowcomputing.commons.resgc.ReclaimContext;
 import org.flowcomputing.commons.resgc.ResCollector;
 
 import java.nio.ByteBuffer;
@@ -104,6 +105,20 @@ public abstract class CommonAllocator<A extends CommonAllocator<A>>
implements A
    *
    * @param mholder
    *          specify a chunk holder to register
+   *
+   * @param rctx
+   *          specify a reclaim context
+   */
+  @Override
+  public void registerChunkAutoReclaim(MemChunkHolder<A> mholder, ReclaimContext<Long>
rctx) {
+    m_chunkcollector.register(mholder, rctx);
+  }
+
+  /**
+   * register a memory chunk for auto-reclaim
+   *
+   * @param mholder
+   *          specify a chunk holder to register
    */
   @Override
   public void registerChunkAutoReclaim(MemChunkHolder<A> mholder) {
@@ -115,6 +130,20 @@ public abstract class CommonAllocator<A extends CommonAllocator<A>>
implements A
    *
    * @param mholder
    *          specify a buffer holder to register
+   *
+   * @param rctx
+   *          specify a reclaim context
+   */
+  @Override
+  public void registerBufferAutoReclaim(MemBufferHolder<A> mholder, ReclaimContext<ByteBuffer>
rctx) {
+    m_bufcollector.register(mholder, rctx);
+  }
+
+  /**
+   * register a memory buffer for auto-reclaim
+   *
+   * @param mholder
+   *          specify a buffer holder to register
    */
   @Override
   public void registerBufferAutoReclaim(MemBufferHolder<A> mholder) {

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-core/src/main/java/org/apache/mnemonic/Durable.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/Durable.java b/mnemonic-core/src/main/java/org/apache/mnemonic/Durable.java
index 8120c62..f24735f 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/Durable.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/Durable.java
@@ -17,6 +17,8 @@
 
 package org.apache.mnemonic;
 
+import org.flowcomputing.commons.resgc.ReclaimContext;
+
 /**
  * this interface defines the interactive functionalities with Mnenomic core
  * part.
@@ -67,6 +69,13 @@ public interface Durable {
   void registerAutoReclaim();
 
   /**
+   * this function could be called by user code to register this object
+   * with reclaim context for auto-reclaim
+   *
+   */
+  void registerAutoReclaim(ReclaimContext rctx);
+
+  /**
    * this function returns its bound handler for this object
    *
    * @return the handler of this object

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-core/src/main/java/org/apache/mnemonic/DurableBuffer.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/DurableBuffer.java b/mnemonic-core/src/main/java/org/apache/mnemonic/DurableBuffer.java
index 870e7cb..8542a4e 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/DurableBuffer.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/DurableBuffer.java
@@ -17,6 +17,8 @@
 
 package org.apache.mnemonic;
 
+import org.flowcomputing.commons.resgc.ReclaimContext;
+
 import java.nio.ByteBuffer;
 
 public class DurableBuffer<A extends RetrievableAllocator<A>> extends MemBufferHolder<A>
implements Durable {
@@ -42,6 +44,11 @@ public class DurableBuffer<A extends RetrievableAllocator<A>>
extends MemBufferH
   }
 
   @Override
+  public void registerAutoReclaim(ReclaimContext rctx) {
+    registerAutoReclaim(rctx);
+  }
+
+  @Override
   public long getHandler() {
     return m_allocator.getBufferHandler(this);
   }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-core/src/main/java/org/apache/mnemonic/DurableChunk.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/DurableChunk.java b/mnemonic-core/src/main/java/org/apache/mnemonic/DurableChunk.java
index ddd6870..f80b481 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/DurableChunk.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/DurableChunk.java
@@ -17,6 +17,8 @@
 
 package org.apache.mnemonic;
 
+import org.flowcomputing.commons.resgc.ReclaimContext;
+
 public class DurableChunk<A extends RetrievableAllocator<A>> extends MemChunkHolder<A>
implements Durable {
   protected Persistence<A> m_persistOps = null;
 
@@ -40,6 +42,11 @@ public class DurableChunk<A extends RetrievableAllocator<A>>
extends MemChunkHol
   }
 
   @Override
+  public void registerAutoReclaim(ReclaimContext rctx) {
+    registerAutoReclaim(rctx);
+  }
+
+  @Override
   public long getHandler() {
     return m_allocator.getChunkHandler(this);
   }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-core/src/main/java/org/apache/mnemonic/GenericField.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/GenericField.java b/mnemonic-core/src/main/java/org/apache/mnemonic/GenericField.java
index 6c417a5..b66da34 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/GenericField.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/GenericField.java
@@ -17,6 +17,7 @@
 
 package org.apache.mnemonic;
 
+import org.flowcomputing.commons.resgc.ReclaimContext;
 import sun.misc.Unsafe;
 
 /**
@@ -330,17 +331,22 @@ public class GenericField<A extends RestorableAllocator<A>,
E> implements Durabl
    */
   @Override
   public void registerAutoReclaim() {
+    registerAutoReclaim(null);
+  }
+
+  @Override
+  public void registerAutoReclaim(ReclaimContext rctx) {
     if (null != m_field) {
-      m_field.registerAutoReclaim();
+      m_field.registerAutoReclaim(rctx);
     }
     if (null != m_strfield) {
-      m_strfield.registerAutoReclaim();
+      m_strfield.registerAutoReclaim(rctx);
     }
     if (null != m_chunkfield) {
-      m_chunkfield.registerAutoReclaim();
+      m_chunkfield.registerAutoReclaim(rctx);
     }
     if (null != m_bufferfield) {
-      m_bufferfield.registerAutoReclaim();
+      m_bufferfield.registerAutoReclaim(rctx);
     }
     m_autoreclaim = true;
   }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-core/src/main/java/org/apache/mnemonic/MemBufferHolder.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/MemBufferHolder.java b/mnemonic-core/src/main/java/org/apache/mnemonic/MemBufferHolder.java
index c14ecc3..79e7f25 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/MemBufferHolder.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/MemBufferHolder.java
@@ -17,6 +17,8 @@
 
 package org.apache.mnemonic;
 
+import org.flowcomputing.commons.resgc.ReclaimContext;
+
 import java.nio.ByteBuffer;
 
 /**
@@ -69,4 +71,15 @@ public class MemBufferHolder<A extends CommonAllocator<A>>
extends MemHolder<A,
     m_allocator.registerBufferAutoReclaim(this);
   }
 
+  /**
+   * register its held buffer for auto-reclaim
+   *
+   * @param rctx
+   *          specify a reclaim context to register
+   */
+  @Override
+  public void registerAutoReclaim(ReclaimContext<ByteBuffer> rctx) {
+    m_allocator.registerBufferAutoReclaim(this, rctx);
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-core/src/main/java/org/apache/mnemonic/MemChunkHolder.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/MemChunkHolder.java b/mnemonic-core/src/main/java/org/apache/mnemonic/MemChunkHolder.java
index 308539f..71d06d1 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/MemChunkHolder.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/MemChunkHolder.java
@@ -17,6 +17,8 @@
 
 package org.apache.mnemonic;
 
+import org.flowcomputing.commons.resgc.ReclaimContext;
+
 /**
  * holder for a memory chunk.
  * 
@@ -72,4 +74,14 @@ public class MemChunkHolder<A extends CommonAllocator<A>> extends
MemHolder<A, L
     m_allocator.registerChunkAutoReclaim(this);
   }
 
+  /**
+   * register its held chunk for auto-reclaim
+   *
+   * @param rctx
+   *          specify a reclaim context to register
+   */
+  @Override
+  public void registerAutoReclaim(ReclaimContext<Long> rctx) {
+    m_allocator.registerChunkAutoReclaim(this, rctx);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/e9396570/mnemonic-core/src/main/java/org/apache/mnemonic/MemHolder.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/MemHolder.java b/mnemonic-core/src/main/java/org/apache/mnemonic/MemHolder.java
index cf702b8..d6fdcff 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/MemHolder.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/MemHolder.java
@@ -17,6 +17,7 @@
 
 package org.apache.mnemonic;
 
+import org.flowcomputing.commons.resgc.ReclaimContext;
 import org.flowcomputing.commons.resgc.ResHolder;
 
 /**
@@ -74,4 +75,11 @@ public abstract class MemHolder<A extends CommonAllocator<A>,
T, H extends MemHo
    */
   public abstract void registerAutoReclaim();
 
+  /**
+   * register its held resource for auto-reclaim
+   *
+   * @param rctx
+   *          specify a reclaim context to register
+   */
+  public abstract void registerAutoReclaim(ReclaimContext<T> rctx);
 }


Mime
View raw message