Interface InternalDataContainer<K,V>
- All Superinterfaces:
DataContainer<K,
,V> Iterable<InternalCacheEntry<K,
V>>
- All Known Implementing Classes:
AbstractDelegatingInternalDataContainer
,AbstractInternalDataContainer
,BoundedOffHeapDataContainer
,BoundedSegmentedDataContainer
,DefaultDataContainer
,DefaultSegmentedDataContainer
,L1SegmentedDataContainer
,OffHeapDataContainer
,SegmentedBoundedOffHeapDataContainer
This container has a notion of what segments are currently associated with it and these can be controlled via
the removeSegments(IntSet)
and addSegments(IntSet)
methods. A segment can be added multiple times
and the implementation must be able to handle this. If a write occurs on a segment that is not associated with this
container it may ignore the write or it could store it temporarily if needed (additional caching). When segments
are removed, an implementation is free to remove any entries that map to segments that aren't associated to this
container.
- Since:
- 9.3
- Author:
- wburns
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.infinispan.container.DataContainer
DataContainer.ComputeAction<K,
V> -
Method Summary
Modifier and TypeMethodDescriptionvoid
addRemovalListener
(Consumer<Iterable<InternalCacheEntry<K, V>>> listener) Adds a listener that is invoked wheneverremoveSegments(IntSet)
is invoked providing a way for the listener to see what actual entries were removed from the container.void
addSegments
(IntSet segments) Sets what segments this data container should be using.default void
cleanUp()
Method used to cleanup any pending data, such as evictionsvoid
Removes entries from the container whose key maps to one of the provided segmentscompute
(int segment, K key, DataContainer.ComputeAction<K, V> action) Same asDataContainer.compute(Object, ComputeAction)
except that the segment of the key can provided to update entries without calculating the segment for the given key.boolean
containsKey
(int segment, Object k) Same asDataContainer.containsKey(Object)
except that the segment of the key can provided to lookup if the entry exists without calculating the segment for the given key.Same asDataContainer.evict(Object)
except that the segment of the key can provided to remove the entry without calculating the segment for the given key.default void
Performs the given action for each element of the container that maps to the given set of segments until all elements have been processed or the action throws an exception.void
forEachSegment
(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.Deprecated, for removal: This API element is subject to removal in a future version.since 10.1Deprecated, for removal: This API element is subject to removal in a future version.since 10.1boolean
Verify if the container has entries that can expire.Same asDataContainer.iterator()
except that only entries that map to the provided segments are returned via the iterator.iteratorIncludingExpired
(IntSet segments) Same asDataContainer.iteratorIncludingExpired()
except that only entries that map to the provided segments are returned via the iterator.Same asDataContainer.peek(Object)
except that the segment of the key can provided to lookup entries without calculating the segment for the given keydefault org.reactivestreams.Publisher<InternalCacheEntry<K,
V>> publisher
(int segment) default org.reactivestreams.Publisher<InternalCacheEntry<K,
V>> void
put
(int segment, K k, V v, Metadata metadata, PrivateMetadata internalMetadata, long createdTimestamp, long lastUseTimestamp) Same asDataContainer.put(Object, Object, Metadata)
except that the segment of the key can provided to write/lookup entries without calculating the segment for the given key.Same asDataContainer.remove(Object)
except that the segment of the key can provided to remove the entry without calculating the segment for the given key.void
removeRemovalListener
(Object listener) Removes a previously registered listener viaaddRemovalListener(Consumer)
.void
removeSegments
(IntSet segments) Removes and un-associates the given segments.default int
Returns how many entries are present in the data container that map to the given segments without counting entries that are currently expired.default int
sizeIncludingExpired
(IntSet segments) Returns how many entries are present in the data container that map to the given segments including any entries that may be expiredspliterator
(IntSet segments) Same asDataContainer.spliterator()
except that only entries that map to the provided segments are returned via this spliterator.spliteratorIncludingExpired
(IntSet segments) Same asDataContainer.spliteratorIncludingExpired()
except that only entries that map to the provided segments are returned via this spliterator.boolean
Touches an entry in the data container.Methods inherited from interface org.infinispan.container.DataContainer
capacity, clear, compute, containsKey, evict, evictionSize, iterator, iteratorIncludingExpired, peek, put, remove, resize, size, sizeIncludingExpired, spliterator, spliteratorIncludingExpired
-
Method Details
-
get
Deprecated, for removal: This API element is subject to removal in a future version.since 10.1Retrieves a cached entryWe should only ever be using the non blocking variant
peek(int, Object)
in Infinispan- Specified by:
get
in interfaceDataContainer<K,
V> - Parameters:
k
- key under which entry is stored- Returns:
- entry, if it exists and has not expired, or null if not
-
get
Deprecated, for removal: This API element is subject to removal in a future version.since 10.1Same asDataContainer.get(Object)
except that the segment of the key can provided to lookup entries without calculating the segment for the given key- Parameters:
segment
- segment for the keyk
- key under which entry is stored- Returns:
- entry, if it exists and has not expired, or null if not
-
peek
Same asDataContainer.peek(Object)
except that the segment of the key can provided to lookup entries without calculating the segment for the given key- Parameters:
segment
- segment for the keyk
- key under which entry is stored- Returns:
- entry, if it exists, or null if not
-
touch
Touches an entry in the data container. This will update the last access time of the entry as well as count this as a access for eviction based recency.- Parameters:
segment
- segment for the keyk
- key under which entry is storedcurrentTimeMillis
- the current time in milliseconds to touch the entry with- Returns:
- true if the entry timestamp was touched
-
put
void put(int segment, K k, V v, Metadata metadata, PrivateMetadata internalMetadata, long createdTimestamp, long lastUseTimestamp) Same asDataContainer.put(Object, Object, Metadata)
except that the segment of the key can provided to write/lookup entries without calculating the segment for the given key.Note: The timestamps ignored if the entry already exists in the data container.
- Parameters:
segment
- segment for the keyk
- key under which to store entryv
- value to storemetadata
- metadata of the entryinternalMetadata
-createdTimestamp
- creation timestamp, or-1
to use the current timelastUseTimestamp
- last use timestamp, or-1
to use the current time- Since:
- 10.0
-
containsKey
Same asDataContainer.containsKey(Object)
except that the segment of the key can provided to lookup if the entry exists without calculating the segment for the given key.- Parameters:
segment
- segment for the keyk
- key under which entry is stored- Returns:
- true if entry exists and has not expired; false otherwise
-
remove
Same asDataContainer.remove(Object)
except that the segment of the key can provided to remove the entry without calculating the segment for the given key.- Parameters:
segment
- segment for the keyk
- key to remove- Returns:
- entry removed, or null if it didn't exist or had expired
-
evict
Same asDataContainer.evict(Object)
except that the segment of the key can provided to remove the entry without calculating the segment for the given key.- Parameters:
segment
- segment for the keykey
- The key to evict.
-
compute
Same asDataContainer.compute(Object, ComputeAction)
except that the segment of the key can provided to update entries without calculating the segment for the given key.- Parameters:
segment
- segment for the keykey
- The key.action
- The action that will compute the new value.- Returns:
- The
InternalCacheEntry
associated to the key.
-
size
Returns how many entries are present in the data container that map to the given segments without counting entries that are currently expired.- Parameters:
segments
- segments of entries to count- Returns:
- count of the number of entries in the container excluding expired entries
-
sizeIncludingExpired
Returns how many entries are present in the data container that map to the given segments including any entries that may be expired- Parameters:
segments
- segments of entries to count- Returns:
- count of the number of entries in the container including expired entries
-
clear
Removes entries from the container whose key maps to one of the provided segments- Parameters:
segments
- segments of entries to remove
-
spliterator
Same 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
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.- Parameters:
segments
- segments of entries to use- Returns:
- spliterator containing entries mapping to those segments that could be expired
-
iterator
Same 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
-
iteratorIncludingExpired
Same 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
-
publisher
-
publisher
-
forEach
Performs the given action for each element of the container that maps to the given set of segments until all elements have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of iteration (if an iteration order is specified). Exceptions thrown by the action are relayed to the caller.- Parameters:
action
- The action to be performed for each element- Throws:
NullPointerException
- if the specified action is null
-
forEachSegment
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. 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- Throws:
NullPointerException
- if the specified action is null
-
addSegments
Sets 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
Removes and un-associates the given segments. This will notify any listeners registered viaaddRemovalListener(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
addRemovalListener(Consumer)
.- Parameters:
segments
- segments that should no longer be associated with this container
-
addRemovalListener
Adds a listener that is invoked wheneverremoveSegments(IntSet)
is invoked providing a way for the listener to see what actual entries were removed from the container.- Parameters:
listener
- listener that invoked of removed entries
-
removeRemovalListener
Removes a previously registered listener viaaddRemovalListener(Consumer)
.- Parameters:
listener
- the listener to remove
-
cleanUp
default void cleanUp()Method used to cleanup any pending data, such as evictions -
hasExpirable
boolean hasExpirable()Verify if the container has entries that can expire. This is __not__ the same thing as verifying for expired entries. This method can return true even if entries are not expired.- Returns:
- true if any entry can expire, false otherwise.
-