Package org.infinispan.container.offheap
Class SegmentedBoundedOffHeapDataContainer
- java.lang.Object
-
- org.infinispan.container.impl.AbstractDelegatingDataContainer<K,V>
-
- org.infinispan.container.impl.AbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes>
-
- org.infinispan.container.offheap.SegmentedBoundedOffHeapDataContainer
-
- All Implemented Interfaces:
Iterable<InternalCacheEntry<WrappedBytes,WrappedBytes>>
,DataContainer<WrappedBytes,WrappedBytes>
,org.infinispan.container.impl.InternalDataContainer<WrappedBytes,WrappedBytes>
- Direct Known Subclasses:
BoundedOffHeapDataContainer
public class SegmentedBoundedOffHeapDataContainer extends org.infinispan.container.impl.AbstractDelegatingInternalDataContainer<WrappedBytes,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 org.infinispan.container.impl.DefaultSegmentedDataContainer
dataContainer
protected EvictionManager
evictionManager
protected long
firstAddress
protected long
lastAddress
protected Lock
lruLock
protected long
maxSize
protected OffHeapEntryFactory
offHeapEntryFactory
protected org.infinispan.factories.impl.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<WrappedBytes,WrappedBytes>
compute(int segment, WrappedBytes key, DataContainer.ComputeAction<WrappedBytes,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<WrappedBytes,WrappedBytes>
compute(WrappedBytes key, DataContainer.ComputeAction<WrappedBytes,WrappedBytes> action)
Computes the new value for the key.protected org.infinispan.container.impl.InternalDataContainer<WrappedBytes,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, WrappedBytes key, 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(WrappedBytes key, 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
-
-
-
-
Field Detail
-
allocator
protected OffHeapMemoryAllocator allocator
-
offHeapEntryFactory
protected OffHeapEntryFactory offHeapEntryFactory
-
evictionManager
protected EvictionManager evictionManager
-
passivator
protected org.infinispan.factories.impl.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 org.infinispan.container.impl.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 org.infinispan.container.impl.InternalDataContainer<WrappedBytes,WrappedBytes> delegate()
- Specified by:
delegate
in classorg.infinispan.container.impl.AbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes>
-
put
public void put(WrappedBytes key, 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<WrappedBytes,WrappedBytes>
- Overrides:
put
in classorg.infinispan.container.impl.AbstractDelegatingDataContainer<WrappedBytes,WrappedBytes>
- Parameters:
key
- key under which to store entryvalue
- value to storemetadata
- metadata of the entry
-
put
public void put(int segment, WrappedBytes key, WrappedBytes value, Metadata metadata, long createdTimestamp, long lastUseTimestamp)
Description copied from interface:org.infinispan.container.impl.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 interfaceorg.infinispan.container.impl.InternalDataContainer<WrappedBytes,WrappedBytes>
- Overrides:
put
in classorg.infinispan.container.impl.AbstractDelegatingInternalDataContainer<WrappedBytes,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<WrappedBytes,WrappedBytes> compute(WrappedBytes key, DataContainer.ComputeAction<WrappedBytes,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<WrappedBytes,WrappedBytes>
- Overrides:
compute
in classorg.infinispan.container.impl.AbstractDelegatingDataContainer<WrappedBytes,WrappedBytes>
- Parameters:
key
- The key.action
- The action that will compute the new value.- Returns:
- The
InternalCacheEntry
associated to the key.
-
compute
public InternalCacheEntry<WrappedBytes,WrappedBytes> compute(int segment, WrappedBytes key, DataContainer.ComputeAction<WrappedBytes,WrappedBytes> action)
Description copied from interface:org.infinispan.container.impl.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 interfaceorg.infinispan.container.impl.InternalDataContainer<WrappedBytes,WrappedBytes>
- Overrides:
compute
in classorg.infinispan.container.impl.AbstractDelegatingInternalDataContainer<WrappedBytes,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<WrappedBytes,WrappedBytes>
- Overrides:
capacity
in classorg.infinispan.container.impl.AbstractDelegatingDataContainer<WrappedBytes,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<WrappedBytes,WrappedBytes>
- Overrides:
evictionSize
in classorg.infinispan.container.impl.AbstractDelegatingDataContainer<WrappedBytes,WrappedBytes>
- Returns:
- how large the counted eviction is
-
-