public abstract class AbstractInternalDataContainer<K,V> extends Object implements InternalDataContainer<K,V>
getSegmentForKey(Object)
for methods that don't provide a segment and implementors can provide what
map we should look into for a given segment via getMapForSegment(int)
.Modifier and Type | Class and Description |
---|---|
protected class |
AbstractInternalDataContainer.EntryIterator |
DataContainer.ComputeAction<K,V>
Modifier and Type | Field and Description |
---|---|
protected Configuration |
configuration |
protected InternalEntryFactory |
entryFactory |
protected EvictionManager<K,V> |
evictionManager |
protected InternalExpirationManager<K,V> |
expirationManager |
protected KeyPartitioner |
keyPartitioner |
protected List<Consumer<Iterable<InternalCacheEntry<K,V>>>> |
listeners |
protected DataOperationOrderer |
orderer |
protected ComponentRef<PassivationManager> |
passivator |
protected TimeService |
timeService |
Constructor and Description |
---|
AbstractInternalDataContainer() |
Modifier and Type | Method and Description |
---|---|
void |
addRemovalListener(Consumer<Iterable<InternalCacheEntry<K,V>>> listener)
Adds a listener that is invoked whenever
InternalDataContainer.removeSegments(IntSet) is invoked providing a way for
the listener to see what actual entries were removed from the container. |
protected com.github.benmanes.caffeine.cache.Caffeine<K,InternalCacheEntry<K,V>> |
applyListener(com.github.benmanes.caffeine.cache.Caffeine<K,InternalCacheEntry<K,V>> caffeine,
org.infinispan.container.impl.AbstractInternalDataContainer.DefaultEvictionListener listener,
com.github.benmanes.caffeine.cache.CacheWriter<K,InternalCacheEntry<K,V>> additionalWriter) |
void |
clear(IntSet segments)
Removes entries from the container whose key maps to one of the provided segments
|
InternalCacheEntry<K,V> |
compute(int segment,
K key,
DataContainer.ComputeAction<K,V> action)
Same as
DataContainer.compute(Object, ComputeAction) except that the segment of the key can provided to
update entries without calculating the segment for the given key. |
InternalCacheEntry<K,V> |
compute(K key,
DataContainer.ComputeAction<K,V> action)
Computes the new value for the key.
|
protected void |
computeEntryRemoved(K key,
InternalCacheEntry<K,V> value)
This method is invoked every time an entry is removed inside a compute block
|
protected void |
computeEntryWritten(K key,
InternalCacheEntry<K,V> value)
This method is invoked every time an entry is written inside a compute block
|
boolean |
containsKey(int segment,
Object k)
Same as
DataContainer.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. |
boolean |
containsKey(Object k)
Tests whether an entry exists in the container
|
CompletionStage<Void> |
evict(int segment,
K key)
Same as
DataContainer.evict(Object) except that the segment of the key can provided to
remove the entry without calculating the segment for the given key. |
void |
evict(K key)
Atomically, it removes the key from
DataContainer and passivates it to persistence. |
protected Predicate<InternalCacheEntry<K,V>> |
expiredIterationPredicate(long accessTime)
Returns a predicate that will return false when an entry is expired.
|
protected Spliterator<InternalCacheEntry<K,V>> |
filterExpiredEntries(Spliterator<InternalCacheEntry<K,V>> spliterator)
Returns a new spliterator that will not return entries that have expired.
|
InternalCacheEntry<K,V> |
get(int segment,
Object k)
Same as
DataContainer.get(Object) except that the segment of the key can provided to lookup entries
without calculating the segment for the given key |
InternalCacheEntry<K,V> |
get(Object k)
Retrieves a cached entry
|
protected abstract PeekableTouchableMap<K,V> |
getMapForSegment(int segment) |
protected abstract int |
getSegmentForKey(Object key) |
static <K,V> CompletionStage<Void> |
handleEviction(InternalCacheEntry<K,V> entry,
DataOperationOrderer orderer,
PassivationManager passivator,
EvictionManager<K,V> evictionManager,
DataContainer<K,V> dataContainer,
CompletionStage<Void> selfDelay)
Performs the eviction logic, except it doesn't actually remove the entry from the data container.
|
InternalCacheEntry<K,V> |
peek(int segment,
Object k)
Same as
DataContainer.peek(Object) except that the segment of the key can provided to lookup entries
without calculating the segment for the given key |
InternalCacheEntry<K,V> |
peek(Object k)
Retrieves a cache entry in the same way as
DataContainer.get(Object) } except that it does not update or reorder any of
the internal constructs. |
void |
put(int segment,
K k,
V v,
Metadata metadata,
PrivateMetadata internalMetadata,
long createdTimestamp,
long lastUseTimestamp)
Same as
DataContainer.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. |
void |
put(K k,
V v,
Metadata metadata)
Puts an entry in the cache along with metadata adding information such lifespan of entry, max idle time, version
information...etc.
|
InternalCacheEntry<K,V> |
remove(int segment,
Object k)
Same as
DataContainer.remove(Object) except that the segment of the key can provided to
remove the entry without calculating the segment for the given key. |
InternalCacheEntry<K,V> |
remove(Object k)
Removes an entry from the cache
The
key must be activate by invoking ActivationManager.activateAsync(Object, int) |
void |
removeRemovalListener(Object listener)
Removes a previously registered listener via
InternalDataContainer.addRemovalListener(Consumer) . |
boolean |
touch(int segment,
Object k,
long currentTimeMillis)
Touches an entry in the data container.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addSegments, cleanUp, forEach, iterator, iteratorIncludingExpired, publisher, removeSegments, size, sizeIncludingExpired, spliterator, spliteratorIncludingExpired
capacity, clear, evictionSize, iterator, iteratorIncludingExpired, resize, size, sizeIncludingExpired, spliterator, spliteratorIncludingExpired
protected TimeService timeService
protected EvictionManager<K,V> evictionManager
protected InternalExpirationManager<K,V> expirationManager
protected InternalEntryFactory entryFactory
protected ComponentRef<PassivationManager> passivator
protected Configuration configuration
protected KeyPartitioner keyPartitioner
protected DataOperationOrderer orderer
protected abstract PeekableTouchableMap<K,V> getMapForSegment(int segment)
protected abstract int getSegmentForKey(Object key)
public InternalCacheEntry<K,V> get(int segment, Object k)
InternalDataContainer
DataContainer.get(Object)
except that the segment of the key can provided to lookup entries
without calculating the segment for the given keyget
in interface InternalDataContainer<K,V>
segment
- segment for the keyk
- key under which entry is storedpublic InternalCacheEntry<K,V> get(Object k)
InternalDataContainer
We should only ever be using the non blocking variant InternalDataContainer.peek(int, Object)
in Infinispan
get
in interface DataContainer<K,V>
get
in interface InternalDataContainer<K,V>
k
- key under which entry is storedpublic InternalCacheEntry<K,V> peek(int segment, Object k)
InternalDataContainer
DataContainer.peek(Object)
except that the segment of the key can provided to lookup entries
without calculating the segment for the given keypeek
in interface InternalDataContainer<K,V>
segment
- segment for the keyk
- key under which entry is storedpublic InternalCacheEntry<K,V> peek(Object k)
DataContainer
DataContainer.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 of DataContainer.get(Object)
} when called while iterating through the data container
using methods like DataContainer.iterator()
to avoid changing the underlying collection's order.peek
in interface DataContainer<K,V>
k
- key under which entry is storedpublic boolean touch(int segment, Object k, long currentTimeMillis)
InternalDataContainer
touch
in interface InternalDataContainer<K,V>
segment
- segment for the keyk
- key under which entry is storedcurrentTimeMillis
- the current time in milliseconds to touch the entry withpublic void put(int segment, K k, V v, Metadata metadata, PrivateMetadata internalMetadata, long createdTimestamp, long lastUseTimestamp)
InternalDataContainer
DataContainer.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.
put
in interface InternalDataContainer<K,V>
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 timepublic void put(K k, V v, Metadata metadata)
DataContainer
key
must be activate by invoking ActivationManager.activateAsync(Object, int)
boolean)}.put
in interface DataContainer<K,V>
k
- key under which to store entryv
- value to storemetadata
- metadata of the entrypublic boolean containsKey(int segment, Object k)
InternalDataContainer
DataContainer.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.containsKey
in interface InternalDataContainer<K,V>
segment
- segment for the keyk
- key under which entry is storedpublic boolean containsKey(Object k)
DataContainer
containsKey
in interface DataContainer<K,V>
k
- key to testpublic InternalCacheEntry<K,V> remove(int segment, Object k)
InternalDataContainer
DataContainer.remove(Object)
except that the segment of the key can provided to
remove the entry without calculating the segment for the given key.remove
in interface InternalDataContainer<K,V>
segment
- segment for the keyk
- key to removepublic InternalCacheEntry<K,V> remove(Object k)
DataContainer
key
must be activate by invoking ActivationManager.activateAsync(Object, int)
remove
in interface DataContainer<K,V>
k
- key to removepublic CompletionStage<Void> evict(int segment, K key)
InternalDataContainer
DataContainer.evict(Object)
except that the segment of the key can provided to
remove the entry without calculating the segment for the given key.evict
in interface InternalDataContainer<K,V>
segment
- segment for the keykey
- The key to evict.public void evict(K key)
DataContainer
DataContainer
and passivates it to persistence.
The passivation must be done by invoking the method PassivationManager.passivateAsync(InternalCacheEntry)
.evict
in interface DataContainer<K,V>
key
- The key to evict.public InternalCacheEntry<K,V> compute(int segment, K key, DataContainer.ComputeAction<K,V> action)
InternalDataContainer
DataContainer.compute(Object, ComputeAction)
except that the segment of the key can provided to
update entries without calculating the segment for the given key.compute
in interface InternalDataContainer<K,V>
segment
- segment for the keykey
- The key.action
- The action that will compute the new value.InternalCacheEntry
associated to the key.public InternalCacheEntry<K,V> compute(K key, DataContainer.ComputeAction<K,V> action)
DataContainer
DataContainer.ComputeAction.compute(Object,
org.infinispan.container.entries.InternalCacheEntry, InternalEntryFactory)
.
The key
must be activated by invoking ActivationManager.activateAsync(Object, int)
.
Note the entry provided to DataContainer.ComputeAction
may be expired as these
entries are not filtered as many other methods do.
compute
in interface DataContainer<K,V>
key
- The key.action
- The action that will compute the new value.InternalCacheEntry
associated to the key.public void clear(IntSet segments)
InternalDataContainer
clear
in interface InternalDataContainer<K,V>
segments
- segments of entries to removeprotected void computeEntryWritten(K key, InternalCacheEntry<K,V> value)
key
- key passed to compute methodvalue
- the new valueprotected void computeEntryRemoved(K key, InternalCacheEntry<K,V> value)
key
- key passed to compute methodvalue
- the old valuepublic void addRemovalListener(Consumer<Iterable<InternalCacheEntry<K,V>>> listener)
InternalDataContainer
InternalDataContainer.removeSegments(IntSet)
is invoked providing a way for
the listener to see what actual entries were removed from the container.addRemovalListener
in interface InternalDataContainer<K,V>
listener
- listener that invoked of removed entriespublic void removeRemovalListener(Object listener)
InternalDataContainer
InternalDataContainer.addRemovalListener(Consumer)
.removeRemovalListener
in interface InternalDataContainer<K,V>
listener
- the listener to removeprotected com.github.benmanes.caffeine.cache.Caffeine<K,InternalCacheEntry<K,V>> applyListener(com.github.benmanes.caffeine.cache.Caffeine<K,InternalCacheEntry<K,V>> caffeine, org.infinispan.container.impl.AbstractInternalDataContainer.DefaultEvictionListener listener, com.github.benmanes.caffeine.cache.CacheWriter<K,InternalCacheEntry<K,V>> additionalWriter)
public static <K,V> CompletionStage<Void> handleEviction(InternalCacheEntry<K,V> entry, DataOperationOrderer orderer, PassivationManager passivator, EvictionManager<K,V> evictionManager, DataContainer<K,V> dataContainer, CompletionStage<Void> selfDelay)
K
- key type of the entryV
- value type of the entryentry
- evicted entryorderer
- used to guarantee ordering between other operations. May be null when an operation is already orderedpassivator
- Passivates the entry to the store if necessaryevictionManager
- Handles additional eviction logic. May be null if eviction is also not requireddataContainer
- container to check if the key has already been removedselfDelay
- if null, the entry was already removed;
if non-null, completes after the eviction finishes removing the entryprotected Spliterator<InternalCacheEntry<K,V>> filterExpiredEntries(Spliterator<InternalCacheEntry<K,V>> spliterator)
spliterator
- the spliterator to filter expired entries out ofprotected Predicate<InternalCacheEntry<K,V>> expiredIterationPredicate(long accessTime)
accessTime
- the access time to base expiration off ofCopyright © 2021 JBoss by Red Hat. All rights reserved.