|
||||||||||
| 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> |
| 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,
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 |
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. |
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
FinegrainedLock |
createFinegrainedLock(K key)
Obtain a fine-grained lock instance for a particular key. |
Set<Map.Entry<K,V>> |
entrySet()
|
boolean |
flush(Object key,
Object value)
|
V |
get(Object key)
|
Collection<Map.Entry<K,V>> |
getAllEntriesSnapshot()
|
Collection<Map.Entry<K,V>> |
getAllLocalEntriesSnapshot()
|
List<Map<K,?>> |
getConstituentMaps()
|
String |
getLockIdForKey(K key)
|
Map.Entry<K,V> |
getRandomEntry()
|
Map.Entry<K,V> |
getRandomLocalEntry()
|
boolean |
isEmpty()
This method reflects the state of the map instance that is local on the node. |
Set<K> |
keySet()
|
int |
localSize()
|
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. |
MapSizeListener |
registerMapSizeListener(MapSizeListener newListener)
|
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. |
V |
replace(K key,
V value)
|
boolean |
replace(K key,
V oldValue,
V newValue)
|
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)
|
V |
unlockedGet(Object key)
|
void |
unlockedPutNoReturn(K key,
V value)
|
void |
unlockedRemoveNoReturn(K key)
|
void |
unlockEntry(K key)
In a shared instance of a concurrent distributed map this will unlock the associated entry. |
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 |
| 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| 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 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.
key - the key of the entry to removepublic void unlockedRemoveNoReturn(K key)
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)
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)
public boolean isEmpty()
isEmpty in interface Map<K,V>public Set<K> keySet()
keySet in interface Map<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.
key - the key of the entry to putvalue - the value of the entry to put
public void unlockedPutNoReturn(K key,
V value)
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()
public Collection<V> values()
values in interface Map<K,V>public Collection<Map.Entry<K,V>> getAllLocalEntriesSnapshot()
public Collection<Map.Entry<K,V>> getAllEntriesSnapshot()
public FinegrainedLock createFinegrainedLock(K key)
LockableMap
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 String getLockIdForKey(K key)
public 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,?>> getConstituentMaps()
public Map.Entry<K,V> getRandomEntry()
public Map.Entry<K,V> getRandomLocalEntry()
public boolean flush(Object key,
Object value)
public boolean tryRemove(Object key,
long time,
TimeUnit unit)
public MapSizeListener registerMapSizeListener(MapSizeListener newListener)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||