org.apache.ignite.internal.processors.cache

## Class GridCacheSwapManager

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter
  - - org.apache.ignite.internal.processors.cache.GridCacheSwapManager

All Implemented Interfaces:
  GridCacheManager

    public class GridCacheSwapManager
    extends GridCacheManagerAdapter

Handles all swap operations.

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter

`cctx, log`

### Constructor Summary

Constructors
Constructor and Description
`GridCacheSwapManager(boolean enabled)`

### Method Summary

Methods
`void` `addOffHeapListener(int part, GridCacheSwapListener lsnr)`
`void` `addSwapListener(int part, GridCacheSwapListener lsnr)`
`void` `clearOffHeap()` Clears off-heap.
`void` `clearSwap()` Clears swap.
`boolean` `containsKey(KeyCacheObject key)`
`GridCloseableIterator<Map.Entry<byte[],GridCacheSwapEntry>>` `iterator(int part)` Gets offheap and swap iterator over partition.
`<K,V> Iterator<Map.Entry<K,V>>` `lazyOffHeapIterator()`
`<K,V> Iterator<Map.Entry<K,V>>` `lazySwapIterator()`
`long` `offHeapAllocatedSize()` Gets memory size allocated in off-heap.
`boolean` `offHeapEnabled()`
`long` `offHeapEntriesCount()` Gets number of elements in off-heap
`int` `offheapEntriesCount(boolean primary, boolean backup, long topVer)`
`<K,V> Iterator<javax.cache.Cache.Entry<K,V>>` `offheapIterator(boolean primary, boolean backup, long topVer)`
`GridCloseableIterator<Map.Entry<byte[],GridCacheSwapEntry>>` `offHeapIterator(int part)` Gets offheap iterator over partition.
`Iterator<KeyCacheObject>` `offHeapKeyIterator(boolean primary, boolean backup, long topVer)`
`int` `onUndeploy(ClassLoader ldr)`
`GridCloseableIterator<Map.Entry<byte[],byte[]>>` `rawIterator()` Gets offheap and swap iterator over partition.
`GridCloseableIterator<Map.Entry<byte[],byte[]>>` `rawOffHeapIterator()`
`<T> GridCloseableIterator<T>` `rawOffHeapIterator(CX2<T2<Long,Integer>,T2<Long,Integer>,T> c)`
`GridCloseableIterator<Map.Entry<byte[],byte[]>>` `rawSwapIterator()`
`GridCacheSwapEntry` `read(KeyCacheObject key, boolean readOffheap, boolean readSwap)`
`Collection<GridCacheBatchSwapEntry>` `readAndRemove(Collection<? extends KeyCacheObject> keys)`
`void` `remove(KeyCacheObject key)`
`void` `removeOffHeapListener(int part, GridCacheSwapListener lsnr)`
`void` `removeSwapListener(int part, GridCacheSwapListener lsnr)`
`String` `spaceName()`
`void` `start0()`
`boolean` `swapEnabled()`
`int` `swapEntriesCount(boolean primary, boolean backup, long topVer)`
`<K,V> Iterator<javax.cache.Cache.Entry<K,V>>` `swapIterator(boolean primary, boolean backup, long topVer)`
`GridCloseableIterator<Map.Entry<byte[],GridCacheSwapEntry>>` `swapIterator(int part)` Gets swap space iterator over partition.
`Iterator<KeyCacheObject>` `swapKeyIterator(boolean primary, boolean backup, long topVer)`
`long` `swapKeys()` Gets number of swap entries (keys).
`long` `swapSize()`

### Methods inherited from class org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter

`context, kernalStartInfo, kernalStopInfo, log, onKernalStart, onKernalStart0, onKernalStop, onKernalStop0, printMemoryStats, start, startInfo, stop, stop0, stopInfo, toString`

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

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

### Constructor Detail

#### GridCacheSwapManager

    public GridCacheSwapManager(boolean enabled)

Parameters:
  `enabled` - Flag to indicate if swap is enabled.

### Method Detail

#### start0

    public void start0()
                throws IgniteCheckedException

Overrides:
  `start0` in class `GridCacheManagerAdapter`
Throws:
  `IgniteCheckedException` - If failed.

#### swapEnabled

    public boolean swapEnabled()

Returns:
  `True` if swap store is enabled.

#### offHeapEnabled

    public boolean offHeapEnabled()

Returns:
  `True` if off-heap cache is enabled.

#### swapSize

    public long swapSize()
                  throws IgniteCheckedException

Returns:
  Swap size.
Throws:
  `IgniteCheckedException` - If failed.

#### swapEntriesCount

    public int swapEntriesCount(boolean primary,
                       boolean backup,
                       long topVer)
                         throws IgniteCheckedException

Parameters:
  `primary` - If `true` includes primary entries.
  `backup` - If `true` includes backup entries.
  `topVer` - Topology version.
Returns:
  Number of swap entries.
Throws:
  `IgniteCheckedException` - If failed.

#### offheapEntriesCount

    public int offheapEntriesCount(boolean primary,
                          boolean backup,
                          long topVer)
                            throws IgniteCheckedException

Parameters:
  `primary` - If `true` includes primary entries.
  `backup` - If `true` includes backup entries.
  `topVer` - Topology version.
Returns:
  Number of offheap entries.
Throws:
  `IgniteCheckedException` - If failed.

#### swapKeys

    public long swapKeys()
                  throws IgniteCheckedException

Gets number of swap entries (keys).

Returns:
  Swap keys count.
Throws:
  `IgniteCheckedException` - If failed.

#### addSwapListener

    public void addSwapListener(int part,
                       GridCacheSwapListener lsnr)

Parameters:
  `part` - Partition.
  `lsnr` - Listener.

#### removeSwapListener

    public void removeSwapListener(int part,
                          GridCacheSwapListener lsnr)

Parameters:
  `part` - Partition.
  `lsnr` - Listener.

#### addOffHeapListener

    public void addOffHeapListener(int part,
                          GridCacheSwapListener lsnr)

Parameters:
  `part` - Partition.
  `lsnr` - Listener.

#### removeOffHeapListener

    public void removeOffHeapListener(int part,
                             GridCacheSwapListener lsnr)

Parameters:
  `part` - Partition.
  `lsnr` - Listener.

#### containsKey

    public boolean containsKey(KeyCacheObject key)
                        throws IgniteCheckedException

Parameters:
  `key` - Key to check.
Returns:
  `True` if key is contained.
Throws:
  `IgniteCheckedException` - If failed.

#### read

    @Nullable
    public GridCacheSwapEntry read(KeyCacheObject key,
                                   boolean readOffheap,
                                   boolean readSwap)
                            throws IgniteCheckedException

Parameters:
  `key` - Key to read swap entry for.
  `readOffheap` - Read offheap flag.
  `readSwap` - Read swap flag.
Returns:
  Read value.
Throws:
  `IgniteCheckedException` - If read failed.

#### readAndRemove

    public Collection<GridCacheBatchSwapEntry> readAndRemove(Collection<? extends KeyCacheObject> keys)
                                                      throws IgniteCheckedException

Parameters:
  `keys` - Collection of keys to remove from swap.
Returns:
  Collection of swap entries.
Throws:
  `IgniteCheckedException` - If failed,

#### remove

    public void remove(KeyCacheObject key)
                throws IgniteCheckedException

Parameters:
  `key` - Key to remove.
Throws:
  `IgniteCheckedException` - If failed.

#### clearOffHeap

    public void clearOffHeap()

Clears off-heap.

#### clearSwap

    public void clearSwap()
                   throws IgniteCheckedException

Clears swap.

Throws:
  `IgniteCheckedException` - If failed.

#### iterator

    @Nullable
    public GridCloseableIterator<Map.Entry<byte[],GridCacheSwapEntry>> iterator(int part)
                                                                         throws IgniteCheckedException

Gets offheap and swap iterator over partition.

Parameters:
  `part` - Partition to iterate over.
Returns:
  Iterator over partition.
Throws:
  `IgniteCheckedException` - If failed.

#### rawIterator

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

Gets offheap and swap iterator over partition.

Returns:
  Iterator over partition.
Throws:
  `IgniteCheckedException` - If failed.

#### lazySwapIterator

    public <K,V> Iterator<Map.Entry<K,V>> lazySwapIterator()
                                              throws IgniteCheckedException

Returns:
  Lazy swap iterator.
Throws:
  `IgniteCheckedException` - If failed.

#### offHeapKeyIterator

    public Iterator<KeyCacheObject> offHeapKeyIterator(boolean primary,
                                              boolean backup,
                                              long topVer)

Returns:
  Iterator over off-heap keys.

#### swapKeyIterator

    public Iterator<KeyCacheObject> swapKeyIterator(boolean primary,
                                           boolean backup,
                                           long topVer)
                                             throws IgniteCheckedException

Returns:
  Iterator over off-heap keys.
Throws:
  `IgniteCheckedException`

#### lazyOffHeapIterator

    public <K,V> Iterator<Map.Entry<K,V>> lazyOffHeapIterator()

Returns:
  Lazy off-heap iterator.

#### offHeapEntriesCount

    public long offHeapEntriesCount()

Gets number of elements in off-heap

Returns:
  Number of elements or `0` if off-heap is disabled.

#### offHeapAllocatedSize

    public long offHeapAllocatedSize()

Gets memory size allocated in off-heap.

Returns:
  Allocated memory size or `0` if off-heap is disabled.

#### offHeapIterator

    @Nullable
    public GridCloseableIterator<Map.Entry<byte[],GridCacheSwapEntry>> offHeapIterator(int part)
                                                                                throws IgniteCheckedException

Gets offheap iterator over partition.

Parameters:
  `part` - Partition to iterate over.
Returns:
  Iterator over partition.
Throws:
  `IgniteCheckedException` - If failed.

#### rawOffHeapIterator

    public <T> GridCloseableIterator<T> rawOffHeapIterator(CX2<T2<Long,Integer>,T2<Long,Integer>,T> c)

Parameters:
  `c` - Key/value closure.
Returns:
  Off-heap iterator.

#### rawOffHeapIterator

    public GridCloseableIterator<Map.Entry<byte[],byte[]>> rawOffHeapIterator()

Returns:
  Raw off-heap iterator.

#### swapIterator

    @Nullable
    public GridCloseableIterator<Map.Entry<byte[],GridCacheSwapEntry>> swapIterator(int part)
                                                                             throws IgniteCheckedException

Gets swap space iterator over partition.

Parameters:
  `part` - Partition to iterate over.
Returns:
  Iterator over partition.
Throws:
  `IgniteCheckedException` - If failed.

#### rawSwapIterator

    public GridCloseableIterator<Map.Entry<byte[],byte[]>> rawSwapIterator()
                                                                    throws IgniteCheckedException

Returns:
  Raw off-heap iterator.
Throws:
  `IgniteCheckedException` - If failed.

#### swapIterator

    public <K,V> Iterator<javax.cache.Cache.Entry<K,V>> swapIterator(boolean primary,
                                                            boolean backup,
                                                            long topVer)
                                                        throws IgniteCheckedException

Parameters:
  `primary` - If `true` includes primary entries.
  `backup` - If `true` includes backup entries.
  `topVer` - Topology version.
Returns:
  Swap entries iterator.
Throws:
  `IgniteCheckedException` - If failed.

#### offheapIterator

    public <K,V> Iterator<javax.cache.Cache.Entry<K,V>> offheapIterator(boolean primary,
                                                               boolean backup,
                                                               long topVer)
                                                           throws IgniteCheckedException

Parameters:
  `primary` - If `true` includes primary entries.
  `backup` - If `true` includes backup entries.
  `topVer` - Topology version.
Returns:
  Offheap entries iterator.
Throws:
  `IgniteCheckedException` - If failed.

#### onUndeploy

    public int onUndeploy(ClassLoader ldr)

Parameters:
  `ldr` - Undeployed class loader.
Returns:
  Undeploy count.

#### spaceName

    public String spaceName()

Returns:
  Swap space name.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC3
Release Date | : March 24 2015