org.terracotta.offheapstore.storage
Class OffHeapBufferHalfStorageEngine<T>

java.lang.Object
  extended by org.terracotta.offheapstore.storage.PortabilityBasedHalfStorageEngine<T>
      extended by org.terracotta.offheapstore.storage.OffHeapBufferHalfStorageEngine<T>
All Implemented Interfaces:
OffHeapStorageArea.Owner, HalfStorageEngine<T>

public class OffHeapBufferHalfStorageEngine<T>
extends PortabilityBasedHalfStorageEngine<T>
implements OffHeapStorageArea.Owner

Author:
cdennis

Constructor Summary
OffHeapBufferHalfStorageEngine(PageSource source, int initialPageSize, int maximalPageSize, Portability<? super T> portability, boolean thief, boolean victim)
           
OffHeapBufferHalfStorageEngine(PageSource source, int pageSize, Portability<? super T> portability)
          Creates a storage engine using the given allocator, and portabilities.
OffHeapBufferHalfStorageEngine(PageSource source, int pageSize, Portability<? super T> portability, boolean thief, boolean victim)
           
 
Method Summary
 void bind(StorageEngine.Owner o, long m)
           
 void clear()
          Called to indicate that all keys and values are now free.
static
<T> Factory<OffHeapBufferHalfStorageEngine<T>>
createFactory(PageSource source, int initialPageSize, int maximalPageSize, Portability<? super T> portability, boolean thief, boolean victim)
           
static
<T> Factory<OffHeapBufferHalfStorageEngine<T>>
createFactory(PageSource source, int pageSize, Portability<? super T> portability)
           
static
<T> Factory<OffHeapBufferHalfStorageEngine<T>>
createFactory(PageSource source, int pageSize, Portability<? super T> portability, boolean thief, boolean victim)
           
 void destroy()
           
 boolean evictAtAddress(long address, boolean shrink)
           
 void free(int address)
          Called to indicate that the associated encoded value is no longer needed.
 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.
 long getOccupiedMemory()
          Returns a measure of the amount of memory consumed by this storage engine.
 long getVitalMemory()
          Returns a measure of the amount of vital memory allocated for this storage engine.
 boolean isThief()
           
 boolean moved(long from, long to)
           
protected  ByteBuffer readBuffer(int address)
           
 boolean shrink()
           
 int sizeOf(long address)
           
 String toString()
           
protected  Integer writeBuffer(ByteBuffer buffer, int hash)
           
 Lock writeLock()
           
 
Methods inherited from class org.terracotta.offheapstore.storage.PortabilityBasedHalfStorageEngine
equals, invalidateCache, read, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OffHeapBufferHalfStorageEngine

public OffHeapBufferHalfStorageEngine(PageSource source,
                                      int pageSize,
                                      Portability<? super T> portability)
Creates a storage engine using the given allocator, and portabilities.

Parameters:
allocator - allocator used for storage allocation
keyPortability - key type portability
valuePortability - value type portability

OffHeapBufferHalfStorageEngine

public OffHeapBufferHalfStorageEngine(PageSource source,
                                      int pageSize,
                                      Portability<? super T> portability,
                                      boolean thief,
                                      boolean victim)

OffHeapBufferHalfStorageEngine

public OffHeapBufferHalfStorageEngine(PageSource source,
                                      int initialPageSize,
                                      int maximalPageSize,
                                      Portability<? super T> portability,
                                      boolean thief,
                                      boolean victim)
Method Detail

createFactory

public static <T> Factory<OffHeapBufferHalfStorageEngine<T>> createFactory(PageSource source,
                                                                           int pageSize,
                                                                           Portability<? super T> portability)

createFactory

public static <T> Factory<OffHeapBufferHalfStorageEngine<T>> createFactory(PageSource source,
                                                                           int pageSize,
                                                                           Portability<? super T> portability,
                                                                           boolean thief,
                                                                           boolean victim)

createFactory

public static <T> Factory<OffHeapBufferHalfStorageEngine<T>> createFactory(PageSource source,
                                                                           int initialPageSize,
                                                                           int maximalPageSize,
                                                                           Portability<? super T> portability,
                                                                           boolean thief,
                                                                           boolean victim)

clear

public void clear()
Description copied from interface: HalfStorageEngine
Called to indicate that all keys and values are now free.

Specified by:
clear in interface HalfStorageEngine<T>

free

public void free(int address)
Description copied from interface: HalfStorageEngine
Called to indicate that the associated encoded value is no longer needed.

This call can be used to free any associated resources tied to the lifecycle of the supplied encoded value.

Specified by:
free in interface HalfStorageEngine<T>
Specified by:
free in class PortabilityBasedHalfStorageEngine<T>
Parameters:
address - encoded value

readBuffer

protected ByteBuffer readBuffer(int address)
Specified by:
readBuffer in class PortabilityBasedHalfStorageEngine<T>

writeBuffer

protected Integer writeBuffer(ByteBuffer buffer,
                              int hash)
Specified by:
writeBuffer in class PortabilityBasedHalfStorageEngine<T>

getAllocatedMemory

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

Specified by:
getAllocatedMemory in interface HalfStorageEngine<T>
Returns:
memory allocated for this engine in bytes

getOccupiedMemory

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

Specified by:
getOccupiedMemory in interface HalfStorageEngine<T>
Returns:
memory occupied by this engine in bytes

getVitalMemory

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

Specified by:
getVitalMemory in interface HalfStorageEngine<T>
Returns:
vital memory allocated for this engine in bytes

getDataSize

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

Specified by:
getDataSize in interface HalfStorageEngine<T>
Returns:
size of the stored keys and values in bytes

toString

public String toString()
Overrides:
toString in class Object

bind

public void bind(StorageEngine.Owner o,
                 long m)
Specified by:
bind in interface HalfStorageEngine<T>

destroy

public void destroy()
Specified by:
destroy in interface HalfStorageEngine<T>

shrink

public boolean shrink()
Specified by:
shrink in interface HalfStorageEngine<T>

evictAtAddress

public boolean evictAtAddress(long address,
                              boolean shrink)
Specified by:
evictAtAddress in interface OffHeapStorageArea.Owner

writeLock

public Lock writeLock()
Specified by:
writeLock in interface OffHeapStorageArea.Owner

isThief

public boolean isThief()
Specified by:
isThief in interface OffHeapStorageArea.Owner

moved

public boolean moved(long from,
                     long to)
Specified by:
moved in interface OffHeapStorageArea.Owner

sizeOf

public int sizeOf(long address)
Specified by:
sizeOf in interface OffHeapStorageArea.Owner


Copyright © 2015. All Rights Reserved.