@ThreadSafe public class DefaultDataContainer<K,V> extends AbstractInternalDataContainer<K,V>
AbstractInternalDataContainer.EntryIterator
DataContainer.ComputeAction<K,V>
configuration, entryFactory, evictionManager, expirationManager, keyPartitioner, listeners, orderer, passivator, timeService
Modifier | Constructor and Description |
---|---|
|
DefaultDataContainer(int concurrencyLevel) |
protected |
DefaultDataContainer(int concurrencyLevel,
long thresholdSize,
EntrySizeCalculator<? super K,? super V> sizeCalculator)
Method invoked when memory policy is used.
|
protected |
DefaultDataContainer(int concurrencyLevel,
long thresholdSize,
EvictionType thresholdPolicy) |
protected |
DefaultDataContainer(long thresholdSize,
EntrySizeCalculator<? super K,? super InternalCacheEntry<K,V>> sizeCalculator)
Constructor that allows user to provide a size calculator that also handles the cache entry and metadata.
|
Modifier and Type | Method and Description |
---|---|
void |
addSegments(IntSet segments)
Sets what segments this data container should be using.
|
static <K,V> DefaultDataContainer<K,V> |
boundedDataContainer(int concurrencyLevel,
long maxEntries,
EntrySizeCalculator<? super K,? super V> sizeCalculator) |
static <K,V> DefaultDataContainer<K,V> |
boundedDataContainer(int concurrencyLevel,
long maxEntries,
EvictionType thresholdPolicy) |
long |
capacity()
Returns the capacity of the underlying container.
|
void |
cleanUp()
Method used to cleanup any pending data, such as evictions
|
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
|
long |
evictionSize()
Returns how large the eviction size is currently.
|
protected PeekableTouchableMap<K,V> |
getMapForSegment(int segment) |
protected int |
getSegmentForKey(Object key) |
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. |
void |
removeSegments(IntSet segments)
Removes and un-associates the given segments.
|
void |
resize(long newSize)
Resizes the capacity of the underlying container.
|
int |
sizeIncludingExpired() |
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. |
static <K,V> DefaultDataContainer<K,V> |
unBoundedDataContainer(int concurrencyLevel) |
addRemovalListener, applyListener, compute, compute, computeEntryRemoved, computeEntryWritten, containsKey, containsKey, evict, evict, expiredIterationPredicate, filterExpiredEntries, get, get, handleEviction, peek, peek, put, put, remove, remove, removeRemovalListener, touch
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, publisher, size, sizeIncludingExpired
size
public DefaultDataContainer(int concurrencyLevel)
protected DefaultDataContainer(int concurrencyLevel, long thresholdSize, EvictionType thresholdPolicy)
protected DefaultDataContainer(int concurrencyLevel, long thresholdSize, EntrySizeCalculator<? super K,? super V> sizeCalculator)
concurrencyLevel
- thresholdSize
- sizeCalculator
- protected DefaultDataContainer(long thresholdSize, EntrySizeCalculator<? super K,? super InternalCacheEntry<K,V>> sizeCalculator)
thresholdSize
- sizeCalculator
- public static <K,V> DefaultDataContainer<K,V> boundedDataContainer(int concurrencyLevel, long maxEntries, EvictionType thresholdPolicy)
public static <K,V> DefaultDataContainer<K,V> boundedDataContainer(int concurrencyLevel, long maxEntries, EntrySizeCalculator<? super K,? super V> sizeCalculator)
public static <K,V> DefaultDataContainer<K,V> unBoundedDataContainer(int concurrencyLevel)
protected PeekableTouchableMap<K,V> getMapForSegment(int segment)
getMapForSegment
in class AbstractInternalDataContainer<K,V>
protected int getSegmentForKey(Object key)
getSegmentForKey
in class AbstractInternalDataContainer<K,V>
public long capacity()
DataContainer
UnsupportedOperationException
is thrown
otherwise.public void resize(long newSize)
DataContainer
UnsupportedOperationException
is thrown otherwise.newSize
- the new sizepublic int sizeIncludingExpired()
public void clear(IntSet segments)
InternalDataContainer
clear
in interface InternalDataContainer<K,V>
clear
in class AbstractInternalDataContainer<K,V>
segments
- segments of entries to removepublic void clear()
DataContainer
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.
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.segments
- segments of entries to usepublic Spliterator<InternalCacheEntry<K,V>> spliterator()
DataContainer
This spliterator only returns entries that are not expired, however it will not remove them while doing so.
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.segments
- segments of entries to returnpublic Spliterator<InternalCacheEntry<K,V>> spliteratorIncludingExpired()
DataContainer
DataContainer.spliterator()
except that is also returns expired entries.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.segments
- segments of entries to usepublic Iterator<InternalCacheEntry<K,V>> iteratorIncludingExpired()
DataContainer
DataContainer.iterator()
except that is also returns expired entries.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.segments
- segments of entries to usepublic long evictionSize()
DataContainer
UnsupportedOperationException
is thrown otherwise. This value will always be lower than the value returned
from DataContainer.capacity()
public void addSegments(IntSet segments)
InternalDataContainer
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)
.
segments
- segments that should no longer be associated with this containerpublic void cleanUp()
InternalDataContainer
Copyright © 2021 JBoss by Red Hat. All rights reserved.