|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.terracotta.collections.ConcurrentDistributedMap<K,V>
K - type of mapped keysV - type of mapped valuespublic class ConcurrentDistributedMap<K,V>
A ConcurrentMap that automatically switches its implementation to one that is highly concurrent 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 principal aspects of the Terracotta DSO optimized implementation is that locking is done on several levels.
First of all, each local instance of the map is always correctly synchronized locally to ensure consistency and coherency within a single JVM.
Secondly, cluster-wide locking is split up in two levels:
This cluster-wide locking scheme provides very high concurrency at the cost of unbalanced coherency. This means that the visibility of changes made through the key-based methods will not necessarily be in order with map-based locking methods and vice-versa.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface java.util.Map |
|---|
Map.Entry<K,V> |
| Field Summary | |
|---|---|
protected CacheConfig |
cacheConfig
|
static int |
DEFAULT_CONCURRENCY
|
static boolean |
DEFAULT_INVALIDATE_ON_CHANGE
|
protected boolean |
deleteValueOnRemove
|
protected boolean |
invalidateOnChange
|
protected ClusteredMap<K,V> |
map
|
protected MutatorsWithCallbacks<K,V> |
mutateCallbacks
|
| Constructor Summary | |
|---|---|
ConcurrentDistributedMap()
Creates a new ConcurrentDistributedMap instance with a default lock type of WRITE
and the default lock strategy of HashcodeLockStrategy. |
|
ConcurrentDistributedMap(LockType lockType,
GenericLockStrategy<L,? super K> lockStrategy,
int concurrency)
|
|
ConcurrentDistributedMap(LockType lockType,
LockStrategy<? super K> lockStrategy)
Creates a new ConcurrentDistributedMap instance that allows the specification of the internal lock type
that should be used when Terracotta DSO is active. |
|
ConcurrentDistributedMap(LockType lockType,
LockStrategy<? super K> lockStrategy,
int concurrency)
Creates a new ConcurrentDistributedMap 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 |
__tc_applicator_clear()
|
void |
__tc_applicator_put(Object obj,
Object obj1)
|
void |
__tc_applicator_remove(Object obj)
|
Collection |
__tc_getAllEntriesSnapshot()
|
Collection |
__tc_getAllLocalEntriesSnapshot()
|
void |
__tc_put_logical(Object key,
Object value)
|
void |
__tc_remove_logical(Object key)
|
void |
checkInObject(K key,
V value)
|
V |
checkOutObject(K key,
V value)
|
void |
clear()
This method clears the map locally on the node that is resides on but doesn't guarantee when this is done on other nodes in the cluster. |
void |
clearWithCallback(MutationCallback<K,V> callback)
|
boolean |
containsKey(Object key)
|
boolean |
containsLocalKey(K key)
|
boolean |
containsValue(Object value)
|
ClusteredLock |
createFinegrainedLock(K key)
Create a lock for the given key. |
Set<Map.Entry<K,V>> |
entrySet()
|
boolean |
flush(Object key,
Object value)
Attempt to recover any local memory resources used by this mapping. |
V |
get(Object key)
|
Collection<Map.Entry<K,V>> |
getAllEntriesSnapshot()
A collection of all entries within this map. |
Collection<Map.Entry<K,V>> |
getAllLocalEntriesSnapshot()
A collection of all in-heap entries within this map. |
List<Map<K,V>> |
getConstituentMaps()
Get a list of the constituent maps that comprise this map. |
Map.Entry<K,V> |
getRandomEntry()
Get a randomly selected entry from this map. |
Map.Entry<K,V> |
getRandomLocalEntry()
Get a randomly selected in-heap entry from this map. |
boolean |
isEmpty()
This method reflects the state of the map instance that is local on the node. |
boolean |
isPinned(K key)
|
Set<K> |
keySet()
|
Set<K> |
localKeySet()
|
int |
localSize()
Return the count of local in-heap entries. |
void |
lockEntry(K key)
In a shared instance of a concurrent distributed map this will lock the associated entry. |
V |
put(K key,
V value)
|
void |
putAll(Map<? extends K,? extends V> t)
|
V |
putIfAbsent(K key,
V value)
|
void |
putNoReturn(K key,
V value)
Behaves the same as the standard put(Object, Object)�method except that the previous value is not
returned. |
void |
putNoReturnWithCallback(K key,
V value,
MutationCallback<K,V> callback)
|
MapSizeListener |
registerMapSizeListener(MapSizeListener newListener)
Register a map-size listener on this map. |
V |
remove(Object key)
|
boolean |
remove(Object key,
Object value)
|
void |
removeNoReturn(K key)
Behaves the same as the standard remove(Object) method except that the previous value is not returned. |
void |
removeNoReturnWithCallback(K key,
MutationCallback<K,V> callback)
|
V |
removeWithCallback(K key,
MutationCallback<K,V> callback)
|
boolean |
removeWithCallback(K key,
V value,
MutationCallback<K,V> callback)
|
V |
replace(K key,
V value)
|
boolean |
replace(K key,
V oldValue,
V newValue)
|
void |
setMaxTTI(int maxTTI)
|
void |
setMaxTTL(int maxTTL)
|
void |
setPinned(K key,
boolean pinned)
|
void |
setTargetMaxTotalCount(int targetMaxTotalCount)
|
int |
size()
This method reflects the state of the map instance that is local on the node. |
boolean |
tryRemove(Object key,
long time,
TimeUnit unit)
Attempts to remove the mapping for the given key. |
V |
unlockedGet(Object key)
Perform an unlocked read for the given key. |
Map<K,V> |
unlockedGetAll(Set<K> keys)
|
void |
unlockedPutIfAbsentNoReturn(K key,
V value)
|
void |
unlockedPutIfAbsentNoReturnWithCallback(K key,
V value,
MutationCallback<K,V> callback)
|
void |
unlockedPutNoReturn(K key,
V value)
Performs an unlocked ClusteredMap.putNoReturn(Object, Object) |
void |
unlockedPutNoReturnWithCallback(K key,
V value,
MutationCallback<K,V> callback)
|
void |
unlockedRemoveNoReturn(K key)
Performs an unlocked ClusteredMap.removeNoReturn(Object) |
void |
unlockedRemoveNoReturn(K key,
V value)
|
void |
unlockedRemoveNoReturnWithCallback(K key,
MutationCallback<K,V> callback)
|
void |
unlockedRemoveNoReturnWithCallback(K key,
V value,
MutationCallback<K,V> callback)
|
void |
unlockedReplaceNoReturn(K key,
V currentValue,
V newValue)
|
void |
unlockedReplaceNoReturnWithCallback(K key,
V current,
V newValue,
MutationCallback<K,V> callback)
|
void |
unlockEntry(K key)
In a shared instance of a concurrent distributed map this will unlock the associated entry. |
void |
unpinAll()
|
V |
unsafeGet(K key)
Perform a raw/unlocked read for the given key. |
Collection<V> |
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 |
|---|
public static final int DEFAULT_CONCURRENCY
public static final boolean DEFAULT_INVALIDATE_ON_CHANGE
protected final ClusteredMap<K,V> map
protected final boolean invalidateOnChange
protected final boolean deleteValueOnRemove
protected final MutatorsWithCallbacks<K,V> mutateCallbacks
protected final CacheConfig cacheConfig
| Constructor Detail |
|---|
public ConcurrentDistributedMap()
ConcurrentDistributedMap instance with a default lock type of WRITE
and the default lock strategy of HashcodeLockStrategy.
ConcurrentDistributedMap(LockType, LockStrategy)
public ConcurrentDistributedMap(LockType lockType,
LockStrategy<? super K> lockStrategy)
ConcurrentDistributedMap instance that allows the specification of the internal lock type
that should be used when Terracotta DSO is active.
lockType - the lock type that should be used internally when Terracotta DSO is activelockStrategy - the lock strategy to use for this mapLockType,
LockStrategy
public ConcurrentDistributedMap(LockType lockType,
LockStrategy<? super K> lockStrategy,
int concurrency)
ConcurrentDistributedMap 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.
lockType - the lock type that should be used internally when Terracotta DSO is activelockStrategy - the lock strategy to use for this mapconcurrency - the estimated number of concurrently updating threadsLockType,
LockStrategy
public ConcurrentDistributedMap(LockType lockType,
GenericLockStrategy<L,? super K> lockStrategy,
int concurrency)
| Method Detail |
|---|
public V putIfAbsent(K key,
V value)
putIfAbsent in interface ConcurrentMap<K,V>
public boolean remove(Object key,
Object value)
remove in interface ConcurrentMap<K,V>
public boolean removeWithCallback(K key,
V value,
MutationCallback<K,V> callback)
removeWithCallback in interface MutatorsWithCallbacks<K,V>
public V replace(K key,
V value)
replace in interface ConcurrentMap<K,V>public void removeNoReturn(K key)
remove(Object) method except that the previous value is not returned.
This can provide significant performance improvements when used in a Terracotta DSO cluster.
removeNoReturn in interface ClusteredMap<K,V>key - the key of the entry to removepublic void unlockedRemoveNoReturn(K key)
ClusteredMapClusteredMap.removeNoReturn(Object)
unlockedRemoveNoReturn in interface ClusteredMap<K,V>
public boolean replace(K key,
V oldValue,
V newValue)
replace in interface ConcurrentMap<K,V>public void clear()
clear in interface Map<K,V>public boolean containsKey(Object key)
containsKey in interface Map<K,V>public V unsafeGet(K key)
unsafeGet in interface ClusteredMap<K,V>key - The key to lookup
public boolean containsValue(Object value)
containsValue in interface Map<K,V>public Set<Map.Entry<K,V>> entrySet()
entrySet in interface Map<K,V>public V get(Object key)
get in interface Map<K,V>public V unlockedGet(Object key)
ClusteredMapThis method performs no locking and thus provides no visibility guarantees.
unlockedGet in interface ClusteredMap<K,V>key - the key to lookup
public Map<K,V> unlockedGetAll(Set<K> keys)
unlockedGetAll in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>public boolean isEmpty()
isEmpty in interface Map<K,V>public Set<K> keySet()
keySet in interface Map<K,V>public Set<K> localKeySet()
localKeySet in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>public void unpinAll()
unpinAll in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>public boolean isPinned(K key)
isPinned in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>
public void setPinned(K key,
boolean pinned)
setPinned in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>public boolean containsLocalKey(K key)
containsLocalKey in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>
public V put(K key,
V value)
put in interface Map<K,V>
public void putNoReturn(K key,
V value)
put(Object, Object)�method except that the previous value is not
returned. This can provide significant performance improvements when used in a Terracotta DSO cluster.
putNoReturn in interface ClusteredMap<K,V>key - the key of the entry to putvalue - the value of the entry to put
public void unlockedPutNoReturn(K key,
V value)
ClusteredMapClusteredMap.putNoReturn(Object, Object)
unlockedPutNoReturn in interface ClusteredMap<K,V>public void putAll(Map<? extends K,? extends V> t)
putAll in interface Map<K,V>public V remove(Object key)
remove in interface Map<K,V>public int size()
size in interface Map<K,V>public int localSize()
ClusteredMap
localSize in interface ClusteredMap<K,V>public Collection<V> values()
values in interface Map<K,V>public Collection<Map.Entry<K,V>> getAllLocalEntriesSnapshot()
ClusteredMap
getAllLocalEntriesSnapshot in interface ClusteredMap<K,V>public Collection<Map.Entry<K,V>> getAllEntriesSnapshot()
ClusteredMap
getAllEntriesSnapshot in interface ClusteredMap<K,V>public ClusteredLock createFinegrainedLock(K key)
ClusteredMapThis methods returns as finegrained a lock that still provides exclusion against modification of the mapping for this key.
createFinegrainedLock in interface ClusteredMap<K,V>createFinegrainedLock in interface LockableMap<K>key - the key for which a fine-grained lock has to be constructed
public void lockEntry(K key)
ConcurrentDistributedMap instances allow non existent entries to be locked.
lockEntry in interface LockableMap<K>key - the key for which all entry accesses have to be lockedpublic void unlockEntry(K key)
unlockEntry in interface LockableMap<K>key - the key for which all entry accesses have to be unlockedpublic void __tc_applicator_clear()
public void __tc_applicator_put(Object obj,
Object obj1)
public void __tc_applicator_remove(Object obj)
public Collection __tc_getAllEntriesSnapshot()
public Collection __tc_getAllLocalEntriesSnapshot()
public void __tc_put_logical(Object key,
Object value)
public void __tc_remove_logical(Object key)
public List<Map<K,V>> getConstituentMaps()
ClusteredMap
This list will be a singleton list whose element is this if this map is not a composite map.
getConstituentMaps in interface ClusteredMap<K,V>public Map.Entry<K,V> getRandomEntry()
ClusteredMap
getRandomEntry in interface ClusteredMap<K,V>public Map.Entry<K,V> getRandomLocalEntry()
ClusteredMap
getRandomLocalEntry in interface ClusteredMap<K,V>
public boolean flush(Object key,
Object value)
ClusteredMap
flush in interface ClusteredMap<K,V>key - key for the mappingvalue - value for the mapping
true if memory was recovered
public boolean tryRemove(Object key,
long time,
TimeUnit unit)
ClusteredMap
If the mapping is succesfully removed inside the specified time then true is returned.
tryRemove in interface ClusteredMap<K,V>key - key for the mapping to be removedtime - time to spend attempting removalunit - time unit for the timeout
true if the mapping was removedpublic MapSizeListener registerMapSizeListener(MapSizeListener newListener)
ClusteredMap
This method returns the listener previously associated with this map. This allows for simple listener chaining or
composition when multiple listeners are required. If no listener was previously registered then null is
returned.
registerMapSizeListener in interface ClusteredMap<K,V>newListener - listener to register
public void putNoReturnWithCallback(K key,
V value,
MutationCallback<K,V> callback)
putNoReturnWithCallback in interface MutatorsWithCallbacks<K,V>public void clearWithCallback(MutationCallback<K,V> callback)
clearWithCallback in interface MutatorsWithCallbacks<K,V>
public void removeNoReturnWithCallback(K key,
MutationCallback<K,V> callback)
removeNoReturnWithCallback in interface MutatorsWithCallbacks<K,V>
public V removeWithCallback(K key,
MutationCallback<K,V> callback)
removeWithCallback in interface MutatorsWithCallbacks<K,V>
public void unlockedPutNoReturnWithCallback(K key,
V value,
MutationCallback<K,V> callback)
unlockedPutNoReturnWithCallback in interface MutatorsWithCallbacks<K,V>
public void unlockedRemoveNoReturnWithCallback(K key,
MutationCallback<K,V> callback)
unlockedRemoveNoReturnWithCallback in interface MutatorsWithCallbacks<K,V>
public void unlockedReplaceNoReturn(K key,
V currentValue,
V newValue)
unlockedReplaceNoReturn in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>
public void unlockedRemoveNoReturn(K key,
V value)
unlockedRemoveNoReturn in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>
public void unlockedPutIfAbsentNoReturn(K key,
V value)
unlockedPutIfAbsentNoReturn in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>
public void unlockedRemoveNoReturnWithCallback(K key,
V value,
MutationCallback<K,V> callback)
unlockedRemoveNoReturnWithCallback in interface MutatorsWithCallbacks<K,V>
public void unlockedReplaceNoReturnWithCallback(K key,
V current,
V newValue,
MutationCallback<K,V> callback)
unlockedReplaceNoReturnWithCallback in interface MutatorsWithCallbacks<K,V>
public void unlockedPutIfAbsentNoReturnWithCallback(K key,
V value,
MutationCallback<K,V> callback)
unlockedPutIfAbsentNoReturnWithCallback in interface MutatorsWithCallbacks<K,V>public void setTargetMaxTotalCount(int targetMaxTotalCount)
setTargetMaxTotalCount in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>public void setMaxTTI(int maxTTI)
setMaxTTI in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>public void setMaxTTL(int maxTTL)
setMaxTTL in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>
public void checkInObject(K key,
V value)
checkInObject in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>
public V checkOutObject(K key,
V value)
checkOutObject in interface com.terracotta.toolkit.collections.InternalClusteredMap<K,V>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||