Class SharedBoundedLocalContainer<K,V>
java.lang.Object
org.infinispan.container.impl.AbstractInternalDataContainer<K,V>
org.infinispan.container.impl.DefaultDataContainer<K,V>
org.infinispan.container.impl.SharedBoundedLocalContainer<K,V>
- Type Parameters:
K- The key typeV- The value type
- All Implemented Interfaces:
Iterable<InternalCacheEntry<K,V>>, DataContainer<K, V>, EvictionListener<K, V>, InternalDataContainer<K, V>
public class SharedBoundedLocalContainer<K,V>
extends DefaultDataContainer<K,V>
implements EvictionListener<K,V>
A non-segmented shared container for use with simple/local caches. All entries are stored in the shared
caffeine map, but indexed in the single
entries map inherited from DefaultDataContainer.
This class avoids the DefaultSegmentedDataContainer array-based segment indexing which causes
ArrayIndexOutOfBoundsException when callers pass segment sets larger than the container's
single-segment array.
Write operations must be done while holding the lock for the corresponding key in the shared caffeine map,
same as SharedBoundedContainer.
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractInternalDataContainer
AbstractInternalDataContainer.EntryIteratorNested classes/interfaces inherited from interface DataContainer
DataContainer.ComputeAction<K,V> -
Field Summary
Fields inherited from class DefaultDataContainer
entries, evictionCacheFields inherited from class AbstractInternalDataContainer
configuration, entryFactory, evictionManager, expirationManager, keyPartitioner, listeners, orderer, passivator, timeService -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionlongcapacity()Returns the capacity of the underlying container.voidcleanUp()Method used to cleanup any pending data, such as evictionsvoidclear()Removes all entries in the containervoidRemoves entries from the container whose key maps to one of the provided segmentsprotected voidcomputeEntryRemoved(int segment, K key, InternalCacheEntry<K, V> value) This method is invoked every time an entry is removed inside a compute blockprotected voidcomputeEntryWritten(int segment, K key, InternalCacheEntry<K, V> value) This method is invoked every time an entry is written inside a compute blockbooleanTests whether an entry exists in the containerlongReturns how large the eviction size is currently.protected PeekableTouchableMap<K, V> getMapForSegment(int segment) protected intgetSegmentForKey(Object key) voidonEntryChosenForEviction(boolean pre, K key, InternalCacheEntry<K, V> value) Method invoked every time an entry is evicted from the cache along with its key.Retrieves a cache entry.protected voidputEntryInMap(PeekableTouchableMap<K, V> map, int segment, K key, InternalCacheEntry<K, V> ice) protected InternalCacheEntry<K, V> removeEntryInMap(PeekableTouchableMap<K, V> map, int segment, Object key) voidresize(long newSize) Resizes the capacity of the underlying container.Methods inherited from class DefaultDataContainer
addSegments, boundedDataContainer, boundedDataContainer, forEachSegment, iterator, iterator, iteratorIncludingExpired, iteratorIncludingExpired, publisher, removeSegments, sizeIncludingExpired, spliterator, spliterator, spliteratorIncludingExpired, spliteratorIncludingExpired, unBoundedDataContainerMethods inherited from class AbstractInternalDataContainer
addRemovalListener, applyListener, compute, compute, containsKey, entryAdded, entryRemoved, entryUpdated, evict, evict, expiredIterationPredicate, filterExpiredEntries, get, get, handleEviction, hasExpirable, peek, put, put, remove, remove, removeRemovalListener, segmentRemoved, touchMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DataContainer
sizeMethods inherited from interface InternalDataContainer
forEach, publisher, size, sizeIncludingExpired
-
Constructor Details
-
SharedBoundedLocalContainer
-
-
Method Details
-
getMapForSegment
- Overrides:
getMapForSegmentin classDefaultDataContainer<K,V>
-
getSegmentForKey
- Overrides:
getSegmentForKeyin classDefaultDataContainer<K,V>
-
computeEntryRemoved
Description copied from class:AbstractInternalDataContainerThis method is invoked every time an entry is removed inside a compute block- Overrides:
computeEntryRemovedin classAbstractInternalDataContainer<K,V> - Parameters:
segment- the segment for the keykey- key passed to compute methodvalue- the old value
-
computeEntryWritten
Description copied from class:AbstractInternalDataContainerThis method is invoked every time an entry is written inside a compute block- Overrides:
computeEntryWrittenin classAbstractInternalDataContainer<K,V> - Parameters:
segment- the segment for the keykey- key passed to compute methodvalue- the new value
-
putEntryInMap
protected void putEntryInMap(PeekableTouchableMap<K, V> map, int segment, K key, InternalCacheEntry<K, V> ice) - Overrides:
putEntryInMapin classAbstractInternalDataContainer<K,V>
-
removeEntryInMap
protected InternalCacheEntry<K,V> removeEntryInMap(PeekableTouchableMap<K, V> map, int segment, Object key) - Overrides:
removeEntryInMapin classAbstractInternalDataContainer<K,V>
-
clear
public void clear()Description copied from interface:DataContainerRemoves all entries in the container- Specified by:
clearin interfaceDataContainer<K,V> - Overrides:
clearin classDefaultDataContainer<K,V>
-
clear
Description copied from interface:InternalDataContainerRemoves entries from the container whose key maps to one of the provided segments- Specified by:
clearin interfaceInternalDataContainer<K,V> - Overrides:
clearin classDefaultDataContainer<K,V> - Parameters:
segments- segments of entries to remove
-
peek
Description copied from interface:DataContainerRetrieves a cache entry. This method does not update or reorder any of the internal constructs. I.e., expiration does not happen, and in the case of the LRU container, the entry is not moved to the end of the chain.- Specified by:
peekin interfaceDataContainer<K,V> - Overrides:
peekin classAbstractInternalDataContainer<K,V> - Parameters:
k- key under which entry is stored- Returns:
- entry, if it exists, or null if not
-
containsKey
Description copied from interface:DataContainerTests whether an entry exists in the container- Specified by:
containsKeyin interfaceDataContainer<K,V> - Overrides:
containsKeyin classAbstractInternalDataContainer<K,V> - Parameters:
k- key to test- Returns:
- true if entry exists and has not expired; false otherwise
-
cleanUp
public void cleanUp()Description copied from interface:InternalDataContainerMethod used to cleanup any pending data, such as evictions- Specified by:
cleanUpin interfaceInternalDataContainer<K,V> - Overrides:
cleanUpin classDefaultDataContainer<K,V>
-
capacity
public long capacity()Description copied from interface:DataContainerReturns the capacity of the underlying container. This is only supported if the container is bounded. AnUnsupportedOperationExceptionis thrown otherwise.- Specified by:
capacityin interfaceDataContainer<K,V> - Overrides:
capacityin classDefaultDataContainer<K,V> - Returns:
- the capacity of a bounded container
-
resize
public void resize(long newSize) Description copied from interface:DataContainerResizes the capacity of the underlying container. This is only supported if the container is bounded. AnUnsupportedOperationExceptionis thrown otherwise.- Specified by:
resizein interfaceDataContainer<K,V> - Overrides:
resizein classDefaultDataContainer<K,V> - Parameters:
newSize- the new size
-
evictionSize
public long evictionSize()Description copied from interface:DataContainerReturns how large the eviction size is currently. This is only supported if the container is bounded. AnUnsupportedOperationExceptionis thrown otherwise. This value will always be lower than the value returned fromDataContainer.capacity()- Specified by:
evictionSizein interfaceDataContainer<K,V> - Overrides:
evictionSizein classDefaultDataContainer<K,V> - Returns:
- how large the counted eviction is
-
onEntryChosenForEviction
Description copied from interface:EvictionListenerMethod invoked every time an entry is evicted from the cache along with its key. Note that when the pre value is true the entry is still in the cache and the lock is held for this entry. When invoked with pre being false is after the fact without the lock held. If any exception is thrown during this invocation it is not deterministic if it will stop the operation and may only be logged.- Specified by:
onEntryChosenForEvictionin interfaceEvictionListener<K,V> - Parameters:
pre- Whether this is just before the eviction completes or not.key- The key tied the removed entryvalue- The entry that is removed due to eviction
-