Class FineGrainedAtomicMapProxyImpl<K,V,MK>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- org.infinispan.atomic.impl.FineGrainedAtomicMapProxyImpl<K,V,MK>
-
- All Implemented Interfaces:
Map<K,V>
,FineGrainedAtomicMap<K,V>
public class FineGrainedAtomicMapProxyImpl<K,V,MK> extends AbstractMap<K,V> implements FineGrainedAtomicMap<K,V>
Implementation ofFineGrainedAtomicMap
that usesGrouping API
to co-locate subkeys on the same node. Therefore the entries in this map are held as regular cache entries, but in order to prevent the need for iterating all data in the owning node we also keep a set of keys under the map's key.The implementation requires to be executed on a transactional cache with grouping API enabled. Neither null keys nor null values are supported.
This cached set implemented by
AtomicKeySetImpl
is accessed using functional API and can be modified without acquiring its lock as long as we modify the same keys in that transaction.Once the map is created or fully read ({@link #size(),
keySet()
,values()
orentrySet()
), the whole map (both keys and values) is loaded into context to guarantee repeatable reads semantics.clear()
removes only those keys that are known - if the map is read, and another transaction adds a key afterwards, such key may not be removed from the map.The map cannot be safely removed (using
AtomicMapLookup.removeAtomicMap(Cache, Object)
concurrently to another modifications - such operation may result in leaked entries, map being cleared but not removed, failures during commit phase or other undefined behaviour.
-
-
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 FineGrainedAtomicMapProxyImpl(Cache<Object,Object> cache, FunctionalMap.ReadOnlyMap<Object,Object> ro, FunctionalMap.ReadWriteMap<Object,Object> rw, MK group, InvocationContextFactory icf, EntryFactory entryFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(Object key)
Set<Map.Entry<K,V>>
entrySet()
V
get(Object key)
Set<K>
keySet()
static <K,V,MK>
FineGrainedAtomicMap<K,V>newInstance(Cache<Object,Object> cache, MK group, boolean createIfAbsent)
V
put(K key, V value)
void
putAll(Map<? extends K,? extends V> m)
V
remove(Object key)
static void
removeMap(Cache<Object,Object> cache, Object group)
Warning: with pessimistic locking/optimistic locking without WSC, when the map is removed and a new key is added before the removal transaction commit, the map may be removed but the key left dangling.int
size()
String
toString()
Collection<V>
values()
-
Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsValue, equals, forEach, getOrDefault, hashCode, isEmpty, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Constructor Detail
-
FineGrainedAtomicMapProxyImpl
public FineGrainedAtomicMapProxyImpl(Cache<Object,Object> cache, FunctionalMap.ReadOnlyMap<Object,Object> ro, FunctionalMap.ReadWriteMap<Object,Object> rw, MK group, InvocationContextFactory icf, EntryFactory entryFactory)
-
-
Method Detail
-
newInstance
public static <K,V,MK> FineGrainedAtomicMap<K,V> newInstance(Cache<Object,Object> cache, MK group, boolean createIfAbsent)
-
removeMap
public static void removeMap(Cache<Object,Object> cache, Object group)
Warning: with pessimistic locking/optimistic locking without WSC, when the map is removed and a new key is added before the removal transaction commit, the map may be removed but the key left dangling.
-
size
public int size()
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
- Overrides:
containsKey
in classAbstractMap<K,V>
-
clear
public void clear()
-
values
public Collection<V> values()
-
toString
public String toString()
- Overrides:
toString
in classAbstractMap<K,V>
-
-