Class WrapperConcurrentMap<K,V> 
- All Implemented Interfaces:
- ConcurrentMap<K,,- V> - ObservableMap<K,,- V> - Map<K,- V> 
- Direct Known Subclasses:
- WrapperNamedCache
- Author:
- gg 2002.04.02
- 
Nested Class SummaryNested ClassesNested classes/interfaces inherited from class com.tangosol.util.WrapperObservableMapWrapperObservableMap.InternalListenerNested classes/interfaces inherited from class com.tangosol.util.AbstractKeySetBasedMapAbstractKeySetBasedMap.EntrySet, AbstractKeySetBasedMap.KeyIterator, AbstractKeySetBasedMap.KeySet, AbstractKeySetBasedMap.ValuesCollectionNested classes/interfaces inherited from class com.tangosol.util.AbstractKeyBasedMapAbstractKeyBasedMap.DeferredCacheEvent<K,V> Nested classes/interfaces inherited from class com.tangosol.util.BaseBase.LoggingWriter
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected longThe number of milliseconds to continue trying to obtain a lock in case when the locking is enforced.protected booleanFlag indicating whether or not the locking is enforced for put, remove and clear operations.protected final GateThe ThreadGate object for the entire map.protected final SafeHashMapThe map containing all the locks.Fields inherited from class com.tangosol.util.WrapperObservableMapm_fDeferredEvent, m_fTranslateEvents, m_listenerInternal, m_listenerSupport, m_map, m_statsFields inherited from class com.tangosol.util.BaseLOG_ALWAYS, LOG_CONFIG, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_MAX, LOG_MIN, LOG_QUIET, LOG_WARN, POWER_0, POWER_G, POWER_K, POWER_M, POWER_T, UNIT_D, UNIT_H, UNIT_M, UNIT_MS, UNIT_NS, UNIT_S, UNIT_USFields inherited from interface com.tangosol.util.ConcurrentMapLOCK_ALL
- 
Constructor SummaryConstructorsConstructorDescriptionWrapperConcurrentMap(Map<K, V> map) Construct a ConcurrentMap wrapper based on the specified map with locking enforced for put, remove and clear operations.WrapperConcurrentMap(Map<K, V> map, boolean fEnforceLocking, long cWaitMillis) Construct a ConcurrentMap wrapper based on the specified map.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()Clear all key/value mappings.protected StringAssemble a human-readable description.getLockDescription(Object oKey) Make a human-readable description of the information kept about the passed key.longReturn the number of milliseconds to continue trying to obtain a lock in case when the locking is enforced.protected WrapperConcurrentMap.LockinstantiateLock(Object oKey) Factory pattern.protected booleanDetermine 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.booleanObtain the flag indicating whether or not the locking is enforced for put, remove and clear operations.booleanAttempt to lock the specified item and return immediately.booleanAttempt to lock the specified item within the specified period of time.Associates the specified value with the specified key in this map.voidCopies all of the mappings from the specified map to this map.Removes the mapping for this key from this map if present.protected booleanremoveBlind(Object oKey) Removes the mapping for this key from this map if present.voidsetLockingEnforced(boolean fEnforce) Set the flag indicating whether or not the locking is enforced for put, remove and clear operations.voidsetWaitMillis(long cWaitMillis) Specify the number of milliseconds to continue trying to obtain a lock in case when the locking is enforced.toString()Returns a string representation of this Map.booleanUnlock the specified item.Methods inherited from class com.tangosol.util.WrapperObservableMapaddMapListener, addMapListener, addMapListener, containsValue, dispatchEvent, dispatchPendingEvent, ensureInternalListener, ensureMapListenerSupport, equals, get, getCacheStatistics, getInternalKeySet, getMap, getMapListenerSupport, hashCode, hasListeners, instantiateInternalListener, isCollectStats, isEventFabricator, isSynthetic, isTranslateEvents, removeMapListener, removeMapListener, removeMapListener, setCollectStats, setTranslateEventsMethods inherited from class com.tangosol.util.AbstractKeySetBasedMapcontainsKey, instantiateEntrySet, instantiateKeyIterator, instantiateKeySet, instantiateValues, isEmpty, iterateKeys, sizeMethods inherited from class com.tangosol.util.AbstractKeyBasedMapclone, entrySet, getAll, keySet, valuesMethods inherited from class com.tangosol.util.Baseazzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, waitMethods inherited from class java.lang.Objectfinalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.tangosol.util.ConcurrentMapcontainsKey, containsValue, get, isEmpty, sizeMethods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, entrySet, equals, forEach, getOrDefault, hashCode, keySet, merge, putIfAbsent, remove, replace, replace, replaceAll, values
- 
Field Details- 
m_fEnforceLockingprotected boolean m_fEnforceLockingFlag indicating whether or not the locking is enforced for put, remove and clear operations.
- 
m_cWaitMillisprotected long m_cWaitMillisThe number of milliseconds to continue trying to obtain a lock in case when the locking is enforced.
- 
m_mapLockThe map containing all the locks.
- 
m_gateMapThe ThreadGate object for the entire map.
 
- 
- 
Constructor Details- 
WrapperConcurrentMapConstruct a ConcurrentMap wrapper based on the specified map with locking enforced for put, remove and clear operations.Note: it is assumed that while the WrapperConcurrentMap exists, there is no direct manipulation with the content of the wrapped map. - Parameters:
- map- the Map that will be wrapped by this WrapperConcurrentMap
 
- 
WrapperConcurrentMapConstruct a ConcurrentMap wrapper based on the specified map.Note: it is assumed that while the WrapperConcurrentMap exists, there is no direct manipulation with the content of the wrapped map. - Parameters:
- map- the Map that will be wrapped by this WrapperConcurrentMap
- fEnforceLocking- if true the locking is enforced for put, remove and clear operations; otherwise a client is responsible for calling lock and unlock explicitly
- cWaitMillis- if locking enforcement is required then this parameter specifies the number of milliseconds to continue trying to obtain a lock; pass -1 to block the calling thread until the lock could be obtained
 
 
- 
- 
Method Details- 
lockAttempt to lock the specified item within the specified period of time.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_ALLas the oKey parameter to indicate the map lock.- Specified by:
- lockin interface- ConcurrentMap<K,- V> 
- Parameters:
- oKey- key being locked
- cWait- 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 obtained
- Returns:
- true if the item was successfully locked within the specified time; false otherwise
 
- 
lockAttempt to lock the specified item and return immediately.This method behaves exactly as if it simply performs the call lock(oKey, 0). - Specified by:
- lockin interface- ConcurrentMap<K,- V> 
- Parameters:
- oKey- key being locked
- Returns:
- true if the item was successfully locked; false otherwise
 
- 
unlockUnlock the specified item. The item doesn't have to exist to be unlocked. If the item is currently locked, only the holder of the lock could successfully unlock it.- Specified by:
- unlockin interface- ConcurrentMap<K,- V> 
- Parameters:
- oKey- key being unlocked
- Returns:
- true if the item was successfully unlocked; false otherwise
 
- 
clearpublic void clear()Clear all key/value mappings.If lock enforcement is required an attempt will be made to lock the entire map using the ConcurrentMap.LOCK_ALLobject.Note: if this operation fails due to a ConcurrentModificationException, then any subset of the current mappings could still remain in the map. - Specified by:
- clearin interface- ConcurrentMap<K,- V> 
- Specified by:
- clearin interface- Map<K,- V> 
- Overrides:
- clearin class- WrapperObservableMap<K,- V> 
- Throws:
- ConcurrentModificationException- if any entry is locked by another thread
 
- 
putAssociates the specified value with the specified key in this map.- Specified by:
- putin interface- ConcurrentMap<K,- V> 
- Specified by:
- putin interface- Map<K,- V> 
- Overrides:
- putin class- WrapperObservableMap<K,- V> 
- Parameters:
- oKey- key with which the specified value is to be associated
- oValue- value to be associated with the specified key
- Returns:
- previous value associated with specified key, or null if there was no mapping for key
- Throws:
- ConcurrentModificationException- if the entry is locked by another thread
 
- 
putAllCopies all of the mappings from the specified map to this map. The effect of this call is equivalent to that of callingAbstractKeyBasedMap.put(K, V)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.- Specified by:
- putAllin interface- ConcurrentMap<K,- V> 
- Specified by:
- putAllin interface- Map<K,- V> 
- Overrides:
- putAllin class- WrapperObservableMap<K,- V> 
- Parameters:
- map- the Map containing the key/value pairings to put into this Map
- Throws:
- ConcurrentModificationException- if the entry is locked by another thread
 
- 
removeRemoves the mapping for this key from this map if present. Expensive: updates both the underlying cache and the local cache.- Specified by:
- removein interface- ConcurrentMap<K,- V> 
- Specified by:
- removein interface- Map<K,- V> 
- Overrides:
- removein class- WrapperObservableMap<K,- V> 
- Parameters:
- oKey- key whose mapping is to be removed from the map
- Returns:
- previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key, if the implementation supports null values.
- Throws:
- ConcurrentModificationException- if the entry is locked by another thread
 
- 
isInternalKeySetIteratorMutableprotected 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.- Overrides:
- isInternalKeySetIteratorMutablein class- WrapperObservableMap<K,- V> 
- Returns:
- true to remove using the internal key Set Iterator or false to
         use the AbstractKeyBasedMap.removeBlind(Object)method
 
- 
removeBlindRemoves the mapping for this key from this map if present. This method exists to allow sub-classes to optimize remove functionality for situations in which the original value is not required.- Overrides:
- removeBlindin class- WrapperObservableMap<K,- V> 
- Parameters:
- oKey- key whose mapping is to be removed from the map
- Returns:
- true iff the Map changed as the result of this operation
- Throws:
- ConcurrentModificationException- if the entry is locked by another thread
 
- 
toStringReturns a string representation of this Map. The string representation consists of a list of key-value mappings in the order returned by the Map's entrySet view's iterator, enclosed in braces ("{}"). Adjacent mappings are separated by the characters ", " (comma and space). Each key-value mapping is rendered as the key followed by an equals sign ("=") followed by the associated value. Keys and values are converted to strings as by String.valueOf(Object).- Overrides:
- toStringin class- WrapperObservableMap<K,- V> 
- Returns:
- a String representation of this Map
 
- 
isLockingEnforcedpublic boolean isLockingEnforced()Obtain the flag indicating whether or not the locking is enforced for put, remove and clear operations.- Returns:
- true if locking is enforced; false otherwise
 
- 
setLockingEnforcedpublic void setLockingEnforced(boolean fEnforce) Set the flag indicating whether or not the locking is enforced for put, remove and clear operations.- Parameters:
- fEnforce- pass true to enforce locking; false otherwise
 
- 
getWaitMillispublic long getWaitMillis()Return the number of milliseconds to continue trying to obtain a lock in case when the locking is enforced.- Returns:
- the wait time in milliseconds
 
- 
setWaitMillispublic void setWaitMillis(long cWaitMillis) Specify the number of milliseconds to continue trying to obtain a lock in case when the locking is enforced.- Parameters:
- cWaitMillis- the wait time in milliseconds
 
- 
getDescriptionAssemble a human-readable description.- Overrides:
- getDescriptionin class- WrapperObservableMap<K,- V> 
- Returns:
- a description of this Map
 
- 
getLockDescriptionMake a human-readable description of the information kept about the passed key.- Parameters:
- oKey- the key
- Returns:
- the information known about the passed key
 
- 
instantiateLockFactory pattern.- Parameters:
- oKey- the key
- Returns:
- a new instance of the Lock class (or a subclass thereof)
 
 
-