public abstract class AbstractDelegatingInternalDataContainer<K,V> extends Object implements InternalDataContainer<K,V>
delegate()
DataContainer.ComputeAction<K,V>
Constructor and Description |
---|
AbstractDelegatingInternalDataContainer() |
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. |
void |
addSegments(IntSet segments)
Sets what segments this data container should be using.
|
long |
capacity()
Returns the capacity of the underlying container.
|
void |
clear()
Removes all entries in the container
|
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.
|
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
|
protected abstract InternalDataContainer<K,V> |
delegate() |
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. |
long |
evictionSize()
Returns how large the eviction size is currently.
|
void |
forEach(Consumer<? super InternalCacheEntry<K,V>> action) |
void |
forEach(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 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
|
Iterator<InternalCacheEntry<K,V>> |
iterator() |
Iterator<InternalCacheEntry<K,V>> |
iterator(IntSet segments)
Same as
DataContainer.iterator() except that only entries that map to the provided segments are
returned via the iterator. |
Iterator<InternalCacheEntry<K,V>> |
iteratorIncludingExpired()
Same as
DataContainer.iterator() except that is also returns expired entries. |
Iterator<InternalCacheEntry<K,V>> |
iteratorIncludingExpired(IntSet segments)
Same as
DataContainer.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 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) . |
void |
removeSegments(IntSet segments)
Removes and un-associates the given segments.
|
void |
resize(long newSize)
Resizes the capacity of the underlying container.
|
int |
size() |
int |
size(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() |
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 expired
|
Spliterator<InternalCacheEntry<K,V>> |
spliterator() |
Spliterator<InternalCacheEntry<K,V>> |
spliterator(IntSet segments)
Same as
DataContainer.spliterator() except that only entries that map to the provided segments are
returned via this spliterator. |
Spliterator<InternalCacheEntry<K,V>> |
spliteratorIncludingExpired()
Same as
DataContainer.spliterator() except that is also returns expired entries. |
Spliterator<InternalCacheEntry<K,V>> |
spliteratorIncludingExpired(IntSet segments)
Same as
DataContainer.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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cleanUp, publisher
public AbstractDelegatingInternalDataContainer()
protected abstract InternalDataContainer<K,V> delegate()
public 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> 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> 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 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 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(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 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 boolean containsKey(Object k)
DataContainer
containsKey
in interface DataContainer<K,V>
k
- key to testpublic 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 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 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 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 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 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 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 void clear()
DataContainer
clear
in interface DataContainer<K,V>
public void clear(IntSet segments)
InternalDataContainer
clear
in interface InternalDataContainer<K,V>
segments
- segments of entries to removepublic Spliterator<InternalCacheEntry<K,V>> spliterator()
DataContainer
This spliterator only returns entries that are not expired, however it will not remove them while doing so.
spliterator
in interface Iterable<InternalCacheEntry<K,V>>
spliterator
in interface DataContainer<K,V>
public Spliterator<InternalCacheEntry<K,V>> spliterator(IntSet segments)
InternalDataContainer
DataContainer.spliterator()
except that only entries that map to the provided segments are
returned via this spliterator. The spliterator will not return expired entries.spliterator
in interface InternalDataContainer<K,V>
segments
- segments of entries to returnpublic Spliterator<InternalCacheEntry<K,V>> spliteratorIncludingExpired()
DataContainer
DataContainer.spliterator()
except that is also returns expired entries.spliteratorIncludingExpired
in interface DataContainer<K,V>
public Spliterator<InternalCacheEntry<K,V>> spliteratorIncludingExpired(IntSet segments)
InternalDataContainer
DataContainer.spliteratorIncludingExpired()
except that only entries that map to the provided
segments are returned via this spliterator. The spliterator will return expired entries as well.spliteratorIncludingExpired
in interface InternalDataContainer<K,V>
segments
- segments of entries to usepublic Iterator<InternalCacheEntry<K,V>> iterator()
DataContainer
This iterator only returns entries that are not expired, however it will not remove them while doing so.
iterator
in interface Iterable<InternalCacheEntry<K,V>>
iterator
in interface DataContainer<K,V>
public Iterator<InternalCacheEntry<K,V>> iterator(IntSet segments)
InternalDataContainer
DataContainer.iterator()
except that only entries that map to the provided segments are
returned via the iterator. The iterator will not return expired entries.iterator
in interface InternalDataContainer<K,V>
segments
- segments of entries to usepublic Iterator<InternalCacheEntry<K,V>> iteratorIncludingExpired()
DataContainer
DataContainer.iterator()
except that is also returns expired entries.iteratorIncludingExpired
in interface DataContainer<K,V>
public Iterator<InternalCacheEntry<K,V>> iteratorIncludingExpired(IntSet segments)
InternalDataContainer
DataContainer.iteratorIncludingExpired()
except that only entries that map to the provided
segments are returned via the iterator. The iterator can return expired entries.iteratorIncludingExpired
in interface InternalDataContainer<K,V>
segments
- segments of entries to usepublic void forEach(Consumer<? super InternalCacheEntry<K,V>> action)
forEach
in interface Iterable<InternalCacheEntry<K,V>>
public void forEach(IntSet segments, Consumer<? super InternalCacheEntry<K,V>> action)
InternalDataContainer
forEach
in interface InternalDataContainer<K,V>
action
- The action to be performed for each elementpublic int size()
size
in interface DataContainer<K,V>
public int size(IntSet segments)
InternalDataContainer
size
in interface InternalDataContainer<K,V>
segments
- segments of entries to countpublic int sizeIncludingExpired()
sizeIncludingExpired
in interface DataContainer<K,V>
public int sizeIncludingExpired(IntSet segments)
InternalDataContainer
sizeIncludingExpired
in interface InternalDataContainer<K,V>
segments
- segments of entries to countpublic void addSegments(IntSet segments)
InternalDataContainer
addSegments
in interface InternalDataContainer<K,V>
segments
- segments to associate with this containerpublic void removeSegments(IntSet segments)
InternalDataContainer
InternalDataContainer.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)
.
removeSegments
in interface InternalDataContainer<K,V>
segments
- segments that should no longer be associated with this containerpublic 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 removepublic long capacity()
DataContainer
UnsupportedOperationException
is thrown
otherwise.capacity
in interface DataContainer<K,V>
public long evictionSize()
DataContainer
UnsupportedOperationException
is thrown otherwise. This value will always be lower than the value returned
from DataContainer.capacity()
evictionSize
in interface DataContainer<K,V>
public void resize(long newSize)
DataContainer
UnsupportedOperationException
is thrown otherwise.resize
in interface DataContainer<K,V>
newSize
- the new sizeCopyright © 2021 JBoss by Red Hat. All rights reserved.