@@ -29,6 +29,8 @@ public class ChunkBuffer<A extends RetrievableAllocator<A>> {
29
29
30
30
protected DurableChunk <A > m_dchunk = null ;
31
31
protected ByteBuffer m_buffer = null ;
32
+ protected long m_offset ;
33
+ protected int m_size ;
32
34
33
35
public ChunkBuffer (DurableChunk <A > dchunk , long offset , int size ) {
34
36
Field address , capacity ;
@@ -45,6 +47,8 @@ public ChunkBuffer(DurableChunk<A> dchunk, long offset, int size) {
45
47
capacity .setInt (bb , size );
46
48
bb .limit (size );
47
49
m_buffer = bb ;
50
+ m_offset = offset ;
51
+ m_size = size ;
48
52
} catch (NoSuchFieldException e ) {
49
53
throw new ConfigurationException ("Buffer fields not found." );
50
54
} catch (IllegalAccessException e ) {
@@ -62,5 +66,28 @@ public ByteBuffer get() {
62
66
public DurableChunk <A > getChunk () {
63
67
return m_dchunk ;
64
68
}
69
+
70
+ public void persist () {
71
+ if (m_dchunk .getAllocator () instanceof NonVolatileMemAllocator ) {
72
+ NonVolatileMemAllocator alloc = (NonVolatileMemAllocator ) m_dchunk .getAllocator ();
73
+ alloc .persist (m_dchunk .get () + m_offset , m_size , false );
74
+ } else {
75
+ throw new UnsupportedOperationException ("The ChunkBuffer does not backed by a non-volatile allocator" );
76
+ }
77
+ }
78
+
79
+ public void sync () {
80
+ m_dchunk .getAllocator ().sync (m_dchunk .get () + m_offset , m_size , false );
81
+ }
82
+
83
+ public void flush () {
84
+ if (m_dchunk .getAllocator () instanceof NonVolatileMemAllocator ) {
85
+ NonVolatileMemAllocator alloc = (NonVolatileMemAllocator ) m_dchunk .getAllocator ();
86
+ alloc .flush (m_dchunk .get () + m_offset , m_size , false );
87
+ } else {
88
+ throw new UnsupportedOperationException ("The ChunkBuffer does not backed by a non-volatile allocator" );
89
+ }
90
+ }
91
+
65
92
}
66
93
0 commit comments