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/07/01 23:58:35 UTC
incubator-mnemonic git commit: MNEMONIC-293:Provide a way to persist
the Bytebuffers created out of a durable chunk
Repository: incubator-mnemonic
Updated Branches:
refs/heads/master 9385e7160 -> 8c4092003
MNEMONIC-293:Provide a way to persist the Bytebuffers created out of a durable chunk
Project: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/commit/8c409200
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/tree/8c409200
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/diff/8c409200
Branch: refs/heads/master
Commit: 8c4092003b4d3d7397d87c59e4466b347e373de3
Parents: 9385e71
Author: paley <pa...@gmail.com>
Authored: Sat Jul 1 15:42:06 2017 -0700
Committer: paley <pa...@gmail.com>
Committed: Sat Jul 1 16:15:43 2017 -0700
----------------------------------------------------------------------
.../java/org/apache/mnemonic/ChunkBuffer.java | 27 ++++++++++++++++++++
1 file changed, 27 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mnemonic/blob/8c409200/mnemonic-core/src/main/java/org/apache/mnemonic/ChunkBuffer.java
----------------------------------------------------------------------
diff --git a/mnemonic-core/src/main/java/org/apache/mnemonic/ChunkBuffer.java b/mnemonic-core/src/main/java/org/apache/mnemonic/ChunkBuffer.java
index f9e91d8..f9e165b 100644
--- a/mnemonic-core/src/main/java/org/apache/mnemonic/ChunkBuffer.java
+++ b/mnemonic-core/src/main/java/org/apache/mnemonic/ChunkBuffer.java
@@ -29,6 +29,8 @@ public class ChunkBuffer<A extends RetrievableAllocator<A>> {
protected DurableChunk<A> m_dchunk = null;
protected ByteBuffer m_buffer = null;
+ protected long m_offset;
+ protected int m_size;
public ChunkBuffer(DurableChunk<A> dchunk, long offset, int size) {
Field address, capacity;
@@ -45,6 +47,8 @@ public class ChunkBuffer<A extends RetrievableAllocator<A>> {
capacity.setInt(bb, size);
bb.limit(size);
m_buffer = bb;
+ m_offset = offset;
+ m_size = size;
} catch (NoSuchFieldException e) {
throw new ConfigurationException("Buffer fields not found.");
} catch (IllegalAccessException e) {
@@ -62,5 +66,28 @@ public class ChunkBuffer<A extends RetrievableAllocator<A>> {
public DurableChunk<A> getChunk() {
return m_dchunk;
}
+
+ public void persist() {
+ if (m_dchunk.getAllocator() instanceof NonVolatileMemAllocator) {
+ NonVolatileMemAllocator alloc = (NonVolatileMemAllocator) m_dchunk.getAllocator();
+ alloc.persist(m_dchunk.get() + m_offset, m_size, false);
+ } else {
+ throw new UnsupportedOperationException("The ChunkBuffer does not backed by a non-volatile allocator");
+ }
+ }
+
+ public void sync() {
+ m_dchunk.getAllocator().sync(m_dchunk.get() + m_offset, m_size, false);
+ }
+
+ public void flush() {
+ if (m_dchunk.getAllocator() instanceof NonVolatileMemAllocator) {
+ NonVolatileMemAllocator alloc = (NonVolatileMemAllocator) m_dchunk.getAllocator();
+ alloc.flush(m_dchunk.get() + m_offset, m_size, false);
+ } else {
+ throw new UnsupportedOperationException("The ChunkBuffer does not backed by a non-volatile allocator");
+ }
+ }
+
}