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 OffHeapMemoryAllocatorallocatorprotected longcurrentSizeprotected org.infinispan.container.impl.DefaultSegmentedDataContainerdataContainerprotected EvictionManagerevictionManagerprotected longfirstAddressprotected longlastAddressprotected LocklruLockprotected longmaxSizeprotected OffHeapEntryFactoryoffHeapEntryFactoryprotected org.infinispan.factories.impl.ComponentRef<PassivationManager>passivatorprotected booleanuseCount
-
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 longcapacity()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()longevictionSize()Returns how large the eviction size is currently.protected OffHeapConcurrentMapgetMapThatContainsKey(byte[] key)longgetSize(long address)voidput(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.voidput(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.voidstart()voidstop()-
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:
delegatein classorg.infinispan.container.impl.AbstractDelegatingInternalDataContainer<WrappedBytes,WrappedBytes>
-
put
public void put(WrappedBytes key, WrappedBytes value, Metadata metadata)
Description copied from interface:DataContainerPuts an entry in the cache along with metadata adding information such lifespan of entry, max idle time, version information...etc. Thekeymust be activate by invokingActivationManager.onUpdate(Object, boolean).- Specified by:
putin interfaceDataContainer<WrappedBytes,WrappedBytes>- Overrides:
putin 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.InternalDataContainerSame 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:
putin interfaceorg.infinispan.container.impl.InternalDataContainer<WrappedBytes,WrappedBytes>- Overrides:
putin 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-1to use the current timelastUseTimestamp- last use timestamp, or-1to use the current time
-
compute
public InternalCacheEntry<WrappedBytes,WrappedBytes> compute(WrappedBytes key, DataContainer.ComputeAction<WrappedBytes,WrappedBytes> action)
Description copied from interface:DataContainerComputes the new value for the key. SeeDataContainer.ComputeAction.compute(Object, org.infinispan.container.entries.InternalCacheEntry, InternalEntryFactory). Thekeymust be activate by invokingActivationManager.onRemove(Object, boolean)orActivationManager.onUpdate(Object, boolean)depending if the value returned by theDataContainer.ComputeActionis null or not respectively.Note the entry provided to
DataContainer.ComputeActionmay be expired as these entries are not filtered as many other methods do.- Specified by:
computein interfaceDataContainer<WrappedBytes,WrappedBytes>- Overrides:
computein classorg.infinispan.container.impl.AbstractDelegatingDataContainer<WrappedBytes,WrappedBytes>- Parameters:
key- The key.action- The action that will compute the new value.- Returns:
- The
InternalCacheEntryassociated 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.InternalDataContainerSame 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:
computein interfaceorg.infinispan.container.impl.InternalDataContainer<WrappedBytes,WrappedBytes>- Overrides:
computein 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
InternalCacheEntryassociated to the key.
-
getMapThatContainsKey
protected OffHeapConcurrentMap getMapThatContainsKey(byte[] key)
-
getSize
public long getSize(long address)
-
capacity
public long capacity()
Description copied from interface:DataContainerReturns the capacity of the underlying container. This is only supported if the container is bounded. AnUnsupportedOperationExceptionis thrown otherwise.- Specified by:
capacityin interfaceDataContainer<WrappedBytes,WrappedBytes>- Overrides:
capacityin classorg.infinispan.container.impl.AbstractDelegatingDataContainer<WrappedBytes,WrappedBytes>- Returns:
-
evictionSize
public long evictionSize()
Description copied from interface:DataContainerReturns how large the eviction size is currently. This is only supported if the container is bounded. AnUnsupportedOperationExceptionis thrown otherwise. This value will always be lower than the value returned fromDataContainer.capacity()- Specified by:
evictionSizein interfaceDataContainer<WrappedBytes,WrappedBytes>- Overrides:
evictionSizein classorg.infinispan.container.impl.AbstractDelegatingDataContainer<WrappedBytes,WrappedBytes>- Returns:
- how large the counted eviction is
-
-