public class RestartableStorageEngine<T extends StorageEngine<K,LinkedNode<V>> & BinaryStorageEngine,I,K,V> extends AbstractListenableStorageEngine<K,V> implements StorageEngine<K,V>, BinaryStorageEngine, com.terracottatech.frs.object.ObjectManagerSegment<I,ByteBuffer,ByteBuffer>, StorageEngine.Owner
StorageEngine.Owner| Modifier and Type | Field and Description |
|---|---|
protected T |
delegateStorageEngine |
protected I |
identifier |
static long |
NULL_ENCODING |
protected StorageEngine.Owner |
owner |
protected boolean |
synchronous |
protected com.terracottatech.frs.RestartStore<I,ByteBuffer,ByteBuffer> |
transactionSource |
| Constructor and Description |
|---|
RestartableStorageEngine(I identifier,
com.terracottatech.frs.RestartStore<I,ByteBuffer,ByteBuffer> transactionSource,
T storageEngine,
boolean synchronous) |
| Modifier and Type | Method and Description |
|---|---|
com.terracottatech.frs.object.ObjectManagerEntry<I,ByteBuffer,ByteBuffer> |
acquireCompactionEntry(long ceilingLsn) |
protected void |
assignLsn(long encoding,
long lsn) |
void |
attachedMapping(long encoding,
int hash,
int metadata) |
void |
bind(StorageEngine.Owner owner) |
void |
clear()
Called to indicate that all keys and values are now free.
|
static <T extends StorageEngine<K,LinkedNode<V>> & BinaryStorageEngine,I,K,V> |
createFactory(I identifier,
com.terracottatech.frs.RestartStore<I,ByteBuffer,ByteBuffer> transactionSource,
Factory<T> delegateFactory,
boolean synchronous) |
static ByteBuffer |
decodeKey(ByteBuffer frsBinaryKey) |
static ByteBuffer |
decodeValue(ByteBuffer frsBinaryValue) |
protected int |
deriveMetadata(long encoding) |
void |
destroy() |
static ByteBuffer |
encodeKey(ByteBuffer offheapBinaryKey,
int pojoHash) |
static ByteBuffer |
encodeValue(ByteBuffer offheapBinaryValue,
long encoding,
int metadata) |
Iterable<Long> |
encodingSet() |
boolean |
equalsBinaryKey(ByteBuffer offheapBinaryKey,
long encoding) |
boolean |
equalsKey(Object key,
long encoding)
Called to determine the equality of the given object against the
given encoded form.
|
boolean |
equalsValue(Object value,
long encoding)
Called to determine the equality of the given Java object value against the
given encoded form.
|
boolean |
evict(int slot,
boolean b) |
static long |
extractEncoding(ByteBuffer frsBinaryValue) |
static int |
extractHashcode(ByteBuffer frsBinaryKey) |
static int |
extractMetadata(ByteBuffer frsBinaryValue) |
protected long |
firstEncoding() |
void |
freeMapping(long encoding,
int hash,
boolean removal)
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 |
getEncodingForHashAndBinary(int hash,
ByteBuffer offHeapBinaryKey) |
Long |
getLowestLsn() |
Long |
getLsn(int pojoHash,
ByteBuffer frsBinaryKey) |
long |
getOccupiedMemory()
Returns a measure of the amount of memory consumed by this storage engine.
|
long |
getSize() |
Integer |
getSlotForHashAndEncoding(int hash,
long address,
long mask) |
long |
getVitalMemory()
Returns a measure of the amount of vital memory allocated for this storage engine.
|
long |
installMappingForHashAndEncoding(int pojoHash,
ByteBuffer offheapBinaryKey,
ByteBuffer offheapBinaryValue,
int metadata) |
void |
invalidateCache()
Invalidate any local key/value caches.
|
boolean |
isThiefForTableAllocations() |
protected long |
lastEncoding() |
protected void |
linkNodeExpectingFirst(LinkedNode<?> node,
long encoding,
long lsn) |
protected void |
linkNodeExpectingLast(LinkedNode<?> node,
long encoding,
long lsn) |
void |
put(int pojoHash,
ByteBuffer frsBinaryKey,
ByteBuffer frsBinaryValue,
long lsn) |
ByteBuffer |
readBinaryKey(long encoding) |
ByteBuffer |
readBinaryValue(long encoding) |
K |
readKey(long encoding,
int hashCode)
Converts the supplied encoded key into its correct object form.
|
int |
readKeyHash(long encoding) |
Lock |
readLock() |
V |
readValue(long encoding)
Converts the supplied encoded value into its correct object form.
|
void |
releaseCompactionEntry(com.terracottatech.frs.object.ObjectManagerEntry<I,ByteBuffer,ByteBuffer> entry) |
void |
remove(int pojoHash,
ByteBuffer frsBinaryKey) |
void |
replayPut(int pojoHash,
ByteBuffer frsBinaryKey,
ByteBuffer frsBinaryValue,
long lsn) |
protected void |
restartabilityPut(long encoding,
int pojoHash,
int metadata) |
boolean |
shrink() |
long |
size() |
long |
sizeInBytes() |
protected void |
unlinkNode(LinkedNode<?> node,
long encoding) |
boolean |
updateEncoding(int hashCode,
long lastAddress,
long compressed,
long mask) |
void |
updateLsn(int pojoHash,
com.terracottatech.frs.object.ObjectManagerEntry<I,ByteBuffer,ByteBuffer> entry,
long newLsn) |
protected void |
validChain() |
Long |
writeBinaryMapping(ByteBuffer[] binaryKey,
ByteBuffer[] binaryValue,
int pojoHash,
int metadata) |
Long |
writeBinaryMapping(ByteBuffer binaryKey,
ByteBuffer binaryValue,
int pojoHash,
int metadata) |
Lock |
writeLock() |
Long |
writeMapping(K key,
V value,
int hash,
int metadata)
Converts the supplied key and value objects into their encoded form.
|
fireCleared, fireCopied, fireFreed, fireRecovered, fireWritten, hasListeners, hasRecoveryListeners, registerListenerpublic static final long NULL_ENCODING
protected final T extends StorageEngine<K,LinkedNode<V>> & BinaryStorageEngine delegateStorageEngine
protected final I identifier
protected final com.terracottatech.frs.RestartStore<I,ByteBuffer,ByteBuffer> transactionSource
protected final boolean synchronous
protected volatile StorageEngine.Owner owner
public RestartableStorageEngine(I identifier, com.terracottatech.frs.RestartStore<I,ByteBuffer,ByteBuffer> transactionSource, T storageEngine, boolean synchronous)
public static <T extends StorageEngine<K,LinkedNode<V>> & BinaryStorageEngine,I,K,V> Factory<RestartableStorageEngine<T,I,K,V>> createFactory(I identifier, com.terracottatech.frs.RestartStore<I,ByteBuffer,ByteBuffer> transactionSource, Factory<T> delegateFactory, boolean synchronous)
public Long writeMapping(K key, V value, int hash, int metadata)
StorageEnginewriteMapping in interface StorageEngine<K,V>key - a key objectvalue - a value objecthash - the key hashmetadata - the metadata bitspublic void attachedMapping(long encoding,
int hash,
int metadata)
attachedMapping in interface StorageEngine<K,V>protected void restartabilityPut(long encoding,
int pojoHash,
int metadata)
public void freeMapping(long encoding,
int hash,
boolean removal)
StorageEngineThis call can be used to free any associated resources tied to the lifecycle of the supplied encoded value.
freeMapping in interface StorageEngine<K,V>encoding - encoded valuehash - hash of the freed mappingremoval - marks removal from a mappublic V readValue(long encoding)
StorageEnginereadValue in interface StorageEngine<K,V>encoding - encoded valuepublic boolean equalsValue(Object value, long encoding)
StorageEngine
Simple implementations will probably perform a decode on the given encoded
form in order to do a regular Object.equals(Object) comparison.
This method is provided to allow implementations to optimize this
comparison if possible.
equalsValue in interface StorageEngine<K,V>value - a value objectencoding - encoded valuetrue if the value and the encoding are equalpublic K readKey(long encoding, int hashCode)
StorageEnginereadKey in interface StorageEngine<K,V>encoding - encoded keyhashCode - hash-code of the decoded keypublic boolean equalsKey(Object key, long encoding)
StorageEngine
Simple implementations will probably perform a decode on the given encoded
form in order to do a regular Object.equals(Object) comparison.
This method is provided to allow implementations to optimize this
comparison if possible.
equalsKey in interface StorageEngine<K,V>key - a key objectencoding - encoded valuetrue if the key and the encoding are equalpublic boolean equalsBinaryKey(ByteBuffer offheapBinaryKey, long encoding)
equalsBinaryKey in interface BinaryStorageEnginepublic void clear()
StorageEngineclear in interface StorageEngine<K,V>public long getAllocatedMemory()
StorageEnginegetAllocatedMemory in interface StorageEngine<K,V>public long getOccupiedMemory()
StorageEnginegetOccupiedMemory in interface StorageEngine<K,V>public long getVitalMemory()
StorageEnginegetVitalMemory in interface StorageEngine<K,V>public long getDataSize()
StorageEnginegetDataSize in interface StorageEngine<K,V>public void invalidateCache()
StorageEngineThis is called to indicate the termination of a map write "phase". Caching is permitted within a write operation (i.e. to cache around allocation failures during eviction processes).
invalidateCache in interface StorageEngine<K,V>public void bind(StorageEngine.Owner owner)
bind in interface StorageEngine<K,V>public void destroy()
destroy in interface StorageEngine<K,V>public boolean shrink()
shrink in interface StorageEngine<K,V>protected final void assignLsn(long encoding,
long lsn)
protected final void unlinkNode(LinkedNode<?> node, long encoding)
protected final void linkNodeExpectingLast(LinkedNode<?> node, long encoding, long lsn)
protected final void linkNodeExpectingFirst(LinkedNode<?> node, long encoding, long lsn)
protected final void validChain()
protected long firstEncoding()
protected long lastEncoding()
public long size()
size in interface com.terracottatech.frs.object.ObjectManagerSegment<I,ByteBuffer,ByteBuffer>public Long getLowestLsn()
getLowestLsn in interface com.terracottatech.frs.object.ObjectManagerSegment<I,ByteBuffer,ByteBuffer>public Long getLsn(int pojoHash, ByteBuffer frsBinaryKey)
getLsn in interface com.terracottatech.frs.object.ObjectManagerSegment<I,ByteBuffer,ByteBuffer>public void put(int pojoHash,
ByteBuffer frsBinaryKey,
ByteBuffer frsBinaryValue,
long lsn)
put in interface com.terracottatech.frs.object.ObjectManagerSegment<I,ByteBuffer,ByteBuffer>public void remove(int pojoHash,
ByteBuffer frsBinaryKey)
remove in interface com.terracottatech.frs.object.ObjectManagerSegment<I,ByteBuffer,ByteBuffer>public void replayPut(int pojoHash,
ByteBuffer frsBinaryKey,
ByteBuffer frsBinaryValue,
long lsn)
replayPut in interface com.terracottatech.frs.object.ObjectManagerSegment<I,ByteBuffer,ByteBuffer>public Long writeBinaryMapping(ByteBuffer binaryKey, ByteBuffer binaryValue, int pojoHash, int metadata)
writeBinaryMapping in interface BinaryStorageEnginepublic Long writeBinaryMapping(ByteBuffer[] binaryKey, ByteBuffer[] binaryValue, int pojoHash, int metadata)
writeBinaryMapping in interface BinaryStorageEnginepublic int readKeyHash(long encoding)
readKeyHash in interface BinaryStorageEnginepublic ByteBuffer readBinaryKey(long encoding)
readBinaryKey in interface BinaryStorageEnginepublic ByteBuffer readBinaryValue(long encoding)
readBinaryValue in interface BinaryStorageEnginepublic com.terracottatech.frs.object.ObjectManagerEntry<I,ByteBuffer,ByteBuffer> acquireCompactionEntry(long ceilingLsn)
acquireCompactionEntry in interface com.terracottatech.frs.object.ObjectManagerSegment<I,ByteBuffer,ByteBuffer>public void releaseCompactionEntry(com.terracottatech.frs.object.ObjectManagerEntry<I,ByteBuffer,ByteBuffer> entry)
releaseCompactionEntry in interface com.terracottatech.frs.object.ObjectManagerSegment<I,ByteBuffer,ByteBuffer>public void updateLsn(int pojoHash,
com.terracottatech.frs.object.ObjectManagerEntry<I,ByteBuffer,ByteBuffer> entry,
long newLsn)
updateLsn in interface com.terracottatech.frs.object.ObjectManagerSegment<I,ByteBuffer,ByteBuffer>protected int deriveMetadata(long encoding)
public static ByteBuffer encodeKey(ByteBuffer offheapBinaryKey, int pojoHash)
public static ByteBuffer decodeKey(ByteBuffer frsBinaryKey)
public static int extractHashcode(ByteBuffer frsBinaryKey)
public static ByteBuffer encodeValue(ByteBuffer offheapBinaryValue, long encoding, int metadata)
public static ByteBuffer decodeValue(ByteBuffer frsBinaryValue)
public static int extractMetadata(ByteBuffer frsBinaryValue)
public static long extractEncoding(ByteBuffer frsBinaryValue)
public long sizeInBytes()
sizeInBytes in interface com.terracottatech.frs.object.ObjectManagerSegment<I,ByteBuffer,ByteBuffer>public Long getEncodingForHashAndBinary(int hash, ByteBuffer offHeapBinaryKey)
getEncodingForHashAndBinary in interface StorageEngine.Ownerpublic long getSize()
getSize in interface StorageEngine.Ownerpublic long installMappingForHashAndEncoding(int pojoHash,
ByteBuffer offheapBinaryKey,
ByteBuffer offheapBinaryValue,
int metadata)
installMappingForHashAndEncoding in interface StorageEngine.Ownerpublic Iterable<Long> encodingSet()
encodingSet in interface StorageEngine.Ownerpublic boolean updateEncoding(int hashCode,
long lastAddress,
long compressed,
long mask)
updateEncoding in interface StorageEngine.Ownerpublic Integer getSlotForHashAndEncoding(int hash, long address, long mask)
getSlotForHashAndEncoding in interface StorageEngine.Ownerpublic boolean evict(int slot,
boolean b)
evict in interface StorageEngine.Ownerpublic boolean isThiefForTableAllocations()
isThiefForTableAllocations in interface StorageEngine.Ownerpublic Lock readLock()
readLock in interface ReadWriteLockpublic Lock writeLock()
writeLock in interface ReadWriteLockCopyright © 2015–2024. All rights reserved.