Package org.infinispan.container.impl
Class AbstractDelegatingInternalDataContainer<K,V>
- java.lang.Object
-
- org.infinispan.container.impl.AbstractDelegatingDataContainer<K,V>
-
- org.infinispan.container.impl.AbstractDelegatingInternalDataContainer<K,V>
-
- All Implemented Interfaces:
Iterable<InternalCacheEntry<K,V>>
,DataContainer<K,V>
,InternalDataContainer<K,V>
- Direct Known Subclasses:
SegmentedBoundedOffHeapDataContainer
public abstract class AbstractDelegatingInternalDataContainer<K,V> extends AbstractDelegatingDataContainer<K,V> implements InternalDataContainer<K,V>
- Since:
- 9.0
- Author:
- wburns
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.container.DataContainer
DataContainer.ComputeAction<K,V>
-
-
Constructor Summary
Constructors Constructor Description AbstractDelegatingInternalDataContainer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addRemovalListener(Consumer<Iterable<InternalCacheEntry<K,V>>> listener)
Adds 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.void
addSegments(org.infinispan.commons.util.IntSet segments)
Sets what segments this data container should be using.void
clear(org.infinispan.commons.util.IntSet segments)
Removes entries from the container whose key maps to one of the provided segmentsInternalCacheEntry<K,V>
compute(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.protected abstract InternalDataContainer<K,V>
delegate()
void
evict(int segment, K 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.void
forEach(org.infinispan.commons.util.IntSet segments, Consumer<? super InternalCacheEntry<K,V>> action)
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.InternalCacheEntry<K,V>
get(int segment, Object k)
Same asDataContainer.get(Object)
except that the segment of the key can provided to lookup entries without calculating the segment for the given keyIterator<InternalCacheEntry<K,V>>
iterator(org.infinispan.commons.util.IntSet segments)
Same asDataContainer.iterator()
except that only entries that map to the provided segments are returned via the iterator.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 keyvoid
put(int segment, K k, V v, Metadata metadata, 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.InternalCacheEntry<K,V>
remove(int segment, Object k)
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 viaInternalDataContainer.addRemovalListener(Consumer)
.void
removeSegments(org.infinispan.commons.util.IntSet segments)
Removes and un-associates the given segments.int
size(org.infinispan.commons.util.IntSet segments)
Returns how many entries are present in the data container that map to the given segments without counting entries that are currently expired.int
sizeIncludingExpired(org.infinispan.commons.util.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<InternalCacheEntry<K,V>>
spliterator(org.infinispan.commons.util.IntSet segments)
Same asDataContainer.spliterator()
except that only entries that map to the provided segments are returned via this spliterator.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.boolean
touch(int segment, Object k, long currentTimeMillis)
Touches an entry in the data container.-
Methods inherited from class org.infinispan.container.impl.AbstractDelegatingDataContainer
capacity, clear, compute, containsKey, entrySet, evict, evictionSize, executeTask, executeTask, forEach, get, iterator, iteratorIncludingExpired, keySet, peek, put, remove, resize, size, sizeIncludingExpired, spliterator, spliteratorIncludingExpired, 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
capacity, clear, compute, containsKey, entrySet, evict, evictionSize, executeTask, executeTask, iterator, iteratorIncludingExpired, keySet, peek, put, remove, resize, size, sizeIncludingExpired, spliterator, spliteratorIncludingExpired, values
-
Methods inherited from interface org.infinispan.container.impl.InternalDataContainer
get
-
-
-
-
Method Detail
-
delegate
protected abstract InternalDataContainer<K,V> delegate()
-
get
public InternalCacheEntry<K,V> get(int segment, Object k)
Description copied from interface:InternalDataContainer
Same 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:
get
in interfaceInternalDataContainer<K,V>
- 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
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>
- Parameters:
segment
- segment for the keyk
- key under which entry is stored- Returns:
- entry, if it exists, or null if not
-
touch
public boolean touch(int segment, Object k, long currentTimeMillis)
Description copied from interface:InternalDataContainer
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.- Specified by:
touch
in interfaceInternalDataContainer<K,V>
- 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
public void put(int segment, K k, V v, Metadata metadata, long createdTimestamp, long lastUseTimestamp)
Description copied from interface:InternalDataContainer
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.
- Specified by:
put
in interfaceInternalDataContainer<K,V>
- Parameters:
segment
- segment for the keyk
- key under which to store entryv
- value to storemetadata
- metadata of the entrycreatedTimestamp
- creation timestamp, or-1
to use the current timelastUseTimestamp
- last use timestamp, or-1
to use the current time
-
containsKey
public boolean containsKey(int segment, Object k)
Description copied from interface:InternalDataContainer
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.- Specified by:
containsKey
in interfaceInternalDataContainer<K,V>
- Parameters:
segment
- segment for the keyk
- key under which entry is stored- Returns:
- true if entry exists and has not expired; false otherwise
-
remove
public InternalCacheEntry<K,V> remove(int segment, Object k)
Description copied from interface:InternalDataContainer
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.- Specified by:
remove
in interfaceInternalDataContainer<K,V>
- Parameters:
segment
- segment for the keyk
- key to remove- Returns:
- entry removed, or null if it didn't exist or had expired
-
evict
public void evict(int segment, K key)
Description copied from interface:InternalDataContainer
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.- Specified by:
evict
in interfaceInternalDataContainer<K,V>
- Parameters:
segment
- segment for the keykey
- The key to evict.
-
compute
public InternalCacheEntry<K,V> compute(int segment, K key, DataContainer.ComputeAction<K,V> action)
Description copied from interface:InternalDataContainer
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.- Specified by:
compute
in interfaceInternalDataContainer<K,V>
- Parameters:
segment
- segment for the keykey
- The key.action
- The action that will compute the new value.- Returns:
- The
InternalCacheEntry
associated to the key.
-
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>
- Parameters:
segments
- segments of entries to remove
-
spliterator
public Spliterator<InternalCacheEntry<K,V>> spliterator(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainer
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.- Specified by:
spliterator
in interfaceInternalDataContainer<K,V>
- Parameters:
segments
- segments of entries to return- Returns:
- spliterator containing entries mapping to those segments that aren't expired
-
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>
- Parameters:
segments
- segments of entries to use- Returns:
- spliterator containing entries mapping to those segments that could be expired
-
iterator
public Iterator<InternalCacheEntry<K,V>> iterator(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainer
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.- Specified by:
iterator
in interfaceInternalDataContainer<K,V>
- Parameters:
segments
- segments of entries to use- Returns:
- iterator that returns all entries mapped to the given segments
-
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>
- Parameters:
segments
- segments of entries to use- Returns:
- iterator that returns all entries mapped to the given segments that could be expired
-
forEach
public void forEach(org.infinispan.commons.util.IntSet segments, Consumer<? super InternalCacheEntry<K,V>> action)
Description copied from interface:InternalDataContainer
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.- Specified by:
forEach
in interfaceInternalDataContainer<K,V>
action
- The action to be performed for each element
-
size
public int size(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainer
Returns how many entries are present in the data container that map to the given segments without counting entries that are currently expired.- Specified by:
size
in interfaceInternalDataContainer<K,V>
- Parameters:
segments
- segments of entries to count- Returns:
- count of the number of entries in the container excluding expired entries
-
sizeIncludingExpired
public int sizeIncludingExpired(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainer
Returns how many entries are present in the data container that map to the given segments including any entries that may be expired- Specified by:
sizeIncludingExpired
in interfaceInternalDataContainer<K,V>
- Parameters:
segments
- segments of entries to count- Returns:
- count of the number of entries in the container including expired entries
-
addSegments
public void addSegments(org.infinispan.commons.util.IntSet segments)
Description copied from interface:InternalDataContainer
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.- Specified by:
addSegments
in interfaceInternalDataContainer<K,V>
- Parameters:
segments
- segments to associate with this container
-
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>
- Parameters:
segments
- segments that should no longer be associated with this container
-
addRemovalListener
public void addRemovalListener(Consumer<Iterable<InternalCacheEntry<K,V>>> listener)
Description copied from interface:InternalDataContainer
Adds 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:
addRemovalListener
in interfaceInternalDataContainer<K,V>
- Parameters:
listener
- listener that invoked of removed entries
-
removeRemovalListener
public void removeRemovalListener(Object listener)
Description copied from interface:InternalDataContainer
Removes a previously registered listener viaInternalDataContainer.addRemovalListener(Consumer)
.- Specified by:
removeRemovalListener
in interfaceInternalDataContainer<K,V>
- Parameters:
listener
- the listener to remove
-
-