org.terracotta.toolkit.internal.cache
Interface ToolkitCacheInternal<K,V>

All Superinterfaces:
ConcurrentMap<K,V>, org.terracotta.toolkit.object.Destroyable, Map<K,V>, org.terracotta.toolkit.search.SearchableMap<K,V>, org.terracotta.toolkit.bulkload.ToolkitBulkLoadObject, org.terracotta.toolkit.cache.ToolkitCache<K,V>, org.terracotta.toolkit.object.ToolkitObject
All Known Subinterfaces:
BufferingToolkitCache<K,V>

public interface ToolkitCacheInternal<K,V>
extends org.terracotta.toolkit.cache.ToolkitCache<K,V>

Internal api for ToolkitCache


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Method Summary
 void clearLocalCache()
          Clear the local cache
 void clearVersioned()
          This method clears the cache but wont generate the server events.
 boolean containsKeyLocalOffHeap(Object key)
          Returns true if the key is present off-heap in current node.
 boolean containsKeyLocalOnHeap(Object key)
          Returns true if the key is present on-heap in current node.
 boolean containsLocalKey(Object key)
          Query whether key is present locally or not
 void disposeLocally()
          Dispose the Store from this node.
 Map<Object,Set<org.terracotta.toolkit.cluster.ClusterNode>> getNodesWithKeys(Set portableKeys)
          Returns set of nodes which has the corresponding key in its local jvm
 VersionedValue<V> getVersionedValue(Object key)
          This method returns the VersionedValue corresponding to the given key.
 Set<K> keySetForSegment(int segmentIndex)
          Return the set of Keys in the given segment of cache
 Set<K> localKeySet()
          Returns a Set containing keys in the Store which are present in the node locally.
 int localOffHeapSize()
          Return the number of elements present locally in off-heap of current node.
 long localOffHeapSizeInBytes()
          Return the off-heap size in bytes present locally in current node.
 int localOnHeapSize()
          Return the number of elements present locally on-heap in current node.
The count returned might not be very accurate if maxEntriesLocalHeap is set to small values.
 long localOnHeapSizeInBytes()
          Return the on-heap size in bytes present locally in current node.
 int localSize()
          Return the count of local entries.
 V put(K key, V value, int createTimeInSecs, int customMaxTTISeconds, int customMaxTTLSeconds)
           
 void putIfAbsentVersioned(K key, V value, long version)
          This method is required for WAN specific usecase.
 void putIfAbsentVersioned(K key, V value, long version, int createTimeInSecs, int customMaxTTISeconds, int customMaxTTLSeconds)
          This method is required for WAN specific usecase.
 void putVersioned(K key, V value, long version)
           
 void putVersioned(K key, V value, long version, int createTimeInSecs, int customMaxTTISeconds, int customMaxTTLSeconds)
           
 void quickClear()
          This method submit a request to clear for this cache and returns.
 int quickSize()
          Returns approximate size of this cache without waiting for all transaction to finish.
 void registerVersionUpdateListener(VersionUpdateListener listener)
           
 boolean remove(Object key, Object value, ToolkitValueComparator<V> comparator)
          Removes the entry for a key only if currently mapped to a given value.
 void removeAll(Set<K> keys)
           
 void removeVersioned(Object key, long version)
           
 boolean replace(K key, V oldValue, V newValue, ToolkitValueComparator<V> comparator)
          Replaces the entry for a key only if currently mapped to a given value.
 V unlockedGet(Object k, boolean quiet)
          Performs an unlocked get.
 Map<K,V> unlockedGetAll(Collection<K> keys, boolean quiet)
           
 void unlockedPutNoReturn(K k, V v, int createTime, int customTTI, int customTTL)
          Performs an unlocked put.
 void unlockedPutNoReturnVersioned(K k, V v, long version, int createTime, int customTTI, int customTTL)
           
 void unlockedRemoveNoReturn(Object k)
          Performs an unlocked remove.
 void unlockedRemoveNoReturnVersioned(Object key, long version)
           
 V unsafeLocalGet(Object key)
          Perform a local unlocked read for the given key.
 
Methods inherited from interface org.terracotta.toolkit.cache.ToolkitCache
addListener, createLockForKey, getAll, getAllQuiet, getConfiguration, getQuiet, putIfAbsent, putNoReturn, putNoReturn, removeListener, removeNoReturn, setConfigField
 
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
 
Methods inherited from interface org.terracotta.toolkit.object.Destroyable
destroy, isDestroyed
 
Methods inherited from interface org.terracotta.toolkit.search.SearchableMap
createQueryBuilder, setAttributeExtractor
 
Methods inherited from interface org.terracotta.toolkit.bulkload.ToolkitBulkLoadObject
isBulkLoadEnabled, isNodeBulkLoadEnabled, setNodeBulkLoadEnabled, waitUntilBulkLoadComplete
 
Methods inherited from interface org.terracotta.toolkit.object.ToolkitObject
getName
 

Method Detail

getNodesWithKeys

Map<Object,Set<org.terracotta.toolkit.cluster.ClusterNode>> getNodesWithKeys(Set portableKeys)
Returns set of nodes which has the corresponding key in its local jvm


unlockedPutNoReturn

void unlockedPutNoReturn(K k,
                         V v,
                         int createTime,
                         int customTTI,
                         int customTTL)
Performs an unlocked put. This method does not take any lock so strong cache behaves like eventual cache. If user takes lock outside then eventual cache will behave like strong cache.


unlockedPutNoReturnVersioned

void unlockedPutNoReturnVersioned(K k,
                                  V v,
                                  long version,
                                  int createTime,
                                  int customTTI,
                                  int customTTL)

unlockedRemoveNoReturn

void unlockedRemoveNoReturn(Object k)
Performs an unlocked remove. This method does not take any lock so strong cache behaves like eventual cache. If user takes lock outside then eventual cache will behave like strong cache.


unlockedRemoveNoReturnVersioned

void unlockedRemoveNoReturnVersioned(Object key,
                                     long version)

unlockedGet

V unlockedGet(Object k,
              boolean quiet)
Performs an unlocked get.


unlockedGetAll

Map<K,V> unlockedGetAll(Collection<K> keys,
                        boolean quiet)

clearLocalCache

void clearLocalCache()
Clear the local cache


unsafeLocalGet

V unsafeLocalGet(Object key)
Perform a local unlocked read for the given key.

This method performs no locking and thus provides absolutely no visibility guarantees. If the value is not local it will NOT be looked up from elsewhere and null is returned instead - thus one cannot distinguish between a non-existent mapping from one where its present elsewhere. USE WITH CAUTION.

Parameters:
key - The key to lookup
Returns:
value mapped to key if present locally in the current node, otherwise null.

containsLocalKey

boolean containsLocalKey(Object key)
Query whether key is present locally or not

Returns:
true if key is local, otherwise false

localSize

int localSize()
Return the count of local entries.
The count returned might not be very accurate if maxEntriesLocalHeap is set to small values.

Returns:
count of local entries

localKeySet

Set<K> localKeySet()
Returns a Set containing keys in the Store which are present in the node locally. The returned set is immutable.

Returns:
Set of keys which are present in the node locally.

localOnHeapSizeInBytes

long localOnHeapSizeInBytes()
Return the on-heap size in bytes present locally in current node.

Returns:
the on-heap size in bytes present locally in current node.

localOffHeapSizeInBytes

long localOffHeapSizeInBytes()
Return the off-heap size in bytes present locally in current node.

Returns:
the off-heap size in bytes present locally in current node.

localOnHeapSize

int localOnHeapSize()
Return the number of elements present locally on-heap in current node.
The count returned might not be very accurate if maxEntriesLocalHeap is set to small values.

Returns:
the number of elements present locally on-heap in current node.

localOffHeapSize

int localOffHeapSize()
Return the number of elements present locally in off-heap of current node.

Returns:
the number of elements present locally in off-heap of current node.

containsKeyLocalOnHeap

boolean containsKeyLocalOnHeap(Object key)
Returns true if the key is present on-heap in current node.

Returns:
true if the key is present on-heap in current node otherwise false.

containsKeyLocalOffHeap

boolean containsKeyLocalOffHeap(Object key)
Returns true if the key is present off-heap in current node.

Returns:
true if the key is present off-heap in current node otherwise false.

put

V put(K key,
      V value,
      int createTimeInSecs,
      int customMaxTTISeconds,
      int customMaxTTLSeconds)

putVersioned

void putVersioned(K key,
                  V value,
                  long version)

putVersioned

void putVersioned(K key,
                  V value,
                  long version,
                  int createTimeInSecs,
                  int customMaxTTISeconds,
                  int customMaxTTLSeconds)

putIfAbsentVersioned

void putIfAbsentVersioned(K key,
                          V value,
                          long version)
This method is required for WAN specific usecase. NOT to be used by other Toolkit clients. It puts the new value only if the key was absent.

Parameters:
key -
value -
version - the new version

putIfAbsentVersioned

void putIfAbsentVersioned(K key,
                          V value,
                          long version,
                          int createTimeInSecs,
                          int customMaxTTISeconds,
                          int customMaxTTLSeconds)
This method is required for WAN specific usecase. NOT to be used by other Toolkit clients. It puts the new value only if the key was absent.

Parameters:
key -
value -
version -
createTimeInSecs -
customMaxTTISeconds -
customMaxTTLSeconds -

disposeLocally

void disposeLocally()
Dispose the Store from this node. If present elsewhere, the key-value store is still usable. Trying to use the store after disposing locally will throw IllegalStateException.


removeAll

void removeAll(Set<K> keys)

removeVersioned

void removeVersioned(Object key,
                     long version)

registerVersionUpdateListener

void registerVersionUpdateListener(VersionUpdateListener listener)

keySetForSegment

Set<K> keySetForSegment(int segmentIndex)
Return the set of Keys in the given segment of cache

Parameters:
segmentIndex -
Returns:

getVersionedValue

VersionedValue<V> getVersionedValue(Object key)
This method returns the VersionedValue corresponding to the given key. Note that it wont update the lastAccessedTime and will act as quite GET.

Parameters:
key -
Returns:
VersionedValue

clearVersioned

void clearVersioned()
This method clears the cache but wont generate the server events.


quickClear

void quickClear()
This method submit a request to clear for this cache and returns. The cache size may not be 0 immediately after this method call.


quickSize

int quickSize()
Returns approximate size of this cache without waiting for all transaction to finish.

Returns:
approximate size of this cache

remove

boolean remove(Object key,
               Object value,
               ToolkitValueComparator<V> comparator)
Removes the entry for a key only if currently mapped to a given value. This is equivalent to
   if (map.containsKey(key) &&comparator.equals(map.get(key), value)) {
       map.remove(key);
       return true;
   } else return false;
except that the action is performed atomically.

Parameters:
key - key with which the specified value is associated
value - value expected to be associated with the specified key
comparator - comparator to compare values
Returns:
true if the value was removed
Throws:
UnsupportedOperationException - if the remove operation is not supported by this map
ClassCastException - if the key or value is of an inappropriate type for this map (optional)
NullPointerException - if the specified key or value is null, and this map does not permit null keys or values (optional)

replace

boolean replace(K key,
                V oldValue,
                V newValue,
                ToolkitValueComparator<V> comparator)
Replaces the entry for a key only if currently mapped to a given value. This is equivalent to
   if (map.containsKey(key) && comparator.equals(map.get(key), oldValue)) {
       map.put(key, newValue);
       return true;
   } else return false;
except that the action is performed atomically.

Parameters:
key - key with which the specified value is associated
oldValue - value expected to be associated with the specified key
newValue - value to be associated with the specified key
comparator - comparator to compare values
Returns:
true if the value was replaced
Throws:
UnsupportedOperationException - if the put operation is not supported by this map
ClassCastException - if the class of a specified key or value prevents it from being stored in this map
NullPointerException - if a specified key or value is null, and this map does not permit null keys or values
IllegalArgumentException - if some property of a specified key or value prevents it from being stored in this map


Copyright © 2013 Terracotta, Inc.. All Rights Reserved.