Package org.infinispan.container.offheap
Class SegmentedBoundedOffHeapDataContainer
- java.lang.Object
-
- org.infinispan.container.impl.AbstractDelegatingDataContainer<K,V>
-
- org.infinispan.container.impl.AbstractDelegatingInternalDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
-
- org.infinispan.container.offheap.SegmentedBoundedOffHeapDataContainer
-
- All Implemented Interfaces:
Iterable<InternalCacheEntry<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>>
,DataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
,InternalDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Direct Known Subclasses:
BoundedOffHeapDataContainer
public class SegmentedBoundedOffHeapDataContainer extends AbstractDelegatingInternalDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Since:
- 9.4
- Author:
- wburns
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.container.DataContainer
DataContainer.ComputeAction<K,V>
-
-
Field Summary
Fields Modifier and Type Field Description protected OffHeapMemoryAllocator
allocator
protected long
currentSize
protected DefaultSegmentedDataContainer
dataContainer
protected EvictionManager
evictionManager
protected long
firstAddress
protected long
lastAddress
protected Lock
lruLock
protected long
maxSize
protected OffHeapEntryFactory
offHeapEntryFactory
protected ComponentRef<PassivationManager>
passivator
protected boolean
useCount
-
Constructor Summary
Constructors Constructor Description SegmentedBoundedOffHeapDataContainer(int addressCount, int numSegments, long maxSize, EvictionType type)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
capacity()
Returns the capacity of the underlying container.InternalCacheEntry<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
compute(int segment, org.infinispan.commons.marshall.WrappedBytes key, DataContainer.ComputeAction<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes> 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.InternalCacheEntry<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
compute(org.infinispan.commons.marshall.WrappedBytes key, DataContainer.ComputeAction<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes> action)
Computes the new value for the key.protected InternalDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
delegate()
long
evictionSize()
Returns how large the eviction size is currently.protected OffHeapConcurrentMap
getMapThatContainsKey(byte[] key)
long
getSize(long address)
void
put(int segment, org.infinispan.commons.marshall.WrappedBytes key, org.infinispan.commons.marshall.WrappedBytes value, 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.void
put(org.infinispan.commons.marshall.WrappedBytes key, org.infinispan.commons.marshall.WrappedBytes value, Metadata metadata)
Puts an entry in the cache along with metadata adding information such lifespan of entry, max idle time, version information...etc.void
start()
void
stop()
-
Methods inherited from class org.infinispan.container.impl.AbstractDelegatingInternalDataContainer
addRemovalListener, addSegments, clear, containsKey, evict, forEach, get, iterator, iteratorIncludingExpired, peek, remove, removeRemovalListener, removeSegments, size, sizeIncludingExpired, spliterator, spliteratorIncludingExpired, touch
-
Methods inherited from class org.infinispan.container.impl.AbstractDelegatingDataContainer
clear, containsKey, entrySet, evict, executeTask, executeTask, forEach, get, iterator, iteratorIncludingExpired, keySet, peek, 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
clear, containsKey, entrySet, evict, executeTask, executeTask, iterator, iteratorIncludingExpired, keySet, peek, remove, resize, size, sizeIncludingExpired, spliterator, spliteratorIncludingExpired, values
-
Methods inherited from interface org.infinispan.container.impl.InternalDataContainer
get
-
-
-
-
Field Detail
-
allocator
protected OffHeapMemoryAllocator allocator
-
offHeapEntryFactory
protected OffHeapEntryFactory offHeapEntryFactory
-
evictionManager
protected EvictionManager evictionManager
-
passivator
protected ComponentRef<PassivationManager> passivator
-
maxSize
protected final long maxSize
-
lruLock
protected final Lock lruLock
-
useCount
protected final boolean useCount
-
currentSize
protected long currentSize
-
firstAddress
protected long firstAddress
-
lastAddress
protected long lastAddress
-
dataContainer
protected DefaultSegmentedDataContainer dataContainer
-
-
Constructor Detail
-
SegmentedBoundedOffHeapDataContainer
public SegmentedBoundedOffHeapDataContainer(int addressCount, int numSegments, long maxSize, EvictionType type)
-
-
Method Detail
-
start
public void start()
-
stop
public void stop()
-
delegate
protected InternalDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes> delegate()
- Specified by:
delegate
in classAbstractDelegatingInternalDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
-
put
public void put(org.infinispan.commons.marshall.WrappedBytes key, org.infinispan.commons.marshall.WrappedBytes value, Metadata metadata)
Description copied from interface:DataContainer
Puts an entry in the cache along with metadata adding information such lifespan of entry, max idle time, version information...etc. Thekey
must be activate by invokingActivationManager.onUpdate(Object, boolean)
.- Specified by:
put
in interfaceDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Overrides:
put
in classAbstractDelegatingDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Parameters:
key
- key under which to store entryvalue
- value to storemetadata
- metadata of the entry
-
put
public void put(int segment, org.infinispan.commons.marshall.WrappedBytes key, org.infinispan.commons.marshall.WrappedBytes value, 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<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Overrides:
put
in classAbstractDelegatingInternalDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Parameters:
segment
- segment for the keykey
- key under which to store entryvalue
- 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
-
compute
public InternalCacheEntry<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes> compute(org.infinispan.commons.marshall.WrappedBytes key, DataContainer.ComputeAction<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes> action)
Description copied from interface:DataContainer
Computes the new value for the key. SeeDataContainer.ComputeAction.compute(Object, org.infinispan.container.entries.InternalCacheEntry, InternalEntryFactory)
. Thekey
must be activate by invokingActivationManager.onRemove(Object, boolean)
orActivationManager.onUpdate(Object, boolean)
depending if the value returned by theDataContainer.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.- Specified by:
compute
in interfaceDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Overrides:
compute
in classAbstractDelegatingDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Parameters:
key
- The key.action
- The action that will compute the new value.- Returns:
- The
InternalCacheEntry
associated to the key.
-
compute
public InternalCacheEntry<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes> compute(int segment, org.infinispan.commons.marshall.WrappedBytes key, DataContainer.ComputeAction<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes> 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<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Overrides:
compute
in classAbstractDelegatingInternalDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Parameters:
segment
- segment for the keykey
- The key.action
- The action that will compute the new value.- Returns:
- The
InternalCacheEntry
associated to the key.
-
getMapThatContainsKey
protected OffHeapConcurrentMap getMapThatContainsKey(byte[] key)
-
getSize
public long getSize(long address)
-
capacity
public long capacity()
Description copied from interface:DataContainer
Returns the capacity of the underlying container. This is only supported if the container is bounded. AnUnsupportedOperationException
is thrown otherwise.- Specified by:
capacity
in interfaceDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Overrides:
capacity
in classAbstractDelegatingDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Returns:
-
evictionSize
public long evictionSize()
Description copied from interface:DataContainer
Returns how large the eviction size is currently. This is only supported if the container is bounded. AnUnsupportedOperationException
is thrown otherwise. This value will always be lower than the value returned fromDataContainer.capacity()
- Specified by:
evictionSize
in interfaceDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Overrides:
evictionSize
in classAbstractDelegatingDataContainer<org.infinispan.commons.marshall.WrappedBytes,org.infinispan.commons.marshall.WrappedBytes>
- Returns:
- how large the counted eviction is
-
-