org.terracotta.offheapstore.disk.storage
Class FileBackedStorageEngine<K,V>

java.lang.Object
  extended by org.terracotta.offheapstore.storage.listener.AbstractListenableStorageEngine<K,V>
      extended by org.terracotta.offheapstore.storage.PortabilityBasedStorageEngine<K,V>
          extended by org.terracotta.offheapstore.disk.storage.FileBackedStorageEngine<K,V>
All Implemented Interfaces:
Persistent, PersistentStorageEngine<K,V>, BinaryStorageEngine, ListenableStorageEngine<K,V>, StorageEngine<K,V>

public class FileBackedStorageEngine<K,V>
extends PortabilityBasedStorageEngine<K,V>
implements PersistentStorageEngine<K,V>

Author:
Chris Dennis

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.terracotta.offheapstore.storage.StorageEngine
StorageEngine.Owner
 
Field Summary
 
Fields inherited from class org.terracotta.offheapstore.storage.PortabilityBasedStorageEngine
keyPortability, valuePortability
 
Constructor Summary
FileBackedStorageEngine(MappedPageSource source, long maxChunkSize, MemoryUnit maxChunkUnit, Portability<? super K> keyPortability, Portability<? super V> valuePortability)
           
FileBackedStorageEngine(MappedPageSource source, long maxChunkSize, MemoryUnit maxChunkUnit, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean bootstrap)
           
FileBackedStorageEngine(MappedPageSource source, long maxChunkSize, MemoryUnit maxChunkUnit, Portability<? super K> keyPortability, Portability<? super V> valuePortability, ExecutorService writer)
           
FileBackedStorageEngine(MappedPageSource source, long maxChunkSize, MemoryUnit maxChunkUnit, Portability<? super K> keyPortability, Portability<? super V> valuePortability, ExecutorService writer, boolean bootstrap)
           
 
Method Summary
 void bind(StorageEngine.Owner m)
           
 void bootstrap(ObjectInput input)
           
protected  void clearInternal()
           
 void close()
           
static
<K,V> Factory<FileBackedStorageEngine<K,V>>
createFactory(MappedPageSource source, long maxChunkSize, MemoryUnit maxChunkUnit, Portability<? super K> keyPortability, Portability<? super V> valuePortability)
           
static
<K,V> Factory<FileBackedStorageEngine<K,V>>
createFactory(MappedPageSource source, long maxChunkSize, MemoryUnit maxChunkUnit, Portability<? super K> keyPortability, Portability<? super V> valuePortability, boolean bootstrap)
           
static
<K,V> Factory<FileBackedStorageEngine<K,V>>
createFactory(MappedPageSource source, long maxChunkSize, MemoryUnit maxChunkUnit, Portability<? super K> keyPortability, Portability<? super V> valuePortability, Factory<ExecutorService> executorFactory, boolean bootstrap)
           
 void destroy()
           
 void flush()
           
protected  void free(long address)
           
 long getAllocatedMemory()
          Returns a measure of the amount of memory allocated for this storage engine.
 long getDataSize()
          Returns a measure of the total size of the keys and values stored in this storage engine.
protected  WriteContext getKeyWriteContext(long address)
           
 long getOccupiedMemory()
          Returns a measure of the amount of memory consumed by this storage engine.
protected  WriteContext getValueWriteContext(long address)
           
 long getVitalMemory()
          Returns a measure of the amount of vital memory allocated for this storage engine.
 void persist(ObjectOutput output)
           
protected  ByteBuffer readKeyBuffer(long address)
           
 int readKeyHash(long address)
           
protected  ByteBuffer readValueBuffer(long address)
           
 boolean shrink()
           
protected  Long writeMappingBuffers(ByteBuffer keyBuffer, ByteBuffer valueBuffer, int hash)
           
 
Methods inherited from class org.terracotta.offheapstore.storage.PortabilityBasedStorageEngine
attachedMapping, clear, equalsBinaryKey, equalsKey, equalsValue, freeMapping, invalidateCache, readBinaryKey, readBinaryValue, readKey, readValue, writeBinaryMapping, writeBinaryMapping, writeMapping, writeMappingBuffersGathering
 
Methods inherited from class org.terracotta.offheapstore.storage.listener.AbstractListenableStorageEngine
fireCleared, fireCopied, fireFreed, fireRecovered, fireWritten, hasListeners, hasRecoveryListeners, registerListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.terracotta.offheapstore.storage.StorageEngine
attachedMapping, clear, equalsKey, equalsValue, freeMapping, invalidateCache, readKey, readValue, writeMapping
 

Constructor Detail

FileBackedStorageEngine

public FileBackedStorageEngine(MappedPageSource source,
                               long maxChunkSize,
                               MemoryUnit maxChunkUnit,
                               Portability<? super K> keyPortability,
                               Portability<? super V> valuePortability)

FileBackedStorageEngine

public FileBackedStorageEngine(MappedPageSource source,
                               long maxChunkSize,
                               MemoryUnit maxChunkUnit,
                               Portability<? super K> keyPortability,
                               Portability<? super V> valuePortability,
                               ExecutorService writer)

FileBackedStorageEngine

public FileBackedStorageEngine(MappedPageSource source,
                               long maxChunkSize,
                               MemoryUnit maxChunkUnit,
                               Portability<? super K> keyPortability,
                               Portability<? super V> valuePortability,
                               boolean bootstrap)

FileBackedStorageEngine

public FileBackedStorageEngine(MappedPageSource source,
                               long maxChunkSize,
                               MemoryUnit maxChunkUnit,
                               Portability<? super K> keyPortability,
                               Portability<? super V> valuePortability,
                               ExecutorService writer,
                               boolean bootstrap)
Method Detail

createFactory

public static <K,V> Factory<FileBackedStorageEngine<K,V>> createFactory(MappedPageSource source,
                                                                        long maxChunkSize,
                                                                        MemoryUnit maxChunkUnit,
                                                                        Portability<? super K> keyPortability,
                                                                        Portability<? super V> valuePortability)

createFactory

public static <K,V> Factory<FileBackedStorageEngine<K,V>> createFactory(MappedPageSource source,
                                                                        long maxChunkSize,
                                                                        MemoryUnit maxChunkUnit,
                                                                        Portability<? super K> keyPortability,
                                                                        Portability<? super V> valuePortability,
                                                                        boolean bootstrap)

createFactory

public static <K,V> Factory<FileBackedStorageEngine<K,V>> createFactory(MappedPageSource source,
                                                                        long maxChunkSize,
                                                                        MemoryUnit maxChunkUnit,
                                                                        Portability<? super K> keyPortability,
                                                                        Portability<? super V> valuePortability,
                                                                        Factory<ExecutorService> executorFactory,
                                                                        boolean bootstrap)

clearInternal

protected void clearInternal()
Specified by:
clearInternal in class PortabilityBasedStorageEngine<K,V>

destroy

public void destroy()
Specified by:
destroy in interface StorageEngine<K,V>

flush

public void flush()
           throws IOException
Specified by:
flush in interface Persistent
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Persistent
Throws:
IOException

persist

public void persist(ObjectOutput output)
             throws IOException
Specified by:
persist in interface Persistent
Throws:
IOException

bootstrap

public void bootstrap(ObjectInput input)
               throws IOException
Specified by:
bootstrap in interface Persistent
Throws:
IOException

free

protected void free(long address)
Specified by:
free in class PortabilityBasedStorageEngine<K,V>

readKeyBuffer

protected ByteBuffer readKeyBuffer(long address)
Specified by:
readKeyBuffer in class PortabilityBasedStorageEngine<K,V>

getKeyWriteContext

protected WriteContext getKeyWriteContext(long address)
Specified by:
getKeyWriteContext in class PortabilityBasedStorageEngine<K,V>

readValueBuffer

protected ByteBuffer readValueBuffer(long address)
Specified by:
readValueBuffer in class PortabilityBasedStorageEngine<K,V>

getValueWriteContext

protected WriteContext getValueWriteContext(long address)
Specified by:
getValueWriteContext in class PortabilityBasedStorageEngine<K,V>

writeMappingBuffers

protected Long writeMappingBuffers(ByteBuffer keyBuffer,
                                   ByteBuffer valueBuffer,
                                   int hash)
Specified by:
writeMappingBuffers in class PortabilityBasedStorageEngine<K,V>

getAllocatedMemory

public long getAllocatedMemory()
Description copied from interface: StorageEngine
Returns a measure of the amount of memory allocated for this storage engine.

Specified by:
getAllocatedMemory in interface StorageEngine<K,V>
Returns:
memory allocated for this engine in bytes

getOccupiedMemory

public long getOccupiedMemory()
Description copied from interface: StorageEngine
Returns a measure of the amount of memory consumed by this storage engine.

Specified by:
getOccupiedMemory in interface StorageEngine<K,V>
Returns:
memory occupied by this engine in bytes

getVitalMemory

public long getVitalMemory()
Description copied from interface: StorageEngine
Returns a measure of the amount of vital memory allocated for this storage engine.

Specified by:
getVitalMemory in interface StorageEngine<K,V>
Returns:
vital memory allocated for this engine in bytes

getDataSize

public long getDataSize()
Description copied from interface: StorageEngine
Returns a measure of the total size of the keys and values stored in this storage engine.

Specified by:
getDataSize in interface StorageEngine<K,V>
Returns:
size of the stored keys and values in bytes

shrink

public boolean shrink()
Specified by:
shrink in interface StorageEngine<K,V>

bind

public void bind(StorageEngine.Owner m)
Specified by:
bind in interface StorageEngine<K,V>

readKeyHash

public int readKeyHash(long address)
Specified by:
readKeyHash in interface BinaryStorageEngine


Copyright © 2016. All rights reserved.