public interface GridSwapSpaceSpi extends GridSpi
Grid API swap-related methods. Logically storage is organized into
independent 'spaces' in which data is stored.
All swap space implementations can be configured to prevent infinite growth and evict oldest entries.
The default swap space SPI is GridFileSwapSpaceSpi which stores values on disk in files and keeps keys in
memory.
Gridgain provides the following GridSwapSpaceSpi implementations:
GridFileSwapSpaceSpi - pure Java implementation with in-memory keys. This SPI is used by default.
GridNoopSwapSpaceSpi - no-op SPI mainly for testing.
NOTE: this SPI (i.e. methods in this interface) should never be used directly. SPIs provide
internal view on the subsystem and is used internally by GridGain kernal. In rare use cases when
access to a specific implementation of this SPI is required - an instance of this SPI can be obtained
via Grid.configuration() method to check its configuration properties or call other non-SPI
methods. Note again that calling methods from this interface on the obtained instance can lead
to undefined behavior and explicitly not supported.
| Modifier and Type | Method and Description |
|---|---|
void |
clear(String spaceName)
Entirely clears data space with given name, if any.
|
long |
count(String spaceName)
Gets number of stored entries (keys) in data space with given name.
|
<K> GridSpiCloseableIterator<K> |
keyIterator(String spaceName,
GridSwapContext ctx)
Gets iterator over space keys.
|
Collection<Integer> |
partitions(String spaceName)
Gets partitions IDs that are stored in the passed in space.
|
GridSpiCloseableIterator<Map.Entry<byte[],byte[]>> |
rawIterator(String spaceName)
Gets raw iterator over space entries.
|
GridSpiCloseableIterator<Map.Entry<byte[],byte[]>> |
rawIterator(String spaceName,
int part)
Gets raw iterator over space entries.
|
byte[] |
read(String spaceName,
GridSwapKey key,
GridSwapContext ctx)
Reads stored value as array of bytes by key from data space with given name.
|
Map<GridSwapKey,byte[]> |
readAll(String spaceName,
Iterable<GridSwapKey> keys,
GridSwapContext ctx)
Reads stored values as array of bytes by all passed keys from data space with
given name.
|
void |
remove(String spaceName,
GridSwapKey key,
GridInClosure<byte[]> c,
GridSwapContext ctx)
Removes value stored in data space with given name corresponding to specified key.
|
void |
removeAll(String spaceName,
Collection<GridSwapKey> keys,
GridBiInClosure<GridSwapKey,byte[]> c,
GridSwapContext ctx)
Removes values stored in data space with given name corresponding to specified keys.
|
void |
setListener(GridSwapSpaceSpiListener evictLsnr)
Sets eviction listener to receive notifications on evicted swap entries.
|
long |
size(String spaceName)
Gets size in bytes for data space with given name.
|
void |
store(String spaceName,
GridSwapKey key,
byte[] val,
GridSwapContext ctx)
Stores value as array of bytes with given key into data space with given name.
|
void |
storeAll(String spaceName,
Map<GridSwapKey,byte[]> pairs,
GridSwapContext ctx)
Stores key-value pairs (both keys and values are arrays of bytes) into data
space with given name.
|
getName, getNodeAttributes, onContextDestroyed, onContextInitialized, spiStart, spiStopvoid clear(@Nullable String spaceName) throws GridSpiException
spaceName - Space name to clear.GridSpiException - In case of any errors.long size(@Nullable String spaceName) throws GridSpiException
0.spaceName - Space name to get size for.GridSpiException - In case of any errors.long count(@Nullable String spaceName) throws GridSpiException
0.spaceName - Space name to get number of entries for.GridSpiException - In case of any errors.@Nullable byte[] read(@Nullable String spaceName, GridSwapKey key, GridSwapContext ctx) throws GridSpiException
null.spaceName - Name of the data space to read from.key - Key used to read value from data space.ctx - Swap context.GridSpiException - In case of any errors.Map<GridSwapKey,byte[]> readAll(@Nullable String spaceName, Iterable<GridSwapKey> keys, GridSwapContext ctx) throws GridSpiException
spaceName - Name of the data space to read from.keys - Keys used to read values from data space.ctx - Swap context.GridSpiException - In case of any errors.void remove(@Nullable String spaceName, GridSwapKey key, @Nullable GridInClosure<byte[]> c, GridSwapContext ctx) throws GridSpiException
spaceName - Space name to remove value from.key - Key to remove value in the specified space for.c - Optional closure that takes removed value and executes after actual
removing. If there was no value in storage the closure is not executed.ctx - Swap context.GridSpiException - In case of any errors.void removeAll(@Nullable String spaceName, Collection<GridSwapKey> keys, @Nullable GridBiInClosure<GridSwapKey,byte[]> c, GridSwapContext ctx) throws GridSpiException
spaceName - Space name to remove values from.keys - Keys to remove value in the specified space for.c - Optional closure that takes removed value and executes after actual
removing. If there was no value in storage the closure is not executed.ctx - Swap context.GridSpiException - In case of any errors.void store(@Nullable String spaceName, GridSwapKey key, @Nullable byte[] val, GridSwapContext ctx) throws GridSpiException
spaceName - Space name to store key-value pair into.key - Key to store given value for. This key can be used further to
read or remove stored value.val - Some value as array of bytes to store into specified data space.ctx - Swap context.GridSpiException - In case of any errors.void storeAll(@Nullable String spaceName, Map<GridSwapKey,byte[]> pairs, GridSwapContext ctx) throws GridSpiException
spaceName - Space name to store key-value pairs into.pairs - Map of stored key-value pairs where each one is an array of bytes.ctx - Swap context.GridSpiException - In case of any errors.void setListener(@Nullable GridSwapSpaceSpiListener evictLsnr)
evictLsnr - Eviction listener (null to stop receiving notifications).@Nullable Collection<Integer> partitions(@Nullable String spaceName) throws GridSpiException
spaceName - Space name.null if space is unknown.GridSpiException - If failed.@Nullable <K> GridSpiCloseableIterator<K> keyIterator(@Nullable String spaceName, GridSwapContext ctx) throws GridSpiException
spaceName - Space name.ctx - Swap context.null if space is unknown.GridSpiException - If failed.@Nullable GridSpiCloseableIterator<Map.Entry<byte[],byte[]>> rawIterator(@Nullable String spaceName) throws GridSpiException
spaceName - Space name.null if space is unknown.GridSpiException - If failed.@Nullable GridSpiCloseableIterator<Map.Entry<byte[],byte[]>> rawIterator(@Nullable String spaceName, int part) throws GridSpiException
spaceName - Space name.part - Partition.null if space is unknown.GridSpiException - If failed.Copyright © 2014. All rights reserved.