@ThreadSafe public class DefaultDataContainer<K,V> extends Object implements DataContainer<K,V>
Modifier and Type | Class and Description |
---|---|
class |
DefaultDataContainer.EntryIterator |
DataContainer.ComputeAction<K,V>
Modifier and Type | Field and Description |
---|---|
protected InternalEntryFactory |
entryFactory |
Modifier | Constructor and Description |
---|---|
|
DefaultDataContainer(int concurrencyLevel) |
|
DefaultDataContainer(int concurrencyLevel,
Equivalence<? super K> keyEq) |
protected |
DefaultDataContainer(int concurrencyLevel,
long thresholdSize,
EvictionStrategy strategy,
EvictionThreadPolicy policy,
Equivalence<? super K> keyEquivalence,
EntrySizeCalculator<? super K,? super V> sizeCalculator) |
protected |
DefaultDataContainer(int concurrencyLevel,
long thresholdSize,
EvictionStrategy strategy,
EvictionThreadPolicy policy,
Equivalence<? super K> keyEquivalence,
EvictionType thresholdPolicy) |
Modifier and Type | Method and Description |
---|---|
static <K,V> DefaultDataContainer<K,V> |
boundedDataContainer(int concurrencyLevel,
long maxEntries,
EvictionStrategy strategy,
EvictionThreadPolicy thredPolicy,
Equivalence<? super K> keyEquivalence,
EntrySizeCalculator<? super K,? super V> sizeCalculator) |
static <K,V> DefaultDataContainer<K,V> |
boundedDataContainer(int concurrencyLevel,
long maxEntries,
EvictionStrategy strategy,
EvictionThreadPolicy thredPolicy,
Equivalence<? super K> keyEquivalence,
EvictionType thresholdPolicy) |
long |
capacity()
Returns the capacity of the underlying container.
|
void |
clear()
Removes all entries in the container
|
InternalCacheEntry<K,V> |
compute(K key,
DataContainer.ComputeAction<K,V> action)
Computes the new value for the key.
|
boolean |
containsKey(Object k)
Tests whether an entry exists in the container
|
Set<InternalCacheEntry<K,V>> |
entrySet()
Returns a mutable set of immutable cache entries exposed as immutable Map.Entry instances.
|
void |
evict(K key)
Atomically, it removes the key from
DataContainer and passivates it to persistence. |
void |
executeTask(KeyFilter<? super K> filter,
BiConsumer<? super K,InternalCacheEntry<K,V>> action)
Executes task specified by the given action on the container key/values filtered using the specified key filter.
|
void |
executeTask(KeyValueFilter<? super K,? super V> filter,
BiConsumer<? super K,InternalCacheEntry<K,V>> action)
Executes task specified by the given action on the container key/values filtered using the specified keyvalue filter.
|
InternalCacheEntry<K,V> |
get(Object k)
Retrieves a cached entry
|
void |
initialize(EvictionManager evictionManager,
PassivationManager passivator,
InternalEntryFactory entryFactory,
ActivationManager activator,
PersistenceManager clm,
TimeService timeService,
CacheNotifier cacheNotifier,
ExpirationManager<K,V> expirationManager) |
Iterator<InternalCacheEntry<K,V>> |
iterator() |
Iterator<InternalCacheEntry<K,V>> |
iteratorIncludingExpired()
Same as
DataContainer.iterator() except that is also returns expired entries. |
Set<K> |
keySet()
Returns a set of keys in the container.
|
InternalCacheEntry<K,V> |
peek(Object key)
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 |
purgeExpired()
This method just calls to
ExpirationManager.processExpiration() |
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(Object k)
Removes an entry from the cache
The
key must be activate by invoking ActivationManager.onRemove(Object,
boolean) . |
void |
resize(long newSize)
Resizes the capacity of the underlying container.
|
int |
size() |
int |
sizeIncludingExpired() |
static <K,V> DefaultDataContainer<K,V> |
unBoundedDataContainer(int concurrencyLevel) |
static <K,V> DefaultDataContainer<K,V> |
unBoundedDataContainer(int concurrencyLevel,
Equivalence<? super K> keyEquivalence) |
Collection<V> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
protected InternalEntryFactory entryFactory
public DefaultDataContainer(int concurrencyLevel)
public DefaultDataContainer(int concurrencyLevel, Equivalence<? super K> keyEq)
protected DefaultDataContainer(int concurrencyLevel, long thresholdSize, EvictionStrategy strategy, EvictionThreadPolicy policy, Equivalence<? super K> keyEquivalence, EvictionType thresholdPolicy)
protected DefaultDataContainer(int concurrencyLevel, long thresholdSize, EvictionStrategy strategy, EvictionThreadPolicy policy, Equivalence<? super K> keyEquivalence, EntrySizeCalculator<? super K,? super V> sizeCalculator)
public void initialize(EvictionManager evictionManager, PassivationManager passivator, InternalEntryFactory entryFactory, ActivationManager activator, PersistenceManager clm, TimeService timeService, CacheNotifier cacheNotifier, ExpirationManager<K,V> expirationManager)
public static <K,V> DefaultDataContainer<K,V> boundedDataContainer(int concurrencyLevel, long maxEntries, EvictionStrategy strategy, EvictionThreadPolicy thredPolicy, Equivalence<? super K> keyEquivalence, EvictionType thresholdPolicy)
public static <K,V> DefaultDataContainer<K,V> boundedDataContainer(int concurrencyLevel, long maxEntries, EvictionStrategy strategy, EvictionThreadPolicy thredPolicy, Equivalence<? super K> keyEquivalence, EntrySizeCalculator<? super K,? super V> sizeCalculator)
public static <K,V> DefaultDataContainer<K,V> unBoundedDataContainer(int concurrencyLevel, Equivalence<? super K> keyEquivalence)
public static <K,V> DefaultDataContainer<K,V> unBoundedDataContainer(int concurrencyLevel)
public InternalCacheEntry<K,V> peek(Object key)
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.keySet()
to avoid changing the underlying collection's order.peek
in interface DataContainer<K,V>
key
- key under which entry is storedpublic InternalCacheEntry<K,V> get(Object k)
DataContainer
get
in interface DataContainer<K,V>
k
- key under which entry is storedpublic void put(K k, V v, Metadata metadata)
DataContainer
key
must be activate by invoking ActivationManager.onUpdate(Object,
boolean)
.put
in interface DataContainer<K,V>
k
- key under which to store entryv
- value to storemetadata
- metadata of the entrypublic boolean containsKey(Object k)
DataContainer
containsKey
in interface DataContainer<K,V>
k
- key to testpublic InternalCacheEntry<K,V> remove(Object k)
DataContainer
key
must be activate by invoking ActivationManager.onRemove(Object,
boolean)
.remove
in interface DataContainer<K,V>
k
- key to removepublic long capacity()
DataContainer
UnsupportedOperationException
is thrown
otherwise.capacity
in interface DataContainer<K,V>
public void resize(long newSize)
DataContainer
UnsupportedOperationException
is thrown otherwise.resize
in interface DataContainer<K,V>
newSize
- the new sizepublic int size()
size
in interface DataContainer<K,V>
public int sizeIncludingExpired()
sizeIncludingExpired
in interface DataContainer<K,V>
public void clear()
DataContainer
clear
in interface DataContainer<K,V>
public Set<K> keySet()
DataContainer
DataContainer.get(Object)
method but instead DataContainer.peek(Object)
, in order to avoid changing the order of
the underlying collection as a side of effect of iterating through it.keySet
in interface DataContainer<K,V>
public Collection<V> values()
values
in interface DataContainer<K,V>
public Set<InternalCacheEntry<K,V>> entrySet()
DataContainer
entrySet
in interface DataContainer<K,V>
public void purgeExpired()
DataContainer
ExpirationManager.processExpiration()
purgeExpired
in interface DataContainer<K,V>
ExpirationManager.processExpiration()
public void evict(K key)
DataContainer
DataContainer
and passivates it to persistence.
The passivation must be done by invoking the method PassivationManager.passivate(org.infinispan.container.entries.InternalCacheEntry)
.evict
in interface DataContainer<K,V>
key
- 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 activate by invoking ActivationManager.onRemove(Object,
boolean)
or ActivationManager.onUpdate(Object, boolean)
depending if the value
returned by the DataContainer.ComputeAction
is null or not respectively.
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 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>> iteratorIncludingExpired()
DataContainer
DataContainer.iterator()
except that is also returns expired entries.iteratorIncludingExpired
in interface DataContainer<K,V>
public void executeTask(KeyFilter<? super K> filter, BiConsumer<? super K,InternalCacheEntry<K,V>> action) throws InterruptedException
DataContainer
executeTask
in interface DataContainer<K,V>
filter
- the filter for the container keysaction
- the specified action to execute on filtered key/valuesInterruptedException
public void executeTask(KeyValueFilter<? super K,? super V> filter, BiConsumer<? super K,InternalCacheEntry<K,V>> action) throws InterruptedException
DataContainer
executeTask
in interface DataContainer<K,V>
filter
- the filter for the container key/valuesaction
- the specified action to execute on filtered key/valuesInterruptedException
Copyright © 2020 JBoss, a division of Red Hat. All rights reserved.