Package org.apache.ignite.internal.util
Class GridBoundedConcurrentOrderedMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.concurrent.ConcurrentSkipListMap<K,V>
-
- org.apache.ignite.internal.util.GridBoundedConcurrentOrderedMap<K,V>
-
- All Implemented Interfaces:
Serializable,Cloneable,ConcurrentMap<K,V>,ConcurrentNavigableMap<K,V>,Map<K,V>,NavigableMap<K,V>,SortedMap<K,V>
public class GridBoundedConcurrentOrderedMap<K,V> extends ConcurrentSkipListMap<K,V>
Concurrent ordered map that automatically manages its maximum size. Once it exceeds its maximum, it will start removing smallest elements until the maximum is reached again. If optional listener is set viaevictionListener(org.apache.ignite.lang.IgniteBiInClosure)method, then listener will be notified for every eviction.Note that due to concurrent nature of this map, it may grow slightly larger than its maximum allowed size, but in this case it will quickly readjust back to allowed size.
Note that
remove(Object)andremove(Object, Object)methods are not supported for this kind of map.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description GridBoundedConcurrentOrderedMap(int max)Constructs a new, empty map that orders its elements according to their natural ordering.GridBoundedConcurrentOrderedMap(int max, Comparator<? super K> comparator)Constructs a new, empty set that orders its elements according to the specified comparator.GridBoundedConcurrentOrderedMap(int max, Map<? extends K,? extends V> map)Constructs a new map containing the elements in the specified map, that orders its elements according to their natural ordering.GridBoundedConcurrentOrderedMap(int max, SortedMap<K,V> map)Constructs a new map containing the same elements and using the same ordering as the specified sorted map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()GridBoundedConcurrentOrderedMap<K,V>clone()IgniteBiInClosure<K,V>evictionListener()Gets closure listener to be called for every eviction event.voidevictionListener(IgniteBiInClosure<K,V> lsnr)Sets closure listener to be called for every eviction event.Vput(K k, V v)VputIfAbsent(K k, V v)Vremove(Object o)This method is not supported and always throwsUnsupportedOperationException.booleanremove(Object key, Object val)This method is not supported and always throwsUnsupportedOperationException.intsize()Approximate size at this point of time.-
Methods inherited from class java.util.concurrent.ConcurrentSkipListMap
ceilingEntry, ceilingKey, comparator, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, equals, firstEntry, firstKey, floorEntry, floorKey, forEach, get, getOrDefault, headMap, headMap, higherEntry, higherKey, isEmpty, keySet, lastEntry, lastKey, lowerEntry, lowerKey, merge, navigableKeySet, pollFirstEntry, pollLastEntry, replace, replace, replaceAll, subMap, subMap, tailMap, tailMap, values
-
Methods inherited from class java.util.AbstractMap
hashCode, putAll, toString
-
-
-
-
Constructor Detail
-
GridBoundedConcurrentOrderedMap
public GridBoundedConcurrentOrderedMap(int max)
Constructs a new, empty map that orders its elements according to their natural ordering.- Parameters:
max- Upper bound of this map.
-
GridBoundedConcurrentOrderedMap
public GridBoundedConcurrentOrderedMap(int max, Comparator<? super K> comparator)Constructs a new, empty set that orders its elements according to the specified comparator.- Parameters:
max- Upper bound of this map.comparator- The comparator that will be used to order this map. If null, the natural ordering of the elements will be used.
-
GridBoundedConcurrentOrderedMap
public GridBoundedConcurrentOrderedMap(int max, Map<? extends K,? extends V> map)Constructs a new map containing the elements in the specified map, that orders its elements according to their natural ordering.- Parameters:
max- Upper bound of this map.map- The elements that will comprise the new map.- Throws:
ClassCastException- if the elements in map are notComparable, or are not mutually comparable.NullPointerException- if the specified map or any of its elements arenull.
-
GridBoundedConcurrentOrderedMap
public GridBoundedConcurrentOrderedMap(int max, SortedMap<K,V> map)Constructs a new map containing the same elements and using the same ordering as the specified sorted map.- Parameters:
max- Upper bound of this map.map- Sorted map whose elements will comprise the new map.- Throws:
NullPointerException- if the specified sorted map or any of its elements arenull.
-
-
Method Detail
-
evictionListener
public void evictionListener(IgniteBiInClosure<K,V> lsnr)
Sets closure listener to be called for every eviction event.- Parameters:
lsnr- Closure to be called for every eviction event.
-
evictionListener
public IgniteBiInClosure<K,V> evictionListener()
Gets closure listener to be called for every eviction event.- Returns:
- Closure to be called for every eviction event.
-
putIfAbsent
@Nullable public V putIfAbsent(K k, V v)
- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V>- Specified by:
putIfAbsentin interfaceMap<K,V>- Overrides:
putIfAbsentin classConcurrentSkipListMap<K,V>
-
size
public int size()
Approximate size at this point of time. Note, that unlikesizemethods on otherconcurrentcollections, this method executes in constant time without traversal of the elements.
-
clone
public GridBoundedConcurrentOrderedMap<K,V> clone()
- Overrides:
clonein classConcurrentSkipListMap<K,V>
-
remove
public V remove(Object o)
This method is not supported and always throwsUnsupportedOperationException.
-
remove
public boolean remove(Object key, Object val)
This method is not supported and always throwsUnsupportedOperationException.
-
-