org.terracotta.collections
Class ConcurrentDistributedServerMap<K,V>

java.lang.Object
  extended by org.terracotta.collections.ConcurrentDistributedMap<K,V>
      extended by org.terracotta.collections.ConcurrentDistributedServerMap<K,V>
Type Parameters:
K - type of mapped keys
V - type of mapped values
All Implemented Interfaces:
com.terracotta.toolkit.collections.InternalClusteredMap<K,V>, com.terracotta.toolkit.collections.InternalLocallyCacheable, ConcurrentMap<K,V>, Map<K,V>, CacheEvictionListenerSupport, LocallyCacheable, ClusteredMap<K,V>, MutatorsWithCallbacks<K,V>, LockableMap<K>
Direct Known Subclasses:
EnterpriseConcurrentDistributedMap

public class ConcurrentDistributedServerMap<K,V>
extends ConcurrentDistributedMap<K,V>
implements com.terracotta.toolkit.collections.InternalLocallyCacheable, CacheEvictionListenerSupport

A ConcurrentMap that automatically switches its implementation to one that is highly concurrent server-side map in a Terracotta DSO cluster. When Terracotta DSO isn't active, a traditional ConcurrentMap implementation like ConcurrentHashMap is used within a single JVM.

Map entries can't use null for keys or values.

One of the map difference between EnterpriseConcurrentDistributedMap and ConcurrentDistributedMap is the DCV2 Storage Strategy; This allows for an unlimited key-space for this map.

Author:
Abhishek Sanoujam , Nabib El-Rahman

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Field Summary
static int SERVERMAP_DEFAULT_CONCURRENCY
           
 
Fields inherited from class org.terracotta.collections.ConcurrentDistributedMap
cacheConfig, DEFAULT_CONCURRENCY, DEFAULT_INVALIDATE_ON_CHANGE, deleteValueOnRemove, invalidateOnChange, map, mutateCallbacks
 
Constructor Summary
ConcurrentDistributedServerMap(CacheConfig cacheConfig, LockType lockType, GenericLockStrategy<L,? super K> lockStrategy, int concurrency)
           
ConcurrentDistributedServerMap(CacheConfig cacheConfig, LockType lockType, GenericLockStrategy<L,? super K> lockStrategy, int concurrency, boolean invalidateOnChange)
           
ConcurrentDistributedServerMap(CacheConfig cacheConfig, LockType lockType, GenericLockStrategy<L,? super K> lockStrategy, int concurrency, boolean invalidateOnChange, boolean deleteValueOnRemove)
           
ConcurrentDistributedServerMap(CacheConfig cacheConfig, LockType lockType, LockStrategy<? super K> lockStrategy)
          Creates a new EnterpriseConcurrentDistributedMap instance that allows the specification of the internal lock type that should be used when Terracotta DSO is active and the concurrency of internal data structures.
ConcurrentDistributedServerMap(CacheConfig cacheConfig, LockType lockType, LockStrategy<? super K> lockStrategy, int concurrency)
          Creates a new EnterpriseConcurrentDistributedMap instance that allows the specification of the internal lock type that should be used when Terracotta DSO is active and the concurrency of internal data structures.
ConcurrentDistributedServerMap(ConcurrentDistributedServerMapParameters<K,L> parameters)
           
ConcurrentDistributedServerMap(LockType lockType, LockStrategy<? super K> lockStrategy)
          Creates a new EnterpriseConcurrentDistributedMap instance that allows the specification of the internal lock type that should be used when Terracotta DSO is active.
ConcurrentDistributedServerMap(LockType lockType, LockStrategy<? super K> lockStrategy, int concurrency)
          Creates a new EnterpriseConcurrentDistributedMap instance that allows the specification of the internal lock type that should be used when Terracotta DSO is active and the concurrency of internal data structures
 
Method Summary
 void addCacheEvictionListener(CacheEvictionListener listener)
           
 void clearLocalCache()
          Clears the local cache
 boolean containsKeyLocalOffHeap(Object key)
           
 boolean containsKeyLocalOnHeap(Object key)
           
 void destroyLocalCache()
           
 Collection<Map.Entry<K,V>> getAllEntriesSnapshot()
          A collection of all entries within this map.
protected
<L> ClusteredMap<K,V>
initBackend(CacheConfig cacheConfigParam, LockType lockType, GenericLockStrategy<L,? super K> lockStrategy, int concurrency)
           
 void initializeLocalCache()
           
 boolean isEmpty()
          This method reflects the state of the map instance that is local on the node.
 int localOffHeapSize()
           
 long localOffHeapSizeInBytes()
           
 int localOnHeapSize()
           
 long localOnHeapSizeInBytes()
           
 void onLoad()
           
 void recalculateLocalCacheSize(Object key)
           
 void removeCacheEvictionListener(CacheEvictionListener listener)
           
 void setLocalCacheEnabled(boolean enabled)
           
 void setMaxBytesLocalHeap(long maxBytesLocalHeap)
           
 void setMaxEntriesLocalHeap(int maxEntriesLocalHeap)
           
 void setMaxTTI(int maxTTI)
           
 void setMaxTTL(int maxTTL)
           
 void setTargetMaxTotalCount(int targetMaxTotalCount)
           
 int size()
          This method reflects the state of the map instance that is local on the node.
 
Methods inherited from class org.terracotta.collections.ConcurrentDistributedMap
__tc_applicator_clear, __tc_applicator_put, __tc_applicator_remove, __tc_getAllEntriesSnapshot, __tc_getAllLocalEntriesSnapshot, __tc_put_logical, __tc_remove_logical, checkInObject, checkOutObject, clear, clearWithCallback, containsKey, containsLocalKey, containsValue, createFinegrainedLock, entrySet, flush, get, getAllLocalEntriesSnapshot, getConstituentMaps, getRandomEntry, getRandomLocalEntry, isPinned, keySet, localKeySet, localSize, lockEntry, put, putAll, putIfAbsent, putNoReturn, putNoReturnWithCallback, registerMapSizeListener, remove, remove, removeNoReturn, removeNoReturnWithCallback, removeWithCallback, removeWithCallback, replace, replace, setPinned, tryRemove, unlockedGet, unlockedGetAll, unlockedPutIfAbsentNoReturn, unlockedPutIfAbsentNoReturnWithCallback, unlockedPutNoReturn, unlockedPutNoReturnWithCallback, unlockedRemoveNoReturn, unlockedRemoveNoReturn, unlockedRemoveNoReturnWithCallback, unlockedRemoveNoReturnWithCallback, unlockedReplaceNoReturn, unlockedReplaceNoReturnWithCallback, unlockEntry, unpinAll, unsafeGet, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

SERVERMAP_DEFAULT_CONCURRENCY

public static final int SERVERMAP_DEFAULT_CONCURRENCY
See Also:
Constant Field Values
Constructor Detail

ConcurrentDistributedServerMap

public ConcurrentDistributedServerMap(LockType lockType,
                                      LockStrategy<? super K> lockStrategy)
Creates a new EnterpriseConcurrentDistributedMap instance that allows the specification of the internal lock type that should be used when Terracotta DSO is active.

Parameters:
lockType - the lock type that should be used internally when Terracotta DSO is active
lockStrategy - the lock strategy to use for this map
See Also:
LockType, LockStrategy

ConcurrentDistributedServerMap

public ConcurrentDistributedServerMap(LockType lockType,
                                      LockStrategy<? super K> lockStrategy,
                                      int concurrency)
Creates a new EnterpriseConcurrentDistributedMap instance that allows the specification of the internal lock type that should be used when Terracotta DSO is active and the concurrency of internal data structures

Parameters:
lockType - the lock type that should be used internally when Terracotta DSO is active
lockStrategy - the lock strategy to use for this map
concurrency - the estimated number of concurrently updating threads
See Also:
LockType, LockStrategy

ConcurrentDistributedServerMap

public ConcurrentDistributedServerMap(CacheConfig cacheConfig,
                                      LockType lockType,
                                      LockStrategy<? super K> lockStrategy)
Creates a new EnterpriseConcurrentDistributedMap instance that allows the specification of the internal lock type that should be used when Terracotta DSO is active and the concurrency of internal data structures.

Parameters:
cacheConfig - specific configuration for cache (i.e. tti, tti)
lockType - the lock type that should be used internally when Terracotta DSO is active
lockStrategy - the lock strategy to use for this map
See Also:
CacheConfig, LockType, LockStrategy

ConcurrentDistributedServerMap

public ConcurrentDistributedServerMap(CacheConfig cacheConfig,
                                      LockType lockType,
                                      LockStrategy<? super K> lockStrategy,
                                      int concurrency)
Creates a new EnterpriseConcurrentDistributedMap instance that allows the specification of the internal lock type that should be used when Terracotta DSO is active and the concurrency of internal data structures.

Parameters:
cacheConfig - specific configuration for cache (i.e. tti, tti)
lockType - the lock type that should be used internally when Terracotta DSO is active
lockStrategy - the lock strategy to use for this map
concurrency - the estimated number of concurrently updating threads
See Also:
CacheConfig, LockType, LockStrategy

ConcurrentDistributedServerMap

public ConcurrentDistributedServerMap(CacheConfig cacheConfig,
                                      LockType lockType,
                                      GenericLockStrategy<L,? super K> lockStrategy,
                                      int concurrency)

ConcurrentDistributedServerMap

public ConcurrentDistributedServerMap(CacheConfig cacheConfig,
                                      LockType lockType,
                                      GenericLockStrategy<L,? super K> lockStrategy,
                                      int concurrency,
                                      boolean invalidateOnChange,
                                      boolean deleteValueOnRemove)

ConcurrentDistributedServerMap

public ConcurrentDistributedServerMap(CacheConfig cacheConfig,
                                      LockType lockType,
                                      GenericLockStrategy<L,? super K> lockStrategy,
                                      int concurrency,
                                      boolean invalidateOnChange)

ConcurrentDistributedServerMap

public ConcurrentDistributedServerMap(ConcurrentDistributedServerMapParameters<K,L> parameters)
Method Detail

initBackend

protected <L> ClusteredMap<K,V> initBackend(CacheConfig cacheConfigParam,
                                            LockType lockType,
                                            GenericLockStrategy<L,? super K> lockStrategy,
                                            int concurrency)

onLoad

public void onLoad()

clearLocalCache

public void clearLocalCache()
Description copied from interface: LocallyCacheable
Clears the local cache

Specified by:
clearLocalCache in interface LocallyCacheable

addCacheEvictionListener

public void addCacheEvictionListener(CacheEvictionListener listener)
Specified by:
addCacheEvictionListener in interface CacheEvictionListenerSupport

removeCacheEvictionListener

public void removeCacheEvictionListener(CacheEvictionListener listener)
Specified by:
removeCacheEvictionListener in interface CacheEvictionListenerSupport

size

public int size()
Description copied from class: ConcurrentDistributedMap
This method reflects the state of the map instance that is local on the node. Any changes that are done through methods that operate on specific keys are not guaranteed to have been propagated throughout the cluster.

Specified by:
size in interface Map<K,V>
Overrides:
size in class ConcurrentDistributedMap<K,V>

isEmpty

public boolean isEmpty()
Description copied from class: ConcurrentDistributedMap
This method reflects the state of the map instance that is local on the node. Any changes that are done through methods that operate on specific keys are not guaranteed to have been propagated throughout the cluster.

Specified by:
isEmpty in interface Map<K,V>
Overrides:
isEmpty in class ConcurrentDistributedMap<K,V>

getAllEntriesSnapshot

public Collection<Map.Entry<K,V>> getAllEntriesSnapshot()
Description copied from interface: ClusteredMap
A collection of all entries within this map.

Specified by:
getAllEntriesSnapshot in interface ClusteredMap<K,V>
Overrides:
getAllEntriesSnapshot in class ConcurrentDistributedMap<K,V>
Returns:
all map entries

initializeLocalCache

public void initializeLocalCache()
Specified by:
initializeLocalCache in interface com.terracotta.toolkit.collections.InternalLocallyCacheable

localOnHeapSizeInBytes

public long localOnHeapSizeInBytes()
Specified by:
localOnHeapSizeInBytes in interface com.terracotta.toolkit.collections.InternalLocallyCacheable

localOffHeapSizeInBytes

public long localOffHeapSizeInBytes()
Specified by:
localOffHeapSizeInBytes in interface com.terracotta.toolkit.collections.InternalLocallyCacheable

localOnHeapSize

public int localOnHeapSize()
Specified by:
localOnHeapSize in interface com.terracotta.toolkit.collections.InternalLocallyCacheable

localOffHeapSize

public int localOffHeapSize()
Specified by:
localOffHeapSize in interface com.terracotta.toolkit.collections.InternalLocallyCacheable

destroyLocalCache

public void destroyLocalCache()
Specified by:
destroyLocalCache in interface com.terracotta.toolkit.collections.InternalLocallyCacheable

containsKeyLocalOnHeap

public boolean containsKeyLocalOnHeap(Object key)
Specified by:
containsKeyLocalOnHeap in interface com.terracotta.toolkit.collections.InternalLocallyCacheable

containsKeyLocalOffHeap

public boolean containsKeyLocalOffHeap(Object key)
Specified by:
containsKeyLocalOffHeap in interface com.terracotta.toolkit.collections.InternalLocallyCacheable

setTargetMaxTotalCount

public void setTargetMaxTotalCount(int targetMaxTotalCount)
Specified by:
setTargetMaxTotalCount in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>
Overrides:
setTargetMaxTotalCount in class ConcurrentDistributedMap<K,V>

setMaxTTI

public void setMaxTTI(int maxTTI)
Specified by:
setMaxTTI in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>
Overrides:
setMaxTTI in class ConcurrentDistributedMap<K,V>

setMaxTTL

public void setMaxTTL(int maxTTL)
Specified by:
setMaxTTL in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>
Overrides:
setMaxTTL in class ConcurrentDistributedMap<K,V>

setMaxEntriesLocalHeap

public void setMaxEntriesLocalHeap(int maxEntriesLocalHeap)
Specified by:
setMaxEntriesLocalHeap in interface com.terracotta.toolkit.collections.InternalLocallyCacheable

setMaxBytesLocalHeap

public void setMaxBytesLocalHeap(long maxBytesLocalHeap)
Specified by:
setMaxBytesLocalHeap in interface com.terracotta.toolkit.collections.InternalLocallyCacheable

setLocalCacheEnabled

public void setLocalCacheEnabled(boolean enabled)
Specified by:
setLocalCacheEnabled in interface com.terracotta.toolkit.collections.InternalLocallyCacheable

recalculateLocalCacheSize

public void recalculateLocalCacheSize(Object key)
Specified by:
recalculateLocalCacheSize in interface com.terracotta.toolkit.collections.InternalLocallyCacheable


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