Package org.infinispan.container.impl
Class BoundedSegmentedDataContainer<K,V>
- java.lang.Object
-
- org.infinispan.container.impl.AbstractInternalDataContainer<K,V>
-
- org.infinispan.container.impl.DefaultSegmentedDataContainer<K,V>
-
- org.infinispan.container.impl.BoundedSegmentedDataContainer<K,V>
-
- All Implemented Interfaces:
Iterable<InternalCacheEntry<K,V>>
,DataContainer<K,V>
,InternalDataContainer<K,V>
public class BoundedSegmentedDataContainer<K,V> extends DefaultSegmentedDataContainer<K,V>
Bounded implementation of segmented data container. Bulk operations (iterator|spliterator) that are given segments use the segments maps directly to only read the given segments (non segment based just read from bounded container).Note this implementation supports both temporary non owned segments and not (L1). This map only utilizes heap based (ie. ConcurrentHashMap) maps internally
- Since:
- 9.3
- Author:
- wburns
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.infinispan.container.impl.AbstractInternalDataContainer
AbstractInternalDataContainer.EntryIterator, AbstractInternalDataContainer.Values
-
Nested classes/interfaces inherited from interface org.infinispan.container.DataContainer
DataContainer.ComputeAction<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description protected PeekableTouchableMap<K,InternalCacheEntry<K,V>>
entries
protected com.github.benmanes.caffeine.cache.Cache<K,InternalCacheEntry<K,V>>
evictionCache
-
Fields inherited from class org.infinispan.container.impl.DefaultSegmentedDataContainer
maps, mapSupplier, shouldStopSegments
-
Fields inherited from class org.infinispan.container.impl.AbstractInternalDataContainer
activator, configuration, entryFactory, evictionManager, expirationManager, keyPartitioner, listeners, passivator, timeService
-
-
Constructor Summary
Constructors Constructor Description BoundedSegmentedDataContainer(int numSegments, long thresholdSize, org.infinispan.commons.util.EntrySizeCalculator<? super K,? super InternalCacheEntry<K,V>> sizeCalculator)
BoundedSegmentedDataContainer(int numSegments, long thresholdSize, EvictionType thresholdPolicy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
capacity()
Returns the capacity of the underlying container.void
clear()
Removes all entries in the containervoid
clear(org.infinispan.commons.util.IntSet segments)
Removes entries from the container whose key maps to one of the provided segmentsprotected void
computeEntryRemoved(K key, InternalCacheEntry<K,V> value)
This method is invoked every time an entry is removed inside a compute blockprotected void
computeEntryWritten(K key, InternalCacheEntry<K,V> value)
This method is invoked every time an entry is written inside a compute blocklong
evictionSize()
Returns how large the eviction size is currently.PeekableTouchableMap<K,InternalCacheEntry<K,V>>
getMapForSegment(int segment)
Iterator<InternalCacheEntry<K,V>>
iteratorIncludingExpired()
Same asDataContainer.iterator()
except that is also returns expired entries.Iterator<InternalCacheEntry<K,V>>
iteratorIncludingExpired(org.infinispan.commons.util.IntSet segments)
Same asDataContainer.iteratorIncludingExpired()
except that only entries that map to the provided segments are returned via the iterator.InternalCacheEntry<K,V>
peek(int segment, Object k)
Same asDataContainer.peek(Object)
except that the segment of the key can provided to lookup entries without calculating the segment for the given keyInternalCacheEntry<K,V>
peek(Object k)
Retrieves a cache entry in the same way asDataContainer.get(Object)
} except that it does not update or reorder any of the internal constructs.void
removeSegments(org.infinispan.commons.util.IntSet segments)
Removes and un-associates the given segments.void
resize(long newSize)
Resizes the capacity of the underlying container.int
sizeIncludingExpired()
Spliterator<InternalCacheEntry<K,V>>
spliteratorIncludingExpired()
Same asDataContainer.spliterator()
except that is also returns expired entries.Spliterator<InternalCacheEntry<K,V>>
spliteratorIncludingExpired(org.infinispan.commons.util.IntSet segments)
Same asDataContainer.spliteratorIncludingExpired()
except that only entries that map to the provided segments are returned via this spliterator.-
Methods inherited from class org.infinispan.container.impl.DefaultSegmentedDataContainer
addSegments, forEach, getSegmentForKey, iterator, iterator, sizeIncludingExpired, spliterator, spliterator, start, stop
-
Methods inherited from class org.infinispan.container.impl.AbstractInternalDataContainer
addRemovalListener, applyListener, compute, compute, containsKey, containsKey, entrySet, evict, evict, expiredIterationPredicate, filterExpiredEntries, get, get, keySet, put, put, remove, remove, removeRemovalListener, touch, values
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.container.DataContainer
executeTask, executeTask, size
-
Methods inherited from interface org.infinispan.container.impl.InternalDataContainer
size
-
-
-
-
Field Detail
-
evictionCache
protected final com.github.benmanes.caffeine.cache.Cache<K,InternalCacheEntry<K,V>> evictionCache
-
entries
protected final PeekableTouchableMap<K,InternalCacheEntry<K,V>> entries
-
-
Constructor Detail
-
BoundedSegmentedDataContainer
public BoundedSegmentedDataContainer(int numSegments, long thresholdSize, EvictionType thresholdPolicy)
-
BoundedSegmentedDataContainer
public BoundedSegmentedDataContainer(int numSegments, long thresholdSize, org.infinispan.commons.util.EntrySizeCalculator<? super K,? super InternalCacheEntry<K,V>> sizeCalculator)
-
-
Method Detail
-
computeEntryWritten
protected void computeEntryWritten(K key, InternalCacheEntry<K,V> value)
Description copied from class:AbstractInternalDataContainer
This method is invoked every time an entry is written inside a compute block- Overrides:
computeEntryWritten
in classAbstractInternalDataContainer<K,V>
- Parameters:
key
- key passed to compute methodvalue
- the new value
-
computeEntryRemoved
protected void computeEntryRemoved(K key, InternalCacheEntry<K,V> value)
Description copied from class:AbstractInternalDataContainer
This method is invoked every time an entry is removed inside a compute block- Overrides:
computeEntryRemoved
in classAbstractInternalDataContainer<K,V>
- Parameters:
key
- key passed to compute methodvalue
- the old value
-
getMapForSegment
public PeekableTouchableMap<K,InternalCacheEntry<K,V>> getMapForSegment(int segment)
- Overrides:
getMapForSegment
in classDefaultSegmentedDataContainer<K,V>
-
peek
public InternalCacheEntry<K,V> peek(Object k)
Description copied from interface:DataContainer
Retrieves a cache entry in the same way asDataContainer.get(Object)
} except that it 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. This method should be used instead ofDataContainer.get(Object)
} when called while iterating through the data container using methods likeDataContainer.iterator()
to avoid changing the underlying collection's order.- Specified by:
peek
in interfaceDataContainer<K,V>
- Overrides:
peek
in classAbstractInternalDataContainer<K,V>
- Parameters:
k
- key under which entry is stored- Returns:
- entry, if it exists, or null if not
-
peek
public InternalCacheEntry<K,V> peek(int segment, Object k)
Description copied from interface:InternalDataContainer
Same asDataContainer.peek(Object)
except that the segment of the key can provided to lookup entries without calculating the segment for the given key- Specified by:
peek
in interfaceInternalDataContainer<K,V>
- Overrides:
peek
in classAbstractInternalDataContainer<K,V>
- Parameters:
segment
- segment for the keyk
- key under which entry is stored- Returns:
- entry, if it exists, or null if not
-
clear
public void clear()
Description copied from interface:DataContainer
Removes all entries in the container- Specified by:
clear
in interfaceDataContainer<K,V>
- Overrides:
clear
in classDefaultSegmentedDataContainer<K,V>
-
clear
public void clear(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainer
Removes entries from the container whose key maps to one of the provided segments- Specified by:
clear
in interfaceInternalDataContainer<K,V>
- Overrides:
clear
in classAbstractInternalDataContainer<K,V>
- Parameters:
segments
- segments of entries to remove
-
iteratorIncludingExpired
public Iterator<InternalCacheEntry<K,V>> iteratorIncludingExpired()
Description copied from interface:DataContainer
Same asDataContainer.iterator()
except that is also returns expired entries.- Specified by:
iteratorIncludingExpired
in interfaceDataContainer<K,V>
- Overrides:
iteratorIncludingExpired
in classDefaultSegmentedDataContainer<K,V>
- Returns:
- iterator that returns all entries including expired ones
-
iteratorIncludingExpired
public Iterator<InternalCacheEntry<K,V>> iteratorIncludingExpired(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainer
Same asDataContainer.iteratorIncludingExpired()
except that only entries that map to the provided segments are returned via the iterator. The iterator can return expired entries.- Specified by:
iteratorIncludingExpired
in interfaceInternalDataContainer<K,V>
- Overrides:
iteratorIncludingExpired
in classDefaultSegmentedDataContainer<K,V>
- Parameters:
segments
- segments of entries to use- Returns:
- iterator that returns all entries mapped to the given segments that could be expired
-
spliteratorIncludingExpired
public Spliterator<InternalCacheEntry<K,V>> spliteratorIncludingExpired()
Description copied from interface:DataContainer
Same asDataContainer.spliterator()
except that is also returns expired entries.- Specified by:
spliteratorIncludingExpired
in interfaceDataContainer<K,V>
- Overrides:
spliteratorIncludingExpired
in classDefaultSegmentedDataContainer<K,V>
- Returns:
- spliterator that returns all entries including expired ones
-
spliteratorIncludingExpired
public Spliterator<InternalCacheEntry<K,V>> spliteratorIncludingExpired(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainer
Same asDataContainer.spliteratorIncludingExpired()
except that only entries that map to the provided segments are returned via this spliterator. The spliterator will return expired entries as well.- Specified by:
spliteratorIncludingExpired
in interfaceInternalDataContainer<K,V>
- Overrides:
spliteratorIncludingExpired
in classDefaultSegmentedDataContainer<K,V>
- Parameters:
segments
- segments of entries to use- Returns:
- spliterator containing entries mapping to those segments that could be expired
-
sizeIncludingExpired
public int sizeIncludingExpired()
- Specified by:
sizeIncludingExpired
in interfaceDataContainer<K,V>
- Overrides:
sizeIncludingExpired
in classDefaultSegmentedDataContainer<K,V>
- Returns:
- count of the number of entries in the container including expired entries
-
removeSegments
public void removeSegments(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainer
Removes and un-associates the given segments. This will notify any listeners registered viaInternalDataContainer.addRemovalListener(Consumer)
of entries that were removed due to no longer being associated with this container. There is no guarantee if the consumer is invoked once or multiple times for a given group of segments and could be in any order.When this method is invoked an implementation is free to remove any entries that don't map to segments currently associated with this container. Note that entries that were removed due to their segments never being associated with this container do not notify listeners registered via
InternalDataContainer.addRemovalListener(Consumer)
.- Specified by:
removeSegments
in interfaceInternalDataContainer<K,V>
- Overrides:
removeSegments
in classDefaultSegmentedDataContainer<K,V>
- Parameters:
segments
- segments that should no longer be associated with this container
-
capacity
public long capacity()
Description copied from interface:DataContainer
Returns the capacity of the underlying container. This is only supported if the container is bounded. AnUnsupportedOperationException
is thrown otherwise.- Returns:
-
resize
public void resize(long newSize)
Description copied from interface:DataContainer
Resizes the capacity of the underlying container. This is only supported if the container is bounded. AnUnsupportedOperationException
is thrown otherwise.- Parameters:
newSize
- the new size
-
evictionSize
public long evictionSize()
Description copied from interface:DataContainer
Returns how large the eviction size is currently. This is only supported if the container is bounded. AnUnsupportedOperationException
is thrown otherwise. This value will always be lower than the value returned fromDataContainer.capacity()
- Returns:
- how large the counted eviction is
-
-