org.apache.ignite.internal.managers.swapspace

## Class GridSwapSpaceManager

- java.lang.Object
- - org.apache.ignite.internal.managers.GridManagerAdapter<SwapSpaceSpi>
  - - org.apache.ignite.internal.managers.swapspace.GridSwapSpaceManager

All Implemented Interfaces:
  GridComponent, GridManager

    public class GridSwapSpaceManager
    extends GridManagerAdapter<SwapSpaceSpi>

### 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.managers.GridManagerAdapter

`ctx, log`

### Constructor Summary

Constructors
Constructor and Description
`GridSwapSpaceManager(GridKernalContext ctx)`

### Method Summary

Methods
`void` `clear(String spaceName)`
`<K> GridCloseableIterator<K>` `keysIterator(String spaceName, ClassLoader ldr)` Gets iterator over space entries.
`protected void` `onKernalStop0(boolean cancel)`
`GridCloseableIterator<Map.Entry<byte[],byte[]>>` `rawIterator(String spaceName)` Gets iterator over space entries.
`GridCloseableIterator<Map.Entry<byte[],byte[]>>` `rawIterator(String spaceName, int part)` Gets raw iterator over space entries.
`byte[]` `read(String spaceName, SwapKey key, ClassLoader ldr)` Reads value from swap.
`<T> T` `readValue(String spaceName, SwapKey key, ClassLoader ldr)` Reads value from swap.
`void` `remove(String spaceName, Object key, IgniteInClosure<byte[]> c, ClassLoader ldr)` Removes value from swap.
`void` `remove(String spaceName, SwapKey key, IgniteInClosure<byte[]> c, ClassLoader ldr)` Removes value from swap.
`void` `removeAll(String spaceName, Collection<SwapKey> keys, IgniteBiInClosure<SwapKey,byte[]> c, ClassLoader ldr)` Removes value from swap.
`void` `start()` Starts grid component.
`void` `stop(boolean cancel)` Stops grid component.
`long` `swapKeys(String spaceName)` Gets number of swap entries (keys).
`long` `swapKeys(String spaceName, Set<Integer> parts)` Gets number of swap entries for given partitions.
`long` `swapSize(String spaceName)` Gets size in bytes for swap space.
`void` `write(String spaceName, Object key, Object val, ClassLoader ldr)` Writes value to swap.
`void` `write(String spaceName, SwapKey key, byte[] val, ClassLoader ldr)` Writes value to swap.
`<K,V> void` `writeAll(String spaceName, Map<SwapKey,byte[]> batch, ClassLoader ldr)` Writes batch to swap.

### Methods inherited from class org.apache.ignite.internal.managers.GridManagerAdapter

`assertParameter, collectDiscoveryData, discoveryDataType, enabled, getSpi, getSpi, getSpis, onAfterSpiStart, onBeforeSpiStart, onDisconnected, onDiscoveryDataReceived, onKernalStart, onKernalStart0, onKernalStop, onReconnected, printMemoryStats, startInfo, startSpi, stopInfo, stopSpi, toString, validateNode`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### GridSwapSpaceManager

    public GridSwapSpaceManager(GridKernalContext ctx)

Parameters:
  `ctx` - Grid kernal context.

### Method Detail

#### start

    public void start()
               throws IgniteCheckedException

Starts grid component.

Throws:
  `IgniteCheckedException` - Throws in case of any errors.

#### onKernalStop0

    protected void onKernalStop0(boolean cancel)

Overrides:
  `onKernalStop0` in class `GridManagerAdapter<SwapSpaceSpi>`
Parameters:
  `cancel` - Cancel flag.

#### stop

    public void stop(boolean cancel)
              throws IgniteCheckedException

Stops grid component.

Parameters:
  `cancel` - If `true`, then all ongoing tasks or jobs for relevant components need to be cancelled.
Throws:
  `IgniteCheckedException` - Thrown in case of any errors.

#### read

    @Nullable
    public byte[] read(@Nullable
                       String spaceName,
                       SwapKey key,
                       @Nullable
                       ClassLoader ldr)
                throws IgniteCheckedException

Reads value from swap.

Parameters:
  `spaceName` - Space name.
  `key` - Key.
  `ldr` - Class loader (optional).
Returns:
  Value.
Throws:
  `IgniteCheckedException` - If failed.

#### readValue

    @Nullable
    public <T> T readValue(@Nullable
                           String spaceName,
                           SwapKey key,
                           @Nullable
                           ClassLoader ldr)
                throws IgniteCheckedException

Reads value from swap.

Parameters:
  `spaceName` - Space name.
  `key` - Swap key.
  `ldr` - Class loader (optional).
Returns:
  Value.
Throws:
  `IgniteCheckedException` - If failed.

#### write

    public void write(@Nullable
             String spaceName,
             SwapKey key,
             byte[] val,
             @Nullable
             ClassLoader ldr)
               throws IgniteCheckedException

Writes value to swap.

Parameters:
  `spaceName` - Space name.
  `key` - Key.
  `val` - Value.
  `ldr` - Class loader (optional).
Throws:
  `IgniteCheckedException` - If failed.

#### writeAll

    public <K,V> void writeAll(String spaceName,
                      Map<SwapKey,byte[]> batch,
                      @Nullable
                      ClassLoader ldr)
                  throws IgniteCheckedException

Writes batch to swap.

Parameters:
  `spaceName` - Space name.
  `batch` - Swapped entries.
  `ldr` - Class loader (optional).
Throws:
  `IgniteCheckedException` - If failed.

#### write

    public void write(@Nullable
             String spaceName,
             Object key,
             @Nullable
             Object val,
             @Nullable
             ClassLoader ldr)
               throws IgniteCheckedException

Writes value to swap.

Parameters:
  `spaceName` - Space name.
  `key` - Key.
  `val` - Value.
  `ldr` - Class loader (optional).
Throws:
  `IgniteCheckedException` - If failed.

#### remove

    public void remove(@Nullable
              String spaceName,
              SwapKey key,
              @Nullable
              IgniteInClosure<byte[]> c,
              @Nullable
              ClassLoader ldr)
                throws IgniteCheckedException

Removes value from swap.

Parameters:
  `spaceName` - Space name.
  `key` - Key.
  `c` - Optional closure that takes removed value and executes after actual removing. If there was no value in storage the closure is executed given `null` value as parameter.
  `ldr` - Class loader (optional).
Throws:
  `IgniteCheckedException` - If failed.

#### removeAll

    public void removeAll(@Nullable
                 String spaceName,
                 Collection<SwapKey> keys,
                 IgniteBiInClosure<SwapKey,byte[]> c,
                 @Nullable
                 ClassLoader ldr)
                   throws IgniteCheckedException

Removes value from swap.

Parameters:
  `spaceName` - Space name.
  `keys` - Collection of keys.
  `c` - Optional closure that takes removed value and executes after actual removing. If there was no value in storage the closure is executed given `null` value as parameter.
  `ldr` - Class loader (optional).
Throws:
  `IgniteCheckedException` - If failed.

#### remove

    public void remove(@Nullable
              String spaceName,
              Object key,
              @Nullable
              IgniteInClosure<byte[]> c,
              @Nullable
              ClassLoader ldr)
                throws IgniteCheckedException

Removes value from swap.

Parameters:
  `spaceName` - Space name.
  `key` - Key.
  `c` - Optional closure that takes removed value and executes after actual removing. If there was no value in storage the closure is executed given `null` value as parameter.
  `ldr` - Class loader (optional).
Throws:
  `IgniteCheckedException` - If failed.

#### swapSize

    public long swapSize(@Nullable
                String spaceName)
                  throws IgniteCheckedException

Gets size in bytes for swap space.

Parameters:
  `spaceName` - Space name.
Returns:
  Swap size.
Throws:
  `IgniteCheckedException` - If failed.

#### swapKeys

    public long swapKeys(@Nullable
                String spaceName)
                  throws IgniteCheckedException

Gets number of swap entries (keys).

Parameters:
  `spaceName` - Space name.
Returns:
  Number of stored entries in swap space.
Throws:
  `IgniteCheckedException` - If failed.

#### swapKeys

    public long swapKeys(@Nullable
                String spaceName,
                Set<Integer> parts)
                  throws IgniteCheckedException

Gets number of swap entries for given partitions.

Parameters:
  `spaceName` - Space name.
  `parts` - Partitions.
Returns:
  Number of swap entries for given partitions.
Throws:
  `IgniteCheckedException` - If failed.

#### clear

    public void clear(@Nullable
             String spaceName)
               throws IgniteCheckedException

Parameters:
  `spaceName` - Space name.
Throws:
  `IgniteCheckedException` - If failed.

#### rawIterator

    @Nullable
    public GridCloseableIterator<Map.Entry<byte[],byte[]>> rawIterator(@Nullable
                                                                       String spaceName)
                                                                throws IgniteCheckedException

Gets iterator over space entries.

Parameters:
  `spaceName` - Space name.
Returns:
  Iterator over space entries or `null` if space is unknown.
Throws:
  `IgniteSpiException` - If failed.
  `IgniteCheckedException`

#### rawIterator

    @Nullable
    public GridCloseableIterator<Map.Entry<byte[],byte[]>> rawIterator(@Nullable
                                                                       String spaceName,
                                                                       int part)
                                                                throws IgniteCheckedException

Gets raw iterator over space entries.

Parameters:
  `spaceName` - Space name.
  `part` - Partition.
Returns:
  Iterator over space entries or `null` if space is unknown.
Throws:
  `IgniteCheckedException` - If failed.

#### keysIterator

    @Nullable
    public <K> GridCloseableIterator<K> keysIterator(@Nullable
                                                     String spaceName,
                                                     @Nullable
                                                     ClassLoader ldr)
                                          throws IgniteCheckedException

Gets iterator over space entries.

Parameters:
  `spaceName` - Space name.
  `ldr` - Class loader.
Returns:
  Iterator over space entries or `null` if space is unknown.
Throws:
  `IgniteSpiException` - If failed.
  `IgniteCheckedException`

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.4.0
Release Date | : September 24 2015