Package org.infinispan.container.offheap
Class BoundedOffHeapDataContainer
java.lang.Object
org.infinispan.container.impl.AbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes>
org.infinispan.container.offheap.SegmentedBoundedOffHeapDataContainer
org.infinispan.container.offheap.BoundedOffHeapDataContainer
- All Implemented Interfaces:
Iterable<InternalCacheEntry<WrappedBytes,,WrappedBytes>> DataContainer<WrappedBytes,,WrappedBytes> InternalDataContainer<WrappedBytes,WrappedBytes>
- Since:
- 9.4
- Author:
- wburns
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.infinispan.container.DataContainer
DataContainer.ComputeAction<K,V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final List<Consumer<Iterable<InternalCacheEntry<WrappedBytes,WrappedBytes>>>> Fields inherited from class org.infinispan.container.offheap.SegmentedBoundedOffHeapDataContainer
allocator, currentSize, dataContainer, evictionManager, firstAddress, lastAddress, lruLock, maxSize, numSegments, offHeapEntryFactory, orderer, passivator, useCount -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener that is invoked wheneverInternalDataContainer.removeSegments(IntSet)is invoked providing a way for the listener to see what actual entries were removed from the container.voidaddSegments(IntSet segments) Sets what segments this data container should be using.compute(int segment, WrappedBytes key, DataContainer.ComputeAction<WrappedBytes, WrappedBytes> 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.compute(WrappedBytes key, DataContainer.ComputeAction<WrappedBytes, WrappedBytes> action) Computes the new value for the key.booleancontainsKey(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.booleanTests whether an entry exists in the containerevict(int segment, WrappedBytes 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.voidevict(WrappedBytes key) Atomically, it removes the key fromDataContainerand passivates it to persistence.Same asDataContainer.get(Object)except that the segment of the key can provided to lookup entries without calculating the segment for the given keyRetrieves a cached entryprotected OffHeapConcurrentMapgetMapThatContainsKey(byte[] key) 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 keyRetrieves a cache entry in the same way asDataContainer.get(Object)} except that it does not update or reorder any of the internal constructs.voidput(int segment, WrappedBytes key, WrappedBytes value, 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.voidput(WrappedBytes key, WrappedBytes value, Metadata metadata) Puts an entry in the cache along with metadata adding information such lifespan of entry, max idle time, version information...etc.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.Removes an entry from the cachevoidremoveRemovalListener(Object listener) Removes a previously registered listener viaInternalDataContainer.addRemovalListener(Consumer).voidremoveSegments(IntSet segments) Removes and un-associates the given segments.intReturns how many entries are present in the data container that map to the given segments without counting entries that are currently expired.intsizeIncludingExpired(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.Methods inherited from class org.infinispan.container.offheap.SegmentedBoundedOffHeapDataContainer
capacity, delegate, evictionSize, getSize, start, stopMethods inherited from class org.infinispan.container.impl.AbstractDelegatingInternalDataContainer
clear, clear, forEach, forEach, forEachSegment, hasExpirable, iterator, iteratorIncludingExpired, resize, size, sizeIncludingExpired, spliterator, spliteratorIncludingExpired, touchMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.infinispan.container.impl.InternalDataContainer
cleanUp, publisher, publisher
-
Field Details
-
listeners
-
-
Constructor Details
-
BoundedOffHeapDataContainer
-
-
Method Details
-
getMapThatContainsKey
- Overrides:
getMapThatContainsKeyin classSegmentedBoundedOffHeapDataContainer
-
containsKey
Description copied from interface:DataContainerTests whether an entry exists in the container- Specified by:
containsKeyin interfaceDataContainer<WrappedBytes,WrappedBytes> - Overrides:
containsKeyin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
k- key to test- Returns:
- true if entry exists and has not expired; false otherwise
-
peek
Description copied from interface:DataContainerRetrieves 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:
peekin interfaceDataContainer<WrappedBytes,WrappedBytes> - Overrides:
peekin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
k- key under which entry is stored- Returns:
- entry, if it exists, or null if not
-
get
Description copied from interface:InternalDataContainerRetrieves a cached entryWe should only ever be using the non blocking variant
InternalDataContainer.peek(int, Object)in Infinispan- Specified by:
getin interfaceDataContainer<WrappedBytes,WrappedBytes> - Specified by:
getin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
getin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
k- key under which entry is stored- Returns:
- entry, if it exists and has not expired, or null if not
-
compute
public InternalCacheEntry<WrappedBytes,WrappedBytes> compute(WrappedBytes key, DataContainer.ComputeAction<WrappedBytes, WrappedBytes> action) Description copied from interface:DataContainerComputes the new value for the key. SeeDataContainer.ComputeAction.compute(Object, org.infinispan.container.entries.InternalCacheEntry, InternalEntryFactory).Note the entry provided to
DataContainer.ComputeActionmay be expired as these entries are not filtered as many other methods do.- Specified by:
computein interfaceDataContainer<WrappedBytes,WrappedBytes> - Overrides:
computein classSegmentedBoundedOffHeapDataContainer- Parameters:
key- The key.action- The action that will compute the new value.- Returns:
- The
InternalCacheEntryassociated to the key.
-
remove
Description copied from interface:DataContainerRemoves an entry from the cache- Specified by:
removein interfaceDataContainer<WrappedBytes,WrappedBytes> - Overrides:
removein classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
k- key to remove- Returns:
- entry removed, or null if it didn't exist or had expired
-
evict
Description copied from interface:DataContainerAtomically, it removes the key fromDataContainerand passivates it to persistence. The passivation must be done by invoking the methodPassivationManager.passivateAsync(InternalCacheEntry).- Specified by:
evictin interfaceDataContainer<WrappedBytes,WrappedBytes> - Overrides:
evictin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
key- The key to evict.
-
put
Description copied from interface:DataContainerPuts an entry in the cache along with metadata adding information such lifespan of entry, max idle time, version information...etc.- Specified by:
putin interfaceDataContainer<WrappedBytes,WrappedBytes> - Overrides:
putin classSegmentedBoundedOffHeapDataContainer- Parameters:
key- key under which to store entryvalue- value to storemetadata- metadata of the entry
-
containsKey
Description copied from interface:InternalDataContainerSame 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.- Specified by:
containsKeyin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
containsKeyin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
segment- segment for the keyk- key under which entry is stored- Returns:
- true if entry exists and has not expired; false otherwise
-
peek
Description copied from interface:InternalDataContainerSame 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:
peekin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
peekin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
segment- segment for the keyk- key under which entry is stored- Returns:
- entry, if it exists, or null if not
-
get
Description copied from interface:InternalDataContainerSame asDataContainer.get(Object)except that the segment of the key can provided to lookup entries without calculating the segment for the given key- Specified by:
getin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
getin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - 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
-
compute
public InternalCacheEntry<WrappedBytes,WrappedBytes> compute(int segment, WrappedBytes key, DataContainer.ComputeAction<WrappedBytes, WrappedBytes> action) Description copied from interface:InternalDataContainerSame asDataContainer.compute(Object, ComputeAction)except that the segment of the key can provided to update entries without calculating the segment for the given key.- Specified by:
computein interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
computein classSegmentedBoundedOffHeapDataContainer- Parameters:
segment- segment for the keykey- The key.action- The action that will compute the new value.- Returns:
- The
InternalCacheEntryassociated to the key.
-
remove
Description copied from interface:InternalDataContainerSame asDataContainer.remove(Object)except that the segment of the key can provided to remove the entry without calculating the segment for the given key.- Specified by:
removein interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
removein classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
segment- segment for the keyk- key to remove- Returns:
- entry removed, or null if it didn't exist or had expired
-
evict
Description copied from interface:InternalDataContainerSame asDataContainer.evict(Object)except that the segment of the key can provided to remove the entry without calculating the segment for the given key.- Specified by:
evictin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
evictin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
segment- segment for the keykey- The key to evict.
-
put
public void put(int segment, WrappedBytes key, WrappedBytes value, Metadata metadata, PrivateMetadata internalMetadata, long createdTimestamp, long lastUseTimestamp) Description copied from interface:InternalDataContainerSame 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.
- Specified by:
putin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
putin classSegmentedBoundedOffHeapDataContainer- Parameters:
segment- segment for the keykey- key under which to store entryvalue- value to storemetadata- metadata of the entrycreatedTimestamp- creation timestamp, or-1to use the current timelastUseTimestamp- last use timestamp, or-1to use the current time
-
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.- Specified by:
spliteratorin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
spliteratorin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
segments- segments of entries to return- Returns:
- spliterator containing entries mapping to those segments that aren't expired
-
spliteratorIncludingExpired
public Spliterator<InternalCacheEntry<WrappedBytes,WrappedBytes>> spliteratorIncludingExpired(IntSet segments) 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.- Specified by:
spliteratorIncludingExpiredin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
spliteratorIncludingExpiredin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
segments- segments of entries to use- Returns:
- spliterator containing entries mapping to those segments that could be expired
-
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.- Specified by:
iteratorin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
iteratorin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
segments- segments of entries to use- Returns:
- iterator that returns all entries mapped to the given segments
-
iteratorIncludingExpired
public Iterator<InternalCacheEntry<WrappedBytes,WrappedBytes>> iteratorIncludingExpired(IntSet segments) 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.- Specified by:
iteratorIncludingExpiredin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
iteratorIncludingExpiredin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
segments- segments of entries to use- Returns:
- iterator that returns all entries mapped to the given segments that could be expired
-
sizeIncludingExpired
Description copied from interface:InternalDataContainerReturns how many entries are present in the data container that map to the given segments including any entries that may be expired- Specified by:
sizeIncludingExpiredin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
sizeIncludingExpiredin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
segments- segments of entries to count- Returns:
- count of the number of entries in the container including expired entries
-
size
Description copied from interface:InternalDataContainerReturns how many entries are present in the data container that map to the given segments without counting entries that are currently expired.- Specified by:
sizein interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
sizein classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
segments- segments of entries to count- Returns:
- count of the number of entries in the container excluding expired entries
-
addRemovalListener
public void addRemovalListener(Consumer<Iterable<InternalCacheEntry<WrappedBytes, WrappedBytes>>> listener) Description copied from interface:InternalDataContainerAdds a listener that is invoked wheneverInternalDataContainer.removeSegments(IntSet)is invoked providing a way for the listener to see what actual entries were removed from the container.- Specified by:
addRemovalListenerin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
addRemovalListenerin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
listener- listener that invoked of removed entries
-
removeRemovalListener
Description copied from interface:InternalDataContainerRemoves a previously registered listener viaInternalDataContainer.addRemovalListener(Consumer).- Specified by:
removeRemovalListenerin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
removeRemovalListenerin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
listener- the listener to remove
-
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.- Specified by:
addSegmentsin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
addSegmentsin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - 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).- Specified by:
removeSegmentsin interfaceInternalDataContainer<WrappedBytes,WrappedBytes> - Overrides:
removeSegmentsin classAbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes> - Parameters:
segments- segments that should no longer be associated with this container
-