org.terracotta.offheapstore
Class AbstractOffHeapClockCache<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by org.terracotta.offheapstore.OffHeapHashMap<K,V>
          extended by org.terracotta.offheapstore.AbstractLockedOffHeapHashMap<K,V>
              extended by org.terracotta.offheapstore.AbstractOffHeapClockCache<K,V>
Type Parameters:
K - the type of keys maintained by this map
V - the type of mapped values
All Implemented Interfaces:
ConcurrentMap<K,V>, ReadWriteLock, Map<K,V>, MapInternals, PinnableCache<K,V>, PinnableSegment<K,V>, Segment<K,V>, StorageEngine.Owner
Direct Known Subclasses:
AbstractPersistentOffHeapCache, ReadWriteLockedOffHeapClockCache, WriteLockedOffHeapClockCache

public abstract class AbstractOffHeapClockCache<K,V>
extends AbstractLockedOffHeapHashMap<K,V>
implements PinnableCache<K,V>, PinnableSegment<K,V>

An abstract off-heap cache implementation.

Subclasses must implement the two getEvictionIndex(...) methods to instruct the cache regarding which mappings to remove.

Author:
Chris Dennis, Manoj Govindassamy

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class org.terracotta.offheapstore.OffHeapHashMap
ENTRY_SIZE, hashtable, hashTablePage, modCount, removedSlots, reprobeLimit, RESERVED_STATUS_BITS, size, STATUS, STATUS_USED, storageEngine, tableSource
 
Constructor Summary
AbstractOffHeapClockCache(PageSource source, boolean tableAllocationsSteal, StorageEngine<? super K,? super V> storageEngine)
           
AbstractOffHeapClockCache(PageSource source, boolean tableAllocationsSteal, StorageEngine<? super K,? super V> storageEngine, int tableSize)
           
AbstractOffHeapClockCache(PageSource source, StorageEngine<? super K,? super V> storageEngine)
           
AbstractOffHeapClockCache(PageSource source, StorageEngine<? super K,? super V> storageEngine, boolean bootstrap)
           
AbstractOffHeapClockCache(PageSource source, StorageEngine<? super K,? super V> storageEngine, int tableSize)
           
AbstractOffHeapClockCache(PageSource source, StorageEngine<? super K,? super V> storageEngine, int tableSize, boolean bootstrap)
           
 
Method Summary
 boolean evict(int index, boolean shrink)
           
protected  boolean evictable(int status)
           
 int getEvictionIndex()
          Return the table offset of the to be evicted mapping.
protected  void hit(IntBuffer entry)
           
 boolean isPinned(Object key)
           
 V putPinned(K key, V value)
           
 void setPinning(K key, boolean pinned)
           
protected  void storageEngineFailure(Object failure)
           
protected  void tableExpansionFailure(int start, int length)
           
 
Methods inherited from class org.terracotta.offheapstore.AbstractLockedOffHeapHashMap
clear, containsKey, destroy, entrySet, fill, fill, get, getAndSetMetadata, getEncodingForHashAndBinary, installMappingForHashAndEncoding, keySet, put, put, putIfAbsent, readLock, remove, remove, removeMapping, removeNoReturn, replace, replace, setMetadata, shrink, size, values, writeLock
 
Methods inherited from class org.terracotta.offheapstore.OffHeapHashMap
added, encodingSet, fill, getAllocatedMemory, getAtTableOffset, getDataAllocatedMemory, getDataOccupiedMemory, getDataSize, getDataVitalMemory, getEntryAtTableOffset, getMetadata, getOccupiedMemory, getRemovedSlotCount, getReprobeLength, getSize, getSlotForHashAndEncoding, getStorageEngine, getTableCapacity, getUsedSlotCount, getVitalMemory, isAvailable, isPresent, isRemoved, isTerminating, isThiefForTableAllocations, removeAtTableOffset, removed, spread, tryIncreaseReprobe, updated, updateEncoding, updateMetadata
 
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, putAll, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.terracotta.offheapstore.Segment
destroy, fill, fill, getAndSetMetadata, getLock, put, removeNoReturn, setMetadata, shrink
 
Methods inherited from interface org.terracotta.offheapstore.MapInternals
getAllocatedMemory, getDataAllocatedMemory, getDataOccupiedMemory, getDataSize, getDataVitalMemory, getOccupiedMemory, getRemovedSlotCount, getReprobeLength, getSize, getTableCapacity, getUsedSlotCount, getVitalMemory
 
Methods inherited from interface java.util.concurrent.locks.ReadWriteLock
readLock, writeLock
 
Methods inherited from interface java.util.concurrent.ConcurrentMap
putIfAbsent, remove, replace, replace
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Constructor Detail

AbstractOffHeapClockCache

public AbstractOffHeapClockCache(PageSource source,
                                 StorageEngine<? super K,? super V> storageEngine)

AbstractOffHeapClockCache

public AbstractOffHeapClockCache(PageSource source,
                                 boolean tableAllocationsSteal,
                                 StorageEngine<? super K,? super V> storageEngine)

AbstractOffHeapClockCache

public AbstractOffHeapClockCache(PageSource source,
                                 StorageEngine<? super K,? super V> storageEngine,
                                 boolean bootstrap)

AbstractOffHeapClockCache

public AbstractOffHeapClockCache(PageSource source,
                                 StorageEngine<? super K,? super V> storageEngine,
                                 int tableSize)

AbstractOffHeapClockCache

public AbstractOffHeapClockCache(PageSource source,
                                 boolean tableAllocationsSteal,
                                 StorageEngine<? super K,? super V> storageEngine,
                                 int tableSize)

AbstractOffHeapClockCache

public AbstractOffHeapClockCache(PageSource source,
                                 StorageEngine<? super K,? super V> storageEngine,
                                 int tableSize,
                                 boolean bootstrap)
Method Detail

storageEngineFailure

protected void storageEngineFailure(Object failure)
Overrides:
storageEngineFailure in class OffHeapHashMap<K,V>

tableExpansionFailure

protected void tableExpansionFailure(int start,
                                     int length)
Overrides:
tableExpansionFailure in class OffHeapHashMap<K,V>

hit

protected void hit(IntBuffer entry)
Overrides:
hit in class OffHeapHashMap<K,V>

getEvictionIndex

public int getEvictionIndex()
Return the table offset of the to be evicted mapping.

The mapping to be evicted can occur anywhere in this cache's table.

Returns:
table offset of the mapping to be evicted

evictable

protected boolean evictable(int status)

evict

public boolean evict(int index,
                     boolean shrink)
Specified by:
evict in interface StorageEngine.Owner
Overrides:
evict in class AbstractLockedOffHeapHashMap<K,V>

isPinned

public boolean isPinned(Object key)
Specified by:
isPinned in interface PinnableCache<K,V>

setPinning

public void setPinning(K key,
                       boolean pinned)
Specified by:
setPinning in interface PinnableCache<K,V>

putPinned

public V putPinned(K key,
                   V value)
Specified by:
putPinned in interface PinnableCache<K,V>


Copyright © 2015. All Rights Reserved.