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-205: Adding Durable to resized memory allocations
Date Tue, 28 Feb 2017 22:41:57 GMT
Repository: incubator-mnemonic
Updated Branches:
  refs/heads/master 212cfe7e6 -> 2edeb55cf


MNEMONIC-205: Adding Durable to resized memory allocations


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

Branch: refs/heads/master
Commit: 2edeb55cfb8c084e47f5bb986761eaaa6f289a34
Parents: 212cfe7
Author: Johnu George <johnugeo@cisco.com>
Authored: Tue Feb 28 11:25:10 2017 -0800
Committer: Johnu George <johnugeo@cisco.com>
Committed: Tue Feb 28 14:33:19 2017 -0800

----------------------------------------------------------------------
 .../mnemonic/NonVolatileMemAllocator.java       | 16 +++++------
 .../apache/mnemonic/RetrievableAllocator.java   | 29 ++++++++++++++++++++
 .../apache/mnemonic/VolatileMemAllocator.java   | 16 +++++------
 3 files changed, 45 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/2edeb55c/mnemonic-core/src/main/java/org/apache/mnemonic/NonVolatileMemAllocator.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/NonVolatileMemAllocator.java
b/mnemonic-core/src/main/java/org/apache/mnemonic/NonVolatileMemAllocator.java
index 22df4e2..5896f90 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/NonVolatileMemAllocator.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/NonVolatileMemAllocator.java
@@ -160,12 +160,12 @@ public class NonVolatileMemAllocator extends RestorableAllocator<NonVolatileMemA
    * @param size
    *          specify a new size of memory chunk
    * 
-   * @return the resized memory chunk handler
+   * @return the resized durable memory chunk handler
    */
   @Override
-  public MemChunkHolder<NonVolatileMemAllocator> resizeChunk(MemChunkHolder<NonVolatileMemAllocator>
mholder,
+  public DurableChunk<NonVolatileMemAllocator> resizeChunk(MemChunkHolder<NonVolatileMemAllocator>
mholder,
       long size) {
-    MemChunkHolder<NonVolatileMemAllocator> ret = null;
+    DurableChunk<NonVolatileMemAllocator> ret = null;
     boolean ac = null != mholder.getRefId();
     if (size > 0) {
       Long addr = m_nvmasvc.reallocate(m_nid, mholder.get(), size, true);
@@ -176,7 +176,7 @@ public class NonVolatileMemAllocator extends RestorableAllocator<NonVolatileMemA
       if (0 != addr) {
         mholder.clear();
         mholder.destroy();
-        ret = new MemChunkHolder<NonVolatileMemAllocator>(this, addr, size);
+        ret = new DurableChunk<NonVolatileMemAllocator>(this, addr, size);
         if (ac) {
           m_chunkcollector.register(ret);
         }
@@ -194,13 +194,13 @@ public class NonVolatileMemAllocator extends RestorableAllocator<NonVolatileMemA
    * @param size
    *          specify a new size of memory chunk
    * 
-   * @return the resized memory buffer handler
+   * @return the resized durable memory buffer handler
    *
    */
   @Override
-  public MemBufferHolder<NonVolatileMemAllocator> resizeBuffer(MemBufferHolder<NonVolatileMemAllocator>
mholder,
+  public DurableBuffer<NonVolatileMemAllocator> resizeBuffer(MemBufferHolder<NonVolatileMemAllocator>
mholder,
       long size) {
-    MemBufferHolder<NonVolatileMemAllocator> ret = null;
+    DurableBuffer<NonVolatileMemAllocator> ret = null;
     boolean ac = null != mholder.getRefId();
     if (size > 0) {
       int bufpos = mholder.get().position();
@@ -215,7 +215,7 @@ public class NonVolatileMemAllocator extends RestorableAllocator<NonVolatileMemA
         mholder.destroy();
         buf.position(bufpos <= size ? bufpos : 0);
         buf.limit(buflimit <= size ? buflimit : (int) size);
-        ret = new MemBufferHolder<NonVolatileMemAllocator>(this, buf);
+        ret = new DurableBuffer<NonVolatileMemAllocator>(this, buf);
         if (ac) {
           m_bufcollector.register(ret);
         }

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/2edeb55c/mnemonic-core/src/main/java/org/apache/mnemonic/RetrievableAllocator.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/RetrievableAllocator.java b/mnemonic-core/src/main/java/org/apache/mnemonic/RetrievableAllocator.java
index ed2fdec..f24843f 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/RetrievableAllocator.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/RetrievableAllocator.java
@@ -127,6 +127,35 @@ public abstract class RetrievableAllocator<A extends RetrievableAllocator<A>>
ex
   public abstract DurableChunk<A> retrieveChunk(long phandler, boolean autoreclaim);
 
   /**
+   * re-size a specified chunk on its backed memory pool.
+   * 
+   * @param mholder
+   *          the holder of memory chunk.
+   *
+   * @param size
+   *         specify a new size of memory chunk
+   *
+   * @return the resized durable memory chunk handler
+   */
+  @Override
+  public abstract DurableChunk<A> resizeChunk(MemChunkHolder<A> mholder, long
size);
+
+  /**
+   * resize a specified buffer on its backed memory pool.
+   *
+   * @param mholder
+   *          the holder of memory buffer. it can be null.
+   * 
+   * @param size
+   *          specify a new size of memory chunk
+   * 
+   * @return the resized durable memory buffer handler
+   *
+   */
+  @Override
+  public abstract DurableBuffer<A> resizeBuffer(MemBufferHolder<A> mholder, long
size);
+
+  /**
    * get the address from a memory buffer holder.
    * 
    * @param mbuf

http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/2edeb55c/mnemonic-core/src/main/java/org/apache/mnemonic/VolatileMemAllocator.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/VolatileMemAllocator.java b/mnemonic-core/src/main/java/org/apache/mnemonic/VolatileMemAllocator.java
index f3af5ff..e4c04cc 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/VolatileMemAllocator.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/VolatileMemAllocator.java
@@ -156,11 +156,11 @@ public class VolatileMemAllocator extends RestorableAllocator<VolatileMemAllocat
    * @param size
    *          specify a new size of memory chunk
    * 
-   * @return the resized memory chunk handler
+   * @return the resized durable memory chunk handler
    */
   @Override
-  public MemChunkHolder<VolatileMemAllocator> resizeChunk(MemChunkHolder<VolatileMemAllocator>
mholder, long size) {
-    MemChunkHolder<VolatileMemAllocator> ret = null;
+  public DurableChunk<VolatileMemAllocator> resizeChunk(MemChunkHolder<VolatileMemAllocator>
mholder, long size) {
+    DurableChunk<VolatileMemAllocator> ret = null;
     boolean ac = null != mholder.getRefId();
     if (size > 0) {
       Long addr = m_vmasvc.reallocate(m_nid, mholder.get(), size, true);
@@ -171,7 +171,7 @@ public class VolatileMemAllocator extends RestorableAllocator<VolatileMemAllocat
       if (0 != addr) {
         mholder.clear();
         mholder.destroy();
-        ret = new MemChunkHolder<VolatileMemAllocator>(this, addr, size);
+        ret = new DurableChunk<VolatileMemAllocator>(this, addr, size);
         if (ac) {
           m_chunkcollector.register(ret);
         }
@@ -189,12 +189,12 @@ public class VolatileMemAllocator extends RestorableAllocator<VolatileMemAllocat
    * @param size
    *          specify a new size of memory chunk
    * 
-   * @return the resized memory buffer handler
+   * @return the resized durable memory buffer handler
    *
    */
   @Override
-  public MemBufferHolder<VolatileMemAllocator> resizeBuffer(MemBufferHolder<VolatileMemAllocator>
mholder, long size) {
-    MemBufferHolder<VolatileMemAllocator> ret = null;
+  public DurableBuffer<VolatileMemAllocator> resizeBuffer(MemBufferHolder<VolatileMemAllocator>
mholder, long size) {
+    DurableBuffer<VolatileMemAllocator> ret = null;
     boolean ac = null != mholder.getRefId();
     if (size > 0) {
       int bufpos = mholder.get().position();
@@ -209,7 +209,7 @@ public class VolatileMemAllocator extends RestorableAllocator<VolatileMemAllocat
         mholder.destroy();
         buf.position(bufpos <= size ? bufpos : 0);
         buf.limit(buflimit <= size ? buflimit : (int) size);
-        ret = new MemBufferHolder<VolatileMemAllocator>(this, buf);
+        ret = new DurableBuffer<VolatileMemAllocator>(this, buf);
         if (ac) {
           m_bufcollector.register(ret);
         }


Mime
View raw message