|
Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ConcurrentMap
Map with additional concurrency features.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface java.util.Map |
---|
Map.Entry |
Field Summary | |
---|---|
static Object |
LOCK_ALL Special key value indicating an intent to lock the entire map. |
Method Summary | |
---|---|
void |
clear() Removes all mappings from this map. |
boolean |
containsKey(Object key) Returns true if this map contains a mapping for the specified key. |
boolean |
containsValue(Object value) Returns true if this map maps one or more keys to the specified value. |
Object |
get(Object key) Returns the value to which this map maps the specified key. |
boolean |
isEmpty() Returns true if this map contains no key-value mappings. |
boolean |
lock(Object oKey) Attempt to lock the specified item and return immediately. |
boolean |
lock(Object oKey, long cWait) Attempt to lock the specified item within the specified period of time. |
Object |
put(Object key, Object value) Associates the specified value with the specified key in this map (optional operation). |
void |
putAll(Map map) Copies all of the mappings from the specified map to this map (optional operation). |
Object |
remove(Object key) Removes the mapping for this key from this map if present (optional operation). |
int |
size() Returns the number of key-value mappings in this map. |
boolean |
unlock(Object oKey) Unlock the specified item. |
Methods inherited from interface java.util.Map |
---|
entrySet, equals, hashCode, keySet, values |
Field Detail |
---|
static final Object LOCK_ALL
Method Detail |
---|
boolean lock(Object oKey, long cWait)
The item doesn't have to exist to be locked. While the item is locked there is known to be a lock holder which has an exclusive right to modify (calling put and remove methods) that item.
Lock holder is an abstract concept that depends on the ConcurrentMap implementation. For example, holder could be a cluster member or a thread (or both).
Locking strategy may vary for concrete implementations as well. Lock could have an expiration time (this lock is sometimes called a "lease") or be held indefinitely (until the lock holder terminates).
Some implementations may allow the entire map to be locked. If the map is locked in such a way, then only a lock holder is allowed to perform any of the "put" or "remove" operations. Pass the special constant LOCK_ALL
as the oKey parameter to indicate the map lock.
oKey
- key being lockedcWait
- the number of milliseconds to continue trying to obtain a lock; pass zero to return immediately; pass -1 to block the calling thread until the lock could be obtainedboolean lock(Object oKey)
This method behaves exactly as if it simply performs the call lock(oKey, 0).
oKey
- key being lockedboolean unlock(Object oKey)
oKey
- key being unlockedint size()
size
in interface Map
boolean isEmpty()
isEmpty
in interface Map
boolean containsKey(Object key)
containsKey
in interface Map
key
- key whose presence in this map is to be tested.ClassCastException
- if the key is of an inappropriate type for this map.NullPointerException
- if the key is null and this map does not not permit null keys.boolean containsValue(Object value)
containsValue
in interface Map
value
- value whose presence in this map is to be tested.Object get(Object key)
get
in interface Map
key
- key whose associated value is to be returned.ClassCastException
- if the key is of an inappropriate type for this map.NullPointerException
- key is null and this map does not not permit null keys.containsKey(Object)
Object put(Object key, Object value)
put
in interface Map
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.IllegalArgumentException
- if the value cannot be stored in the map (i.e. not serializable)ConcurrentModificationException
- if the lock could not be successfully obtained for the specified key.ClassCastException
- if the class of the specified key or value prevents it from being stored in this map.NullPointerException
- this map does not permit null keys or values, and the specified key or value is null.Object remove(Object key)
remove
in interface Map
key
- key whose mapping is to be removed from the map.ConcurrentModificationException
- if the lock could not be successfully obtained for the specified key.void putAll(Map map)
putAll
in interface Map
map
- Mappings to be stored in this map.ClassCastException
- if the class of a key or value in the specified map prevents it from being stored in this map.ConcurrentModificationException
- if the lock could not be successfully obtained for some keyNullPointerException
- this map does not permit null keys or values, and the specified key or value is null.void clear()
clear
in interface Map
ConcurrentModificationException
- if a lock could not be successfully obtained for some key.
|
Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |