Package org.infinispan.container.impl
Class DefaultDataContainer<K,V>
java.lang.Object
org.infinispan.container.impl.AbstractInternalDataContainer<K,V>
org.infinispan.container.impl.DefaultDataContainer<K,V>
- All Implemented Interfaces:
Iterable<InternalCacheEntry<K,,V>> DataContainer<K,,V> InternalDataContainer<K,V>
DefaultDataContainer is both eviction and non-eviction based data container.
- Since:
- 4.0
- Author:
- Manik Surtani, Galder ZamarreƱo, Vladimir Blagojevic, Trustin Lee
-
Nested Class Summary
Nested classes/interfaces inherited from class org.infinispan.container.impl.AbstractInternalDataContainer
AbstractInternalDataContainer.EntryIteratorNested classes/interfaces inherited from interface org.infinispan.container.DataContainer
DataContainer.ComputeAction<K,V> -
Field Summary
Fields inherited from class org.infinispan.container.impl.AbstractInternalDataContainer
configuration, entryFactory, evictionManager, expirationManager, keyPartitioner, listeners, orderer, passivator, timeService -
Constructor Summary
ConstructorsModifierConstructorDescriptionDefaultDataContainer(int concurrencyLevel) protectedDefaultDataContainer(int concurrencyLevel, long thresholdSize, EntrySizeCalculator<? super K, ? super V> sizeCalculator) Method invoked when memory policy is used.protectedDefaultDataContainer(int concurrencyLevel, long thresholdSize, EvictionType thresholdPolicy) protectedDefaultDataContainer(long thresholdSize, EntrySizeCalculator<? super K, ? super InternalCacheEntry<K, V>> sizeCalculator) Constructor that allows user to provide a size calculator that also handles the cache entry and metadata. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSegments(IntSet segments) Sets what segments this data container should be using.static <K,V> DefaultDataContainer<K, V> boundedDataContainer(int concurrencyLevel, long maxEntries, EntrySizeCalculator<? super K, ? super V> sizeCalculator) static <K,V> DefaultDataContainer<K, V> boundedDataContainer(int concurrencyLevel, long maxEntries, EvictionType thresholdPolicy) longcapacity()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 segmentslongReturns how large the eviction size is currently.voidforEachSegment(ObjIntConsumer<PeekableTouchableMap<K, V>> segmentMapConsumer) Performs the given consumer for each map inside this container, once for each segment until all maps have been processed or the action throws an exception.protected PeekableTouchableMap<K,V> getMapForSegment(int segment) protected intgetSegmentForKey(Object key) iterator()Same asDataContainer.iterator()except that only entries that map to the provided segments are returned via the iterator.Same asDataContainer.iterator()except that is also returns expired entries.iteratorIncludingExpired(IntSet segments) Same asDataContainer.iteratorIncludingExpired()except that only entries that map to the provided segments are returned via the iterator.org.reactivestreams.Publisher<InternalCacheEntry<K,V>> voidremoveSegments(IntSet segments) Removes and un-associates the given segments.voidresize(long newSize) Resizes the capacity of the underlying container.intspliterator(IntSet segments) Same asDataContainer.spliterator()except that only entries that map to the provided segments are returned via this spliterator.Same asDataContainer.spliterator()except that is also returns expired entries.spliteratorIncludingExpired(IntSet segments) Same asDataContainer.spliteratorIncludingExpired()except that only entries that map to the provided segments are returned via this spliterator.static <K,V> DefaultDataContainer<K, V> unBoundedDataContainer(int concurrencyLevel) Methods inherited from class org.infinispan.container.impl.AbstractInternalDataContainer
addRemovalListener, applyListener, compute, compute, computeEntryRemoved, computeEntryWritten, containsKey, containsKey, entryAdded, entryRemoved, entryUpdated, evict, evict, expiredIterationPredicate, filterExpiredEntries, get, get, handleEviction, hasExpirable, peek, peek, put, put, putEntryInMap, remove, remove, removeEntryInMap, removeRemovalListener, segmentRemoved, touchMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.infinispan.container.DataContainer
sizeMethods inherited from interface org.infinispan.container.impl.InternalDataContainer
forEach, publisher, size, sizeIncludingExpired
-
Constructor Details
-
DefaultDataContainer
public DefaultDataContainer(int concurrencyLevel) -
DefaultDataContainer
protected DefaultDataContainer(int concurrencyLevel, long thresholdSize, EvictionType thresholdPolicy) -
DefaultDataContainer
protected DefaultDataContainer(int concurrencyLevel, long thresholdSize, EntrySizeCalculator<? super K, ? super V> sizeCalculator) Method invoked when memory policy is used. This calculator only calculates the given key and value.- Parameters:
concurrencyLevel-thresholdSize-sizeCalculator-
-
DefaultDataContainer
protected DefaultDataContainer(long thresholdSize, EntrySizeCalculator<? super K, ? super InternalCacheEntry<K, V>> sizeCalculator) Constructor that allows user to provide a size calculator that also handles the cache entry and metadata.- Parameters:
thresholdSize-sizeCalculator-
-
-
Method Details
-
boundedDataContainer
public static <K,V> DefaultDataContainer<K,V> boundedDataContainer(int concurrencyLevel, long maxEntries, EvictionType thresholdPolicy) -
boundedDataContainer
public static <K,V> DefaultDataContainer<K,V> boundedDataContainer(int concurrencyLevel, long maxEntries, EntrySizeCalculator<? super K, ? super V> sizeCalculator) -
unBoundedDataContainer
-
getMapForSegment
- Specified by:
getMapForSegmentin classAbstractInternalDataContainer<K,V>
-
getSegmentForKey
- Specified by:
getSegmentForKeyin classAbstractInternalDataContainer<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.- Returns:
-
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.- Parameters:
newSize- the new size
-
sizeIncludingExpired
public int sizeIncludingExpired()- Returns:
- count of the number of entries in the container including expired entries
-
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 classAbstractInternalDataContainer<K,V> - Parameters:
segments- segments of entries to remove
-
clear
public void clear()Description copied from interface:DataContainerRemoves all entries in the container -
publisher
-
iterator
Description copied from interface:DataContainerThis iterator only returns entries that are not expired, however it will not remove them while doing so.
- Returns:
- iterator that doesn't produce expired entries
-
iterator
Description copied from interface:InternalDataContainerSame asDataContainer.iterator()except that only entries that map to the provided segments are returned via the iterator. The iterator will not return expired entries.- Parameters:
segments- segments of entries to use- Returns:
- iterator that returns all entries mapped to the given segments
-
spliterator
Description copied from interface:DataContainerThis spliterator only returns entries that are not expired, however it will not remove them while doing so.
- Returns:
- spliterator that doesn't produce expired entries
-
spliterator
Description copied from interface:InternalDataContainerSame asDataContainer.spliterator()except that only entries that map to the provided segments are returned via this spliterator. The spliterator will not return expired entries.- Parameters:
segments- segments of entries to return- Returns:
- spliterator containing entries mapping to those segments that aren't expired
-
spliteratorIncludingExpired
Description copied from interface:DataContainerSame asDataContainer.spliterator()except that is also returns expired entries.- Returns:
- spliterator that returns all entries including expired ones
-
spliteratorIncludingExpired
Description copied from interface:InternalDataContainerSame 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.- Parameters:
segments- segments of entries to use- Returns:
- spliterator containing entries mapping to those segments that could be expired
-
iteratorIncludingExpired
Description copied from interface:DataContainerSame asDataContainer.iterator()except that is also returns expired entries.- Returns:
- iterator that returns all entries including expired ones
-
iteratorIncludingExpired
Description copied from interface:InternalDataContainerSame asDataContainer.iteratorIncludingExpired()except that only entries that map to the provided segments are returned via the iterator. The iterator can return expired entries.- Parameters:
segments- segments of entries to use- Returns:
- iterator that returns all entries mapped to the given segments that could be expired
-
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()- Returns:
- how large the counted eviction is
-
addSegments
Description copied from interface:InternalDataContainerSets what segments this data container should be using. Already associated segments are unaffected by this and takes a union of existing and new segments.- Parameters:
segments- segments to associate with this container
-
removeSegments
Description copied from interface:InternalDataContainerRemoves 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).- Parameters:
segments- segments that should no longer be associated with this container
-
cleanUp
public void cleanUp()Description copied from interface:InternalDataContainerMethod used to cleanup any pending data, such as evictions -
forEachSegment
Description copied from interface:InternalDataContainerPerforms the given consumer for each map inside this container, once for each segment until all maps have been processed or the action throws an exception. Exceptions thrown by the action are relayed to the caller. The consumer will be provided with the segment as well that maps to the given segment.- Parameters:
segmentMapConsumer- The action to be performed for each element map
-