ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [3/4] ignite git commit: ignite-db-10884
Date Wed, 20 Apr 2016 13:02:21 GMT
ignite-db-10884


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

Branch: refs/heads/ignite-db-x-10884
Commit: 3c64b806889557ed4e4da41ea3177c7959e3413a
Parents: 3e88d8b
Author: sboikov <sboikov@gridgain.com>
Authored: Wed Apr 20 13:23:10 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Wed Apr 20 14:58:03 2016 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/internal/IgnitionEx.java  |  11 ++
 .../processors/cache/CacheMetricsImpl.java      |   9 +-
 .../processors/cache/GridCacheAdapter.java      |  17 +-
 .../cache/GridCacheClearAllRunnable.java        |  32 ----
 .../processors/cache/GridCacheContext.java      |  26 +--
 .../processors/cache/GridCacheEntryEx.java      |  13 --
 .../cache/GridCacheEvictionManager.java         |  44 ++---
 .../processors/cache/GridCacheMapEntry.java     | 169 ++-----------------
 .../processors/cache/GridCacheProcessor.java    |  26 +--
 .../processors/cache/GridCacheProxyImpl.java    |  12 --
 .../processors/cache/GridCacheSwapManager.java  |  66 +-------
 .../processors/cache/GridCacheUtils.java        |   4 -
 .../cache/IgniteCacheNoopDatabaseManager.java   |  27 ---
 .../cache/IgniteCacheOffheapManager.java        |  24 ++-
 .../processors/cache/IgniteInternalCache.java   |   8 -
 .../database/IgniteCacheDatabaseManager.java    |  27 ---
 .../IgniteCacheDatabaseSharedManager.java       |   7 -
 .../distributed/dht/GridDhtCacheAdapter.java    |   2 +-
 .../distributed/dht/GridDhtCacheEntry.java      |   2 +-
 .../distributed/dht/GridDhtLocalPartition.java  |   2 +-
 .../distributed/dht/GridDhtTxLocalAdapter.java  |   2 +-
 .../dht/GridPartitionedGetFuture.java           |   2 +-
 .../dht/GridPartitionedSingleGetFuture.java     |   4 +-
 .../dht/atomic/GridDhtAtomicCache.java          |   2 +-
 .../dht/colocated/GridDhtColocatedCache.java    |   2 +-
 .../dht/preloader/GridDhtPartitionDemander.java |   2 +-
 .../dht/preloader/GridDhtPartitionSupplier.java |   8 +-
 .../dht/preloader/GridDhtPreloader.java         |   4 +-
 .../distributed/near/GridNearGetFuture.java     |   2 +-
 .../local/atomic/GridLocalAtomicCache.java      |   7 +-
 .../cache/query/GridCacheQueryManager.java      |  23 +--
 .../transactions/IgniteTxLocalAdapter.java      |   4 +-
 .../cache/transactions/IgniteTxManager.java     |   5 +-
 .../processors/cache/GridCacheTestEntryEx.java  |   6 -
 .../loadtests/hashmap/GridCacheTestContext.java |   1 -
 .../database/IgniteCacheH2DatabaseManager.java  |  97 -----------
 .../processors/query/h2/IgniteH2Indexing.java   |  71 +++++---
 .../IgniteDbSingleNodePutGetSelfTest.java       |   3 +-
 38 files changed, 168 insertions(+), 605 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 193e28e..7b7c8a6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -57,6 +57,7 @@ import org.apache.ignite.compute.ComputeJob;
 import org.apache.ignite.configuration.AtomicConfiguration;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.ConnectorConfiguration;
+import org.apache.ignite.configuration.DatabaseConfiguration;
 import org.apache.ignite.configuration.DeploymentMode;
 import org.apache.ignite.configuration.FileSystemConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
@@ -1897,6 +1898,16 @@ public class IgnitionEx {
 
             initializeDefaultCacheConfiguration(myCfg);
 
+            if (myCfg.getDatabaseConfiguration() == null) {
+                DatabaseConfiguration dbCfg = new DatabaseConfiguration();
+
+                dbCfg.setConcurrencyLevel(Runtime.getRuntime().availableProcessors() * 4);
+                dbCfg.setPageSize(100 * 1024);
+                dbCfg.setPageCacheSize(100 * 1024 * 1024);
+
+                myCfg.setDatabaseConfiguration(dbCfg);
+            }
+
             return myCfg;
         }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
index a60c22b..fd30ea3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheMetricsImpl.java
@@ -150,14 +150,7 @@ public class CacheMetricsImpl implements CacheMetrics {
 
     /** {@inheritDoc} */
     @Override public long getOverflowSize() {
-        try {
-            GridCacheAdapter<?, ?> cache = cctx.cache();
-
-            return cache != null ? cache.overflowSize() : -1;
-        }
-        catch (IgniteCheckedException ignored) {
-            return -1;
-        }
+        return 0;
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 2da297e..b51074a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -1861,7 +1861,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
 
                 final boolean storeEnabled = !skipVals && readThrough && ctx.readThrough();
 
-                final boolean needEntry = storeEnabled || ctx.isSwapOrOffheapEnabled() || ctx.isDatabaseEnabled();
+                final boolean needEntry = storeEnabled || ctx.offheap0().enabled();
 
                 Map<KeyCacheObject, GridCacheVersion> misses = null;
 
@@ -1878,7 +1878,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
 
                         try {
                             T2<CacheObject, GridCacheVersion> res = entry.innerGetVersioned(null,
-                                ctx.isSwapOrOffheapEnabled() || ctx.isDatabaseEnabled(),
+                                ctx.offheap0().enabled(),
                                 /*unmarshal*/true,
                                 /*update-metrics*/!skipVals,
                                 /*event*/!skipVals,
@@ -3458,13 +3458,6 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         return txs.txStartEx(ctx, concurrency, isolation, timeout, txSize).proxy();
     }
 
-    /** {@inheritDoc} */
-    @Override public long overflowSize() throws IgniteCheckedException {
-        GridCacheSwapManager swapMgr = ctx.swap();
-
-        return swapMgr != null ? swapMgr.swapSize() : -1;
-    }
-
     /**
      * Checks if cache is working in JTA transaction and enlist cache as XAResource if necessary.
      *
@@ -4001,7 +3994,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
 
         final CacheOperationContext opCtx = ctx.operationContextPerCall();
 
-        if (!ctx0.isSwapOrOffheapEnabled() && ctx0.kernalContext().discovery().size() == 1)
+        if (!ctx0.isOffHeapEnabled() && ctx0.kernalContext().discovery().size() == 1)
             return localIteratorHonorExpirePolicy(opCtx);
 
         CacheQueryFuture<Map.Entry<K, V>> fut = ctx0.queries().createScanQuery(null, null, ctx.keepBinary())
@@ -4602,7 +4595,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
         try {
             KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
 
-            GridCacheEntryEx entry = ctx.isSwapOrOffheapEnabled() ? entryEx(cacheKey) : peekEx(cacheKey);
+            GridCacheEntryEx entry = ctx.isOffHeapEnabled() ? entryEx(cacheKey) : peekEx(cacheKey);
 
             if (entry != null)
                 return entry.clear(obsoleteVer, readers, null);
@@ -4639,7 +4632,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
 
         GridCacheVersion obsoleteVer = ctx.versions().next();
 
-        if (!ctx.evicts().evictSyncOrNearSync() && ctx.isSwapOrOffheapEnabled()) {
+        if (!ctx.evicts().evictSyncOrNearSync() && ctx.isOffHeapEnabled()) {
             try {
                 ctx.evicts().batchEvict(keys, obsoleteVer);
             }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
index 77c5a55..91310b7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheClearAllRunnable.java
@@ -101,38 +101,6 @@ public class GridCacheClearAllRunnable<K, V> implements Runnable {
                 else if (id == 0)
                     ctx.swap().clearOffHeap();
             }
-
-            if (ctx.isSwapOrOffheapEnabled()) {
-                if (ctx.swap().swapEnabled()) {
-                    if (GridQueryProcessor.isEnabled(ctx.config())) {
-                        Iterator<KeyCacheObject> it = null;
-
-                        try {
-                            it = ctx.swap().swapKeyIterator(true, true, AffinityTopologyVersion.NONE);
-                        }
-                        catch (IgniteCheckedException e) {
-                            U.error(log, "Failed to get iterator over swap.", e);
-                        }
-
-                        if (it != null) {
-                            while (it.hasNext()) {
-                                KeyCacheObject key = it.next();
-
-                                if (owns(key))
-                                    clearEntry(cache.entryEx(key));
-                            }
-                        }
-                    }
-                    else if (id == 0) {
-                        try {
-                            ctx.swap().clearSwap();
-                        }
-                        catch (IgniteCheckedException e) {
-                            U.error(log, "Failed to clearLocally entries from swap storage.", e);
-                        }
-                    }
-                }
-            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index eeaf668..9c7c98f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -56,7 +56,6 @@ import org.apache.ignite.internal.managers.discovery.GridDiscoveryManager;
 import org.apache.ignite.internal.managers.eventstorage.GridEventStorageManager;
 import org.apache.ignite.internal.managers.swapspace.GridSwapSpaceManager;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
-import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseManager;
 import org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheAdapter;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry;
@@ -178,9 +177,6 @@ public class GridCacheContext<K, V> implements Externalizable {
     /** Replication manager. */
     private GridCacheDrManager drMgr;
 
-    /** Database manager. */
-    private IgniteCacheDatabaseManager dbMgr;
-
     /** */
     private IgniteCacheOffheapManager offheapMgr;
 
@@ -303,7 +299,6 @@ public class GridCacheContext<K, V> implements Externalizable {
         CacheDataStructuresManager dataStructuresMgr,
         GridCacheTtlManager ttlMgr,
         GridCacheDrManager drMgr,
-        IgniteCacheDatabaseManager dbMgr,
         IgniteCacheOffheapManager offheapMgr,
         CacheConflictResolutionManager<K, V> rslvrMgr,
         CachePluginManager pluginMgr,
@@ -324,7 +319,7 @@ public class GridCacheContext<K, V> implements Externalizable {
         assert ttlMgr != null;
         assert rslvrMgr != null;
         assert pluginMgr != null;
-        assert dbMgr != null;
+        assert offheapMgr != null;
 
         this.ctx = ctx;
         this.sharedCtx = sharedCtx;
@@ -347,7 +342,6 @@ public class GridCacheContext<K, V> implements Externalizable {
         this.dataStructuresMgr = add(dataStructuresMgr);
         this.ttlMgr = add(ttlMgr);
         this.drMgr = add(drMgr);
-        this.dbMgr = add(dbMgr);
         this.offheapMgr = add(offheapMgr);
         this.rslvrMgr = add(rslvrMgr);
         this.pluginMgr = add(pluginMgr);
@@ -1078,13 +1072,6 @@ public class GridCacheContext<K, V> implements Externalizable {
         return drMgr;
     }
 
-    /**
-     * @return Database manager.
-     */
-    public <T extends IgniteCacheDatabaseManager> T database() {
-        return (T)dbMgr;
-    }
-
     public IgniteCacheOffheapManager offheap0() {
         return offheapMgr;
     }
@@ -1441,21 +1428,22 @@ public class GridCacheContext<K, V> implements Externalizable {
      * @return {@code True} if swap store of off-heap cache are enabled.
      */
     public boolean isSwapOrOffheapEnabled() {
-        return swapMgr.swapEnabled() || isOffHeapEnabled();
+        return isOffHeapEnabled();
     }
 
     /**
      * @return {@code True} if offheap storage is enabled.
      */
     public boolean isOffHeapEnabled() {
-        return swapMgr.offHeapEnabled();
+        return offheapMgr.enabled();
     }
 
     /**
-     * @return If database is enabled.
+     * @return {@code True} if should use offheap (PageMemory) index.
      */
-    public boolean isDatabaseEnabled() {
-        return sharedCtx.database().enabled();
+    public boolean offheapIndex() {
+        // TODO GG-10884.
+        return true;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index ccbaf38..076dfc0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@ -922,19 +922,6 @@ public interface GridCacheEntryEx {
     public void updateTtl(@Nullable GridCacheVersion ver, long ttl);
 
     /**
-     * Tries to do offheap -> swap eviction.
-     *
-     * @param entry Serialized swap entry.
-     * @param evictVer Version when entry was selected for eviction.
-     * @param obsoleteVer Obsolete version.
-     * @throws IgniteCheckedException If failed.
-     * @throws GridCacheEntryRemovedException If entry was removed.
-     * @return {@code True} if entry was obsoleted and written to swap.
-     */
-    public boolean offheapSwapEvict(byte[] entry, GridCacheVersion evictVer, GridCacheVersion obsoleteVer)
-        throws IgniteCheckedException, GridCacheEntryRemovedException;
-
-    /**
      * @return Value.
      * @throws IgniteCheckedException If failed to read from swap storage.
      * @throws GridCacheEntryRemovedException If entry was removed.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index c774821..109167d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -185,7 +185,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
             throw new IgniteCheckedException("Configuration parameter 'evictSynchronizedKeyBufferSize' cannot be negative.");
 
         if (!cctx.isLocal()) {
-            evictSync = cfg.isEvictSynchronized() && !cctx.isNear() && !cctx.isSwapOrOffheapEnabled();
+            evictSync = cfg.isEvictSynchronized() && !cctx.isNear() && !cctx.isOffHeapEnabled();
 
             nearSync = isNearEnabled(cctx) && !cctx.isNear() && cfg.isEvictSynchronized();
         }
@@ -706,7 +706,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
 
         boolean hasVal = recordable && entry.hasValue();
 
-        boolean evicted = entry.evictInternal(cctx.isSwapOrOffheapEnabled(), obsoleteVer, filter);
+        boolean evicted = entry.evictInternal(cctx.isOffHeapEnabled(), obsoleteVer, filter);
 
         if (evicted) {
             // Remove manually evicted entry from policy.
@@ -735,9 +735,6 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
      * @param txEntry Transactional entry.
      */
     public void touch(IgniteTxEntry txEntry, boolean loc) {
-        if (!plcEnabled && memoryMode != OFFHEAP_TIERED && !cctx.isDatabaseEnabled())
-            return;
-
         if (!loc) {
             if (cctx.isNear())
                 return;
@@ -759,20 +756,27 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
             U.error(log, "Failed to evict entry from cache: " + e, ex);
         }
 
-        if (memoryMode == OFFHEAP_TIERED || cctx.isDatabaseEnabled()) {
-            try {
-                evict0(cctx.cache(), e, cctx.versions().next(), null, false);
-            }
-            catch (IgniteCheckedException ex) {
-                U.error(log, "Failed to evict entry from on heap memory: " + e, ex);
-            }
-        }
-        else {
-            notifyPolicy(e);
-
-            if (evictSyncAgr)
-                waitForEvictionFutures();
+        try {
+            evict0(cctx.cache(), e, cctx.versions().next(), null, false);
         }
+        catch (IgniteCheckedException ex) {
+            U.error(log, "Failed to evict entry from on heap memory: " + e, ex);
+        }
+// TODO GG-10884.
+//        if (memoryMode == OFFHEAP_TIERED || cctx.isDatabaseEnabled()) {
+//            try {
+//                evict0(cctx.cache(), e, cctx.versions().next(), null, false);
+//            }
+//            catch (IgniteCheckedException ex) {
+//                U.error(log, "Failed to evict entry from on heap memory: " + e, ex);
+//            }
+//        }
+//        else {
+//            notifyPolicy(e);
+//
+//            if (evictSyncAgr)
+//                waitForEvictionFutures();
+//        }
     }
 
     /**
@@ -791,7 +795,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
             U.error(log, "Failed to evict entry from cache: " + e, ex);
         }
 
-        if (!cctx.isNear() && (memoryMode == OFFHEAP_TIERED || cctx.isDatabaseEnabled())) {
+        if (!cctx.isNear()) {
             try {
                 evict0(cctx.cache(), e, cctx.versions().next(), null, false);
             }
@@ -951,7 +955,7 @@ public class GridCacheEvictionManager extends GridCacheManagerAdapter {
      */
     public void batchEvict(Collection<?> keys, @Nullable GridCacheVersion obsoleteVer) throws IgniteCheckedException {
         assert !evictSyncAgr;
-        assert cctx.isSwapOrOffheapEnabled();
+        assert cctx.isOffHeapEnabled();
 
         List<GridCacheEntryEx> locked = new ArrayList<>(keys.size());
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index f3b296e..6f1799f 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -425,41 +425,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     }
 
     /** {@inheritDoc} */
-    @Override public boolean offheapSwapEvict(byte[] entry, GridCacheVersion evictVer, GridCacheVersion obsoleteVer)
-        throws IgniteCheckedException, GridCacheEntryRemovedException {
-        assert cctx.swap().swapEnabled() && cctx.swap().offHeapEnabled() : this;
-
-        boolean obsolete;
-
-        synchronized (this) {
-            checkObsolete();
-
-            if (hasReaders() || !isStartVersion())
-                return false;
-
-            GridCacheMvcc mvcc = mvccExtras();
-
-            if (mvcc != null && !mvcc.isEmpty(obsoleteVer))
-                return false;
-
-            if (cctx.swap().offheapSwapEvict(key, entry, partition(), evictVer)) {
-                assert !hasValueUnlocked() : this;
-
-                obsolete = markObsolete0(obsoleteVer, false, null);
-
-                assert obsolete : this;
-            }
-            else
-                obsolete = false;
-        }
-
-        if (obsolete)
-            onMarkedObsolete();
-
-        return obsolete;
-    }
-
-    /** {@inheritDoc} */
     @Override public final CacheObject unswap() throws IgniteCheckedException, GridCacheEntryRemovedException {
         return unswap(true);
     }
@@ -550,65 +515,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     }
 
     /**
-     * @throws IgniteCheckedException If failed.
-     */
-    private void swap() throws IgniteCheckedException {
-        if (cctx.isSwapOrOffheapEnabled() && !deletedUnlocked() && hasValueUnlocked() && !detached()) {
-            assert Thread.holdsLock(this);
-
-            long expireTime = expireTimeExtras();
-
-            if (expireTime > 0 && U.currentTimeMillis() >= expireTime) { // Don't swap entry if it's expired.
-                // Entry might have been updated.
-                if (cctx.offheapTiered()) {
-                    cctx.swap().removeOffheap(key);
-
-                    offHeapPointer(0);
-                }
-
-                return;
-            }
-
-            if (cctx.offheapTiered() && hasOffHeapPointer()) {
-                if (log.isDebugEnabled())
-                    log.debug("Value did not change, skip write swap entry: " + this);
-
-                if (cctx.swap().offheapEvictionEnabled())
-                    cctx.swap().enableOffheapEviction(key(), partition());
-
-                return;
-            }
-
-            IgniteUuid valClsLdrId = null;
-            IgniteUuid keyClsLdrId = null;
-
-            if (cctx.deploymentEnabled()) {
-                if (val != null) {
-                    valClsLdrId = cctx.deploy().getClassLoaderId(
-                        U.detectObjectClassLoader(val.value(cctx.cacheObjectContext(), false)));
-                }
-
-                keyClsLdrId = cctx.deploy().getClassLoaderId(
-                    U.detectObjectClassLoader(key.value(cctx.cacheObjectContext(), false)));
-            }
-
-            IgniteBiTuple<byte[], Byte> valBytes = valueBytes0();
-
-            cctx.swap().write(key(),
-                ByteBuffer.wrap(valBytes.get1()),
-                valBytes.get2(),
-                ver,
-                ttlExtras(),
-                expireTime,
-                keyClsLdrId,
-                valClsLdrId);
-
-            if (log.isDebugEnabled())
-                log.debug("Wrote swap entry: " + this);
-        }
-    }
-
-    /**
      * @return Value bytes and flag indicating whether value is byte array.
      */
     protected IgniteBiTuple<byte[], Byte> valueBytes0() {
@@ -634,20 +540,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     }
 
     /**
-     * @throws IgniteCheckedException If failed.
-     */
-    protected final void releaseSwap() throws IgniteCheckedException {
-        if (cctx.isSwapOrOffheapEnabled()) {
-            synchronized (this) {
-                cctx.swap().remove(key());
-            }
-
-            if (log.isDebugEnabled())
-                log.debug("Removed swap entry [entry=" + this + ']');
-        }
-    }
-
-    /**
      * @param tx Transaction.
      * @param key Key.
      * @param reload flag.
@@ -796,10 +688,10 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
                     // If this entry is already expired (expiration time was too low),
                     // we simply remove from swap and clear index.
                     if (expired) {
-                        releaseSwap();
-
                         // Previous value is guaranteed to be null
                         clearIndex(null, ver);
+
+                        cctx.offheap0().remove(key);
                     }
                     else {
                         // Read and remove swap entry.
@@ -1020,8 +912,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
                 // If version matched, set value.
                 if (startVer.equals(ver)) {
-                    releaseSwap();
-
                     CacheObject old = rawGetOrUnmarshalUnlocked(false);
 
                     long expTime = CU.toExpireTime(ttl);
@@ -1045,6 +935,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
                     update(ret, expTime, ttl, nextVer);
 
+                    cctx.offheap0().put(key, ret, nextVer, partition());
+
                     touch = true;
 
                     // If value was set - return, otherwise try again.
@@ -1125,7 +1017,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
             // Load and remove from swap if it is new.
             boolean startVer = isStartVersion();
 
-            if (startVer && (!cctx.isDatabaseEnabled() || retval || intercept))
+            if (startVer && (retval || intercept))
                 unswap(retval);
 
             newVer = explicitVer != null ? explicitVer : tx == null ?
@@ -1308,13 +1200,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
             assert tx == null || (!tx.local() && tx.onePhaseCommit()) || tx.ownsLock(this) :
                 "Transaction does not own lock for remove[entry=" + this + ", tx=" + tx + ']';
 
-            boolean startVer = isStartVersion();
-
-            if (startVer) {
-                // Release swap.
-                releaseSwap();
-            }
-
             newVer = explicitVer != null ? explicitVer : tx == null ? nextVersion() : tx.writeVersion();
 
             old = (retval || intercept) ? rawGetOrUnmarshalUnlocked(!retval) : val;
@@ -2637,8 +2522,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
                 clearIndex(val, ver);
 
-                releaseSwap();
-
                 cctx.offheap0().remove(key);
 
                 ret = true;
@@ -2816,10 +2699,10 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
             ver = newVer;
 
-            releaseSwap();
-
             clearIndex(val, ver);
 
+            cctx.offheap0().remove(key);
+
             onInvalidate();
         }
 
@@ -3143,10 +3026,10 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
                 log.debug("Checked expiration time for entry [timeLeft=" + delta + ", entry=" + this + ']');
 
             if (delta <= 0) {
-                releaseSwap();
-
                 clearIndex(saveValueForIndexUnlocked(), ver);
 
+                cctx.offheap0().remove(key);
+
                 return true;
             }
         }
@@ -3604,7 +3487,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
 
                     clearIndex(expiredVal, ver);
 
-                    releaseSwap();
+                    cctx.offheap0().remove(key);
 
                     if (cctx.events().isRecordable(EVT_CACHE_OBJECT_EXPIRED)) {
                         cctx.events().addEvent(partition(),
@@ -3912,6 +3795,8 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     /** {@inheritDoc} */
     @Override public boolean evictInternal(boolean swap, GridCacheVersion obsoleteVer,
         @Nullable CacheEntryPredicate[] filter) throws IgniteCheckedException {
+        // TODO GG-10884: evictions from offheap are not supported.
+
         boolean marked = false;
 
         try {
@@ -3929,20 +3814,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
                     CacheObject prev = saveOldValueUnlocked(false);
 
                     if (!hasReaders() && markObsolete0(obsoleteVer, false, null)) {
-                        if (swap) {
-                            if (!isStartVersion()) {
-                                try {
-                                    // Write to swap.
-                                    swap();
-                                }
-                                catch (IgniteCheckedException e) {
-                                    U.error(log, "Failed to write entry to swap storage: " + this, e);
-                                }
-                            }
-                        }
-                        else if (!cctx.isDatabaseEnabled())
-                            clearIndex(prev, ver);
-
                         // Nullify value after swap.
                         value(null);
 
@@ -3983,20 +3854,6 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
                         CacheObject prevVal = saveValueForIndexUnlocked();
 
                         if (!hasReaders() && markObsolete0(obsoleteVer, false, null)) {
-                            if (swap) {
-                                if (!isStartVersion()) {
-                                    try {
-                                        // Write to swap.
-                                        swap();
-                                    }
-                                    catch (IgniteCheckedException e) {
-                                        U.error(log, "Failed to write entry to swap storage: " + this, e);
-                                    }
-                                }
-                            }
-                            else if (!cctx.isDatabaseEnabled())
-                                clearIndex(prevVal, ver);
-
                             // Nullify value after swap.
                             value(null);
 
@@ -4052,7 +3909,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     @Override public GridCacheBatchSwapEntry evictInBatchInternal(GridCacheVersion obsoleteVer)
         throws IgniteCheckedException {
         assert Thread.holdsLock(this);
-        assert cctx.isSwapOrOffheapEnabled();
+        assert cctx.isOffHeapEnabled();
         assert !obsolete();
 
         GridCacheBatchSwapEntry ret = null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 21a827d..fe439fd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -77,7 +77,6 @@ import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager;
 import org.apache.ignite.internal.processors.GridProcessorAdapter;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl;
-import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseManager;
 import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
 import org.apache.ignite.internal.processors.cache.datastructures.CacheDataStructuresManager;
 import org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCache;
@@ -1298,11 +1297,12 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         CacheConflictResolutionManager rslvrMgr = pluginMgr.createComponent(CacheConflictResolutionManager.class);
         GridCacheDrManager drMgr = pluginMgr.createComponent(GridCacheDrManager.class);
         CacheStoreManager storeMgr = pluginMgr.createComponent(CacheStoreManager.class);
-        IgniteCacheDatabaseManager dbMgr = createDatabaseManager(cfg);
 
-        boolean cacheIndexing = INDEXING.inClassPath() && GridQueryProcessor.isEnabled(cfg);
+        boolean cacheIndexingEnabled = INDEXING.inClassPath() && GridQueryProcessor.isEnabled(cfg);
 
-        IgniteCacheOffheapManager offheapMgr = new IgniteCacheOffheapManager(cacheIndexing);
+        IgniteCacheOffheapManager offheapMgr = new IgniteCacheOffheapManager(cfg.getCacheMode() == LOCAL ||
+            !GridCacheUtils.isNearEnabled(cfg),
+            cacheIndexingEnabled);
 
         storeMgr.initialize(cfgStore, sesHolders);
 
@@ -1327,7 +1327,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
             dataStructuresMgr,
             ttlMgr,
             drMgr,
-            dbMgr,
             offheapMgr,
             rslvrMgr,
             pluginMgr,
@@ -1432,6 +1431,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
              * ===============================================
              */
             swapMgr = new GridCacheSwapManager(true);
+            offheapMgr = new IgniteCacheOffheapManager(true, cacheIndexingEnabled);
             evictMgr = new GridCacheEvictionManager();
             evtMgr = new GridCacheEventManager();
             pluginMgr = new CachePluginManager(ctx, cfg);
@@ -1458,7 +1458,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 dataStructuresMgr,
                 ttlMgr,
                 drMgr,
-                dbMgr,
                 offheapMgr,
                 rslvrMgr,
                 pluginMgr,
@@ -1519,21 +1518,6 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         return ret;
     }
 
-    private IgniteCacheDatabaseManager createDatabaseManager(CacheConfiguration ccfg) throws IgniteCheckedException {
-        if (sharedCtx.database().enabled() && INDEXING.inClassPath()) {
-            try {
-                return (IgniteCacheDatabaseManager)Class
-                    .forName("org.apache.ignite.internal.processors.cache.database.IgniteCacheH2DatabaseManager")
-                    .newInstance();
-            }
-            catch (Exception e) {
-                throw new IgniteCheckedException(e);
-            }
-        }
-        else
-            return new IgniteCacheNoopDatabaseManager();
-    }
-
     /**
      * Gets a collection of currently started caches.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index 9b4aff3..7219bd7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -172,18 +172,6 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte
     }
 
     /** {@inheritDoc} */
-    @Override public long overflowSize() throws IgniteCheckedException {
-        CacheOperationContext prev = gate.enter(opCtx);
-
-        try {
-            return delegate.overflowSize();
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Override public void localLoadCache(IgniteBiPredicate<K, V> p, @Nullable Object[] args) throws IgniteCheckedException {
         CacheOperationContext prev = gate.enter(opCtx);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index e562559..be45063 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -137,53 +137,6 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
     }
 
     /**
-     *
-     */
-    public void unwindOffheapEvicts() {
-        if (!offheapToSwapEvicts)
-            return;
-
-        Collection<IgniteBiTuple<byte[], byte[]>> evicts = offheapEvicts.get();
-
-        if (evicts != null) {
-            GridCacheVersion obsoleteVer = cctx.versions().next();
-
-            for (IgniteBiTuple<byte[], byte[]> t : evicts) {
-                try {
-                    byte[] kb = t.get1();
-                    byte[] vb = t.get2();
-
-                    GridCacheVersion evictVer = GridCacheSwapEntryImpl.version(vb);
-
-                    KeyCacheObject key = cctx.toCacheKeyObject(kb);
-
-                    while (true) {
-                        GridCacheEntryEx entry = cctx.cache().entryEx(key);
-
-                        try {
-                            if (entry.offheapSwapEvict(vb, evictVer, obsoleteVer))
-                                cctx.cache().removeEntry(entry);
-
-                            break;
-                        }
-                        catch (GridCacheEntryRemovedException ignore) {
-                            // Retry.
-                        }
-                    }
-                }
-                catch (GridDhtInvalidPartitionException e) {
-                    // Skip entry.
-                }
-                catch (IgniteCheckedException e) {
-                    U.error(log, "Failed to unmarshal off-heap entry", e);
-                }
-            }
-
-            offheapEvicts.set(null);
-        }
-    }
-
-    /**
      * Initializes off-heap space.
      */
     private void initOffHeap() {
@@ -259,13 +212,6 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
     }
 
     /**
-     * @return {@code True} if swap store is enabled.
-     */
-    public boolean swapEnabled() {
-        return swapEnabled;
-    }
-
-    /**
      * @return {@code True} if off-heap cache is enabled.
      */
     public boolean offHeapEnabled() {
@@ -1415,15 +1361,15 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
     @Nullable public GridCloseableIterator<Map.Entry<byte[], GridCacheSwapEntry>> iterator(
         final int part)
         throws IgniteCheckedException {
-        if (!swapEnabled() && !offHeapEnabled())
+        if (!offHeapEnabled())
             return null;
 
         checkIteratorQueue();
 
-        if (offHeapEnabled() && !swapEnabled())
+        if (offHeapEnabled())
             return offHeapIterator(part);
 
-        if (swapEnabled() && !offHeapEnabled())
+        if (!offHeapEnabled())
             return swapIterator(part);
 
         // Both, swap and off-heap are enabled.
@@ -1493,15 +1439,15 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
      */
     @Nullable public GridCloseableIterator<Map.Entry<byte[], byte[]>> rawIterator()
         throws IgniteCheckedException {
-        if (!swapEnabled() && !offHeapEnabled())
+        if (!offHeapEnabled())
             return new GridEmptyCloseableIterator<>();
 
         checkIteratorQueue();
 
-        if (offHeapEnabled() && !swapEnabled())
+        if (offHeapEnabled())
             return rawOffHeapIterator(null, true, true);
 
-        if (swapEnabled() && !offHeapEnabled())
+        if (!offHeapEnabled())
             return rawSwapIterator(true, true);
 
         // Both, swap and off-heap are enabled.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
index 8723827..6277c03 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java
@@ -1040,14 +1040,10 @@ public class GridCacheUtils {
 
         ctx.evicts().unwind();
 
-        ctx.swap().unwindOffheapEvicts();
-
         if (ctx.isNear()) {
             GridCacheContext dhtCtx = ctx.near().dht().context();
 
             dhtCtx.evicts().unwind();
-
-            dhtCtx.swap().unwindOffheapEvicts();
         }
 
         ctx.ttl().expire();

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheNoopDatabaseManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheNoopDatabaseManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheNoopDatabaseManager.java
deleted file mode 100644
index ed48b40..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheNoopDatabaseManager.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseManager;
-
-/**
- *
- */
-public class IgniteCacheNoopDatabaseManager extends GridCacheManagerAdapter implements IgniteCacheDatabaseManager {
-
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
index 9c16378..b96446a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteCacheOffheapManager.java
@@ -54,12 +54,17 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
     private CacheDataTree dataTree;
 
     /** */
-    private boolean indexingEnabled;
+    private final boolean enabled;
+
+    /** */
+    private final boolean indexingEnabled;
 
     /**
+     * @param enabled Enabled flag (offheap supposed to be disabled for near cache).
      * @param indexingEnabled {@code True} if indexing is enabled for cache.
      */
-    public IgniteCacheOffheapManager(boolean indexingEnabled) {
+    public IgniteCacheOffheapManager(boolean enabled, boolean indexingEnabled) {
+        this.enabled = enabled;
         this.indexingEnabled = indexingEnabled;
     }
 
@@ -67,7 +72,7 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
     @Override protected void start0() throws IgniteCheckedException {
         super.start0();
 
-        if (!indexingEnabled) {
+        if (enabled && !indexingEnabled) {
             IgniteCacheDatabaseSharedManager dbMgr = cctx.shared().database();
 
             IgniteBiTuple<FullPageId, Boolean> page = dbMgr.meta().getOrAllocateForIndex(cctx.cacheId(), cctx.namexx());
@@ -84,6 +89,13 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
     }
 
     /**
+     * @return Enabled flag.
+     */
+    public boolean enabled() {
+        return enabled;
+    }
+
+    /**
      * @param key Key.
      * @param val Value.
      * @param ver Version.
@@ -91,7 +103,7 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
      * @throws IgniteCheckedException If failed.
      */
     public void put(KeyCacheObject key, CacheObject val, GridCacheVersion ver, int part) throws IgniteCheckedException {
-        if (indexingEnabled)
+        if (!enabled || indexingEnabled)
             return;
 
         DataRow dataRow = new DataRow(key, val, ver, part, 0);
@@ -106,7 +118,7 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
      * @throws IgniteCheckedException If failed.
      */
     public void remove(KeyCacheObject key) throws IgniteCheckedException {
-        if (indexingEnabled)
+        if (!enabled || indexingEnabled)
             return;
 
         DataRow dataRow = dataTree.remove(new KeySearchRow(key));
@@ -126,7 +138,7 @@ public class IgniteCacheOffheapManager extends GridCacheManagerAdapter {
      */
     @Nullable public IgniteBiTuple<CacheObject, GridCacheVersion> read(KeyCacheObject key, int part)
         throws IgniteCheckedException {
-        if (indexingEnabled)
+        if (!enabled || indexingEnabled)
             return cctx.queries().read(key, part);
 
         DataRow dataRow = dataTree.findOne(new KeySearchRow(key));

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
index 68d0f06..962b284 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java
@@ -1557,14 +1557,6 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> {
     public CacheMetricsMXBean mxBean();
 
     /**
-     * Gets size (in bytes) of all entries swapped to disk.
-     *
-     * @return Size (in bytes) of all entries swapped to disk.
-     * @throws IgniteCheckedException In case of error.
-     */
-    public long overflowSize() throws IgniteCheckedException;
-
-    /**
      * Gets number of cache entries stored in off-heap memory.
      *
      * @return Number of cache entries stored in off-heap memory.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseManager.java
deleted file mode 100644
index e38a457..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseManager.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.database;
-
-import org.apache.ignite.internal.processors.cache.GridCacheManager;
-
-/**
- *
- */
-public interface IgniteCacheDatabaseManager extends GridCacheManager {
-    // No-op.
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
index 85de43b..6c7b430 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheDatabaseSharedManager.java
@@ -67,13 +67,6 @@ public class IgniteCacheDatabaseSharedManager extends GridCacheSharedManagerAdap
     }
 
     /**
-     * @return {@code True} if database is enabled.
-     */
-    public boolean enabled() {
-        return cctx.kernalContext().config().getDatabaseConfiguration() != null;
-    }
-
-    /**
      * @return Page memory instance.
      */
     public PageMemory pageMemory() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 5be4e72..671fa61 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -983,7 +983,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
 
         int size = keys.size();
 
-        boolean swap = cache.context().isSwapOrOffheapEnabled();
+        boolean swap = cache.context().isOffHeapEnabled();
 
         for (int i = 0; i < size; i++) {
             try {

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
index 7278f20..8f85304 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheEntry.java
@@ -583,7 +583,7 @@ public class GridDhtCacheEntry extends GridDistributedCacheEntry {
                 update(null, 0L, 0L, ver);
 
                 if (swap) {
-                    releaseSwap();
+                    cctx.offheap0().remove(key);
 
                     if (log.isDebugEnabled())
                         log.debug("Entry has been cleared from swap storage: " + this);

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
index 341b86e..bba2a03 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java
@@ -655,7 +655,7 @@ public class GridDhtLocalPartition implements Comparable<GridDhtLocalPartition>,
     private void clearAll() {
         GridCacheVersion clearVer = cctx.versions().next();
 
-        boolean swap = cctx.isSwapOrOffheapEnabled();
+        boolean swap = cctx.isOffHeapEnabled();
 
         boolean rec = cctx.events().isRecordable(EVT_CACHE_REBALANCE_OBJECT_UNLOADED);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
index 534a560..521b670 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtTxLocalAdapter.java
@@ -584,7 +584,7 @@ public abstract class GridDhtTxLocalAdapter extends IgniteTxLocalAdapter {
                 if (txEntry == null) {
                     GridDhtCacheEntry cached;
 
-                    if (dhtCache.context().isSwapOrOffheapEnabled()) {
+                    if (dhtCache.context().isOffHeapEnabled()) {
                         while (true) {
                             try {
                                 cached = dhtCache.entryExx(key, topVer);

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
index 2c9a760..7e7403e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedGetFuture.java
@@ -439,7 +439,7 @@ public class GridPartitionedGetFuture<K, V> extends CacheDistributedGetFutureAda
             GridCacheEntryEx entry;
 
             try {
-                entry = cache.context().isSwapOrOffheapEnabled() ? cache.entryEx(key) : cache.peekEx(key);
+                entry = cache.context().isOffHeapEnabled() ? cache.entryEx(key) : cache.peekEx(key);
 
                 // If our DHT cache do has value, then we peek it.
                 if (entry != null) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index f928024..c15cd90 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -362,9 +362,7 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
             GridCacheEntryEx entry;
 
             try {
-                entry = colocated.context().isSwapOrOffheapEnabled() || colocated.context().isDatabaseEnabled() ?
-                    colocated.entryEx(key) :
-                    colocated.peekEx(key);
+                entry = colocated.entryEx(key);
 
                 // If our DHT cache do has value, then we peek it.
                 if (entry != null) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index dda7bce..512d8ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -1182,7 +1182,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> {
 
                 while (true) {
                     try {
-                        entry = ctx.isSwapOrOffheapEnabled() ? entryEx(key) : peekEx(key);
+                        entry = ctx.isOffHeapEnabled() ? entryEx(key) : peekEx(key);
 
                         // If our DHT cache do has value, then we peek it.
                         if (entry != null) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
index dc4b6bd..4c9f38b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/colocated/GridDhtColocatedCache.java
@@ -473,7 +473,7 @@ public class GridDhtColocatedCache<K, V> extends GridDhtTransactionalCacheAdapte
 
                 while (true) {
                     try {
-                        entry = ctx.isSwapOrOffheapEnabled() ? entryEx(key) : peekEx(key);
+                        entry = ctx.isOffHeapEnabled() ? entryEx(key) : peekEx(key);
 
                         // If our DHT cache do has value, then we peek it.
                         if (entry != null) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 9634b0b..3ab2efd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -697,7 +697,7 @@ public class GridDhtPartitionDemander {
                                 false, null, null, null, true);
                     }
                     else {
-                        if (cctx.isSwapOrOffheapEnabled())
+                        if (cctx.isOffHeapEnabled())
                             cctx.evicts().touch(cached, topVer); // Start tracking.
 
                         if (log.isDebugEnabled())

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
index 4e33d8e..38e9965 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
@@ -284,7 +284,7 @@ class GridDhtPartitionSupplier {
                 GridCacheEntryInfoCollectSwapListener swapLsnr = null;
 
                 try {
-                    if (phase == SupplyContextPhase.NEW && cctx.isSwapOrOffheapEnabled()) {
+                    if (phase == SupplyContextPhase.NEW && cctx.isOffHeapEnabled()) {
                         swapLsnr = new GridCacheEntryInfoCollectSwapListener(log);
 
                         cctx.swap().addOffHeapListener(part, swapLsnr);
@@ -375,7 +375,7 @@ class GridDhtPartitionSupplier {
                         }
                     }
 
-                    if (phase == SupplyContextPhase.SWAP && cctx.isSwapOrOffheapEnabled()) {
+                    if (phase == SupplyContextPhase.SWAP && cctx.isOffHeapEnabled()) {
                         GridCloseableIterator<Map.Entry<byte[], GridCacheSwapEntry>> iter =
                             sctx != null && sctx.entryIt != null ?
                                 (GridCloseableIterator<Map.Entry<byte[], GridCacheSwapEntry>>)sctx.entryIt :
@@ -785,7 +785,7 @@ class GridDhtPartitionSupplier {
                 GridCacheEntryInfoCollectSwapListener swapLsnr = null;
 
                 try {
-                    if (cctx.isSwapOrOffheapEnabled()) {
+                    if (cctx.isOffHeapEnabled()) {
                         swapLsnr = new GridCacheEntryInfoCollectSwapListener(log);
 
                         cctx.swap().addOffHeapListener(part, swapLsnr);
@@ -836,7 +836,7 @@ class GridDhtPartitionSupplier {
                     if (partMissing)
                         continue;
 
-                    if (cctx.isSwapOrOffheapEnabled()) {
+                    if (cctx.isOffHeapEnabled()) {
                         GridCloseableIterator<Map.Entry<byte[], GridCacheSwapEntry>> iter =
                             cctx.swap().iterator(part);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
index f0054e4..42bdeb9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPreloader.java
@@ -544,7 +544,7 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
 
                 GridCacheEntryEx entry = null;
 
-                if (cctx.isSwapOrOffheapEnabled()) {
+                if (cctx.isOffHeapEnabled()) {
                     while (true) {
                         try {
                             entry = cctx.dht().entryEx(k);
@@ -579,7 +579,7 @@ public class GridDhtPreloader extends GridCachePreloaderAdapter {
                     if (info != null && !info.isNew())
                         res.addInfo(info);
 
-                    if (cctx.isSwapOrOffheapEnabled())
+                    if (cctx.isOffHeapEnabled())
                         cctx.evicts().touch(entry, msg.topologyVersion());
                 }
                 else if (log.isDebugEnabled())

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
index 06fc0a5..3260290 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearGetFuture.java
@@ -563,7 +563,7 @@ public final class GridNearGetFuture<K, V> extends CacheDistributedGetFutureAdap
             GridCacheEntryEx dhtEntry = null;
 
             try {
-                dhtEntry = dht.context().isSwapOrOffheapEnabled() ? dht.entryEx(key) : dht.peekEx(key);
+                dhtEntry = dht.entryEx(key);
 
                 CacheObject v = null;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
index 95919ff..8b929c1 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/atomic/GridLocalAtomicCache.java
@@ -479,7 +479,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
         String taskName = ctx.kernalContext().job().currentTaskName();
 
         Map<K, V> m = getAllInternal(Collections.singleton(key),
-            ctx.isSwapOrOffheapEnabled(),
+            true,
             ctx.readThrough(),
             taskName,
             deserializeBinary,
@@ -500,7 +500,7 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
         String taskName = ctx.kernalContext().job().currentTaskName();
 
         return getAllInternal(keys,
-            ctx.isSwapOrOffheapEnabled(),
+            true,
             ctx.readThrough(),
             taskName,
             deserializeBinary,
@@ -524,12 +524,11 @@ public class GridLocalAtomicCache<K, V> extends GridCacheAdapter<K, V> {
     ) {
         A.notNull(keys, "keys");
 
-        final boolean swapOrOffheap = ctx.isSwapOrOffheapEnabled();
         final boolean storeEnabled = ctx.readThrough();
 
         return asyncOp(new Callable<Map<K, V>>() {
             @Override public Map<K, V> call() throws Exception {
-                return getAllInternal(keys, swapOrOffheap, storeEnabled, taskName, deserializeBinary, skipVals, needVer);
+                return getAllInternal(keys, true, storeEnabled, taskName, deserializeBinary, skipVals, needVer);
             }
         });
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index 50acb08..51f0fca 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -985,7 +985,7 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
 
             final GridIterator<IgniteBiTuple<K, V>> it;
 
-            if (cctx.isSwapOrOffheapEnabled()) {
+            if (cctx.isOffHeapEnabled()) {
                 List<GridIterator<IgniteBiTuple<K, V>>> iters = new ArrayList<>(3);
 
                 iters.add(heapIt);
@@ -993,9 +993,6 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                 if (cctx.isOffHeapEnabled())
                     iters.add(offheapIterator(qry, backups));
 
-                if (cctx.swap().swapEnabled())
-                    iters.add(swapIterator(qry, backups));
-
                 it = new CompoundIterator<>(iters);
             }
             else
@@ -1045,24 +1042,6 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
     /**
      * @param qry Query.
      * @param backups Include backups.
-     * @return Swap iterator.
-     * @throws IgniteCheckedException If failed.
-     */
-    private GridIterator<IgniteBiTuple<K, V>> swapIterator(GridCacheQueryAdapter<?> qry, boolean backups)
-        throws IgniteCheckedException {
-        IgniteBiPredicate<K, V> filter = qry.scanFilter();
-
-        Integer part = qry.partition();
-
-        Iterator<Map.Entry<byte[], byte[]>> it = part == null ? cctx.swap().rawSwapIterator(true, backups) :
-            cctx.swap().rawSwapIterator(part);
-
-        return scanIterator(it, filter, qry.keepBinary());
-    }
-
-    /**
-     * @param qry Query.
-     * @param backups Include backups.
      * @return Offheap iterator.
      */
     private GridIterator<IgniteBiTuple<K, V>> offheapIterator(GridCacheQueryAdapter<?> qry, boolean backups) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index c8435c3..cdec0eb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -1878,7 +1878,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                                     if (needVer) {
                                         T2<CacheObject, GridCacheVersion> res = cached.innerGetVersioned(
                                             IgniteTxLocalAdapter.this,
-                                            /*swap*/cacheCtx.isSwapOrOffheapEnabled(),
+                                            /*swap*/cacheCtx.isOffHeapEnabled(),
                                             /*unmarshal*/true,
                                             /**update-metrics*/true,
                                             /*event*/!skipVals,
@@ -1895,7 +1895,7 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter implements Ig
                                     }
                                     else{
                                         val = cached.innerGet(IgniteTxLocalAdapter.this,
-                                            cacheCtx.isSwapOrOffheapEnabled(),
+                                            cacheCtx.isOffHeapEnabled(),
                                             /*read-through*/false,
                                             /*fail-fast*/true,
                                             /*unmarshal*/true,

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index fed07c0..e847913 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -1435,8 +1435,9 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
                         return false;
                     }
 
-                    if (!cacheCtx.isDatabaseEnabled())
-                        entry1.unswap();
+// TODO GG-10884.
+//                    if (!cacheCtx.isDatabaseEnabled())
+//                        entry1.unswap();
 
                     break;
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index f6eb430..66167f5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@ -850,12 +850,6 @@ public class GridCacheTestEntryEx extends GridMetadataAwareAdapter implements Gr
     }
 
     /** {@inheritDoc} */
-    @Override public boolean offheapSwapEvict(byte[] vb, GridCacheVersion evictVer, GridCacheVersion obsoleteVer)
-        throws IgniteCheckedException, GridCacheEntryRemovedException {
-        return false;
-    }
-
-    /** {@inheritDoc} */
     @Override public CacheObject unswap(boolean needVal) throws IgniteCheckedException {
         return null;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
index 280b250..5474f57 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridCacheTestContext.java
@@ -86,7 +86,6 @@ public class GridCacheTestContext<K, V> extends GridCacheContext<K, V> {
             new GridCacheTtlManager(),
             new GridOsCacheDrManager(),
             null,
-            null,
             new CacheOsConflictResolutionManager<K, V>(),
             new CachePluginManager(ctx, new CacheConfiguration()),
             new GridCacheAffinityManager()

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheH2DatabaseManager.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheH2DatabaseManager.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheH2DatabaseManager.java
deleted file mode 100644
index 72c0c3f..0000000
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/cache/database/IgniteCacheH2DatabaseManager.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache.database;
-
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.pagemem.FullPageId;
-import org.apache.ignite.internal.processors.cache.GridCacheManagerAdapter;
-import org.apache.ignite.internal.processors.query.h2.database.H2RowStore;
-import org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex;
-import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table;
-import org.apache.ignite.lang.IgniteBiTuple;
-import org.h2.index.Index;
-import org.h2.table.IndexColumn;
-
-/**
- *
- */
-public class IgniteCacheH2DatabaseManager extends GridCacheManagerAdapter implements IgniteCacheDatabaseManager {
-    /** Primary index. */
-    private Index primaryIdx;
-
-    /** {@inheritDoc} */
-    @Override protected void start0() throws IgniteCheckedException {
-        super.start0();
-    }
-
-    /**
-     * @param name Index name.
-     * @param tbl Table.
-     * @param pk Primary key flag.
-     * @param keyCol Key column.
-     * @param valCol Value column.
-     * @param cols Columns.
-     * @return Index.
-     */
-    public Index createIndex(
-        String name,
-        GridH2Table tbl,
-        boolean pk,
-        int keyCol,
-        int valCol,
-        IndexColumn[] cols
-    ) throws IgniteCheckedException {
-        IgniteCacheDatabaseSharedManager dbMgr = cctx.shared().database();
-
-        IgniteBiTuple<FullPageId, Boolean> page = dbMgr.meta().getOrAllocateForIndex(cctx.cacheId(), name);
-
-        if (log.isInfoEnabled())
-            log.info("Creating cache index [cacheId=" + cctx.cacheId() + ", idxName=" + name +
-                ", rootPageId=" + page.get1() + ", allocated=" + page.get2() + ']');
-
-        Index idx = new H2TreeIndex(
-            cctx,
-            dbMgr.pageMemory(),
-            page.get1(),
-            page.get2(),
-            keyCol,
-            valCol,
-            tbl,
-            name,
-            pk,
-            cols);
-
-        if (pk) {
-            if (primaryIdx != null)
-                throw new IgniteCheckedException("Primary index already exists for cache " +
-                    "(make sure only one key-value type pair is stored in the cache): " + cctx.name());
-
-            primaryIdx = idx;
-        }
-
-        return idx;
-    }
-
-    /**
-     * @param tbl Table.
-     * @return New row store for the given table.
-     */
-    public H2RowStore createRowStore(GridH2Table tbl) {
-        return new H2RowStore(tbl.rowDescriptor(), cctx, null); // new FreeList(cctx));
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3c64b806/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 7d226ea..463fbeb 100644
--- a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -65,6 +65,7 @@ import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.IgniteInternalFuture;
+import org.apache.ignite.internal.pagemem.FullPageId;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
 import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
 import org.apache.ignite.internal.processors.cache.CacheObject;
@@ -76,7 +77,7 @@ import org.apache.ignite.internal.processors.cache.GridCacheSharedContext;
 import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
 import org.apache.ignite.internal.processors.cache.KeyCacheObject;
 import org.apache.ignite.internal.processors.cache.QueryCursorImpl;
-import org.apache.ignite.internal.processors.cache.database.IgniteCacheH2DatabaseManager;
+import org.apache.ignite.internal.processors.cache.database.IgniteCacheDatabaseSharedManager;
 import org.apache.ignite.internal.processors.cache.query.GridCacheTwoStepQuery;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.processors.query.GridQueryFieldMetadata;
@@ -87,6 +88,7 @@ import org.apache.ignite.internal.processors.query.GridQueryIndexing;
 import org.apache.ignite.internal.processors.query.GridQueryProperty;
 import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
 import org.apache.ignite.internal.processors.query.h2.database.H2RowStore;
+import org.apache.ignite.internal.processors.query.h2.database.H2TreeIndex;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOffheap;
 import org.apache.ignite.internal.processors.query.h2.opt.GridH2KeyValueRowOnheap;
@@ -1981,10 +1983,10 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         @Override public H2RowStore createRowStore(GridH2Table tbl) {
             int cacheId = CU.cacheId(schema.ccfg.getName());
 
-            IgniteCacheH2DatabaseManager dbMgr = databaseManager(cacheId);
+            GridCacheContext cctx = ctx.cache().context().cacheContext(cacheId);
 
-            if (dbMgr != null)
-                return dbMgr.createRowStore(tbl);
+            if (cctx.affinityNode() && cctx.offheapIndex())
+                return new H2RowStore(tbl.rowDescriptor(), cctx, null);
 
             return null;
         }
@@ -2056,18 +2058,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         }
 
         /**
-         * @return Database manager if we are in database mode, {@code null} otherwise.
-         */
-        private IgniteCacheH2DatabaseManager databaseManager(int cacheId) {
-            GridCacheSharedContext<Object,Object> scctx = ctx.cache().context();
-
-            if (scctx.database().enabled() && !ctx.clientNode())
-                return scctx.cacheContext(cacheId).database();
-
-            return null;
-        }
-
-        /**
          * @param name Index name,
          * @param tbl Table.
          * @param pk Primary key flag.
@@ -2086,10 +2076,12 @@ public class IgniteH2Indexing implements GridQueryIndexing {
             IndexColumn... cols
         ) {
             try {
-                IgniteCacheH2DatabaseManager dbMgr = databaseManager(cacheId);
+                GridCacheSharedContext<Object,Object> scctx = ctx.cache().context();
+
+                GridCacheContext cctx = scctx.cacheContext(cacheId);
 
-                if (dbMgr != null)
-                    return dbMgr.createIndex(name, tbl, pk, keyCol, valCol, cols);
+                if (cctx.affinityNode() && cctx.offheapIndex())
+                    return createIndex(cctx, name, tbl, pk, keyCol, valCol, cols);
 
                 return new GridH2TreeIndex(name, tbl, pk, keyCol, valCol, cols);
             }
@@ -2099,6 +2091,45 @@ public class IgniteH2Indexing implements GridQueryIndexing {
         }
 
         /**
+         * @param name Index name.
+         * @param tbl Table.
+         * @param pk Primary key flag.
+         * @param keyCol Key column.
+         * @param valCol Value column.
+         * @param cols Columns.
+         * @return Index.
+         */
+        private Index createIndex(
+            GridCacheContext cctx,
+            String name,
+            GridH2Table tbl,
+            boolean pk,
+            int keyCol,
+            int valCol,
+            IndexColumn[] cols
+        ) throws IgniteCheckedException {
+            IgniteCacheDatabaseSharedManager dbMgr = cctx.shared().database();
+
+            IgniteBiTuple<FullPageId, Boolean> page = dbMgr.meta().getOrAllocateForIndex(cctx.cacheId(), name);
+
+            if (log.isInfoEnabled())
+                log.info("Creating cache index [cacheId=" + cctx.cacheId() + ", idxName=" + name +
+                    ", rootPageId=" + page.get1() + ", allocated=" + page.get2() + ']');
+
+            return new H2TreeIndex(
+                cctx,
+                dbMgr.pageMemory(),
+                page.get1(),
+                page.get2(),
+                keyCol,
+                valCol,
+                tbl,
+                name,
+                pk,
+                cols);
+        }
+
+        /**
          * @param tbl Table.
          * @param idxName Index name.
          * @param cols Columns.
@@ -2527,7 +2558,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
 
             GridCacheContext cctx = cacheContext(schema.spaceName);
 
-            if (cctx.isDatabaseEnabled()) {
+            if (cctx.offheapIndex()) {
                 row.ver = ver;
 
                 row.key = key;


Mime
View raw message