|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.tangosol.util.Base
com.tangosol.util.AbstractKeyBasedMap
com.tangosol.util.AbstractKeySetBasedMap
com.tangosol.util.WrapperObservableMap
com.tangosol.util.WrapperConcurrentMap
public class WrapperConcurrentMap
A simple implementation of ConcurrentMap interface built as a wrapper around any Map implementation. As a subclass of WrapperObservableMap, it naturally implements the ObservableMap interface and provides an implementation of CacheStatistics interface.
Nested Class Summary | |
---|---|
protected static class |
WrapperConcurrentMap.Lock A lock object. |
Nested classes/interfaces inherited from class com.tangosol.util.WrapperObservableMap |
---|
WrapperObservableMap.InternalListener |
Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeySetBasedMap |
---|
AbstractKeySetBasedMap.EntrySet, AbstractKeySetBasedMap.KeyIterator, AbstractKeySetBasedMap.KeySet, AbstractKeySetBasedMap.ValuesCollection |
Nested classes/interfaces inherited from class com.tangosol.util.AbstractKeyBasedMap |
---|
AbstractKeyBasedMap.DeferredCacheEvent |
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry |
Field Summary | |
---|---|
protected long |
m_cWaitMillis The number of milliseconds to continue trying to obtain a lock in case when the locking is enforced. |
protected boolean |
m_fEnforceLocking Flag indicating whether or not the locking is enforced for put, remove and clear operations. |
protected Gate |
m_gateMap The ThreadGate object for the entire map. |
protected SafeHashMap |
m_mapLock The map containing all the locks. |
Fields inherited from class com.tangosol.util.WrapperObservableMap |
---|
m_fDeferredEvent, m_fTranslateEvents, m_listenerInternal, m_listenerSupport, m_map, m_stats |
Fields inherited from interface com.tangosol.util.ConcurrentMap |
---|
LOCK_ALL |
Constructor Summary | |
---|---|
WrapperConcurrentMap(java.util.Map map) Construct a ConcurrentMap wrapper based on the specified map with locking enforced for put, remove and clear operations. |
|
WrapperConcurrentMap(java.util.Map map, boolean fEnforceLocking, long cWaitMillis) Construct a ConcurrentMap wrapper based on the specified map. |
Method Summary | |
---|---|
void |
clear() Clear all key/value mappings. |
protected java.lang.String |
getDescription() Assemble a human-readable description. |
java.lang.String |
getLockDescription(java.lang.Object oKey) Make a human-readable description of the information kept about the passed key. |
long |
getWaitMillis() Return the number of milliseconds to continue trying to obtain a lock in case when the locking is enforced. |
protected WrapperConcurrentMap.Lock |
instantiateLock(java.lang.Object oKey) Factory pattern. |
protected boolean |
isInternalKeySetIteratorMutable() Determine if this Iterator should remove an iterated item by calling remove on the internal key Set Iterator, or by calling removeBlind on the map itself. |
boolean |
isLockingEnforced() Obtain the flag indicatinig whether or not the locking is enforced for put, remove and clear operations. |
boolean |
lock(java.lang.Object oKey) Attempt to lock the specified item and return immediately. |
boolean |
lock(java.lang.Object oKey, long cWait) Attempt to lock the specified item within the specified period of time. |
java.lang.Object |
put(java.lang.Object oKey, java.lang.Object oValue) Associates the specified value with the specified key in this map. |
void |
putAll(java.util.Map map) Copies all of the mappings from the specified map to this map. |
java.lang.Object |
remove(java.lang.Object oKey) Removes the mapping for this key from this map if present. |
protected boolean |
removeBlind(java.lang.Object oKey) Removes the mapping for this key from this map if present. |
void |
setLockingEnforced(boolean fEnforce) Set the flag indicatinig whether or not the locking is enforced for put, remove and clear operations. |
void |
setWaitMillis(long cWaitMillis) Specifiy the number of milliseconds to continue trying to obtain a lock in case when the locking is enforced. |
java.lang.String |
toString() Returns a string representation of this Map. |
boolean |
unlock(java.lang.Object oKey) Unlock the specified item. |
Methods inherited from class com.tangosol.util.AbstractKeySetBasedMap |
---|
containsKey, instantiateEntrySet, instantiateKeyIterator, instantiateKeySet, instantiateValues, isEmpty, iterateKeys, size |
Methods inherited from class com.tangosol.util.AbstractKeyBasedMap |
---|
clone, entrySet, equals, getAll, hashCode, keySet, values |
Methods inherited from interface com.tangosol.util.ConcurrentMap |
---|
containsKey, containsValue, get, isEmpty, size |
Methods inherited from interface java.util.Map |
---|
entrySet, equals, hashCode, keySet, values |
Field Detail |
---|
protected boolean m_fEnforceLocking
protected long m_cWaitMillis
protected final SafeHashMap m_mapLock
protected final Gate m_gateMap
Constructor Detail |
---|
public WrapperConcurrentMap(java.util.Map map)
Note: it is assumed that while the WrapperConcurrentMap exists, there is no direct manipulation with the content of the wrapped map.
map
- the Map that will be wrapped by this WrapperConcurrentMappublic WrapperConcurrentMap(java.util.Map map, boolean fEnforceLocking, long cWaitMillis)
Note: it is assumed that while the WrapperConcurrentMap exists, there is no direct manipulation with the content of the wrapped map.
map
- the Map that will be wrapped by this WrapperConcurrentMapfEnforceLocking
- if true the locking is enforced for put, remove and clear operations; otherwise a client is responsible for calling lock and unlock explicitlycWaitMillis
- if locking enforcement is required then this parameter speicifes the number of milliseconds to continue trying to obtain a lock; pass -1 to block the calling thread until the lock could be obtainedMethod Detail |
---|
public boolean lock(java.lang.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 ConcurrentMap.LOCK_ALL
as the oKey parameter to indicate the map lock.
lock
in interface ConcurrentMap
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 obtainedpublic boolean lock(java.lang.Object oKey)
This method behaves exactly as if it simply performs the call lock(oKey, 0).
lock
in interface ConcurrentMap
oKey
- key being lockedpublic boolean unlock(java.lang.Object oKey)
unlock
in interface ConcurrentMap
oKey
- key being unlockedpublic void clear()
If lock enforcement is required an attempt will be made to lock the entire map using the ConcurrentMap.LOCK_ALL
object.
Note: if this operation fails due to a ConcurrentModificationException, then any subset of the current mappings could still remain in the map.
clear
in interface ConcurrentMap
clear
in interface java.util.Map
clear
in class WrapperObservableMap
java.util.ConcurrentModificationException
- if any entry is locked by another threadpublic java.lang.Object put(java.lang.Object oKey, java.lang.Object oValue)
put
in interface ConcurrentMap
put
in interface java.util.Map
put
in class WrapperObservableMap
oKey
- key with which the specified value is to be associatedoValue
- value to be associated with the specified keyjava.util.ConcurrentModificationException
- if the entry is locked by another threadpublic void putAll(java.util.Map map)
AbstractKeyBasedMap.put(java.lang.Object, java.lang.Object)
on this map once for each mapping in the passed map. The behavior of this operation is unspecified if the passed map is modified while the operation is in progress.putAll
in interface ConcurrentMap
putAll
in interface java.util.Map
putAll
in class WrapperObservableMap
map
- the Map containing the key/value pairings to put into this Mapjava.util.ConcurrentModificationException
- if the entry is locked by another threadpublic java.lang.Object remove(java.lang.Object oKey)
remove
in interface ConcurrentMap
remove
in interface java.util.Map
remove
in class WrapperObservableMap
oKey
- key whose mapping is to be removed from the mapjava.util.ConcurrentModificationException
- if the entry is locked by another threadprotected boolean isInternalKeySetIteratorMutable()
isInternalKeySetIteratorMutable
in class WrapperObservableMap
AbstractKeyBasedMap.removeBlind(Object)
methodprotected boolean removeBlind(java.lang.Object oKey)
removeBlind
in class WrapperObservableMap
oKey
- key whose mapping is to be removed from the mapjava.util.ConcurrentModificationException
- if the entry is locked by another threadpublic java.lang.String toString()
toString
in class WrapperObservableMap
public boolean isLockingEnforced()
public void setLockingEnforced(boolean fEnforce)
fEnforce
- pass true to enforce locking; false otherwisepublic long getWaitMillis()
public void setWaitMillis(long cWaitMillis)
cWaitMillis
- the wait time in millisecondsprotected java.lang.String getDescription()
getDescription
in class WrapperObservableMap
public java.lang.String getLockDescription(java.lang.Object oKey)
oKey
- the keyprotected WrapperConcurrentMap.Lock instantiateLock(java.lang.Object oKey)
|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |