You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mnemonic.apache.org by ga...@apache.org on 2017/10/06 19:27:51 UTC
incubator-mnemonic git commit: MNEMONIC-383: Add missing reclaim
context parameters to allocators
Repository: incubator-mnemonic
Updated Branches:
refs/heads/master e93965705 -> 70a9c0f46
MNEMONIC-383: Add missing reclaim context parameters to allocators
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/70a9c0f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/70a9c0f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/70a9c0f4
Branch: refs/heads/master
Commit: 70a9c0f46594f7ea02cbf2198f10dff9b8706dd7
Parents: e939657
Author: Wang, Gang(Gary) <ga...@intel.com>
Authored: Fri Oct 6 11:44:34 2017 -0700
Committer: Wang, Gang(Gary) <ga...@intel.com>
Committed: Fri Oct 6 11:44:34 2017 -0700
----------------------------------------------------------------------
.../java/org/apache/mnemonic/Allocatable.java | 44 ++++++-
.../org/apache/mnemonic/CommonAllocator.java | 36 +++++-
.../java/org/apache/mnemonic/DurableBuffer.java | 2 +-
.../java/org/apache/mnemonic/DurableChunk.java | 2 +-
.../mnemonic/NonVolatileMemAllocator.java | 36 ++++--
.../apache/mnemonic/RetrievableAllocator.java | 116 +++++++++++++++----
.../org/apache/mnemonic/SysMemAllocator.java | 18 ++-
.../apache/mnemonic/VolatileMemAllocator.java | 36 ++++--
8 files changed, 235 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/70a9c0f4/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 9b81c2d..3ea7093 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/Allocatable.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/Allocatable.java
@@ -30,10 +30,20 @@ public interface Allocatable<A extends CommonAllocator<A>> {
/**
* create a memory chunk that is managed by its holder.
- *
+ *
* @param size
* specify the size of memory chunk
- *
+ *
+ * @return a holder contains a memory chunk
+ */
+ MemChunkHolder<A> createChunk(long size);
+
+ /**
+ * create a memory chunk that is managed by its holder.
+ *
+ * @param size
+ * specify the size of memory chunk
+ *
* @param autoreclaim
* specify whether or not to reclaim this chunk automatically
*
@@ -47,16 +57,32 @@ public interface Allocatable<A extends CommonAllocator<A>> {
* @param size
* specify the size of memory chunk
*
+ * @param autoreclaim
+ * specify whether or not to reclaim this chunk automatically
+ *
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a holder contains a memory chunk
*/
- MemChunkHolder<A> createChunk(long size);
+ MemChunkHolder<A> createChunk(long size, boolean autoreclaim, ReclaimContext<Long> rctx);
/**
* create a memory buffer that is managed by its holder.
- *
+ *
* @param size
* specify the size of memory buffer
- *
+ *
+ * @return a holder contains a memory buffer
+ */
+ MemBufferHolder<A> createBuffer(long size);
+
+ /**
+ * create a memory buffer that is managed by its holder.
+ *
+ * @param size
+ * specify the size of memory buffer
+ *
* @param autoreclaim
* specify whether or not to reclaim this buffer automatically
*
@@ -70,9 +96,15 @@ public interface Allocatable<A extends CommonAllocator<A>> {
* @param size
* specify the size of memory buffer
*
+ * @param autoreclaim
+ * specify whether or not to reclaim this buffer automatically
+ *
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a holder contains a memory buffer
*/
- MemBufferHolder<A> createBuffer(long size);
+ MemBufferHolder<A> createBuffer(long size, boolean autoreclaim, ReclaimContext<ByteBuffer> rctx);
/**
* register a memory chunk for auto-reclaim
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/70a9c0f4/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 fed34d5..5325d86 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/CommonAllocator.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/CommonAllocator.java
@@ -88,11 +88,27 @@ public abstract class CommonAllocator<A extends CommonAllocator<A>> implements A
}
/**
+ * create a memory chunk that is managed by its holder.
+ *
+ * @param size
+ * specify the size of memory chunk
+ *
+ * @param autoreclaim
+ * specify whether or not to reclaim this chunk automatically
+ *
+ * @return a holder contains a memory chunk
+ */
+ @Override
+ public MemChunkHolder<A> createChunk(long size, boolean autoreclaim) {
+ return createChunk(size, autoreclaim, null);
+ }
+
+ /**
* create a memory buffer that is managed by its holder.
- *
+ *
* @param size
* specify the size of memory buffer
- *
+ *
* @return a holder contains a memory buffer
*/
@Override
@@ -101,6 +117,22 @@ public abstract class CommonAllocator<A extends CommonAllocator<A>> implements A
}
/**
+ * create a memory buffer that is managed by its holder.
+ *
+ * @param size
+ * specify the size of memory buffer
+ *
+ * @param autoreclaim
+ * specify whether or not to reclaim this chunk automatically
+ *
+ * @return a holder contains a memory buffer
+ */
+ @Override
+ public MemBufferHolder<A> createBuffer(long size, boolean autoreclaim) {
+ return createBuffer(size, autoreclaim, null);
+ }
+
+ /**
* register a memory chunk for auto-reclaim
*
* @param mholder
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/70a9c0f4/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 8542a4e..dd2e0ee 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/DurableBuffer.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/DurableBuffer.java
@@ -45,7 +45,7 @@ public class DurableBuffer<A extends RetrievableAllocator<A>> extends MemBufferH
@Override
public void registerAutoReclaim(ReclaimContext rctx) {
- registerAutoReclaim(rctx);
+ super.registerAutoReclaim(rctx);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/70a9c0f4/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 f80b481..e66c8a5 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/DurableChunk.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/DurableChunk.java
@@ -43,7 +43,7 @@ public class DurableChunk<A extends RetrievableAllocator<A>> extends MemChunkHol
@Override
public void registerAutoReclaim(ReclaimContext rctx) {
- registerAutoReclaim(rctx);
+ super.registerAutoReclaim(rctx);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/70a9c0f4/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 c00b0f3..8d8f7bc 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/NonVolatileMemAllocator.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/NonVolatileMemAllocator.java
@@ -253,10 +253,14 @@ public class NonVolatileMemAllocator extends RestorableAllocator<NonVolatileMemA
* @param autoreclaim
* specify whether or not to reclaim this chunk automatically
*
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a durable chunk contains a memory chunk
*/
@Override
- public DurableChunk<NonVolatileMemAllocator> createChunk(long size, boolean autoreclaim) {
+ public DurableChunk<NonVolatileMemAllocator> createChunk(long size, boolean autoreclaim,
+ ReclaimContext<Long> rctx) {
DurableChunk<NonVolatileMemAllocator> ret = null;
Long addr = m_nvmasvc.allocate(m_nid, size, true);
if ((null == addr || 0 == addr) && m_activegc) {
@@ -267,7 +271,7 @@ public class NonVolatileMemAllocator extends RestorableAllocator<NonVolatileMemA
ret = new DurableChunk<NonVolatileMemAllocator>(this, addr, size);
ret.setCollector(m_chunkcollector);
if (autoreclaim) {
- m_chunkcollector.register(ret);
+ m_chunkcollector.register(ret, rctx);
}
}
return ret;
@@ -282,10 +286,14 @@ public class NonVolatileMemAllocator extends RestorableAllocator<NonVolatileMemA
* @param autoreclaim
* specify whether or not to reclaim this buffer automatically
*
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a durable buffer contains a memory buffer
*/
@Override
- public DurableBuffer<NonVolatileMemAllocator> createBuffer(long size, boolean autoreclaim) {
+ public DurableBuffer<NonVolatileMemAllocator> createBuffer(long size, boolean autoreclaim,
+ ReclaimContext<ByteBuffer> rctx) {
DurableBuffer<NonVolatileMemAllocator> ret = null;
ByteBuffer bb = m_nvmasvc.createByteBuffer(m_nid, size);
if (null == bb && m_activegc) {
@@ -296,7 +304,7 @@ public class NonVolatileMemAllocator extends RestorableAllocator<NonVolatileMemA
ret = new DurableBuffer<NonVolatileMemAllocator>(this, bb);
ret.setCollector(m_bufcollector);
if (autoreclaim) {
- m_bufcollector.register(ret);
+ m_bufcollector.register(ret, rctx);
}
}
return ret;
@@ -311,18 +319,22 @@ public class NonVolatileMemAllocator extends RestorableAllocator<NonVolatileMemA
* @param autoreclaim
* specify whether this retrieved memory buffer can be reclaimed
* automatically or not
- *
+ *
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a durable buffer contains the retrieved memory buffer
*/
@Override
- public DurableBuffer<NonVolatileMemAllocator> retrieveBuffer(long phandler, boolean autoreclaim) {
+ public DurableBuffer<NonVolatileMemAllocator> retrieveBuffer(long phandler, boolean autoreclaim,
+ ReclaimContext<ByteBuffer> rctx) {
DurableBuffer<NonVolatileMemAllocator> ret = null;
ByteBuffer bb = m_nvmasvc.retrieveByteBuffer(m_nid, getEffectiveAddress(phandler));
if (null != bb) {
ret = new DurableBuffer<NonVolatileMemAllocator>(this, bb);
ret.setCollector(m_bufcollector);
if (autoreclaim) {
- m_bufcollector.register(ret);
+ m_bufcollector.register(ret, rctx);
}
}
return ret;
@@ -337,11 +349,15 @@ public class NonVolatileMemAllocator extends RestorableAllocator<NonVolatileMemA
* @param autoreclaim
* specify whether this retrieved memory chunk can be reclaimed
* automatically or not
- *
+ *
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a durable chunk contains the retrieved memory chunk
*/
@Override
- public DurableChunk<NonVolatileMemAllocator> retrieveChunk(long phandler, boolean autoreclaim) {
+ public DurableChunk<NonVolatileMemAllocator> retrieveChunk(long phandler, boolean autoreclaim,
+ ReclaimContext<Long> rctx) {
DurableChunk<NonVolatileMemAllocator> ret = null;
long eaddr = getEffectiveAddress(phandler);
long sz = m_nvmasvc.retrieveSize(m_nid, eaddr);
@@ -349,7 +365,7 @@ public class NonVolatileMemAllocator extends RestorableAllocator<NonVolatileMemA
ret = new DurableChunk<NonVolatileMemAllocator>(this, eaddr, sz);
ret.setCollector(m_chunkcollector);
if (autoreclaim) {
- m_chunkcollector.register(ret);
+ m_chunkcollector.register(ret, rctx);
}
}
return ret;
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/70a9c0f4/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 f24843f..fd30dc4 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/RetrievableAllocator.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/RetrievableAllocator.java
@@ -17,6 +17,10 @@
package org.apache.mnemonic;
+import org.flowcomputing.commons.resgc.ReclaimContext;
+
+import java.nio.ByteBuffer;
+
public abstract class RetrievableAllocator<A extends RetrievableAllocator<A>> extends CommonAllocator<A>
implements AddressTranslator, HandlerStore, Transaction {
@@ -26,53 +30,87 @@ public abstract class RetrievableAllocator<A extends RetrievableAllocator<A>> ex
* @param size
* specify the size of memory chunk
*
+ * @return a durable chunk contains a memory chunk
+ */
+ public DurableChunk<A> createChunk(long size) {
+ return createChunk(size, true);
+ }
+
+ /**
+ * create a durable chunk that is managed by its holder.
+ *
+ * @param size
+ * specify the size of memory chunk
+ *
* @param autoreclaim
* specify whether or not to reclaim this chunk automatically
*
* @return a durable chunk contains a memory chunk
*/
+ public DurableChunk<A> createChunk(long size, boolean autoreclaim) {
+ return createChunk(size, autoreclaim, null);
+ }
+
+ /**
+ * create a durable chunk that is managed by its holder.
+ *
+ * @param size
+ * specify the size of memory chunk
+ *
+ * @param autoreclaim
+ * specify whether or not to reclaim this chunk automatically
+ *
+ * @param rctx
+ * specify a reclaim context
+ *
+ * @return a durable chunk contains a memory chunk
+ */
@Override
- public abstract DurableChunk<A> createChunk(long size, boolean autoreclaim);
+ public abstract DurableChunk<A> createChunk(long size, boolean autoreclaim, ReclaimContext<Long> rctx);
/**
* create a durable buffer that is managed by its holder.
- *
+ *
* @param size
* specify the size of memory buffer
- *
- * @param autoreclaim
- * specify whether or not to reclaim this buffer automatically
*
* @return a durable buffer contains a memory buffer
*/
- @Override
- public abstract DurableBuffer<A> createBuffer(long size, boolean autoreclaim);
+ public DurableBuffer<A> createBuffer(long size) {
+ return createBuffer(size, true);
+ }
/**
- * create a durable chunk that is managed by its holder.
+ * create a durable buffer that is managed by its holder.
*
* @param size
- * specify the size of memory chunk
+ * specify the size of memory buffer
*
- * @return a durable chunk contains a memory chunk
+ * @param autoreclaim
+ * specify whether or not to reclaim this buffer automatically
+ *
+ * @return a durable buffer contains a memory buffer
*/
- @Override
- public DurableChunk<A> createChunk(long size) {
- return createChunk(size, true);
+ public DurableBuffer<A> createBuffer(long size, boolean autoreclaim) {
+ return createBuffer(size, autoreclaim, null);
}
/**
* create a durable buffer that is managed by its holder.
- *
+ *
* @param size
* specify the size of memory buffer
- *
+ *
+ * @param autoreclaim
+ * specify whether or not to reclaim this buffer automatically
+ *
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a durable buffer contains a memory buffer
*/
@Override
- public DurableBuffer<A> createBuffer(long size) {
- return createBuffer(size, true);
- }
+ public abstract DurableBuffer<A> createBuffer(long size, boolean autoreclaim, ReclaimContext<ByteBuffer> rctx);
/**
* retrieve a memory buffer from its backed memory allocator.
@@ -110,7 +148,9 @@ public abstract class RetrievableAllocator<A extends RetrievableAllocator<A>> ex
*
* @return a durable buffer contains the retrieved memory buffer
*/
- public abstract DurableBuffer<A> retrieveBuffer(long phandler, boolean autoreclaim);
+ public DurableBuffer<A> retrieveBuffer(long phandler, boolean autoreclaim) {
+ return retrieveBuffer(phandler, autoreclaim, null);
+ }
/**
* retrieve a memory chunk from its backed memory allocator.
@@ -124,7 +164,43 @@ public abstract class RetrievableAllocator<A extends RetrievableAllocator<A>> ex
*
* @return a durable chunk contains the retrieved memory chunk
*/
- public abstract DurableChunk<A> retrieveChunk(long phandler, boolean autoreclaim);
+ public DurableChunk<A> retrieveChunk(long phandler, boolean autoreclaim) {
+ return retrieveChunk(phandler, autoreclaim, null);
+ }
+
+ /**
+ * retrieve a memory buffer from its backed memory allocator.
+ *
+ * @param phandler
+ * specify the handler of memory buffer to retrieve
+ *
+ * @param autoreclaim
+ * specify whether this retrieved memory buffer can be reclaimed
+ * automatically or not
+ *
+ * @param rctx
+ * specify a reclaim context
+ *
+ * @return a durable buffer contains the retrieved memory buffer
+ */
+ public abstract DurableBuffer<A> retrieveBuffer(long phandler, boolean autoreclaim, ReclaimContext<ByteBuffer> rctx);
+
+ /**
+ * retrieve a memory chunk from its backed memory allocator.
+ *
+ * @param phandler
+ * specify the handler of memory chunk to retrieve
+ *
+ * @param autoreclaim
+ * specify whether this retrieved memory chunk can be reclaimed
+ * automatically or not
+ *
+ * @param rctx
+ * specify a reclaim context
+ *
+ * @return a durable chunk contains the retrieved memory chunk
+ */
+ public abstract DurableChunk<A> retrieveChunk(long phandler, boolean autoreclaim, ReclaimContext<Long> rctx);
/**
* re-size a specified chunk on its backed memory pool.
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/70a9c0f4/mnemonic-core/src/main/java/org/apache/mnemonic/SysMemAllocator.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/SysMemAllocator.java b/mnemonic-core/src/main/java/org/apache/mnemonic/SysMemAllocator.java
index 2867cf3..827b704 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/SysMemAllocator.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/SysMemAllocator.java
@@ -282,10 +282,14 @@ public class SysMemAllocator extends CommonAllocator<SysMemAllocator> {
* @param autoreclaim
* specify whether or not to reclaim this chunk automatically
*
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a holder contains a memory chunk
*/
@Override
- public MemChunkHolder<SysMemAllocator> createChunk(long size, boolean autoreclaim) {
+ public MemChunkHolder<SysMemAllocator> createChunk(long size, boolean autoreclaim,
+ ReclaimContext<Long> rctx) {
MemChunkHolder<SysMemAllocator> ret = null;
Long addr = null;
if (currentMemory.get() + size > maxStoreCapacity) {
@@ -300,7 +304,7 @@ public class SysMemAllocator extends CommonAllocator<SysMemAllocator> {
ret = new MemChunkHolder<SysMemAllocator>(this, addr, size);
ret.setCollector(m_chunkcollector);
if (autoreclaim) {
- m_chunkcollector.register(ret);
+ m_chunkcollector.register(ret, rctx);
}
m_chunksize.put(addr, size);
currentMemory.getAndAdd(size);
@@ -313,11 +317,15 @@ public class SysMemAllocator extends CommonAllocator<SysMemAllocator> {
*
* @param size
* specify the size of memory buffer
- *
+ *
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a holder contains a memory buffer
*/
@Override
- public MemBufferHolder<SysMemAllocator> createBuffer(long size, boolean autoreclaim) {
+ public MemBufferHolder<SysMemAllocator> createBuffer(long size, boolean autoreclaim,
+ ReclaimContext<ByteBuffer> rctx) {
MemBufferHolder<SysMemAllocator> ret = null;
ByteBuffer bb = null;
if (currentMemory.get() + size > maxStoreCapacity) {
@@ -332,7 +340,7 @@ public class SysMemAllocator extends CommonAllocator<SysMemAllocator> {
ret = new MemBufferHolder<SysMemAllocator>(this, bb);
ret.setCollector(m_bufcollector);
if (autoreclaim) {
- m_bufcollector.register(ret);
+ m_bufcollector.register(ret, rctx);
}
currentMemory.getAndAdd(size);
}
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/70a9c0f4/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 fde82b1..b54dfad 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/VolatileMemAllocator.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/VolatileMemAllocator.java
@@ -256,10 +256,14 @@ public class VolatileMemAllocator extends RestorableAllocator<VolatileMemAllocat
* @param autoreclaim
* specify whether or not to reclaim this chunk automatically
*
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a durable chunk contains a memory chunk
*/
@Override
- public DurableChunk<VolatileMemAllocator> createChunk(long size, boolean autoreclaim) {
+ public DurableChunk<VolatileMemAllocator> createChunk(long size, boolean autoreclaim,
+ ReclaimContext<Long> rctx) {
DurableChunk<VolatileMemAllocator> ret = null;
Long addr = m_vmasvc.allocate(m_nid, size, true);
if (0 == addr && m_activegc) {
@@ -270,7 +274,7 @@ public class VolatileMemAllocator extends RestorableAllocator<VolatileMemAllocat
ret = new DurableChunk<VolatileMemAllocator>(this, addr, size);
ret.setCollector(m_chunkcollector);
if (autoreclaim) {
- m_chunkcollector.register(ret);
+ m_chunkcollector.register(ret, rctx);
}
}
return ret;
@@ -285,10 +289,14 @@ public class VolatileMemAllocator extends RestorableAllocator<VolatileMemAllocat
* @param autoreclaim
* specify whether or not to reclaim this buffer automatically
*
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a durable buffer contains a memory buffer
*/
@Override
- public DurableBuffer<VolatileMemAllocator> createBuffer(long size, boolean autoreclaim) {
+ public DurableBuffer<VolatileMemAllocator> createBuffer(long size, boolean autoreclaim,
+ ReclaimContext<ByteBuffer> rctx) {
DurableBuffer<VolatileMemAllocator> ret = null;
ByteBuffer bb = m_vmasvc.createByteBuffer(m_nid, size);
if (null == bb && m_activegc) {
@@ -299,7 +307,7 @@ public class VolatileMemAllocator extends RestorableAllocator<VolatileMemAllocat
ret = new DurableBuffer<VolatileMemAllocator>(this, bb);
ret.setCollector(m_bufcollector);
if (autoreclaim) {
- m_bufcollector.register(ret);
+ m_bufcollector.register(ret, rctx);
}
}
return ret;
@@ -314,17 +322,21 @@ public class VolatileMemAllocator extends RestorableAllocator<VolatileMemAllocat
* @param autoreclaim
* specify whether this retrieved memory buffer can be reclaimed
* automatically or not
- *
+ *
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a durable buffer contains the retrieved memory buffer
*/
@Override
- public DurableBuffer<VolatileMemAllocator> retrieveBuffer(long phandler, boolean autoreclaim) {
+ public DurableBuffer<VolatileMemAllocator> retrieveBuffer(long phandler, boolean autoreclaim,
+ ReclaimContext<ByteBuffer> rctx) {
DurableBuffer<VolatileMemAllocator> ret = null;
ByteBuffer bb = m_vmasvc.retrieveByteBuffer(m_nid, getEffectiveAddress(phandler));
if (null != bb) {
ret = new DurableBuffer<VolatileMemAllocator>(this, bb);
if (autoreclaim) {
- m_bufcollector.register(ret);
+ m_bufcollector.register(ret, rctx);
}
}
return ret;
@@ -339,18 +351,22 @@ public class VolatileMemAllocator extends RestorableAllocator<VolatileMemAllocat
* @param autoreclaim
* specify whether this retrieved memory chunk can be reclaimed
* automatically or not
- *
+ *
+ * @param rctx
+ * specify a reclaim context
+ *
* @return a durable chunk contains the retrieved memory chunk
*/
@Override
- public DurableChunk<VolatileMemAllocator> retrieveChunk(long phandler, boolean autoreclaim) {
+ public DurableChunk<VolatileMemAllocator> retrieveChunk(long phandler, boolean autoreclaim,
+ ReclaimContext<Long> rctx) {
DurableChunk<VolatileMemAllocator> ret = null;
long eaddr = getEffectiveAddress(phandler);
long sz = m_vmasvc.retrieveSize(m_nid, eaddr);
if (sz > 0L) {
ret = new DurableChunk<VolatileMemAllocator>(this, eaddr, sz);
if (autoreclaim) {
- m_chunkcollector.register(ret);
+ m_chunkcollector.register(ret, rctx);
}
}
return ret;