/** * flush a buffer to persistent memory. * * @param mbuf * specify a buffer to be flushed */ @Override public void syncToLocal(MemBufferHolder<NonVolatileMemAllocator> mbuf) { m_nvmasvc.syncToLocal(m_nid, getBufferAddress(mbuf), 0L, true); }
/** * flush a chunk to persistent memory. * * @param mchunk * specify a chunk to be flushed */ @Override public void syncToLocal(MemChunkHolder<NonVolatileMemAllocator> mchunk) { m_nvmasvc.syncToLocal(m_nid, getChunkAddress(mchunk), 0L, true); }
@Override public byte[] getAbstractAddress(long addr) { byte[] ret; if (useAbstractAddressing()) { ret = m_nvmasvc.getAbstractAddress(addr); } else { throw new ConfigurationException("Do not support get abstract address operation"); } return ret; }
public static void main(String[] argv) throws Exception { NonVolatileMemAllocator act = new NonVolatileMemAllocator(Utils.getNonVolatileMemoryAllocatorService("pmalloc"), 1024L * 1024 * 1024, "./example_helloworld.dat", true); DurableBuffer<?> dbuf = act.createBuffer(20); act.getEffectiveAddress(0L)));
/** * retrieve a durable 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 */ @Override public DurableBuffer<NonVolatileMemAllocator> retrieveBuffer(long phandler, boolean autoreclaim, ReclaimContext 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, rctx); } } return ret; }
public static void main(String[] argv) throws Exception { /* create a non-volatile memory pool from one of memory services */ NonVolatileMemAllocator act = new NonVolatileMemAllocator(Utils.getNonVolatileMemoryAllocatorService("pmalloc"), 1024L * 1024 * 1024, "./example_order.dat", false); DurableType listgftypes[] = {DurableType.DURABLE}; EntityFactoryProxy listefproxies[] = {new EntityFactoryProxyHelper<Product>(Product.class) }; long hdl = 0L; for (long keyid = 1; keyid <= 3; keyid++) { hdl = act.getHandler(keyid); if (0L != hdl) { Order o = OrderFactory.restore(act, listefproxies, listgftypes, hdl, false); o.show(); } } } }
public static void main(String[] argv) throws Exception { NonVolatileMemAllocator act = new NonVolatileMemAllocator(Utils.getNonVolatileMemoryAllocatorService("pmalloc"), 1024L * 1024 * 1024, "./example_order.dat", true); o3.show(); act.setHandler(1, o1.getHandler()); act.setHandler(2, o2.getHandler()); act.setHandler(3, o3.getHandler());
public void syncToNonVolatileMemory() { if (m_dchunk.getAllocator() instanceof NonVolatileMemAllocator) { NonVolatileMemAllocator alloc = (NonVolatileMemAllocator) m_dchunk.getAllocator(); alloc.syncToNonVolatileMemory(m_dchunk.get() + m_offset, m_size, false); } else { throw new UnsupportedOperationException("The ChunkBuffer does not backed by a non-volatile allocator"); } }
public void syncToLocal() { if (m_dchunk.getAllocator() instanceof NonVolatileMemAllocator) { NonVolatileMemAllocator alloc = (NonVolatileMemAllocator) m_dchunk.getAllocator(); alloc.syncToLocal(m_dchunk.get() + m_offset, m_size, false); } else { throw new UnsupportedOperationException("The ChunkBuffer does not backed by a non-volatile allocator"); } }
/** * retrieve a durable 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 */ @Override public DurableChunk<NonVolatileMemAllocator> retrieveChunk(long phandler, boolean autoreclaim, ReclaimContext rctx) { DurableChunk<NonVolatileMemAllocator> ret = null; long eaddr = getEffectiveAddress(phandler); long sz = m_nvmasvc.retrieveSize(m_nid, eaddr); if (sz > 0L) { ret = new DurableChunk<NonVolatileMemAllocator>(this, eaddr, sz); ret.setCollector(m_chunkcollector); if (autoreclaim) { m_chunkcollector.register(ret, rctx); } } return ret; }
public void syncToNonVolatileMemory(long offset, int length) { if (offset < 0 || length < 0 || offset + length > this.m_size) { throw new OutOfBoundsException("The requested offset and length are out of bounds for this buffer: length = " + length + " , offset = " + offset); } if (m_dchunk.getAllocator() instanceof NonVolatileMemAllocator) { NonVolatileMemAllocator alloc = (NonVolatileMemAllocator) m_dchunk.getAllocator(); alloc.syncToNonVolatileMemory(m_dchunk.get() + m_offset + offset, length, false); } else { throw new UnsupportedOperationException("The ChunkBuffer does not backed by a non-volatile allocator"); } }
public void syncToLocal(long offset, int length) { if (offset < 0 || length < 0 || offset + length > this.m_size) { throw new OutOfBoundsException("The requested offset and length are out of bounds for this buffer: length = " + length + " , offset = " + offset); } if (m_dchunk.getAllocator() instanceof NonVolatileMemAllocator) { NonVolatileMemAllocator alloc = (NonVolatileMemAllocator) m_dchunk.getAllocator(); alloc.syncToLocal(m_dchunk.get() + m_offset + offset, length, false); } else { throw new UnsupportedOperationException("The ChunkBuffer does not backed by a non-volatile allocator"); } }
/** * persist a buffer to persistent memory. * * @param mbuf * specify a buffer to be persisted */ @Override public void syncToNonVolatileMemory(MemBufferHolder<NonVolatileMemAllocator> mbuf) { m_nvmasvc.syncToNonVolatileMemory(m_nid, getBufferAddress(mbuf), 0L, true); }
/** * sync. a chunk to underlying memory device. * * @param mchunk * specify a chunk to be sync. */ @Override public void syncToVolatileMemory(MemChunkHolder<NonVolatileMemAllocator> mchunk) { m_nvmasvc.syncToVolatileMemory(m_nid, getChunkAddress(mchunk), 0L, true); }
/** * translate the portable address * * @param addr * the address to be translated * * @return the portable address */ @Override public long getPortableAddress(long addr) { if (useAbstractAddressing()) { return m_nvmasvc.getPortableAddress(addr); } int i; for (i = 0; i < m_ttable.length; ++i) { if (addr >= m_ttable[i][2] && addr < m_ttable[i][1] + m_ttable[i][2]) { return addr - m_ttable[i][2]; } } throw new AddressTranslateError("Portable Address Translate Error"); }
/** * sync. a buffer to underlying memory device. * * @param mbuf * specify a buffer to be sync. */ @Override public void syncToVolatileMemory(MemBufferHolder<NonVolatileMemAllocator> mbuf) { m_nvmasvc.syncToVolatileMemory(m_nid, getBufferAddress(mbuf), 0L, true); }
/** * persist a chunk to persistent memory. * * @param mchunk * specify a chunk to be persisted */ @Override public void syncToNonVolatileMemory(MemChunkHolder<NonVolatileMemAllocator> mchunk) { m_nvmasvc.syncToNonVolatileMemory(m_nid, getChunkAddress(mchunk), 0L, true); }
/** * translate the effective address * * @param addr * the address to be translated * * @return the effective address */ @Override public long getEffectiveAddress(long addr) { if (useAbstractAddressing()) { return m_nvmasvc.getEffectiveAddress(addr); } int i; for (i = 0; i < m_ttable.length; ++i) { if (addr >= m_ttable[i][0] && addr < m_ttable[i][1]) { return addr + m_ttable[i][2]; } } throw new AddressTranslateError("Effective Address Translate Error"); }