# Renaming

Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/c31cec7c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/c31cec7c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/c31cec7c

Branch: refs/heads/master
Commit: c31cec7cb3ec99b2c8818bae9bd413bd70a62095
Parents: f2f4a32
Author: sboikov <sboi...@gridgain.com>
Authored: Fri Dec 5 17:13:27 2014 +0300
Committer: sboikov <sboi...@gridgain.com>
Committed: Fri Dec 5 17:13:27 2014 +0300

----------------------------------------------------------------------
 .../configuration/IgniteConfiguration.java      |   13 +-
 .../org/apache/ignite/spi/IgniteSpiAdapter.java |    2 +-
 .../org/apache/ignite/spi/IgniteSpiContext.java |    2 +-
 .../org/gridgain/grid/kernal/GridGainEx.java    |    4 +-
 .../kernal/managers/GridManagerAdapter.java     |    2 +-
 .../swapspace/GridSwapSpaceManager.java         |   26 +-
 .../processors/cache/GridCacheSwapManager.java  |   24 +-
 .../spi/securesession/GridSecureSessionSpi.java |   85 -
 .../noop/GridNoopSecureSessionSpi.java          |  115 --
 .../noop/GridNoopSecureSessionSpiMBean.java     |   21 -
 .../grid/spi/swapspace/GridSwapContext.java     |   39 -
 .../grid/spi/swapspace/GridSwapKey.java         |  116 --
 .../grid/spi/swapspace/GridSwapSpaceSpi.java    |  204 --
 .../spi/swapspace/GridSwapSpaceSpiListener.java |   26 -
 .../grid/spi/swapspace/SwapContext.java         |   39 +
 .../gridgain/grid/spi/swapspace/SwapKey.java    |  116 ++
 .../grid/spi/swapspace/SwapSpaceSpi.java        |  202 ++
 .../spi/swapspace/SwapSpaceSpiListener.java     |   26 +
 .../grid/spi/swapspace/file/FileSwapArray.java  |  181 ++
 .../spi/swapspace/file/FileSwapSpaceSpi.java    | 1843 ++++++++++++++++++
 .../swapspace/file/FileSwapSpaceSpiMBean.java   |   59 +
 .../spi/swapspace/file/GridFileSwapArray.java   |  181 --
 .../swapspace/file/GridFileSwapSpaceSpi.java    | 1843 ------------------
 .../file/GridFileSwapSpaceSpiMBean.java         |   59 -
 .../swapspace/noop/GridNoopSwapSpaceSpi.java    |  126 --
 .../spi/swapspace/noop/NoopSwapSpaceSpi.java    |  126 ++
 .../core/src/test/config/spring-cache-swap.xml  |    2 +-
 .../managers/GridManagerStopSelfTest.java       |    2 +-
 .../swapspace/GridSwapSpaceManagerSelfTest.java |    6 +-
 .../cache/GridCacheMemoryModeSelfTest.java      |    2 +-
 .../cache/GridCacheOffHeapSelfTest.java         |    2 +-
 .../processors/cache/GridCacheOffHeapTest.java  |    2 +-
 .../cache/GridCacheP2PUndeploySelfTest.java     |    2 +-
 .../cache/GridCacheSwapReloadSelfTest.java      |    4 +-
 ...tractDistributedByteArrayValuesSelfTest.java |    2 +-
 ...tPartitionedOnlyByteArrayValuesSelfTest.java |    2 +-
 ...eColocatedOptimisticTransactionSelfTest.java |    2 +-
 ...idCacheReplicatedUnswapAdvancedSelfTest.java |    2 +-
 .../GridCacheLocalByteArrayValuesSelfTest.java  |    2 +-
 .../GridCacheSwapScanQueryAbstractSelfTest.java |    2 +-
 ...idFileSwapSpaceSpiMultithreadedLoadTest.java |   18 +-
 .../GridSwapSpaceSpiAbstractSelfTest.java       |  118 +-
 .../file/GridFileSwapCompactionSelfTest.java    |   30 +-
 .../file/GridFileSwapSpaceSpiSelfTest.java      |   36 +-
 .../inmemory/GridTestSwapSpaceSpi.java          |   74 +-
 .../noop/GridNoopSwapSpaceSpiSelfTest.java      |    6 +-
 .../swap/GridSwapEvictAllBenchmark.java         |    2 +-
 .../testframework/GridSpiTestContext.java       |    2 +-
 .../cache/GridCacheAbstractQuerySelfTest.java   |    2 +-
 .../cache/GridCacheOffHeapAndSwapSelfTest.java  |    2 +-
 .../GridCacheQueryMultiThreadedSelfTest.java    |    2 +-
 .../processors/cache/GridCacheSwapSelfTest.java |    8 +-
 .../cache/GridIndexingWithNoopSwapSelfTest.java |    2 +-
 53 files changed, 2796 insertions(+), 3020 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
 
b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
index e3dd068..dc2102d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java
@@ -38,7 +38,6 @@ import org.apache.ignite.spi.failover.*;
 import org.apache.ignite.spi.loadbalancing.*;
 import org.apache.ignite.spi.securesession.*;
 import org.gridgain.grid.spi.swapspace.*;
-import org.gridgain.grid.spi.swapspace.file.*;
 import org.gridgain.grid.util.typedef.internal.*;
 import org.jetbrains.annotations.*;
 
@@ -368,7 +367,7 @@ public class IgniteConfiguration {
     private LoadBalancingSpi[] loadBalancingSpi;
 
     /** Checkpoint SPI. */
-    private GridSwapSpaceSpi swapSpaceSpi;
+    private SwapSpaceSpi swapSpaceSpi;
 
     /** Indexing SPI. */
     private IndexingSpi[] indexingSpi;
@@ -2124,26 +2123,26 @@ public class IgniteConfiguration {
     }
 
     /**
-     * Sets fully configured instances of {@link GridSwapSpaceSpi}.
+     * Sets fully configured instances of {@link 
org.gridgain.grid.spi.swapspace.SwapSpaceSpi}.
      *
-     * @param swapSpaceSpi Fully configured instances of {@link 
GridSwapSpaceSpi} or
+     * @param swapSpaceSpi Fully configured instances of {@link 
org.gridgain.grid.spi.swapspace.SwapSpaceSpi} or
      *      <tt>null</tt> if no SPI provided.
      * @see IgniteConfiguration#getSwapSpaceSpi()
      */
-    public void setSwapSpaceSpi(GridSwapSpaceSpi swapSpaceSpi) {
+    public void setSwapSpaceSpi(SwapSpaceSpi swapSpaceSpi) {
         this.swapSpaceSpi = swapSpaceSpi;
     }
 
     /**
      * Should return fully configured swap space SPI implementation. If not 
provided,
-     * {@link GridFileSwapSpaceSpi} will be used.
+     * {@link org.gridgain.grid.spi.swapspace.file.FileSwapSpaceSpi} will be 
used.
      * <p>
      * Note that user can provide one or multiple instances of this SPI (and 
select later which one
      * is used in a particular context).
      *
      * @return Grid swap space SPI implementation or <tt>null</tt> to use 
default implementation.
      */
-    public GridSwapSpaceSpi getSwapSpaceSpi() {
+    public SwapSpaceSpi getSwapSpaceSpi() {
         return swapSpaceSpi;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java 
b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
index 9969650..328ac82 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java
@@ -607,7 +607,7 @@ public abstract class IgniteSpiAdapter implements 
IgniteSpi, IgniteSpiManagement
         }
 
         /** {@inheritDoc} */
-        @Override public <T> T readFromSwap(String spaceName, GridSwapKey key, 
@Nullable ClassLoader ldr)
+        @Override public <T> T readFromSwap(String spaceName, SwapKey key, 
@Nullable ClassLoader ldr)
             throws GridException {
             return null;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java 
b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java
index 8c20c98..a4b2c8d 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiContext.java
@@ -265,7 +265,7 @@ public interface IgniteSpiContext {
      * @return Swapped value.
      * @throws GridException If any exception occurs.
      */
-    @Nullable public <T> T readFromSwap(String spaceName, GridSwapKey key, 
@Nullable ClassLoader ldr)
+    @Nullable public <T> T readFromSwap(String spaceName, SwapKey key, 
@Nullable ClassLoader ldr)
         throws GridException;
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java 
b/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
index 2adda16..a9efc83 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/GridGainEx.java
@@ -1473,7 +1473,7 @@ public class GridGainEx {
             CheckpointSpi[] cpSpi = cfg.getCheckpointSpi();
             FailoverSpi[] failSpi = cfg.getFailoverSpi();
             LoadBalancingSpi[] loadBalancingSpi = cfg.getLoadBalancingSpi();
-            GridSwapSpaceSpi swapspaceSpi = cfg.getSwapSpaceSpi();
+            SwapSpaceSpi swapspaceSpi = cfg.getSwapSpaceSpi();
             IndexingSpi[] indexingSpi = cfg.getIndexingSpi();
 
             execSvc = cfg.getExecutorService();
@@ -1718,7 +1718,7 @@ public class GridGainEx {
                     }
                 }
 
-                swapspaceSpi = needSwap ? new GridFileSwapSpaceSpi() : new 
GridNoopSwapSpaceSpi();
+                swapspaceSpi = needSwap ? new FileSwapSpaceSpi() : new 
NoopSwapSpaceSpi();
             }
 
             if (indexingSpi == null)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
index 3c15e54..fd489ad 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/GridManagerAdapter.java
@@ -433,7 +433,7 @@ public abstract class GridManagerAdapter<T extends 
IgniteSpi> implements GridMan
                     }
 
                     @SuppressWarnings({"unchecked"})
-                    @Nullable @Override public <T> T readFromSwap(String 
spaceName, GridSwapKey key,
+                    @Nullable @Override public <T> T readFromSwap(String 
spaceName, SwapKey key,
                         @Nullable ClassLoader ldr) throws GridException {
                         assert ctx.swap().enabled();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/kernal/managers/swapspace/GridSwapSpaceManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/swapspace/GridSwapSpaceManager.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/swapspace/GridSwapSpaceManager.java
index a219fe2..e08935e 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/managers/swapspace/GridSwapSpaceManager.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/managers/swapspace/GridSwapSpaceManager.java
@@ -29,7 +29,7 @@ import static org.apache.ignite.events.IgniteEventType.*;
 /**
  *
  */
-public class GridSwapSpaceManager extends GridManagerAdapter<GridSwapSpaceSpi> 
{
+public class GridSwapSpaceManager extends GridManagerAdapter<SwapSpaceSpi> {
     /** */
     private IgniteMarshaller marsh;
 
@@ -45,7 +45,7 @@ public class GridSwapSpaceManager extends 
GridManagerAdapter<GridSwapSpaceSpi> {
         if (ctx.config().isDaemon())
             return;
 
-        getSpi().setListener(new GridSwapSpaceSpiListener() {
+        getSpi().setListener(new SwapSpaceSpiListener() {
             @Override public void onSwapEvent(int evtType, @Nullable String 
spaceName, @Nullable byte[] keyBytes) {
                 if (ctx.event().isRecordable(evtType)) {
                     String msg = null;
@@ -135,7 +135,7 @@ public class GridSwapSpaceManager extends 
GridManagerAdapter<GridSwapSpaceSpi> {
      * @return Value.
      * @throws GridException If failed.
      */
-    @Nullable public byte[] read(@Nullable String spaceName, GridSwapKey key, 
@Nullable ClassLoader ldr)
+    @Nullable public byte[] read(@Nullable String spaceName, SwapKey key, 
@Nullable ClassLoader ldr)
         throws GridException {
         assert key != null;
 
@@ -157,7 +157,7 @@ public class GridSwapSpaceManager extends 
GridManagerAdapter<GridSwapSpaceSpi> {
      * @throws GridException If failed.
      */
     @SuppressWarnings({"unchecked"})
-    @Nullable public <T> T readValue(@Nullable String spaceName, GridSwapKey 
key, @Nullable ClassLoader ldr)
+    @Nullable public <T> T readValue(@Nullable String spaceName, SwapKey key, 
@Nullable ClassLoader ldr)
         throws GridException {
         assert key != null;
 
@@ -173,7 +173,7 @@ public class GridSwapSpaceManager extends 
GridManagerAdapter<GridSwapSpaceSpi> {
      * @param ldr Class loader (optional).
      * @throws GridException If failed.
      */
-    public void write(@Nullable String spaceName, GridSwapKey key, byte[] val, 
@Nullable ClassLoader ldr)
+    public void write(@Nullable String spaceName, SwapKey key, byte[] val, 
@Nullable ClassLoader ldr)
         throws GridException {
         assert key != null;
         assert val != null;
@@ -195,7 +195,7 @@ public class GridSwapSpaceManager extends 
GridManagerAdapter<GridSwapSpaceSpi> {
      * @param ldr Class loader (optional).
      * @throws GridException If failed.
      */
-    public <K, V> void writeAll(String spaceName, Map<GridSwapKey, byte[]> 
batch,
+    public <K, V> void writeAll(String spaceName, Map<SwapKey, byte[]> batch,
         @Nullable ClassLoader ldr) throws GridException {
         getSpi().storeAll(spaceName, batch, context(ldr));
     }
@@ -213,7 +213,7 @@ public class GridSwapSpaceManager extends 
GridManagerAdapter<GridSwapSpaceSpi> {
         throws GridException {
         assert key != null;
 
-        write(spaceName, new GridSwapKey(key), marshal(val), ldr);
+        write(spaceName, new SwapKey(key), marshal(val), ldr);
     }
 
     /**
@@ -227,7 +227,7 @@ public class GridSwapSpaceManager extends 
GridManagerAdapter<GridSwapSpaceSpi> {
      * @param ldr Class loader (optional).
      * @throws GridException If failed.
      */
-    public void remove(@Nullable String spaceName, GridSwapKey key, @Nullable 
IgniteInClosure<byte[]> c,
+    public void remove(@Nullable String spaceName, SwapKey key, @Nullable 
IgniteInClosure<byte[]> c,
         @Nullable ClassLoader ldr) throws GridException {
         assert key != null;
 
@@ -250,8 +250,8 @@ public class GridSwapSpaceManager extends 
GridManagerAdapter<GridSwapSpaceSpi> {
      * @param ldr Class loader (optional).
      * @throws GridException If failed.
      */
-    public void removeAll(@Nullable String spaceName, Collection<GridSwapKey> 
keys,
-        IgniteBiInClosure<GridSwapKey, byte[]> c, @Nullable ClassLoader ldr) 
throws GridException {
+    public void removeAll(@Nullable String spaceName, Collection<SwapKey> keys,
+        IgniteBiInClosure<SwapKey, byte[]> c, @Nullable ClassLoader ldr) 
throws GridException {
         assert keys != null;
 
         try {
@@ -278,7 +278,7 @@ public class GridSwapSpaceManager extends 
GridManagerAdapter<GridSwapSpaceSpi> {
         @Nullable ClassLoader ldr) throws GridException {
         assert key != null;
 
-        remove(spaceName, new GridSwapKey(key), c, ldr);
+        remove(spaceName, new SwapKey(key), c, ldr);
     }
 
     /**
@@ -408,8 +408,8 @@ public class GridSwapSpaceManager extends 
GridManagerAdapter<GridSwapSpaceSpi> {
      * @param clsLdr Class loader.
      * @return Swap context.
      */
-    private GridSwapContext context(@Nullable ClassLoader clsLdr) {
-        GridSwapContext ctx = new GridSwapContext();
+    private SwapContext context(@Nullable ClassLoader clsLdr) {
+        SwapContext ctx = new SwapContext();
 
         ctx.classLoader(clsLdr != null ? clsLdr : U.gridClassLoader());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapManager.java
 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapManager.java
index 6096f7e..ff7f0e6 100644
--- 
a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapManager.java
+++ 
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheSwapManager.java
@@ -403,7 +403,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
         if (swapEnabled) {
             assert key != null;
 
-            byte[] valBytes = swapMgr.read(spaceName, new GridSwapKey(key, 
part, keyBytes),
+            byte[] valBytes = swapMgr.read(spaceName, new SwapKey(key, part, 
keyBytes),
                 cctx.deploy().globalLoader());
 
             return valBytes != null;
@@ -450,7 +450,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
 
             assert key != null;
 
-            byte[] bytes = swapMgr.read(spaceName, new GridSwapKey(key, part, 
keyBytes), cctx.deploy().globalLoader());
+            byte[] bytes = swapMgr.read(spaceName, new SwapKey(key, part, 
keyBytes), cctx.deploy().globalLoader());
 
             if (bytes == null && lsnr != null)
                 return lsnr.entry;
@@ -534,7 +534,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
         final GridTuple<GridCacheSwapEntry<V>> t = F.t1();
         final GridTuple<GridException> err = F.t1();
 
-        swapMgr.remove(spaceName, new GridSwapKey(key, part, keyBytes), new 
CI1<byte[]>() {
+        swapMgr.remove(spaceName, new SwapKey(key, part, keyBytes), new 
CI1<byte[]>() {
             @Override public void apply(byte[] rmv) {
                 if (rmv != null) {
                     try {
@@ -708,10 +708,10 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
         // Swap is enabled.
         final GridTuple<GridException> err = F.t1();
 
-        Collection<GridSwapKey> converted = new 
ArrayList<>(F.viewReadOnly(keysList, new C1<K, GridSwapKey>() {
-            @Override public GridSwapKey apply(K key) {
+        Collection<SwapKey> converted = new 
ArrayList<>(F.viewReadOnly(keysList, new C1<K, SwapKey>() {
+            @Override public SwapKey apply(K key) {
                 try {
-                    return new GridSwapKey(key, 
cctx.affinity().partition(key), CU.marshal(cctx.shared(), key));
+                    return new SwapKey(key, cctx.affinity().partition(key), 
CU.marshal(cctx.shared(), key));
                 }
                 catch (GridException e) {
                     throw new GridRuntimeException(e);
@@ -721,8 +721,8 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
 
         swapMgr.removeAll(spaceName,
             converted,
-            new IgniteBiInClosure<GridSwapKey, byte[]>() {
-                @Override public void apply(GridSwapKey swapKey, byte[] rmv) {
+            new IgniteBiInClosure<SwapKey, byte[]>() {
+                @Override public void apply(SwapKey swapKey, byte[] rmv) {
                     if (rmv != null) {
                         try {
                             GridCacheSwapEntry<V> entry = 
swapEntry(unmarshalSwapEntry(rmv));
@@ -873,7 +873,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
         }
 
         if (swapEnabled)
-            swapMgr.remove(spaceName, new GridSwapKey(key, part, keyBytes), c,
+            swapMgr.remove(spaceName, new SwapKey(key, part, keyBytes), c,
                 cctx.deploy().globalLoader());
     }
 
@@ -957,10 +957,10 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             }
         }
         else {
-            Map<GridSwapKey, byte[]> batch = new LinkedHashMap<>();
+            Map<SwapKey, byte[]> batch = new LinkedHashMap<>();
 
             for (GridCacheBatchSwapEntry entry : swapped)
-                batch.put(new GridSwapKey(entry.key(), entry.partition(), 
entry.keyBytes()), entry.marshal());
+                batch.put(new SwapKey(entry.key(), entry.partition(), 
entry.keyBytes()), entry.marshal());
 
             swapMgr.writeAll(spaceName, batch, cctx.deploy().globalLoader());
 
@@ -991,7 +991,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
         if (key == null)
             key = unmarshalKey(keyBytes, cctx.deploy().globalLoader());
 
-        swapMgr.write(spaceName, new GridSwapKey(key, part, keyBytes), entry, 
cctx.deploy().globalLoader());
+        swapMgr.write(spaceName, new SwapKey(key, part, keyBytes), entry, 
cctx.deploy().globalLoader());
 
         if (cctx.events().isRecordable(EVT_CACHE_OBJECT_SWAPPED))
             cctx.events().addEvent(part, key, cctx.nodeId(), (IgniteUuid)null, 
null,

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/spi/securesession/GridSecureSessionSpi.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/spi/securesession/GridSecureSessionSpi.java
 
b/modules/core/src/main/java/org/gridgain/grid/spi/securesession/GridSecureSessionSpi.java
deleted file mode 100644
index a87eaac..0000000
--- 
a/modules/core/src/main/java/org/gridgain/grid/spi/securesession/GridSecureSessionSpi.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.securesession;
-
-import org.apache.ignite.spi.*;
-import org.gridgain.grid.security.*;
-import org.gridgain.grid.spi.securesession.noop.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-
-/**
- * Secure session SPI allows for session creation and validation, typically 
after authentication
- * has successfully happened. The main purpose of this SPI is to ensure that 
remote clients are
- * authenticated only once and upon successful authentication get issued a 
secure session token
- * to reuse for consequent requests (very much the same way like HTTP sessions 
work).
- * <p>
- * The default secure session SPI is {@link GridNoopSecureSessionSpi}
- * which permits any request.
- * <p>
- * Gridgain provides the following {@code GridSecureSessionSpi} 
implementations:
- * <ul>
- * <li>
- *     {@link GridNoopSecureSessionSpi} - permits any request.
- * </li>
- * <li>
- *     {@code GridRememberMeSecureSessionSpi} -
- *     validates client session with remember-me session token.
- * </li>
- * </ul>
- * <p>
- * <b>NOTE:</b> that multiple secure session SPIs may be started on the same 
grid node. In this case
- * GridGain will differentiate between them based on {@link 
#supported(GridSecuritySubjectType)}
- * value. The first SPI which returns {@code true} for a given subject type 
will be used for
- * session validation.
- * <p>
- * <b>NOTE:</b> 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 {@link org.apache.ignite.Ignite#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.
- */
-public interface GridSecureSessionSpi extends IgniteSpi {
-    /**
-     * Checks if given subject is supported by this SPI. If not, then next 
secure session SPI
-     * in the list will be checked.
-     *
-     * @param subjType Subject type.
-     * @return {@code True} if subject type is supported, {@code false} 
otherwise.
-     */
-    public boolean supported(GridSecuritySubjectType subjType);
-
-    /**
-     * Validates given session token.
-     *
-     * @param subjType Subject type.
-     * @param subjId Unique subject ID such as local or remote node ID, client 
ID, etc.
-     * @param tok Token to validate.
-     * @param params Additional implementation-specific parameters.
-     * @return {@code True} if session token is valid, {@code false} otherwise.
-     * @throws org.apache.ignite.spi.IgniteSpiException If validation resulted 
in system error. Note that
-     *      bad credentials should not cause this exception.
-     */
-    public boolean validate(GridSecuritySubjectType subjType, UUID subjId, 
byte[] tok,
-        @Nullable Object params) throws IgniteSpiException;
-
-    /**
-     * Generates new session token.
-     *
-     * @param subjType Subject type.
-     * @param subjId Unique subject ID such as local or remote node ID, client 
ID, etc.
-     * @param params Additional implementation-specific parameters.
-     * @return Session token that should be used for further validation.
-     */
-    public byte[] generateSessionToken(GridSecuritySubjectType subjType, UUID 
subjId, @Nullable Object params)
-        throws IgniteSpiException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/spi/securesession/noop/GridNoopSecureSessionSpi.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/spi/securesession/noop/GridNoopSecureSessionSpi.java
 
b/modules/core/src/main/java/org/gridgain/grid/spi/securesession/noop/GridNoopSecureSessionSpi.java
deleted file mode 100644
index c52a011..0000000
--- 
a/modules/core/src/main/java/org/gridgain/grid/spi/securesession/noop/GridNoopSecureSessionSpi.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.securesession.noop;
-
-import org.apache.ignite.*;
-import org.apache.ignite.resources.*;
-import org.apache.ignite.spi.*;
-import org.gridgain.grid.security.*;
-import org.gridgain.grid.spi.securesession.*;
-import org.gridgain.grid.util.typedef.internal.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-
-/**
- * Default no-op implementation of the secure session SPI which supports all 
subject types and denies any token.
- * <p>
- * <h1 class="header">Configuration</h1>
- * <h2 class="header">Mandatory</h2>
- * This SPI has no mandatory configuration parameters.
- * <h2 class="header">Optional</h2>
- * This SPI has no optional configuration parameters.
- * <h2 class="header">Java Example</h2>
- * GridNoopSecureSessionSpi is used by default and has no parameters to be 
explicitly configured.
- * <pre name="code" class="java">
- * GridNoopSecureSessionSpi spi = new GridNoopSecureSessionSpi();
- *
- * GridConfiguration cfg = new GridConfiguration();
- *
- * // Override default SecureSession SPI.
- * cfg.setSecureSessionSpi(spi);
- *
- * // Start grid.
- * GridGain.start(cfg);
- * </pre>
- * <h2 class="header">Spring Example</h2>
- * GridNoopSecureSessionSpi can be configured from Spring XML configuration 
file:
- * <pre name="code" class="xml">
- * &lt;bean id="grid.custom.cfg" class="org.gridgain.grid.GridConfiguration" 
singleton="true"&gt;
- *         ...
- *         &lt;property name="secureSessionSpi"&gt;
- *             &lt;bean 
class="org.gridgain.grid.spi.SecureSession.noop.GridNoopSecureSessionSpi"/&gt;
- *         &lt;/property&gt;
- *         ...
- * &lt;/bean&gt;
- * </pre>
- * <p>
- * <img src="http://www.gridgain.com/images/spring-small.png";>
- * <br>
- * For information about Spring framework visit <a 
href="http://www.springframework.org/";>www.springframework.org</a>
- * @see GridSecureSessionSpi
- */
-@IgniteSpiNoop
-@IgniteSpiMultipleInstancesSupport(true)
-public class GridNoopSecureSessionSpi extends IgniteSpiAdapter
-    implements GridSecureSessionSpi, GridNoopSecureSessionSpiMBean {
-    /** Empty bytes array. */
-    private static final byte[] EMPTY_BYTE_ARRAY = new byte[0];
-
-    /** Injected grid logger. */
-    @IgniteLoggerResource
-    private IgniteLogger log;
-
-    /** {@inheritDoc} */
-    @Override public boolean supported(GridSecuritySubjectType subjType) {
-        // If this SPI is included, then session management is disabled.
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean validate(GridSecuritySubjectType subjType, UUID 
subjId, @Nullable byte[] tok,
-        @Nullable Object params) throws IgniteSpiException {
-        // Never validate any token - all tokens are invalid.
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public byte[] generateSessionToken(GridSecuritySubjectType 
subjType, UUID subjId,
-        @Nullable Object params) {
-        return EMPTY_BYTE_ARRAY;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void spiStart(String gridName) throws IgniteSpiException {
-        // Start SPI start stopwatch.
-        startStopwatch();
-
-        registerMBean(gridName, this, GridNoopSecureSessionSpiMBean.class);
-
-        // Ack ok start.
-        if (log.isDebugEnabled())
-            log.debug(startInfo());
-    }
-
-    /** {@inheritDoc} */
-    @Override public void spiStop() throws IgniteSpiException {
-        unregisterMBean();
-
-        // Ack ok stop.
-        if (log.isDebugEnabled())
-            log.debug(stopInfo());
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(GridNoopSecureSessionSpi.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/spi/securesession/noop/GridNoopSecureSessionSpiMBean.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/spi/securesession/noop/GridNoopSecureSessionSpiMBean.java
 
b/modules/core/src/main/java/org/gridgain/grid/spi/securesession/noop/GridNoopSecureSessionSpiMBean.java
deleted file mode 100644
index 8acb648..0000000
--- 
a/modules/core/src/main/java/org/gridgain/grid/spi/securesession/noop/GridNoopSecureSessionSpiMBean.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.securesession.noop;
-
-import org.apache.ignite.mbean.*;
-import org.apache.ignite.spi.*;
-
-/**
- * Management bean for {@link GridNoopSecureSessionSpi}.
- */
-@IgniteMBeanDescription("MBean that provides access to no-op secure session 
SPI configuration.")
-public interface GridNoopSecureSessionSpiMBean extends 
IgniteSpiManagementMBean {
-    // No-op.
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapContext.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapContext.java
 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapContext.java
deleted file mode 100644
index 7f24ea4..0000000
--- 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapContext.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.swapspace;
-
-import org.gridgain.grid.util.typedef.internal.*;
-
-/**
- * Context for swap operations.
- */
-public class GridSwapContext {
-    /** */
-    private ClassLoader clsLdr;
-
-    /**
-     * @return Class loader.
-     */
-    public ClassLoader classLoader() {
-        return clsLdr;
-    }
-
-    /**
-     * @param clsLdr Class loader.
-     */
-    public void classLoader(ClassLoader clsLdr) {
-        this.clsLdr = clsLdr;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(GridSwapContext.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapKey.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapKey.java 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapKey.java
deleted file mode 100644
index a7b8624..0000000
--- 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapKey.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.swapspace;
-
-import org.gridgain.grid.util.typedef.internal.*;
-import org.gridgain.grid.util.tostring.*;
-import org.jetbrains.annotations.*;
-
-/**
- * Utility wrapper class that represents swap key.
- * <p>
- * This class also holds information about partition this key belongs to
- * (if needed for caches).
- */
-public class GridSwapKey {
-    /** */
-    @GridToStringInclude
-    private final Object key;
-
-    /** */
-    private final int part;
-
-    /** Serialized key. */
-    @GridToStringExclude
-    private byte[] keyBytes;
-
-    /**
-     * @param key Key.
-     */
-    public GridSwapKey(Object key) {
-        this(key, Integer.MAX_VALUE, null);
-    }
-
-    /**
-     * @param key Key.
-     * @param part Partition.
-     */
-    public GridSwapKey(Object key, int part) {
-        this(key, part, null);
-    }
-
-    /**
-     * @param key Key.
-     * @param part Part.
-     * @param keyBytes Key bytes.
-     */
-    public GridSwapKey(Object key, int part, @Nullable byte[] keyBytes) {
-        assert key != null;
-        assert part >= 0;
-
-        this.key = key;
-        this.part = part;
-        this.keyBytes = keyBytes;
-    }
-
-    /**
-     * @return Key.
-     */
-    public Object key() {
-        return key;
-    }
-
-    /**
-     * @return Partition this key belongs to.
-     */
-    public int partition() {
-        return part;
-    }
-
-    /**
-     * @return Serialized key.
-     */
-    @Nullable public byte[] keyBytes() {
-        return keyBytes;
-    }
-
-    /**
-     * @param keyBytes Serialized key.
-     */
-    public void keyBytes(byte[] keyBytes) {
-        assert keyBytes != null;
-
-        this.keyBytes = keyBytes;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean equals(Object obj) {
-        if (obj == this)
-            return true;
-
-        if (obj instanceof GridSwapKey) {
-            GridSwapKey other = (GridSwapKey)obj;
-
-            return part == other.part && key.equals(other.key);
-        }
-
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int hashCode() {
-        return key.hashCode();
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(GridSwapKey.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapSpaceSpi.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapSpaceSpi.java
 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapSpaceSpi.java
deleted file mode 100644
index a802097..0000000
--- 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapSpaceSpi.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.swapspace;
-
-import org.apache.ignite.lang.*;
-import org.apache.ignite.spi.*;
-import org.gridgain.grid.spi.swapspace.file.*;
-import org.gridgain.grid.spi.swapspace.noop.*;
-import org.jetbrains.annotations.*;
-
-import java.util.*;
-
-/**
- * Provides a mechanism in grid for storing data on disk. GridGain cache uses 
swap space to overflow
- * data to disk if it cannot fit in memory. It's also possible to use swap 
space directly
- * by calling {@link org.apache.ignite.Ignite} API swap-related methods. 
Logically storage is organized into
- * independent 'spaces' in which data is stored.
- * <p>
- * All swap space implementations can be configured to prevent infinite growth 
and evict oldest entries.
- * <p>
- * The default swap space SPI is {@link GridFileSwapSpaceSpi} which stores 
values on disk in files and keeps keys in
- * memory.
- * <p>
- * Gridgain provides the following {@code GridSwapSpaceSpi} implementations:
- * <ul>
- * <li>
- *     {@link GridFileSwapSpaceSpi} - pure Java implementation with in-memory 
keys. This SPI is used by default.
- * </li>
- * <li>
- *     {@link GridNoopSwapSpaceSpi} - no-op SPI mainly for testing.
- * </li>
- * </ul>
- * <p>
- * <p>
- * <b>NOTE:</b> 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 {@link org.apache.ignite.Ignite#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.
- */
-public interface GridSwapSpaceSpi extends IgniteSpi {
-    /**
-     * Entirely clears data space with given name, if any.
-     *
-     * @param spaceName Space name to clear.
-     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
-     */
-    public void clear(@Nullable String spaceName) throws IgniteSpiException;
-
-    /**
-     * Gets size in bytes for data space with given name. If specified space 
does
-     * not exist this method returns {@code 0}.
-     *
-     * @param spaceName Space name to get size for.
-     * @return Size in bytes.
-     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
-     */
-    public long size(@Nullable String spaceName) throws IgniteSpiException;
-
-    /**
-     * Gets number of stored entries (keys) in data space with given name. If 
specified
-     * space does not exist this method returns {@code 0}.
-     *
-     * @param spaceName Space name to get number of entries for.
-     * @return Number of stored entries in specified space.
-     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
-     */
-    public long count(@Nullable String spaceName) throws IgniteSpiException;
-
-    /**
-     * Reads stored value as array of bytes by key from data space with given 
name.
-     * If specified space does not exist this method returns {@code null}.
-     *
-     * @param spaceName Name of the data space to read from.
-     * @param key Key used to read value from data space.
-     * @param ctx Swap context.
-     * @return Value as array of bytes stored in specified data space that 
matches
-     *      to given key.
-     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
-     */
-    @Nullable public byte[] read(@Nullable String spaceName, GridSwapKey key, 
GridSwapContext ctx)
-        throws IgniteSpiException;
-
-    /**
-     * Reads stored values as array of bytes by all passed keys from data 
space with
-     * given name. If specified space does not exist this method returns empty 
map.
-     *
-     * @param spaceName Name of the data space to read from.
-     * @param keys Keys used to read values from data space.
-     * @param ctx Swap context.
-     * @return Map in which keys are the ones passed into method and values are
-     *      corresponding values read from swap storage.
-     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
-     */
-    public Map<GridSwapKey, byte[]> readAll(@Nullable String spaceName,
-        Iterable<GridSwapKey> keys, GridSwapContext ctx) throws 
IgniteSpiException;
-
-    /**
-     * Removes value stored in data space with given name corresponding to 
specified key.
-     *
-     * @param spaceName Space name to remove value from.
-     * @param key Key to remove value in the specified space for.
-     * @param c Optional closure that takes removed value and executes after 
actual
-     *      removing. If there was no value in storage the closure is not 
executed.
-     * @param ctx Swap context.
-     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
-     */
-    public void remove(@Nullable String spaceName, GridSwapKey key,
-        @Nullable IgniteInClosure<byte[]> c, GridSwapContext ctx) throws 
IgniteSpiException;
-
-    /**
-     * Removes values stored in data space with given name corresponding to 
specified keys.
-     *
-     * @param spaceName Space name to remove values from.
-     * @param keys Keys to remove value in the specified space for.
-     * @param c Optional closure that takes removed value and executes after 
actual
-     *      removing. If there was no value in storage the closure is not 
executed.
-     * @param ctx Swap context.
-     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
-     */
-    public void removeAll(@Nullable String spaceName, Collection<GridSwapKey> 
keys,
-        @Nullable IgniteBiInClosure<GridSwapKey, byte[]> c, GridSwapContext 
ctx) throws IgniteSpiException;
-
-    /**
-     * Stores value as array of bytes with given key into data space with 
given name.
-     *
-     * @param spaceName Space name to store key-value pair into.
-     * @param key Key to store given value for. This key can be used further to
-     *      read or remove stored value.
-     * @param val Some value as array of bytes to store into specified data 
space.
-     * @param ctx Swap context.
-     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
-     */
-    public void store(@Nullable String spaceName, GridSwapKey key, @Nullable 
byte[] val, GridSwapContext ctx)
-        throws IgniteSpiException;
-
-    /**
-     * Stores key-value pairs (both keys and values are arrays of bytes) into 
data
-     * space with given name.
-     *
-     * @param spaceName Space name to store key-value pairs into.
-     * @param pairs Map of stored key-value pairs where each one is an array 
of bytes.
-     * @param ctx Swap context.
-     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
-     */
-    public void storeAll(@Nullable String spaceName, Map<GridSwapKey, byte[]> 
pairs, GridSwapContext ctx)
-        throws IgniteSpiException;
-
-    /**
-     * Sets eviction listener to receive notifications on evicted swap entries.
-     *
-     * @param evictLsnr Eviction listener ({@code null} to stop receiving 
notifications).
-     */
-    public void setListener(@Nullable GridSwapSpaceSpiListener evictLsnr);
-
-    /**
-     * Gets partitions IDs that are stored in the passed in space.
-     *
-     * @param spaceName Space name.
-     * @return Partitions IDs or {@code null} if space is unknown.
-     * @throws org.apache.ignite.spi.IgniteSpiException If failed.
-     */
-    @Nullable public Collection<Integer> partitions(@Nullable String 
spaceName) throws IgniteSpiException;
-
-    /**
-     * Gets iterator over space keys.
-     *
-     * @param spaceName Space name.
-     * @param ctx Swap context.
-     * @return Iterator over space entries or {@code null} if space is unknown.
-     * @throws org.apache.ignite.spi.IgniteSpiException If failed.
-     */
-    @Nullable <K> IgniteSpiCloseableIterator<K> keyIterator(@Nullable String 
spaceName, GridSwapContext ctx)
-        throws IgniteSpiException;
-
-    /**
-     * Gets raw iterator over space entries.
-     *
-     * @param spaceName Space name.
-     * @return Iterator over space entries or {@code null} if space is unknown.
-     * @throws org.apache.ignite.spi.IgniteSpiException If failed.
-     */
-    @Nullable public IgniteSpiCloseableIterator<Map.Entry<byte[], byte[]>> 
rawIterator(@Nullable String spaceName)
-        throws IgniteSpiException;
-
-    /**
-     * Gets raw iterator over space entries.
-     *
-     * @param spaceName Space name.
-     * @param part Partition.
-     * @return Iterator over space entries or {@code null} if space is unknown.
-     * @throws org.apache.ignite.spi.IgniteSpiException If failed.
-     */
-    @Nullable public IgniteSpiCloseableIterator<Map.Entry<byte[], byte[]>> 
rawIterator(@Nullable String spaceName,
-        int part) throws IgniteSpiException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapSpaceSpiListener.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapSpaceSpiListener.java
 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapSpaceSpiListener.java
deleted file mode 100644
index 073d995..0000000
--- 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/GridSwapSpaceSpiListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/* @java.file.header */
-
-/*  _________        _____ __________________        _____
- *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
- *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
- *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
- *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
- */
-
-package org.gridgain.grid.spi.swapspace;
-
-import org.jetbrains.annotations.*;
-
-/**
- * Swap space SPI eviction listener.
- */
-public interface GridSwapSpaceSpiListener {
-    /**
-     * Notification for swap space events.
-     *
-     * @param evtType Event type. See {@link 
org.apache.ignite.events.IgniteSwapSpaceEvent}
-     * @param spaceName Space name for this event or {@code null} for default 
space.
-     * @param keyBytes Key bytes of affected entry. Not {@code null} only for 
evict notifications.
-     */
-    public void onSwapEvent(int evtType, @Nullable String spaceName, @Nullable 
byte[] keyBytes);
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapContext.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapContext.java 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapContext.java
new file mode 100644
index 0000000..c757651
--- /dev/null
+++ 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapContext.java
@@ -0,0 +1,39 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.gridgain.grid.spi.swapspace;
+
+import org.gridgain.grid.util.typedef.internal.*;
+
+/**
+ * Context for swap operations.
+ */
+public class SwapContext {
+    /** */
+    private ClassLoader clsLdr;
+
+    /**
+     * @return Class loader.
+     */
+    public ClassLoader classLoader() {
+        return clsLdr;
+    }
+
+    /**
+     * @param clsLdr Class loader.
+     */
+    public void classLoader(ClassLoader clsLdr) {
+        this.clsLdr = clsLdr;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(SwapContext.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapKey.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapKey.java 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapKey.java
new file mode 100644
index 0000000..1bce5f7
--- /dev/null
+++ b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapKey.java
@@ -0,0 +1,116 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.gridgain.grid.spi.swapspace;
+
+import org.gridgain.grid.util.typedef.internal.*;
+import org.gridgain.grid.util.tostring.*;
+import org.jetbrains.annotations.*;
+
+/**
+ * Utility wrapper class that represents swap key.
+ * <p>
+ * This class also holds information about partition this key belongs to
+ * (if needed for caches).
+ */
+public class SwapKey {
+    /** */
+    @GridToStringInclude
+    private final Object key;
+
+    /** */
+    private final int part;
+
+    /** Serialized key. */
+    @GridToStringExclude
+    private byte[] keyBytes;
+
+    /**
+     * @param key Key.
+     */
+    public SwapKey(Object key) {
+        this(key, Integer.MAX_VALUE, null);
+    }
+
+    /**
+     * @param key Key.
+     * @param part Partition.
+     */
+    public SwapKey(Object key, int part) {
+        this(key, part, null);
+    }
+
+    /**
+     * @param key Key.
+     * @param part Part.
+     * @param keyBytes Key bytes.
+     */
+    public SwapKey(Object key, int part, @Nullable byte[] keyBytes) {
+        assert key != null;
+        assert part >= 0;
+
+        this.key = key;
+        this.part = part;
+        this.keyBytes = keyBytes;
+    }
+
+    /**
+     * @return Key.
+     */
+    public Object key() {
+        return key;
+    }
+
+    /**
+     * @return Partition this key belongs to.
+     */
+    public int partition() {
+        return part;
+    }
+
+    /**
+     * @return Serialized key.
+     */
+    @Nullable public byte[] keyBytes() {
+        return keyBytes;
+    }
+
+    /**
+     * @param keyBytes Serialized key.
+     */
+    public void keyBytes(byte[] keyBytes) {
+        assert keyBytes != null;
+
+        this.keyBytes = keyBytes;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object obj) {
+        if (obj == this)
+            return true;
+
+        if (obj instanceof SwapKey) {
+            SwapKey other = (SwapKey)obj;
+
+            return part == other.part && key.equals(other.key);
+        }
+
+        return false;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        return key.hashCode();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(SwapKey.class, this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpi.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpi.java 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpi.java
new file mode 100644
index 0000000..1a07535
--- /dev/null
+++ 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpi.java
@@ -0,0 +1,202 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.gridgain.grid.spi.swapspace;
+
+import org.apache.ignite.lang.*;
+import org.apache.ignite.spi.*;
+import org.jetbrains.annotations.*;
+
+import java.util.*;
+
+/**
+ * Provides a mechanism in grid for storing data on disk. GridGain cache uses 
swap space to overflow
+ * data to disk if it cannot fit in memory. It's also possible to use swap 
space directly
+ * by calling {@link org.apache.ignite.Ignite} API swap-related methods. 
Logically storage is organized into
+ * independent 'spaces' in which data is stored.
+ * <p>
+ * All swap space implementations can be configured to prevent infinite growth 
and evict oldest entries.
+ * <p>
+ * The default swap space SPI is {@link 
org.gridgain.grid.spi.swapspace.file.FileSwapSpaceSpi} which stores values on 
disk in files and keeps keys in
+ * memory.
+ * <p>
+ * Gridgain provides the following {@code GridSwapSpaceSpi} implementations:
+ * <ul>
+ * <li>
+ *     {@link org.gridgain.grid.spi.swapspace.file.FileSwapSpaceSpi} - pure 
Java implementation with in-memory keys. This SPI is used by default.
+ * </li>
+ * <li>
+ *     {@link org.gridgain.grid.spi.swapspace.noop.NoopSwapSpaceSpi} - no-op 
SPI mainly for testing.
+ * </li>
+ * </ul>
+ * <p>
+ * <p>
+ * <b>NOTE:</b> 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 {@link org.apache.ignite.Ignite#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.
+ */
+public interface SwapSpaceSpi extends IgniteSpi {
+    /**
+     * Entirely clears data space with given name, if any.
+     *
+     * @param spaceName Space name to clear.
+     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
+     */
+    public void clear(@Nullable String spaceName) throws IgniteSpiException;
+
+    /**
+     * Gets size in bytes for data space with given name. If specified space 
does
+     * not exist this method returns {@code 0}.
+     *
+     * @param spaceName Space name to get size for.
+     * @return Size in bytes.
+     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
+     */
+    public long size(@Nullable String spaceName) throws IgniteSpiException;
+
+    /**
+     * Gets number of stored entries (keys) in data space with given name. If 
specified
+     * space does not exist this method returns {@code 0}.
+     *
+     * @param spaceName Space name to get number of entries for.
+     * @return Number of stored entries in specified space.
+     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
+     */
+    public long count(@Nullable String spaceName) throws IgniteSpiException;
+
+    /**
+     * Reads stored value as array of bytes by key from data space with given 
name.
+     * If specified space does not exist this method returns {@code null}.
+     *
+     * @param spaceName Name of the data space to read from.
+     * @param key Key used to read value from data space.
+     * @param ctx Swap context.
+     * @return Value as array of bytes stored in specified data space that 
matches
+     *      to given key.
+     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
+     */
+    @Nullable public byte[] read(@Nullable String spaceName, SwapKey key, 
SwapContext ctx)
+        throws IgniteSpiException;
+
+    /**
+     * Reads stored values as array of bytes by all passed keys from data 
space with
+     * given name. If specified space does not exist this method returns empty 
map.
+     *
+     * @param spaceName Name of the data space to read from.
+     * @param keys Keys used to read values from data space.
+     * @param ctx Swap context.
+     * @return Map in which keys are the ones passed into method and values are
+     *      corresponding values read from swap storage.
+     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
+     */
+    public Map<SwapKey, byte[]> readAll(@Nullable String spaceName,
+        Iterable<SwapKey> keys, SwapContext ctx) throws IgniteSpiException;
+
+    /**
+     * Removes value stored in data space with given name corresponding to 
specified key.
+     *
+     * @param spaceName Space name to remove value from.
+     * @param key Key to remove value in the specified space for.
+     * @param c Optional closure that takes removed value and executes after 
actual
+     *      removing. If there was no value in storage the closure is not 
executed.
+     * @param ctx Swap context.
+     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
+     */
+    public void remove(@Nullable String spaceName, SwapKey key,
+        @Nullable IgniteInClosure<byte[]> c, SwapContext ctx) throws 
IgniteSpiException;
+
+    /**
+     * Removes values stored in data space with given name corresponding to 
specified keys.
+     *
+     * @param spaceName Space name to remove values from.
+     * @param keys Keys to remove value in the specified space for.
+     * @param c Optional closure that takes removed value and executes after 
actual
+     *      removing. If there was no value in storage the closure is not 
executed.
+     * @param ctx Swap context.
+     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
+     */
+    public void removeAll(@Nullable String spaceName, Collection<SwapKey> keys,
+        @Nullable IgniteBiInClosure<SwapKey, byte[]> c, SwapContext ctx) 
throws IgniteSpiException;
+
+    /**
+     * Stores value as array of bytes with given key into data space with 
given name.
+     *
+     * @param spaceName Space name to store key-value pair into.
+     * @param key Key to store given value for. This key can be used further to
+     *      read or remove stored value.
+     * @param val Some value as array of bytes to store into specified data 
space.
+     * @param ctx Swap context.
+     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
+     */
+    public void store(@Nullable String spaceName, SwapKey key, @Nullable 
byte[] val, SwapContext ctx)
+        throws IgniteSpiException;
+
+    /**
+     * Stores key-value pairs (both keys and values are arrays of bytes) into 
data
+     * space with given name.
+     *
+     * @param spaceName Space name to store key-value pairs into.
+     * @param pairs Map of stored key-value pairs where each one is an array 
of bytes.
+     * @param ctx Swap context.
+     * @throws org.apache.ignite.spi.IgniteSpiException In case of any errors.
+     */
+    public void storeAll(@Nullable String spaceName, Map<SwapKey, byte[]> 
pairs, SwapContext ctx)
+        throws IgniteSpiException;
+
+    /**
+     * Sets eviction listener to receive notifications on evicted swap entries.
+     *
+     * @param evictLsnr Eviction listener ({@code null} to stop receiving 
notifications).
+     */
+    public void setListener(@Nullable SwapSpaceSpiListener evictLsnr);
+
+    /**
+     * Gets partitions IDs that are stored in the passed in space.
+     *
+     * @param spaceName Space name.
+     * @return Partitions IDs or {@code null} if space is unknown.
+     * @throws org.apache.ignite.spi.IgniteSpiException If failed.
+     */
+    @Nullable public Collection<Integer> partitions(@Nullable String 
spaceName) throws IgniteSpiException;
+
+    /**
+     * Gets iterator over space keys.
+     *
+     * @param spaceName Space name.
+     * @param ctx Swap context.
+     * @return Iterator over space entries or {@code null} if space is unknown.
+     * @throws org.apache.ignite.spi.IgniteSpiException If failed.
+     */
+    @Nullable <K> IgniteSpiCloseableIterator<K> keyIterator(@Nullable String 
spaceName, SwapContext ctx)
+        throws IgniteSpiException;
+
+    /**
+     * Gets raw iterator over space entries.
+     *
+     * @param spaceName Space name.
+     * @return Iterator over space entries or {@code null} if space is unknown.
+     * @throws org.apache.ignite.spi.IgniteSpiException If failed.
+     */
+    @Nullable public IgniteSpiCloseableIterator<Map.Entry<byte[], byte[]>> 
rawIterator(@Nullable String spaceName)
+        throws IgniteSpiException;
+
+    /**
+     * Gets raw iterator over space entries.
+     *
+     * @param spaceName Space name.
+     * @param part Partition.
+     * @return Iterator over space entries or {@code null} if space is unknown.
+     * @throws org.apache.ignite.spi.IgniteSpiException If failed.
+     */
+    @Nullable public IgniteSpiCloseableIterator<Map.Entry<byte[], byte[]>> 
rawIterator(@Nullable String spaceName,
+        int part) throws IgniteSpiException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpiListener.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpiListener.java
 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpiListener.java
new file mode 100644
index 0000000..da8639d
--- /dev/null
+++ 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/SwapSpaceSpiListener.java
@@ -0,0 +1,26 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.gridgain.grid.spi.swapspace;
+
+import org.jetbrains.annotations.*;
+
+/**
+ * Swap space SPI eviction listener.
+ */
+public interface SwapSpaceSpiListener {
+    /**
+     * Notification for swap space events.
+     *
+     * @param evtType Event type. See {@link 
org.apache.ignite.events.IgniteSwapSpaceEvent}
+     * @param spaceName Space name for this event or {@code null} for default 
space.
+     * @param keyBytes Key bytes of affected entry. Not {@code null} only for 
evict notifications.
+     */
+    public void onSwapEvent(int evtType, @Nullable String spaceName, @Nullable 
byte[] keyBytes);
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c31cec7c/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/file/FileSwapArray.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/file/FileSwapArray.java
 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/file/FileSwapArray.java
new file mode 100644
index 0000000..e4a4f28
--- /dev/null
+++ 
b/modules/core/src/main/java/org/gridgain/grid/spi/swapspace/file/FileSwapArray.java
@@ -0,0 +1,181 @@
+/* @java.file.header */
+
+/*  _________        _____ __________________        _____
+ *  __  ____/___________(_)______  /__  ____/______ ____(_)_______
+ *  _  / __  __  ___/__  / _  __  / _  / __  _  __ `/__  / __  __ \
+ *  / /_/ /  _  /    _  /  / /_/ /  / /_/ /  / /_/ / _  /  _  / / /
+ *  \____/   /_/     /_/   \_,__/   \____/   \__,_/  /_/   /_/ /_/
+ */
+
+package org.gridgain.grid.spi.swapspace.file;
+
+import org.jetbrains.annotations.*;
+
+import java.util.concurrent.atomic.*;
+
+/**
+ * Growing array.
+ */
+class FileSwapArray<X> {
+    /** First partition size must be power of two. */
+    private static final int FIRST_ARRAY_SIZE = 4096;
+
+    /** */
+    private static final int LADDER_SIZE = 
Integer.numberOfLeadingZeros(FIRST_ARRAY_SIZE) + 1;
+
+    /** */
+    @SuppressWarnings("unchecked")
+    private final AtomicReferenceArray<X>[] ladder = new 
AtomicReferenceArray[LADDER_SIZE];
+
+    /** */
+    private int idx = 1;
+
+    /**
+     *
+     */
+    FileSwapArray() {
+        synchronized (ladder) {
+            ladder[0] = new AtomicReferenceArray<>(FIRST_ARRAY_SIZE);
+        }
+    }
+
+    /**
+     * @return Size.
+     */
+    public int size() {
+        return idx;
+    }
+
+    /**
+     * Adds value to the end.
+     *
+     * @param x Value.
+     * @return Index where it was added.
+     */
+    int add(X x) {
+        int i = idx++;
+
+        assert i >= 0 && i != Integer.MAX_VALUE : "Integer overflow";
+
+        Slot<X> s = slot(i);
+
+        assert s != null; // We should add always in one thread.
+
+        s.set(x);
+
+        int len = s.arr.length();
+
+        if (s.idx + 1 == len) {
+            synchronized (ladder) {
+                ladder[s.arrIdx + 1] = new AtomicReferenceArray<>(s.arrIdx == 
0 ? len : len << 1);
+            }
+        }
+
+        return i;
+    }
+
+    /**
+     * @param size New size.
+     */
+    void truncate(int size) {
+        assert size > 0;
+
+        idx = size;
+
+        int arrIdx = arrayIndex(idx) + 1;
+
+        if (arrIdx < ladder.length && ladder[arrIdx] != null) {
+            synchronized (ladder) {
+                do {
+                    ladder[arrIdx++] = null;
+                }
+                while (arrIdx < ladder.length && ladder[arrIdx] != null);
+            }
+        }
+    }
+
+    /**
+     * @param idx Absolute slot index.
+     * @return Array index in {@link #ladder}.
+     */
+    static int arrayIndex(int idx) {
+        if (idx < FIRST_ARRAY_SIZE)
+            return 0;
+
+        return LADDER_SIZE - Integer.numberOfLeadingZeros(idx);
+    }
+
+    /**
+     * Slot for given absolute index.
+     *
+     * @param idx Absolute index.
+     * @return Slot.
+     */
+    @Nullable Slot<X> slot(int idx) {
+        assert idx > 0 : idx;
+
+        int arrIdx = arrayIndex(idx);
+
+        AtomicReferenceArray<X> arr = ladder[arrIdx];
+
+        if (arr == null) {
+            synchronized (ladder) { // Ensure visibility.
+                arr = ladder[arrIdx];
+            }
+
+            if (arr == null)
+                return null;
+        }
+
+        return new Slot<>(arrIdx, arr, arrIdx == 0 ? idx : idx - arr.length());
+    }
+
+    /**
+     * Slot in array.
+     */
+    @SuppressWarnings("PublicInnerClass")
+    static final class Slot<X> {
+        /** */
+        private final int arrIdx;
+
+        /** */
+        private final AtomicReferenceArray<X> arr;
+
+        /** */
+        private final int idx;
+
+        /**
+         * @param arrIdx Index of array.
+         * @param arr Array.
+         * @param idx Index within the array.
+         */
+        private Slot(int arrIdx, AtomicReferenceArray<X> arr, int idx) {
+            this.arrIdx = arrIdx;
+            this.arr = arr;
+            this.idx = idx;
+        }
+
+        /**
+         * @return Value.
+         */
+        public X get() {
+            return arr.get(idx);
+        }
+
+        /**
+         * @param exp Expected.
+         * @param x New value.
+         * @return {@code true} If succeeded.
+         */
+        public boolean cas(@Nullable X exp, @Nullable X x) {
+            return exp == x || arr.compareAndSet(idx, exp, x);
+        }
+
+        /**
+         * @param x value.
+         */
+        private void set(X x) {
+            arr.lazySet(idx, x);
+        }
+    }
+}

Reply via email to