Class GridOffHeapProcessor
- java.lang.Object
-
- org.apache.ignite.internal.processors.GridProcessorAdapter
-
- org.apache.ignite.internal.processors.offheap.GridOffHeapProcessor
-
- All Implemented Interfaces:
GridComponent,GridProcessor
public class GridOffHeapProcessor extends GridProcessorAdapter
Manages offheap memory caches.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent
GridComponent.DiscoveryDataExchangeType
-
-
Field Summary
-
Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
ctx, diagnosticLog, log
-
-
Constructor Summary
Constructors Constructor Description GridOffHeapProcessor(GridKernalContext ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longallocatedSize(@Nullable String spaceName)Gets size of a memory allocated for the entries of the given space.booleancontains(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes)Checks if offheap space contains value for the given key.voidcreate(@Nullable String spaceName, int parts, long init, long max, @Nullable GridOffHeapEvictListener lsnr)Creates offheap map for given space name.voiddestruct(@Nullable String spaceName)Destructs offheap map for given space name.voidenableEviction(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes)Enables eviction for entry aftervaluePointer(java.lang.String, int, org.apache.ignite.internal.processors.cache.KeyCacheObject, byte[])was called.longentriesCount(@Nullable String spaceName)Gets number of elements in the given space.longentriesCount(@Nullable String spaceName, Set<Integer> parts)Gets number of elements in the given space.@org.jetbrains.annotations.Nullable byte[]get(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes)Gets value bytes from offheap space for the given key.<T> TgetValue(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes, @Nullable ClassLoader ldr)Gets value from offheap space for the given key.GridCloseableIterator<IgniteBiTuple<byte[],byte[]>>iterator(@Nullable String spaceName)Gets iterator over contents of the given space.GridCloseableIterator<IgniteBiTuple<byte[],byte[]>>iterator(@Nullable String spaceName, int part)Gets iterator over contents of partition.<T> GridCloseableIterator<T>iterator(@Nullable String spaceName, CX2<T2<Long,Integer>,T2<Long,Integer>,T> c)Gets iterator over contents of the given space.<T> GridCloseableIterator<T>iterator(@Nullable String spaceName, CX2<T2<Long,Integer>,T2<Long,Integer>,T> c, int part)Gets iterator over contents of the given space.voidput(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes, byte[] valBytes)Puts the given value to offheap space for the given key.@org.jetbrains.annotations.Nullable byte[]remove(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes)Removes value from offheap space for the given key.booleanremovex(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes)Removes value from offheap space for the given key.booleanremovex(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes, IgniteBiPredicate<Long,Integer> p)Removes value from offheap space for the given key.voidstop(boolean cancel)Stops grid component.@Nullable IgniteBiTuple<Long,Integer>valuePointer(@Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes)Gets value pointer from offheap space for the given key.-
Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
assertParameter, collectGridNodeData, collectJoiningNodeData, discoveryDataType, onDisconnected, onGridDataReceived, onJoiningNodeDataReceived, onKernalStart, onKernalStop, onReconnected, printMemoryStats, start, toString, validateNode, validateNode
-
-
-
-
Constructor Detail
-
GridOffHeapProcessor
public GridOffHeapProcessor(GridKernalContext ctx)
- Parameters:
ctx- Kernal context.
-
-
Method Detail
-
create
public void create(@Nullable @Nullable String spaceName, int parts, long init, long max, @Nullable @Nullable GridOffHeapEvictListener lsnr)Creates offheap map for given space name. Previous one will be destructed if it exists.- Parameters:
spaceName- Space name.parts- Partitions number.init- Initial size.max- Maximum size.lsnr- Eviction listener.
-
destruct
public void destruct(@Nullable @Nullable String spaceName)Destructs offheap map for given space name.- Parameters:
spaceName- Space name.
-
stop
public void stop(boolean cancel) throws IgniteCheckedExceptionStops grid component.- Specified by:
stopin interfaceGridComponent- Overrides:
stopin classGridProcessorAdapter- Parameters:
cancel- Iftrue, then all ongoing tasks or jobs for relevant components need to be cancelled.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
contains
public boolean contains(@Nullable @Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes) throws IgniteCheckedExceptionChecks if offheap space contains value for the given key.- Parameters:
spaceName- Space name.part- Partition.key- Key.keyBytes- Key bytes.- Returns:
trueIf offheap space contains value for the given key.- Throws:
IgniteCheckedException- If failed.
-
get
@Nullable public @org.jetbrains.annotations.Nullable byte[] get(@Nullable @Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes) throws IgniteCheckedExceptionGets value bytes from offheap space for the given key.- Parameters:
spaceName- Space name.part- Partition.key- Key.keyBytes- Key bytes.- Returns:
- Value bytes.
- Throws:
IgniteCheckedException- If failed.
-
valuePointer
@Nullable public @Nullable IgniteBiTuple<Long,Integer> valuePointer(@Nullable @Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes) throws IgniteCheckedException
Gets value pointer from offheap space for the given key. While pointer is in use eviction is disabled for corresponding entry. Eviction for entry is enabled whenput(java.lang.String, int, org.apache.ignite.internal.processors.cache.KeyCacheObject, byte[], byte[])orenableEviction(java.lang.String, int, org.apache.ignite.internal.processors.cache.KeyCacheObject, byte[])is called.- Parameters:
spaceName- Space name.part- Partition.key- Key.keyBytes- Key bytes.- Returns:
- Tuple where first value is pointer and second is value size.
- Throws:
IgniteCheckedException- If failed.
-
enableEviction
public void enableEviction(@Nullable @Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes) throws IgniteCheckedExceptionEnables eviction for entry aftervaluePointer(java.lang.String, int, org.apache.ignite.internal.processors.cache.KeyCacheObject, byte[])was called.- Parameters:
spaceName- Space name.part- Partition.key- Key.keyBytes- Key bytes.- Throws:
IgniteCheckedException- If failed.
-
getValue
@Nullable public <T> T getValue(@Nullable @Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes, @Nullable @Nullable ClassLoader ldr) throws IgniteCheckedExceptionGets value from offheap space for the given key.- Parameters:
spaceName- Space name.part- Partition.key- Key.keyBytes- Key bytes.ldr- Class loader.- Returns:
- Value bytes.
- Throws:
IgniteCheckedException- If failed.
-
remove
@Nullable public @org.jetbrains.annotations.Nullable byte[] remove(@Nullable @Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes) throws IgniteCheckedExceptionRemoves value from offheap space for the given key.- Parameters:
spaceName- Space name.part- Partition.key- Key.keyBytes- Key bytes.- Returns:
- Value bytes.
- Throws:
IgniteCheckedException- If failed.
-
put
public void put(@Nullable @Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes, byte[] valBytes) throws IgniteCheckedExceptionPuts the given value to offheap space for the given key.- Parameters:
spaceName- Space name.part- Partition.key- Key.keyBytes- Key bytes.valBytes- Value bytes.- Throws:
IgniteCheckedException- If failed.
-
removex
public boolean removex(@Nullable @Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes) throws IgniteCheckedExceptionRemoves value from offheap space for the given key.- Parameters:
spaceName- Space name.part- Partition.key- Key.keyBytes- Key bytes.- Returns:
trueIf succeeded.- Throws:
IgniteCheckedException- If failed.
-
removex
public boolean removex(@Nullable @Nullable String spaceName, int part, KeyCacheObject key, byte[] keyBytes, IgniteBiPredicate<Long,Integer> p) throws IgniteCheckedExceptionRemoves value from offheap space for the given key.- Parameters:
spaceName- Space name.part- Partition.key- Key.keyBytes- Key bytes.p- Value predicate (arguments are value address and value length).- Returns:
trueIf succeeded.- Throws:
IgniteCheckedException- If failed.
-
iterator
public GridCloseableIterator<IgniteBiTuple<byte[],byte[]>> iterator(@Nullable @Nullable String spaceName)
Gets iterator over contents of the given space.- Parameters:
spaceName- Space name.- Returns:
- Iterator.
-
iterator
public <T> GridCloseableIterator<T> iterator(@Nullable @Nullable String spaceName, CX2<T2<Long,Integer>,T2<Long,Integer>,T> c)
Gets iterator over contents of the given space.- Parameters:
spaceName- Space name.c- Key/value closure.- Returns:
- Iterator.
-
iterator
public <T> GridCloseableIterator<T> iterator(@Nullable @Nullable String spaceName, CX2<T2<Long,Integer>,T2<Long,Integer>,T> c, int part)
Gets iterator over contents of the given space.- Parameters:
spaceName- Space name.c- Key/value closure.part- Partition.- Returns:
- Iterator.
-
entriesCount
public long entriesCount(@Nullable @Nullable String spaceName)Gets number of elements in the given space.- Parameters:
spaceName- Space name. Optional.- Returns:
- Number of elements or
-1if no space with the given name has been found.
-
entriesCount
public long entriesCount(@Nullable @Nullable String spaceName, Set<Integer> parts)Gets number of elements in the given space.- Parameters:
spaceName- Space name. Optional.parts- Partitions.- Returns:
- Number of elements or
-1if no space with the given name has been found.
-
allocatedSize
public long allocatedSize(@Nullable @Nullable String spaceName)Gets size of a memory allocated for the entries of the given space.- Parameters:
spaceName- Space name. Optional.- Returns:
- Allocated memory size or
-1if no space with the given name has been found.
-
iterator
public GridCloseableIterator<IgniteBiTuple<byte[],byte[]>> iterator(@Nullable @Nullable String spaceName, int part)
Gets iterator over contents of partition.- Parameters:
spaceName- Space name.part- Partition.- Returns:
- Iterator.
-
-