ignite-645 Remove GridCachePeekMode

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

Branch: refs/heads/ignite-645
Commit: dfb4679f912eb226b04c20b29e6e2d6872e95b9f
Parents: 35d05e9
Author: Andrey Gura <ag...@gridgain.com>
Authored: Mon Mar 30 21:57:29 2015 +0300
Committer: Andrey Gura <ag...@gridgain.com>
Committed: Wed Apr 1 11:55:02 2015 +0300

----------------------------------------------------------------------
 .../cache/CacheEvictableEntryImpl.java          |  11 +-
 .../processors/cache/CacheProjection.java       |  36 ---
 .../processors/cache/GridCacheAdapter.java      | 257 +------------------
 .../cache/GridCacheDeploymentManager.java       |   7 +-
 .../processors/cache/GridCacheEntryEx.java      |  42 +--
 .../processors/cache/GridCacheMapEntry.java     | 183 +------------
 .../processors/cache/GridCachePeekMode.java     |  81 ------
 .../cache/GridCacheProjectionImpl.java          |  11 -
 .../processors/cache/GridCacheProxyImpl.java    |  24 --
 .../processors/cache/GridCacheUtils.java        |  11 -
 .../distributed/dht/GridDhtCacheAdapter.java    |   9 +-
 .../dht/atomic/GridDhtAtomicCache.java          |  29 +--
 .../dht/colocated/GridDhtColocatedCache.java    |  45 +---
 .../distributed/near/GridNearCacheAdapter.java  |  54 +---
 .../distributed/near/GridNearTxRemote.java      |  11 +-
 .../processors/task/GridTaskProcessor.java      |   9 +-
 .../resources/META-INF/classnames.properties    |   1 -
 .../GridCachePreloadingEvictionsSelfTest.java   |   4 +-
 .../processors/cache/GridCacheTestEntryEx.java  |  31 +--
 ...GridCacheDhtEvictionNearReadersSelfTest.java |  14 +-
 .../dht/GridCacheDhtEvictionSelfTest.java       |  24 +-
 .../dht/GridCacheDhtMappingSelfTest.java        |   2 +-
 .../near/GridCacheNearMultiNodeSelfTest.java    |  72 ++----
 .../near/GridCacheNearOneNodeSelfTest.java      |  25 +-
 .../near/GridCacheNearReadersSelfTest.java      |  92 +++----
 .../GridCacheReplicatedPreloadSelfTest.java     |  11 +-
 .../processors/igfs/IgfsProcessorSelfTest.java  |   3 +-
 .../processors/igfs/IgfsSizeSelfTest.java       |  46 +---
 .../junits/common/GridCommonAbstractTest.java   |  42 +++
 .../cache/GridIndexingWithNoopSwapSelfTest.java |   2 +-
 30 files changed, 253 insertions(+), 936 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
index 6144807..5d6062e 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEvictableEntryImpl.java
@@ -76,16 +76,18 @@ public class CacheEvictableEntryImpl<K, V> implements 
EvictableEntry<K, V> {
     /**
      * @return Peeks value.
      */
-    @SuppressWarnings("unchecked")
     @Nullable public V peek() {
         try {
-            CacheObject val = cached.peek(GridCachePeekMode.GLOBAL);
+            CacheObject val = cached.peek(true, false, false, null);
 
             return val != null ? 
val.<V>value(cached.context().cacheObjectContext(), false) : null;
         }
         catch (GridCacheEntryRemovedException e) {
             return null;
         }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException(e);
+        }
     }
 
     /** {@inheritDoc} */
@@ -114,13 +116,16 @@ public class CacheEvictableEntryImpl<K, V> implements 
EvictableEntry<K, V> {
                     return null;
 
                 try {
-                    CacheObject val = e.peek(GridCachePeekMode.GLOBAL, 
CU.empty0());
+                    CacheObject val = e.peek(true, false, false, null);
 
                     return val != null ? 
val.<V>value(cached.context().cacheObjectContext(), false) : null;
                 }
                 catch (GridCacheEntryRemovedException ignored) {
                     // No-op.
                 }
+                catch (IgniteCheckedException ex) {
+                    throw new IgniteException(ex);
+                }
             }
         }
         catch (GridCacheFilterFailedException ignored) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
index 0ff316d..b17fdac 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
@@ -336,23 +336,6 @@ public interface CacheProjection<K, V> extends 
Iterable<Cache.Entry<K, V>> {
     public IgniteInternalFuture<V> reloadAsync(K key);
 
     /**
-     * Peeks at in-memory cached value using default {@link 
GridCachePeekMode#SMART}
-     * peek mode.
-     * <p>
-     * This method will not load value from any persistent store or from a 
remote node.
-     * <h2 class="header">Transactions</h2>
-     * This method does not participate in any transactions, however, it will
-     * peek at transactional value according to the {@link 
GridCachePeekMode#SMART} mode
-     * semantics. If you need to look at global cached value even from within 
transaction,
-     * you can use {@link GridCache#peek(Object, Collection)} method.
-     *
-     * @param key Entry key.
-     * @return Peeked value.
-     * @throws NullPointerException If key is {@code null}.
-     */
-    @Nullable public V peek(K key);
-
-    /**
      * @param key Key.
      * @param peekModes Peek modes.
      * @param plc Expiry policy if TTL should be updated.
@@ -370,25 +353,6 @@ public interface CacheProjection<K, V> extends 
Iterable<Cache.Entry<K, V>> {
     public Iterable<Cache.Entry<K, V>> localEntries(CachePeekMode[] peekModes) 
throws IgniteCheckedException;
 
     /**
-     * Peeks at cached value using optional set of peek modes. This method 
will sequentially
-     * iterate over given peek modes in the order passed in, and try to peek 
at value using
-     * each peek mode. Once a {@code non-null} value is found, it will be 
immediately returned.
-     * <p>
-     * Note that if modes are not provided this method works exactly the same 
way as
-     * {@link #peek(Object)}, implicitly using {@link GridCachePeekMode#SMART} 
mode.
-     * <h2 class="header">Transactions</h2>
-     * This method does not participate in any transactions, however, it may
-     * peek at transactional value depending on the peek modes used.
-     *
-     * @param key Entry key.
-     * @param modes Optional set of peek modes.
-     * @return Peeked value.
-     * @throws IgniteCheckedException If peek operation failed.
-     * @throws NullPointerException If key is {@code null}.
-     */
-    @Nullable public V peek(K key, @Nullable Collection<GridCachePeekMode> 
modes) throws IgniteCheckedException;
-
-    /**
      * Retrieves value mapped to the specified key from cache. Value will only 
be returned if
      * its entry passed the optional filter provided. Filter check is atomic, 
and therefore the
      * returned value is guaranteed to be consistent with the filter. The 
return value of {@code null}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/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 02429b3..e749af7 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
@@ -59,11 +59,9 @@ import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.locks.*;
 
-import static java.util.Collections.*;
 import static org.apache.ignite.IgniteSystemProperties.*;
 import static org.apache.ignite.events.EventType.*;
 import static org.apache.ignite.internal.GridClosureCallMode.*;
-import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*;
 import static org.apache.ignite.internal.processors.dr.GridDrType.*;
 import static 
org.apache.ignite.internal.processors.task.GridTaskThreadContextKey.*;
 import static org.apache.ignite.transactions.TransactionConcurrency.*;
@@ -820,219 +818,6 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
         return null;
     }
 
-    /** {@inheritDoc} */
-    @Override public V peek(K key) {
-        return peek(key, (CacheEntryPredicate)null);
-    }
-
-    /** {@inheritDoc} */
-    @Override public V peek(K key, @Nullable Collection<GridCachePeekMode> 
modes) throws IgniteCheckedException {
-        return peek0(key, modes, ctx.tm().localTxx());
-    }
-
-    /**
-     * @param failFast Fail fast flag.
-     * @param key Key.
-     * @param mode Peek mode.
-     * @param filter Filter.
-     * @return Peeked value.
-     * @throws GridCacheFilterFailedException If filter failed.
-     */
-    @Nullable protected GridTuple<V> peek0(boolean failFast, K key, 
GridCachePeekMode mode,
-        @Nullable CacheEntryPredicate... filter) throws 
GridCacheFilterFailedException {
-        A.notNull(key, "key");
-
-        if (keyCheck)
-            validateCacheKey(key);
-
-        ctx.checkSecurity(GridSecurityPermission.CACHE_READ);
-
-        GridCacheEntryEx e = null;
-
-        try {
-            KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
-
-            e = peekEx(cacheKey);
-
-            if (e != null) {
-                GridTuple<CacheObject> peek = e.peek0(failFast, mode, filter, 
ctx.tm().localTxx());
-
-                if (peek != null) {
-                    CacheObject v = peek.get();
-
-                    Object val0 = CU.value(v, ctx, true);
-
-                    val0 = ctx.unwrapPortableIfNeeded(val0, 
ctx.keepPortable());
-
-                    return F.t((V)val0);
-                }
-            }
-
-            IgniteInternalTx tx = ctx.tm().localTx();
-
-            if (tx != null) {
-                GridTuple<CacheObject> peek = tx.peek(ctx, failFast, cacheKey, 
filter);
-
-                if (peek != null) {
-                    CacheObject v = peek.get();
-
-                    Object val0 = CU.value(v, ctx, true);
-
-                    val0 = ctx.unwrapPortableIfNeeded(val0, 
ctx.keepPortable());
-
-                    return F.t((V)val0);
-                }
-            }
-
-            return null;
-        }
-        catch (GridCacheEntryRemovedException ignore) {
-            if (log.isDebugEnabled())
-                log.debug("Got removed entry during 'peek': " + e);
-
-            return null;
-        }
-        catch (IgniteCheckedException ex) {
-            throw new IgniteException(ex);
-        }
-    }
-
-    /**
-     * @param key Key.
-     * @param modes Peek modes.
-     * @param tx Transaction to peek at (if modes contains TX value).
-     * @return Peeked value.
-     * @throws IgniteCheckedException In case of error.
-     */
-    @Nullable protected V peek0(K key, @Nullable Collection<GridCachePeekMode> 
modes, IgniteInternalTx tx)
-        throws IgniteCheckedException {
-        try {
-            GridTuple<V> peek = peek0(false, key, modes, tx);
-
-            return peek != null ? peek.get() : null;
-        }
-        catch (GridCacheFilterFailedException ex) {
-            ex.printStackTrace();
-
-            assert false; // Should never happen.
-
-            return null;
-        }
-    }
-
-    /**
-     * @param failFast If {@code true}, then filter failure will result in 
exception.
-     * @param key Key.
-     * @param modes Peek modes.
-     * @param tx Transaction to peek at (if modes contains TX value).
-     * @return Peeked value.
-     * @throws IgniteCheckedException In case of error.
-     * @throws GridCacheFilterFailedException If filer validation failed.
-     */
-    @Nullable protected GridTuple<V> peek0(boolean failFast, K key, @Nullable 
Collection<GridCachePeekMode> modes,
-        IgniteInternalTx tx) throws IgniteCheckedException, 
GridCacheFilterFailedException {
-        if (F.isEmpty(modes))
-            return F.t(peek(key, (CacheEntryPredicate)null));
-
-        assert modes != null;
-
-        A.notNull(key, "key");
-
-        if (keyCheck)
-            validateCacheKey(key);
-
-        ctx.checkSecurity(GridSecurityPermission.CACHE_READ);
-
-        KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
-
-        GridCacheEntryEx e = peekEx(cacheKey);
-
-        try {
-            for (GridCachePeekMode m : modes) {
-                GridTuple<CacheObject> val = null;
-
-                if (e != null)
-                    val = e.peek0(failFast, m, null, tx);
-                else if (m == TX || m == SMART)
-                    val = tx != null ? tx.peek(ctx, failFast, cacheKey, null) 
: null;
-                else if (m == SWAP)
-                    val = peekSwap(cacheKey);
-                else if (m == DB) {
-                    Object v = peekDb(cacheKey);
-
-                    if (v != null)
-                        return new GridTuple<>((V)v);
-                }
-
-                if (val != null)
-                    return F.t(CU.<V>value(val.get(), ctx, true));
-            }
-        }
-        catch (GridCacheEntryRemovedException ignore) {
-            if (log.isDebugEnabled())
-                log.debug("Got removed entry during 'peek': " + e);
-        }
-
-        return null;
-    }
-
-    /**
-     * @param key Key to read from swap storage.
-     * @return Value from swap storage.
-     * @throws IgniteCheckedException In case of any errors.
-     */
-    @Nullable private GridTuple<CacheObject> peekSwap(KeyCacheObject key) 
throws IgniteCheckedException {
-        GridCacheSwapEntry e = ctx.swap().read(key, true, true);
-
-        return e != null ? F.t(e.value()) : null;
-    }
-
-    /**
-     * @param key Key to read from persistent store.
-     * @return Value from persistent store.
-     * @throws IgniteCheckedException In case of any errors.
-     */
-    @Nullable private Object peekDb(KeyCacheObject key) throws 
IgniteCheckedException {
-        return ctx.store().loadFromStore(ctx.tm().localTxx(), key);
-    }
-
-    /**
-     * @param keys Keys.
-     * @param modes Modes.
-     * @param tx Transaction.
-     * @param skipped Keys skipped during filter validation.
-     * @return Peeked values.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected Map<K, V> peekAll0(@Nullable Collection<? extends K> keys, 
@Nullable Collection<GridCachePeekMode> modes,
-        IgniteInternalTx tx, @Nullable Collection<K> skipped) throws 
IgniteCheckedException {
-        if (F.isEmpty(keys))
-            return emptyMap();
-
-        if (keyCheck)
-            validateCacheKeys(keys);
-
-        Map<K, V> ret = new HashMap<>(keys.size(), 1.0f);
-
-        for (K k : keys) {
-            try {
-                GridTuple<V> val = peek0(skipped != null, k, modes, tx);
-
-                if (val != null)
-                    ret.put(k, val.get());
-            }
-            catch (GridCacheFilterFailedException ignored) {
-                if (log.isDebugEnabled())
-                    log.debug("Filter validation failed for key: " + k);
-
-                if (skipped != null)
-                    skipped.add(k);
-            }
-        }
-
-        return ret;
-    }
-
     /**
      * Undeploys and removes all entries for class loader.
      *
@@ -1688,17 +1473,10 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
                                         if (set || wasNew)
                                             map.put(key, cacheVal);
                                         else {
-                                            try {
-                                                GridTuple<CacheObject> v = 
entry.peek0(false, GLOBAL, null, null);
+                                            CacheObject v = entry.peek(true, 
false, false, null);
 
-                                                if (v != null)
-                                                    map.put(key, v.get());
-                                            }
-                                            catch 
(GridCacheFilterFailedException ex) {
-                                                ex.printStackTrace();
-
-                                                assert false;
-                                            }
+                                            if (v != null)
+                                                map.put(key, v);
                                         }
                                     }
 
@@ -1807,8 +1585,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
 
         if (ctx.config().getInterceptor() != null)
             fut =  fut.chain(new CX1<IgniteInternalFuture<V>, V>() {
-                @Override
-                public V applyx(IgniteInternalFuture<V> f) throws 
IgniteCheckedException {
+                @Override public V applyx(IgniteInternalFuture<V> f) throws 
IgniteCheckedException {
                     return (V)ctx.config().getInterceptor().onGet(key, 
f.get());
                 }
             });
@@ -2450,7 +2227,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
 
         return syncOp(new SyncOp<Map<K, EntryProcessorResult<T>>>(keys.size() 
== 1) {
             @Nullable @Override public Map<K, EntryProcessorResult<T>> 
op(IgniteTxLocalAdapter tx)
-                    throws IgniteCheckedException {
+                throws IgniteCheckedException {
                 Map<? extends K, EntryProcessor<K, V, Object>> invokeMap = 
F.viewAsMap(keys,
                         new C1<K, EntryProcessor<K, V, Object>>() {
                             @Override public EntryProcessor apply(K k) {
@@ -4756,26 +4533,6 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
     }
 
     /**
-     * @param key Key.
-     * @param filter Filter to evaluate.
-     * @return Peeked value.
-     */
-    public V peek(K key, @Nullable CacheEntryPredicate filter) {
-        try {
-            GridTuple<V> peek = peek0(false, key, SMART, filter);
-
-            return peek != null ? peek.get() : null;
-        }
-        catch (GridCacheFilterFailedException e) {
-            e.printStackTrace();
-
-            assert false; // Should never happen.
-
-            return null;
-        }
-    }
-
-    /**
      * @param filter Filters to evaluate.
      * @return Entry set.
      */
@@ -5170,9 +4927,7 @@ public abstract class GridCacheAdapter<K, V> implements 
GridCache<K, V>,
             modes.swap = true;
         }
         else {
-            for (int i = 0; i < peekModes.length; i++) {
-                CachePeekMode peekMode = peekModes[i];
-
+            for (CachePeekMode peekMode : peekModes) {
                 A.notNull(peekMode, "peekMode");
 
                 switch (peekMode) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
index ee17893..8273b24 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheDeploymentManager.java
@@ -211,8 +211,7 @@ public class GridCacheDeploymentManager<K, V> extends 
GridCacheSharedManagerAdap
                 undeploys.put(ctx.name(), queue = new ArrayList<>());
 
             queue.add(new CA() {
-                @Override
-                public void apply() {
+                @Override public void apply() {
                     onUndeploy0(ldr, ctx);
                 }
             });
@@ -310,7 +309,7 @@ public class GridCacheDeploymentManager<K, V> extends 
GridCacheSharedManagerAdap
         Object val0;
 
         try {
-            CacheObject v = entry.peek(GridCachePeekMode.GLOBAL, CU.empty0());
+            CacheObject v = entry.peek(true, false, false, null);
 
             key0 = key.value(cache.context().cacheObjectContext(), false);
 
@@ -321,7 +320,7 @@ public class GridCacheDeploymentManager<K, V> extends 
GridCacheSharedManagerAdap
         catch (GridCacheEntryRemovedException ignore) {
             return false;
         }
-        catch (IgniteException ignore) {
+        catch (IgniteCheckedException | IgniteException ignore) {
             // Peek can throw runtime exception if unmarshalling failed.
             return true;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/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 10176d9..adeb95b 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
@@ -561,17 +561,6 @@ public interface GridCacheEntryEx {
     /**
      * Peeks into entry without loading value or updating statistics.
      *
-     * @param mode Peek mode.
-     * @param filter Optional filter.
-     * @return Value.
-     * @throws GridCacheEntryRemovedException If entry has been removed.
-     */
-    @Nullable public CacheObject peek(GridCachePeekMode mode, 
CacheEntryPredicate... filter)
-        throws GridCacheEntryRemovedException;
-
-    /**
-     * Peeks into entry without loading value or updating statistics.
-     *
      * @param heap Read from heap flag.
      * @param offheap Read from offheap flag.
      * @param swap Read from swap flag.
@@ -591,30 +580,19 @@ public interface GridCacheEntryEx {
     /**
      * Peeks into entry without loading value or updating statistics.
      *
-     * @param modes Peek modes.
-     * @param filter Optional filter.
+     * @param heap Heap.
+     * @param offheap Offheap.
+     * @param swap Swap.
+     * @param plc Policy.
      * @return Value.
      * @throws GridCacheEntryRemovedException If entry has been removed.
+     * @throws IgniteCheckedException If failed.
      */
-    @Nullable public CacheObject peek(Collection<GridCachePeekMode> modes,
-        CacheEntryPredicate... filter) throws GridCacheEntryRemovedException;
-
-    /**
-     * @param failFast Fail-fast flag.
-     * @param mode Peek mode.
-     * @param filter Filter.
-     * @param tx Transaction to peek value at (if mode is TX value).
-     * @return Peeked value.
-     * @throws IgniteCheckedException In case of error.
-     * @throws GridCacheEntryRemovedException If removed.
-     * @throws GridCacheFilterFailedException If filter failed.
-     */
-    @SuppressWarnings({"RedundantTypeArguments"})
-    @Nullable public GridTuple<CacheObject> peek0(boolean failFast,
-        GridCachePeekMode mode,
-        @Nullable CacheEntryPredicate[] filter,
-        @Nullable IgniteInternalTx tx)
-        throws GridCacheEntryRemovedException, GridCacheFilterFailedException, 
IgniteCheckedException;
+    @Nullable public CacheObject peek(boolean heap,
+        boolean offheap,
+        boolean swap,
+        @Nullable IgniteCacheExpiryPolicy plc)
+        throws GridCacheEntryRemovedException, IgniteCheckedException;
 
     /**
      * This method overwrites current in-memory value with new value.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/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 58ff57f..14fa2f7 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
@@ -47,7 +47,6 @@ import java.util.concurrent.atomic.*;
 
 import static org.apache.ignite.events.EventType.*;
 import static org.apache.ignite.internal.processors.dr.GridDrType.*;
-import static org.apache.ignite.transactions.TransactionState.*;
 
 /**
  * Adapter for cache entry.
@@ -2755,25 +2754,6 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public CacheObject peek(GridCachePeekMode mode,
-        CacheEntryPredicate[] filter)
-        throws GridCacheEntryRemovedException {
-        try {
-            GridTuple<CacheObject> peek = peek0(false, mode, filter, 
cctx.tm().localTxx());
-
-            return peek != null ? peek.get() : null;
-        }
-        catch (GridCacheFilterFailedException ignore) {
-            assert false;
-
-            return null;
-        }
-        catch (IgniteCheckedException e) {
-            throw new IgniteException("Unable to perform entry peek() 
operation.", e);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Nullable @Override public CacheObject peek(boolean heap,
         boolean offheap,
         boolean swap,
@@ -2807,88 +2787,17 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
     }
 
     /** {@inheritDoc} */
-    @Override public CacheObject peek(Collection<GridCachePeekMode> modes,
-        CacheEntryPredicate[] filter)
-        throws GridCacheEntryRemovedException {
-        assert modes != null;
-
-        for (GridCachePeekMode mode : modes) {
-            try {
-                GridTuple<CacheObject> val = peek0(false, mode, filter, 
cctx.tm().localTxx());
-
-                if (val != null)
-                    return val.get();
-            }
-            catch (GridCacheFilterFailedException ignored) {
-                assert false;
-
-                return null;
-            }
-            catch (IgniteCheckedException e) {
-                throw new IgniteException("Unable to perform entry peek() 
operation.", e);
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * @param failFast Fail-fast flag.
-     * @param mode Peek mode.
-     * @param filter Filter.
-     * @param tx Transaction to peek value at (if mode is TX value).
-     * @return Peeked value.
-     * @throws IgniteCheckedException In case of error.
-     * @throws GridCacheEntryRemovedException If removed.
-     * @throws GridCacheFilterFailedException If filter failed.
-     */
-    @SuppressWarnings({"RedundantTypeArguments"})
-    @Nullable @Override public GridTuple<CacheObject> peek0(boolean failFast, 
GridCachePeekMode mode,
-        CacheEntryPredicate[] filter, @Nullable IgniteInternalTx tx)
-        throws GridCacheEntryRemovedException, GridCacheFilterFailedException, 
IgniteCheckedException {
-        assert tx == null || tx.local();
+    @Nullable @Override public CacheObject peek(
+        boolean heap,
+        boolean offheap,
+        boolean swap,
+        @Nullable IgniteCacheExpiryPolicy plc)
+        throws GridCacheEntryRemovedException, IgniteCheckedException {
+        IgniteInternalTx tx = cctx.tm().localTxx();
 
         AffinityTopologyVersion topVer = tx != null ? tx.topologyVersion() : 
cctx.affinity().affinityTopologyVersion();
 
-        switch (mode) {
-            case TX:
-                return peekTx(failFast, filter, tx);
-
-            case GLOBAL:
-                return peekGlobal(failFast, topVer, filter, null);
-
-            case NEAR_ONLY:
-                return peekGlobal(failFast, topVer, filter, null);
-
-            case PARTITIONED_ONLY:
-                return peekGlobal(failFast, topVer, filter, null);
-
-            case SMART:
-                /*
-                 * If there is no ongoing transaction, or transaction is NOT 
in ACTIVE state,
-                 * which means that it is either rolling back, preparing to 
commit, or committing,
-                 * then we only check the global cache storage because value 
has already been
-                 * validated against filter and enlisted into transaction and, 
therefore, second
-                 * validation against the same enlisted value will be invalid 
(it will always be false).
-                 *
-                 * However, in ACTIVE state, we must also validate against 
other values that
-                 * may have enlisted into the same transaction and that's why 
we pass 'true'
-                 * to 'e.peek(true)' method in this case.
-                 */
-                return tx == null || tx.state() != ACTIVE ? 
peekGlobal(failFast, topVer, filter, null) :
-                    peekTxThenGlobal(failFast, filter, tx);
-
-            case SWAP:
-                return peekSwap(failFast, filter);
-
-            case DB:
-                return F.t(peekDb(failFast, filter));
-
-            default: // Should never be reached.
-                assert false;
-
-                return null;
-        }
+        return peek(heap, offheap, swap, topVer, plc);
     }
 
     /** {@inheritDoc} */
@@ -2952,31 +2861,6 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
      * @param tx Transaction to peek value at (if mode is TX value).
      * @return Peeked value.
      * @throws GridCacheFilterFailedException If filter failed.
-     * @throws GridCacheEntryRemovedException If entry got removed.
-     * @throws IgniteCheckedException If unexpected cache failure occurred.
-     */
-    @Nullable private GridTuple<CacheObject> peekTxThenGlobal(boolean failFast,
-        CacheEntryPredicate[] filter,
-        IgniteInternalTx tx)
-        throws GridCacheFilterFailedException, GridCacheEntryRemovedException, 
IgniteCheckedException
-    {
-        GridTuple<CacheObject> peek = peekTx(failFast, filter, tx);
-
-        // If transaction has value (possibly null, which means value is to be 
deleted).
-        if (peek != null)
-            return peek;
-
-        AffinityTopologyVersion topVer = tx == null ? 
cctx.affinity().affinityTopologyVersion() : tx.topologyVersion();
-
-        return peekGlobal(failFast, topVer, filter, null);
-    }
-
-    /**
-     * @param failFast Fail fast flag.
-     * @param filter Filter.
-     * @param tx Transaction to peek value at (if mode is TX value).
-     * @return Peeked value.
-     * @throws GridCacheFilterFailedException If filter failed.
      */
     @Nullable private GridTuple<CacheObject> peekTx(boolean failFast,
         CacheEntryPredicate[] filter,
@@ -3043,52 +2927,6 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
     }
 
     /**
-     * @param failFast Fail fast flag.
-     * @param filter Filter.
-     * @return Value from swap storage.
-     * @throws IgniteCheckedException In case of any errors.
-     * @throws GridCacheFilterFailedException If filter failed.
-     */
-    @SuppressWarnings({"unchecked"})
-    @Nullable private GridTuple<CacheObject> peekSwap(boolean failFast,
-        CacheEntryPredicate[] filter)
-        throws IgniteCheckedException, GridCacheFilterFailedException
-    {
-        if (!cctx.isAll(this, filter))
-            return F.t(CU.failed(failFast));
-
-        synchronized (this) {
-            if (checkExpired())
-                return null;
-        }
-
-        GridCacheSwapEntry e = cctx.swap().read(this, false, true, true);
-
-        return e != null ? F.t(e.value()) : null;
-    }
-
-    /**
-     * @param failFast Fail fast flag.
-     * @param filter Filter.
-     * @return Value from persistent store.
-     * @throws IgniteCheckedException In case of any errors.
-     * @throws GridCacheFilterFailedException If filter failed.
-     */
-    @SuppressWarnings({"unchecked"})
-    @Nullable private CacheObject peekDb(boolean failFast, 
CacheEntryPredicate[] filter)
-        throws IgniteCheckedException, GridCacheFilterFailedException {
-        if (!cctx.isAll(this, filter))
-            return CU.failed(failFast);
-
-        synchronized (this) {
-            if (checkExpired())
-                return null;
-        }
-
-        return 
cctx.toCacheObject(cctx.store().loadFromStore(cctx.tm().localTxx(), key));
-    }
-
-    /**
      * TODO: GG-4009: do we need to generate event and invalidate value?
      *
      * @return {@code true} if expired.
@@ -3790,11 +3628,14 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
                     return null;
 
                 try {
-                    return e.peek(GridCachePeekMode.GLOBAL, CU.empty0());
+                    return e.peek(true, false, false, null);
                 }
                 catch (GridCacheEntryRemovedException ignored) {
                     // No-op.
                 }
+                catch (IgniteCheckedException ex) {
+                    throw new IgniteException(ex);
+                }
             }
         }
         catch (GridCacheFilterFailedException ignored) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePeekMode.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePeekMode.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePeekMode.java
deleted file mode 100644
index 0aef1ee..0000000
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCachePeekMode.java
+++ /dev/null
@@ -1,81 +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.jetbrains.annotations.*;
-
-/**
- * Enumeration of all supported cache peek modes. Peek modes can be passed 
into various
- * {@code 'CacheProjection.peek(..)'} and {@code Entry.peek(..)} methods.
- * <p>
- * The following modes are supported:
- * <ul>
- * <li>{@link #TX}</li>
- * <li>{@link #GLOBAL}</li>
- * <li>{@link #SMART}</li>
- * <li>{@link #SWAP}</li>
- * <li>{@link #DB}</li>
- * </ul>
- */
-public enum GridCachePeekMode {
-    /** Peeks value only from in-transaction memory of an ongoing transaction, 
if any. */
-    TX,
-
-    /** Peeks at cache global (not in-transaction) memory. */
-    GLOBAL,
-
-    /**
-     * In this mode value is peeked from in-transaction memory first using 
{@link #TX}
-     * mode and then, if it has not been found there, {@link #GLOBAL} mode is 
used to
-     * search in committed cached values.
-     */
-    SMART,
-
-    /** Peeks value only from off-heap or cache swap storage without loading 
swapped value into cache. */
-    SWAP,
-
-    /** Peek value from the underlying persistent storage without loading this 
value into cache. */
-    DB,
-
-    /**
-     * Peek value from near cache only (don't peek from partitioned cache).
-     * In case of {@link org.apache.ignite.cache.CacheMode#LOCAL} or {@link 
org.apache.ignite.cache.CacheMode#REPLICATED} cache,
-     * behaves as {@link #GLOBAL} mode.
-     */
-    NEAR_ONLY,
-
-    /**
-     * Peek value from partitioned cache only (skip near cache).
-     * In case of {@link org.apache.ignite.cache.CacheMode#LOCAL} or {@link 
org.apache.ignite.cache.CacheMode#REPLICATED} cache,
-     * behaves as {@link #GLOBAL} mode.
-     */
-    PARTITIONED_ONLY;
-
-    /** Enumerated values. */
-    private static final GridCachePeekMode[] VALS = values();
-
-    /**
-     * Efficiently gets enumerated value from its ordinal.
-     *
-     * @param ord Ordinal value.
-     * @return Enumerated value or {@code null} if ordinal out of range.
-     */
-    @Nullable public static GridCachePeekMode fromOrdinal(byte ord) {
-        return ord >= 0 && ord < VALS.length ? VALS[ord] : null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
index 53d353f..9730c39 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
@@ -25,7 +25,6 @@ import org.apache.ignite.internal.processors.cache.dr.*;
 import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.internal.processors.cache.transactions.*;
 import org.apache.ignite.internal.processors.cache.version.*;
-import org.apache.ignite.internal.util.future.*;
 import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -584,11 +583,6 @@ public class GridCacheProjectionImpl<K, V> implements 
GridCacheProjectionEx<K, V
     }
 
     /** {@inheritDoc} */
-    @Override public V peek(K key) {
-        return cache.peek(key);
-    }
-
-    /** {@inheritDoc} */
     @Nullable @Override public V localPeek(K key,
         CachePeekMode[] peekModes,
         @Nullable IgniteCacheExpiryPolicy plc)
@@ -603,11 +597,6 @@ public class GridCacheProjectionImpl<K, V> implements 
GridCacheProjectionEx<K, V
     }
 
     /** {@inheritDoc} */
-    @Override public V peek(K key, @Nullable Collection<GridCachePeekMode> 
modes) throws IgniteCheckedException {
-        return cache.peek(key, modes);
-    }
-
-    /** {@inheritDoc} */
     @Nullable @Override public Cache.Entry<K, V> entry(K key) {
         return cache.entry(key);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/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 d2a561a..2e8449e 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
@@ -1123,18 +1123,6 @@ public class GridCacheProxyImpl<K, V> implements 
GridCacheProxy<K, V>, Externali
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public V peek(K key) {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.peek(key);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Nullable @Override public V localPeek(K key,
         CachePeekMode[] peekModes,
         @Nullable IgniteCacheExpiryPolicy plc)
@@ -1163,18 +1151,6 @@ public class GridCacheProxyImpl<K, V> implements 
GridCacheProxy<K, V>, Externali
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public V peek(K key, @Nullable 
Collection<GridCachePeekMode> modes) throws IgniteCheckedException {
-        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
-
-        try {
-            return delegate.peek(key, modes);
-        }
-        finally {
-            gate.leave(prev);
-        }
-    }
-
-    /** {@inheritDoc} */
     @Nullable @Override public Cache.Entry<K, V> entry(K key) {
         GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/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 8f48d3d..8c72bc2 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
@@ -56,7 +56,6 @@ import static 
org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
 import static org.apache.ignite.internal.GridTopic.*;
 import static org.apache.ignite.internal.IgniteNodeAttributes.*;
 import static org.apache.ignite.internal.processors.cache.GridCacheOperation.*;
-import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*;
 
 /**
  * Cache utility methods.
@@ -77,9 +76,6 @@ public class GridCacheUtils {
     /** Default mask name. */
     private static final String DEFAULT_MASK_NAME = "<default>";
 
-    /** Peek flags. */
-    private static final GridCachePeekMode[] PEEK_FLAGS = new 
GridCachePeekMode[] { GLOBAL, SWAP };
-
     /** TTL: minimum positive value. */
     public static final long TTL_MINIMUM = 1L;
 
@@ -1026,13 +1022,6 @@ public class GridCacheUtils {
     }
 
     /**
-     * @return Peek flags.
-     */
-    public static GridCachePeekMode[] peekFlags() {
-        return PEEK_FLAGS;
-    }
-
-    /**
      * @param log Logger.
      * @param excl Excludes.
      * @return Future listener that logs errors.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/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 6c27566..475fea6 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
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache.distributed.dht;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.affinity.*;
@@ -874,8 +875,12 @@ public abstract class GridDhtCacheAdapter<K, V> extends 
GridDistributedCacheAdap
 
             Cache.Entry<K, V> entry = (Cache.Entry<K, V>)o;
 
-            return partId == ctx.affinity().partition(entry.getKey()) &&
-                F.eq(entry.getValue(), peek(entry.getKey()));
+            try {
+                return partId == ctx.affinity().partition(entry.getKey()) &&
+                    F.eq(entry.getValue(), localPeek(entry.getKey(), new 
CachePeekMode[] {CachePeekMode.ONHEAP}, null));
+            } catch (IgniteCheckedException e) {
+                throw new IgniteException(e);
+            }
         }
 
         /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/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 c376fa0..2d7f58f 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
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache.distributed.dht.atomic;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.cluster.*;
@@ -33,7 +34,6 @@ import org.apache.ignite.internal.processors.cache.version.*;
 import org.apache.ignite.internal.processors.timeout.*;
 import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.future.*;
-import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -56,7 +56,6 @@ import static org.apache.ignite.IgniteSystemProperties.*;
 import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*;
 import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*;
 import static org.apache.ignite.internal.processors.cache.GridCacheOperation.*;
-import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*;
 import static org.apache.ignite.internal.processors.cache.GridCacheUtils.*;
 import static org.apache.ignite.internal.processors.dr.GridDrType.*;
 
@@ -254,27 +253,11 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
 
     /** {@inheritDoc} */
     @Override public Cache.Entry<K, V> entry(K key) throws 
GridDhtInvalidPartitionException {
-        return new CacheEntryImpl<>(key, peek(key));
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("ConstantConditions")
-    @Override public V peek(K key, @Nullable Collection<GridCachePeekMode> 
modes) throws IgniteCheckedException {
-        GridTuple<V> val = null;
-
-        if (ctx.isReplicated() || !modes.contains(NEAR_ONLY)) {
-            try {
-                val = peek0(true, key, modes, ctx.tm().txx());
-            }
-            catch (GridCacheFilterFailedException ignored) {
-                if (log.isDebugEnabled())
-                    log.debug("Filter validation failed for key: " + key);
-
-                return null;
-            }
+        try {
+            return new CacheEntryImpl<>(key, localPeek(key, new 
CachePeekMode[] {CachePeekMode.ONHEAP}, null));
+        } catch (IgniteCheckedException e) {
+            throw new IgniteException(e);
         }
-
-        return val != null ? val.get() : null;
     }
 
     /** {@inheritDoc} */
@@ -1783,8 +1766,6 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                 if (hasNear) {
                     if (primary && updRes.sendToDht()) {
                         if (!ctx.affinity().belongs(node, entry.partition(), 
topVer)) {
-                            GridCacheVersionConflictContext ctx = 
updRes.conflictResolveResult();
-
                             // If put the same value as in request then do not 
need to send it back.
                             if (op == TRANSFORM || writeVal != 
updRes.newValue()) {
                                 res.addNearValue(i,

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/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 eb6d9a6..8d4f153 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
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache.distributed.dht.colocated;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.processors.affinity.*;
@@ -28,7 +29,6 @@ import 
org.apache.ignite.internal.processors.cache.distributed.near.*;
 import org.apache.ignite.internal.processors.cache.transactions.*;
 import org.apache.ignite.internal.processors.cache.version.*;
 import org.apache.ignite.internal.util.future.*;
-import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.plugin.security.*;
@@ -39,8 +39,6 @@ import javax.cache.*;
 import java.io.*;
 import java.util.*;
 
-import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*;
-
 /**
  * Colocated cache.
  */
@@ -82,14 +80,13 @@ public class GridDhtColocatedCache<K, V> extends 
GridDhtTransactionalCacheAdapte
         map.setEntryFactory(new GridCacheMapEntryFactory() {
             /** {@inheritDoc} */
             @Override public GridCacheMapEntry create(GridCacheContext ctx,
-                AffinityTopologyVersion topVer,
-                KeyCacheObject key,
-                int hash,
-                CacheObject val,
-                GridCacheMapEntry next,
-                long ttl,
-                int hdrId)
-            {
+                                                      AffinityTopologyVersion 
topVer,
+                                                      KeyCacheObject key,
+                                                      int hash,
+                                                      CacheObject val,
+                                                      GridCacheMapEntry next,
+                                                      long ttl,
+                                                      int hdrId) {
                 return new GridDhtColocatedCacheEntry(ctx, topVer, key, hash, 
val, next, ttl, hdrId);
             }
         });
@@ -134,25 +131,6 @@ public class GridDhtColocatedCache<K, V> extends 
GridDhtTransactionalCacheAdapte
     }
 
     /** {@inheritDoc} */
-    @Override public V peek(K key, @Nullable Collection<GridCachePeekMode> 
modes) throws IgniteCheckedException {
-        GridTuple<V> val = null;
-
-        if (!modes.contains(NEAR_ONLY)) {
-            try {
-                val = peek0(true, key, modes, ctx.tm().txx());
-            }
-            catch (GridCacheFilterFailedException ignored) {
-                if (log.isDebugEnabled())
-                    log.debug("Filter validation failed for key: " + key);
-
-                return null;
-            }
-        }
-
-        return val != null ? val.get() : null;
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean isLocked(K key) {
         KeyCacheObject cacheKey = ctx.toCacheKeyObject(key);
 
@@ -410,7 +388,12 @@ public class GridDhtColocatedCache<K, V> extends 
GridDhtTransactionalCacheAdapte
 
     /** {@inheritDoc} */
     @Override public Cache.Entry<K, V> entry(K key) throws 
GridDhtInvalidPartitionException {
-        return new CacheEntryImpl<>(key, peek(key));
+        try {
+            return new CacheEntryImpl<>(key, localPeek(key, new 
CachePeekMode[] {CachePeekMode.ONHEAP}, null));
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException(e);
+        }
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
index 75c8978..241af05 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheAdapter.java
@@ -27,7 +27,6 @@ import 
org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.transactions.*;
 import org.apache.ignite.internal.processors.cache.version.*;
 import org.apache.ignite.internal.util.future.*;
-import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
@@ -38,8 +37,6 @@ import javax.cache.expiry.*;
 import java.io.*;
 import java.util.*;
 
-import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*;
-
 /**
  * Common logic for near caches.
  */
@@ -443,7 +440,11 @@ public abstract class GridNearCacheAdapter<K, V> extends 
GridDistributedCacheAda
     @Override public Cache.Entry<K, V> entry(K key) {
         // We don't try wrap entry from near or dht cache.
         // Created object will be wrapped once some method is called.
-        return new CacheEntryImpl<>(key, peek(key));
+        try {
+            return new CacheEntryImpl<>(key, localPeek(key, new 
CachePeekMode[] {CachePeekMode.ONHEAP}, null));
+        } catch (IgniteCheckedException e) {
+            throw new IgniteException(e);
+        }
     }
 
     /**
@@ -454,11 +455,9 @@ public abstract class GridNearCacheAdapter<K, V> extends 
GridDistributedCacheAda
      */
     @Nullable public V peekNearOnly(K key) {
         try {
-            GridTuple<V> peek = peek0(true, key, SMART, CU.empty0());
-
-            return peek != null ? peek.get() : null;
+            return localPeek(key, new CachePeekMode[] {CachePeekMode.ONHEAP}, 
null);
         }
-        catch (GridCacheFilterFailedException ignored) {
+        catch (IgniteCheckedException ignored) {
             if (log.isDebugEnabled())
                 log.debug("Filter validation failed for key: " + key);
 
@@ -467,45 +466,6 @@ public abstract class GridNearCacheAdapter<K, V> extends 
GridDistributedCacheAda
     }
 
     /** {@inheritDoc} */
-    @Override public V peek(K key, @Nullable CacheEntryPredicate filter) {
-        try {
-            GridTuple<V> res = peek0(false, key, SMART, filter);
-
-            if (res != null)
-                return res.get();
-        }
-        catch (GridCacheFilterFailedException e) {
-            e.printStackTrace();
-
-            assert false : "Filter should not fail since fail-fast is false";
-        }
-
-        return dht().peek(key, filter);
-    }
-
-    /** {@inheritDoc} */
-    @Override public V peek(K key, @Nullable Collection<GridCachePeekMode> 
modes) throws IgniteCheckedException {
-        GridTuple<V> val = null;
-
-        if (!modes.contains(PARTITIONED_ONLY)) {
-            try {
-                val = peek0(true, key, modes, ctx.tm().txx());
-            }
-            catch (GridCacheFilterFailedException ignored) {
-                if (log.isDebugEnabled())
-                    log.debug("Filter validation failed for key: " + key);
-
-                return null;
-            }
-        }
-
-        if (val != null)
-            return val.get();
-
-        return !modes.contains(NEAR_ONLY) ? dht().peek(key, modes) : null;
-    }
-
-    /** {@inheritDoc} */
     @Override public boolean clearLocally0(K key, @Nullable 
CacheEntryPredicate[] filter) {
         return super.clearLocally0(key, filter) | dht().clearLocally0(key, 
filter);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
index 9969f65..8c597e2 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTxRemote.java
@@ -26,15 +26,12 @@ import 
org.apache.ignite.internal.processors.cache.version.*;
 import org.apache.ignite.internal.util.*;
 import org.apache.ignite.internal.util.tostring.*;
 import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.transactions.*;
 import org.jetbrains.annotations.*;
 
 import java.io.*;
 import java.util.*;
 
-import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*;
-
 /**
  * Transaction created by system implicitly on remote nodes.
  */
@@ -296,7 +293,9 @@ public class GridNearTxRemote extends 
GridDistributedTxRemoteAdapter {
             cached.unswap();
 
             try {
-                if (cached.peek(GLOBAL, CU.empty0()) == null && 
cached.evictInternal(false, xidVer, null)) {
+                CacheObject val = cached.peek(true, false, false, null);
+
+                if (val == null && cached.evictInternal(false, xidVer, null)) {
                     evicted.add(entry.txKey());
 
                     return false;
@@ -350,7 +349,9 @@ public class GridNearTxRemote extends 
GridDistributedTxRemoteAdapter {
             else {
                 cached.unswap();
 
-                if (cached.peek(GLOBAL, CU.empty0()) == null && 
cached.evictInternal(false, xidVer, null)) {
+                CacheObject peek = cached.peek(true, false, false, null);
+
+                if (peek == null && cached.evictInternal(false, xidVer, null)) 
{
                     cached.context().cache().removeIfObsolete(key.key());
 
                     evicted.add(key);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
index 9eac084..4add987 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/task/GridTaskProcessor.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.task;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.compute.*;
 import org.apache.ignite.events.*;
@@ -343,7 +344,13 @@ public class GridTaskProcessor extends 
GridProcessorAdapter {
 
         assert ctx.security().enabled();
 
-        return tasksMetaCache.peek(new GridTaskNameHashKey(taskNameHash));
+        try {
+            return tasksMetaCache.localPeek(
+                new GridTaskNameHashKey(taskNameHash), new CachePeekMode[] 
{CachePeekMode.ONHEAP}, null);
+        }
+        catch (IgniteCheckedException e) {
+            throw new IgniteException(e);
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/main/resources/META-INF/classnames.properties
----------------------------------------------------------------------
diff --git a/modules/core/src/main/resources/META-INF/classnames.properties 
b/modules/core/src/main/resources/META-INF/classnames.properties
index ccc6aae..21cc7a3 100644
--- a/modules/core/src/main/resources/META-INF/classnames.properties
+++ b/modules/core/src/main/resources/META-INF/classnames.properties
@@ -381,7 +381,6 @@ 
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$3
 org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$4
 
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeFutureSet
 
org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$MessageHandler
-org.apache.ignite.internal.processors.cache.GridCachePeekMode
 org.apache.ignite.internal.processors.cache.GridCacheProcessor$2
 org.apache.ignite.internal.processors.cache.GridCacheProcessor$3
 org.apache.ignite.internal.processors.cache.GridCacheProcessor$4

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java
index 3624b58..89646e9 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCachePreloadingEvictionsSelfTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cache.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
@@ -95,7 +96,6 @@ public class GridCachePreloadingEvictionsSelfTest extends 
GridCommonAbstractTest
     /**
      * @throws Exception If failed.
      */
-    @SuppressWarnings("BusyWait")
     public void testEvictions() throws Exception {
         try {
             final Ignite ignite1 = startGrid(1);
@@ -240,7 +240,7 @@ public class GridCachePreloadingEvictionsSelfTest extends 
GridCommonAbstractTest
             ", s2=" + cache2.size() + ']';
 
         for (Integer key : cache1.keySet()) {
-            Object e = cache1.peek(key);
+            Object e = cache1.localPeek(key, new CachePeekMode[] 
{CachePeekMode.ONHEAP}, null);
 
             if (e != null)
                 assert cache2.containsKey(key) : "Cache2 does not contain key: 
" + key;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/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 1d86984..9bdde1b 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
@@ -24,7 +24,6 @@ import 
org.apache.ignite.internal.processors.cache.transactions.*;
 import org.apache.ignite.internal.processors.cache.version.*;
 import org.apache.ignite.internal.processors.dr.*;
 import org.apache.ignite.internal.util.lang.*;
-import org.apache.ignite.internal.util.typedef.*;
 import org.jetbrains.annotations.*;
 
 import javax.cache.*;
@@ -607,25 +606,6 @@ public class GridCacheTestEntryEx extends 
GridMetadataAwareAdapter implements Gr
         return ver;
     }
 
-    /** @inheritDoc */
-    @Override public CacheObject peek(GridCachePeekMode mode, 
CacheEntryPredicate[] filter) {
-        return val;
-    }
-
-    /** @inheritDoc */
-    @Override public GridTuple<CacheObject> peek0(boolean failFast, 
GridCachePeekMode mode,
-        CacheEntryPredicate[] filter, IgniteInternalTx tx)
-        throws GridCacheEntryRemovedException, GridCacheFilterFailedException, 
IgniteCheckedException {
-        return F.t(val);
-    }
-
-    /** @inheritDoc */
-    @Override public CacheObject peek(Collection<GridCachePeekMode> modes,
-        CacheEntryPredicate[] filter)
-        throws GridCacheEntryRemovedException {
-        return val;
-    }
-
     /** {@inheritDoc} */
     @Override public CacheObject poke(CacheObject val) throws 
GridCacheEntryRemovedException, IgniteCheckedException {
         CacheObject old = this.val;
@@ -859,4 +839,15 @@ public class GridCacheTestEntryEx extends 
GridMetadataAwareAdapter implements Gr
     {
         return null;
     }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public CacheObject peek(
+        boolean heap,
+        boolean offheap,
+        boolean swap,
+        @Nullable IgniteCacheExpiryPolicy plc)
+        throws GridCacheEntryRemovedException, IgniteCheckedException {
+        return null;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
index cf1882a..99b95ce 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
@@ -256,7 +256,7 @@ public class GridCacheDhtEvictionNearReadersSelfTest 
extends GridCommonAbstractT
         assert entryPrimary != null;
         assert entryBackup != null;
 
-        assertEquals(val, nearOther.peek(key));
+        assertEquals(val, localPeek(nearOther, key));
 
         assertTrue(!entryPrimary.readers().isEmpty());
 
@@ -268,13 +268,13 @@ public class GridCacheDhtEvictionNearReadersSelfTest 
extends GridCommonAbstractT
         futBackup.get(3000);
         futPrimary.get(3000);
 
-        assertNull(dhtPrimary.peek(key));
-        assertNull(nearPrimary.peek(key));
+        assertNull(localPeek(dhtPrimary, key));
+        assertNull(localPeek(nearPrimary, key));
 
-        assertNull(dhtBackup.peek(key));
-        assertNull(nearBackup.peek(key));
+        assertNull(localPeek(dhtBackup, key));
+        assertNull(localPeek(nearBackup, key));
 
-        assertNull(dhtOther.peek(key));
-        assertNull(nearOther.peek(key));
+        assertNull(localPeek(dhtOther, key));
+        assertNull(localPeek(nearOther, key));
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionSelfTest.java
index 3b16864..39ef872 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtEvictionSelfTest.java
@@ -210,11 +210,11 @@ public class GridCacheDhtEvictionSelfTest extends 
GridCommonAbstractTest {
         // Put on primary node.
         nearPrimary.put(key, val, null);
 
-        assertEquals(val, nearPrimary.peek(key));
-        assertEquals(val, dhtPrimary.peek(key));
+        assertEquals(val, localPeek(nearPrimary, key));
+        assertEquals(val, localPeek(dhtPrimary, key));
 
-        assertEquals(val, nearBackup.peek(key));
-        assertEquals(val, dhtBackup.peek(key));
+        assertEquals(val, localPeek(nearBackup, key));
+        assertEquals(val, localPeek(dhtBackup, key));
 
         GridDhtCacheEntry entryPrimary = 
(GridDhtCacheEntry)dhtPrimary.peekEx(key);
         GridDhtCacheEntry entryBackup = 
(GridDhtCacheEntry)dhtBackup.peekEx(key);
@@ -281,11 +281,11 @@ public class GridCacheDhtEvictionSelfTest extends 
GridCommonAbstractTest {
         for (Integer key : keys) {
             String val = "v" + key;
 
-            assertEquals(val, nearPrimary.peek(key));
-            assertEquals(val, dhtPrimary.peek(key));
+            assertEquals(val, localPeek(nearPrimary, key));
+            assertEquals(val, localPeek(dhtPrimary, key));
 
-            assertEquals(val, nearBackup.peek(key));
-            assertEquals(val, dhtBackup.peek(key));
+            assertEquals(val, localPeek(nearBackup, key));
+            assertEquals(val, localPeek(dhtBackup, key));
         }
 
         final AtomicInteger cntBackup = new AtomicInteger();
@@ -324,8 +324,8 @@ public class GridCacheDhtEvictionSelfTest extends 
GridCommonAbstractTest {
         for (Integer key : keys) {
             String msg = "Failed key: " + key;
 
-            assertNull(msg, nearBackup.peek(key));
-            assertNull(msg, dhtBackup.peek(key));
+            assertNull(msg, localPeek(nearBackup, key));
+            assertNull(msg, localPeek(dhtBackup, key));
             assertNull(msg, nearBackup.peekEx(key));
             assertNull(msg, dhtBackup.peekEx(key));
         }
@@ -333,8 +333,8 @@ public class GridCacheDhtEvictionSelfTest extends 
GridCommonAbstractTest {
         for (Integer key : keys) {
             String msg = "Failed key: " + key;
 
-            assertNull(msg, nearPrimary.peek(key));
-            assertNull(msg, dhtPrimary.peek(key));
+            assertNull(msg, localPeek(nearPrimary, key));
+            assertNull(msg, localPeek(dhtPrimary, key));
             assertNull(msg, nearPrimary.peekEx(key));
             assertNull(dhtPrimary.peekEx(key));
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMappingSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMappingSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMappingSelfTest.java
index 682a321..bf8a27b 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMappingSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtMappingSelfTest.java
@@ -90,7 +90,7 @@ public class GridCacheDhtMappingSelfTest extends 
GridCommonAbstractTest {
             GridDhtCacheAdapter<Integer, Integer> dht = 
((GridNearCacheAdapter<Integer, Integer>)
                 ((IgniteKernal)g).<Integer, Integer>internalCache()).dht();
 
-            if (dht.peek(kv) != null) {
+            if (localPeek(dht, kv) != null) {
                 info("Key found on node: " + g.cluster().localNode().id());
 
                 cnt++;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
index b3b04e0..8a9816d 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
@@ -44,7 +44,6 @@ import java.util.concurrent.locks.*;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.*;
 import static org.apache.ignite.cache.CacheMode.*;
-import static org.apache.ignite.internal.processors.cache.GridCachePeekMode.*;
 import static org.apache.ignite.transactions.TransactionConcurrency.*;
 import static org.apache.ignite.transactions.TransactionIsolation.*;
 
@@ -186,15 +185,6 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
     }
 
     /**
-     * @param g Grid.
-     * @return Dht cache.
-     */
-    @SuppressWarnings({"unchecked", "TypeMayBeWeakened"})
-    private GridNearCacheAdapter<Integer, String> near(Ignite g) {
-        return (GridNearCacheAdapter)((IgniteKernal)g).internalCache();
-    }
-
-    /**
      * @param idx Index.
      * @return Affinity.
      */
@@ -359,7 +349,7 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
 
             GridCacheAdapter<Integer, String> dhtCache = dht(G.ignite(n.id()));
 
-            String s = dhtCache.peek(key);
+            String s = dhtCache.localPeek(key, new CachePeekMode[] 
{CachePeekMode.ONHEAP}, null);
 
             assert s != null : "Value is null for key: " + key;
             assertEquals(s, Integer.toString(key));
@@ -392,7 +382,7 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
                 if (entry != null)
                     assertNull("Unexpected entry: " + entry, 
entry.rawGetOrUnmarshal(false));
 
-                assertNotNull(dht(primaryGrid(3)).peek(3));
+                assertNotNull(localPeek(dht(primaryGrid(3)), 3));
 
                 tx.commit();
             }
@@ -409,8 +399,8 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
         assertEquals("2", near.localPeek(2, CachePeekMode.ONHEAP));
         assertEquals("3", near.localPeek(3, CachePeekMode.ONHEAP));
 
-        assertEquals("2", dht(primaryGrid(2)).peek(2));
-        assertEquals("3", dht(primaryGrid(3)).peek(3));
+        assertEquals("2", localPeek(dht(primaryGrid(2)), 2));
+        assertEquals("3", localPeek(dht(primaryGrid(3)), 3));
 
         assertEquals(2, near.localSize());
         assertEquals(2, near.localSize());
@@ -425,7 +415,7 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
         assertEquals("2", near.localPeek(2, CachePeekMode.ONHEAP));
         assertEquals("2", near.get(2));
 
-        assertEquals("2", dht(primaryGrid(2)).peek(2));
+        assertEquals("2", localPeek(dht(primaryGrid(2)), 2));
 
         assertEquals(1, near.localSize());
         assertEquals(1, near.localSize());
@@ -454,7 +444,7 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
 
         info("Primary grid for key 3: " + 
U.toShortString(primaryIgnite.cluster().localNode()));
 
-        assertEquals("3", dht(primaryIgnite).peek(3));
+        assertEquals("3", localPeek(dht(primaryIgnite), 3));
 
         assertEquals(1, near.localSize());
         assertEquals(1, near.localSize());
@@ -469,7 +459,7 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
         for (Ignite b : backups) {
             info("Backup grid for key 3: " + 
U.toShortString(b.cluster().localNode()));
 
-            assertEquals("3", dht(b).peek(3));
+            assertEquals("3", localPeek(dht(b), 3));
 
             assertEquals(1, dht(b).size());
         }
@@ -492,8 +482,8 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
         assertEquals("2", near.get(2));
         assertEquals("3", near.get(3));
 
-        assertEquals("2", dht(primaryGrid(2)).peek(2));
-        assertEquals("3", dht(primaryGrid(3)).peek(3));
+        assertEquals("2", localPeek(dht(primaryGrid(2)), 2));
+        assertEquals("3", localPeek(dht(primaryGrid(3)), 3));
 
         assertEquals(2, near.localSize());
         assertEquals(2, near.localSize());
@@ -519,7 +509,7 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
                 assertEquals("2", near.get(2));
                 assertEquals("3", near.get(3));
 
-                assertNotNull(dht(primaryGrid(3)).peek(3, F.asList(GLOBAL)));
+                assertNotNull(dht(primaryGrid(3)).localPeek(3, new 
CachePeekMode[] {CachePeekMode.ONHEAP}, null));
 
                 tx.commit();
             }
@@ -536,8 +526,8 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
         assertEquals("2", near.localPeek(2, CachePeekMode.ONHEAP));
         assertEquals("3", near.localPeek(3, CachePeekMode.ONHEAP));
 
-        assertEquals("2", dht(primaryGrid(2)).peek(2));
-        assertEquals("3", dht(primaryGrid(3)).peek(3));
+        assertEquals("2", localPeek(dht(primaryGrid(2)), 2));
+        assertEquals("3", localPeek(dht(primaryGrid(3)), 3));
 
         assertEquals(2, near.localSize());
         assertEquals(2, near.localSize());
@@ -604,8 +594,8 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
         assertNull(near0.peekNearOnly(key));
         assertNull(near1.peekNearOnly(key));
 
-        assertEquals(val, dht0.peek(key));
-        assertEquals(val, dht1.peek(key));
+        assertEquals(val, localPeek(dht0, key));
+        assertEquals(val, localPeek(dht1, key));
     }
 
     /** @throws Exception If failed. */
@@ -688,8 +678,8 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
             assertTrue("Invalid near entry [hash=" + nearEntry2, 
nearEntry2.valid(topVer));
 
             assertEquals(val, cache.localPeek(key, CachePeekMode.ONHEAP));
-            assertEquals(val, dht(0).peek(key));
-            assertEquals(val, dht(1).peek(key));
+            assertEquals(val, dhtPeek(0, key));
+            assertEquals(val, dhtPeek(1, key));
 
             GridNearCacheEntry nearEntry3 = nearEntry(0, key);
 
@@ -707,7 +697,7 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
             assertEquals(val, cache.getAndRemove(key));
 
             assertNull(cache.localPeek(key, CachePeekMode.ONHEAP));
-            assertNull(dht(primaryGrid(key)).peek(key));
+            assertNull(localPeek(dht(primaryGrid(key)), key));
 
             assertTrue(cache.isLocalLocked(key, false));
             assertTrue(cache.isLocalLocked(key, true));
@@ -753,7 +743,7 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
             near.put(key, val);
 
             assertEquals(val, near.localPeek(key, CachePeekMode.ONHEAP));
-            assertEquals(val, dht(primaryGrid(key)).peek(key));
+            assertEquals(val, localPeek(dht(primaryGrid(key)), key));
 
             assertTrue(near.isLocalLocked(key, false));
             assertTrue(near.isLocalLocked(key, true));
@@ -765,7 +755,7 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
                 assertEquals(val, near.getAndRemove(key));
 
                 assertNull(near.localPeek(key, CachePeekMode.ONHEAP));
-                assertNull(dht(primaryGrid(key)).peek(key));
+                assertNull(localPeek(dht(primaryGrid(key)), key));
 
                 assertTrue(near.isLocalLocked(key, false));
                 assertTrue(near.isLocalLocked(key, true));
@@ -811,8 +801,8 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
 
         cache.put(key, val);
 
-        assertEquals(val, dht(0).peek(key));
-        assertEquals(val, dht(1).peek(key));
+        assertEquals(val, dhtPeek(0, key));
+        assertEquals(val, dhtPeek(1, key));
 
         assertNull(near(0).peekNearOnly(key));
         assertNull(near(1).peekNearOnly(key));
@@ -829,8 +819,8 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
         else
             assertEquals(val, cache.get(key));
 
-        assertEquals(val, dht(0).peek(key));
-        assertEquals(val, dht(1).peek(key));
+        assertEquals(val, dhtPeek(0, key));
+        assertEquals(val, dhtPeek(1, key));
 
         assertNull(near(0).peekNearOnly(key));
         assertNull(near(1).peekNearOnly(key));
@@ -857,8 +847,8 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
 
         cache.put(key, val);
 
-        assertEquals(val, dht(0).peek(key));
-        assertEquals(val, dht(1).peek(key));
+        assertEquals(val, dhtPeek(0, key));
+        assertEquals(val, dhtPeek(1, key));
 
         assertNull(near(0).peekNearOnly(key));
         assertNull(near(1).peekNearOnly(key));
@@ -882,8 +872,8 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
             assertTrue(cache.remove(key));
         }
 
-        assertNull(dht(0).peek(key));
-        assertNull(dht(1).peek(key));
+        assertNull(dhtPeek(0, key));
+        assertNull(dhtPeek(1, key));
 
         assertNull(near(0).peekNearOnly(key));
         assertNull(near(1).peekNearOnly(key));
@@ -926,14 +916,6 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
             return map.get(key);
         }
 
-        /**
-         * @param key Key.
-         * @return {@code True} if has value.
-         */
-        boolean hasValue(Integer key) {
-            return map.containsKey(key);
-        }
-
         /** @return {@code True} if empty. */
         boolean isEmpty() {
             return map.isEmpty();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/dfb4679f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
index d361d91..3cc4e01 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearOneNodeSelfTest.java
@@ -27,7 +27,6 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.junits.common.*;
 import org.apache.ignite.transactions.*;
 
-import javax.cache.configuration.*;
 import java.util.concurrent.*;
 import java.util.concurrent.locks.*;
 
@@ -132,7 +131,7 @@ public class GridCacheNearOneNodeSelfTest extends 
GridCommonAbstractTest {
         assertEquals(1, near.size());
         assertEquals(1, near.size());
 
-        String d = dht.peek(1);
+        String d = localPeek(dht, 1);
 
         assert d != null;
         assertEquals(d, "1");
@@ -163,7 +162,6 @@ public class GridCacheNearOneNodeSelfTest extends 
GridCommonAbstractTest {
             GridCacheEntryEx entry = dht.peekEx(2);
 
             assert entry == null || entry.rawGetOrUnmarshal(false) == null : 
"Invalid entry: " + entry;
-            assert dht.peek(3) != null;
 
             tx.commit();
         }
@@ -215,13 +213,13 @@ public class GridCacheNearOneNodeSelfTest extends 
GridCommonAbstractTest {
             near.put(1, "1");
 
             assertEquals("1", near.localPeek(1, CachePeekMode.ONHEAP));
-            assertEquals("1", dht().peek(1));
+            assertEquals("1", dhtPeek(1));
 
             assertEquals("1", near.get(1));
             assertEquals("1", near.getAndRemove(1));
 
             assertNull(near.localPeek(1, CachePeekMode.ONHEAP));
-            assertNull(dht().peek(1));
+            assertNull(dhtPeek(1));
 
             assertTrue(near.isLocalLocked(1, false));
             assertTrue(near.isLocalLocked(1, true));
@@ -246,7 +244,7 @@ public class GridCacheNearOneNodeSelfTest extends 
GridCommonAbstractTest {
             near.put(1, "1");
 
             assertEquals("1", near.localPeek(1, CachePeekMode.ONHEAP));
-            assertEquals("1", dht().peek(1));
+            assertEquals("1", dhtPeek(1));
 
             assertTrue(near.isLocalLocked(1, false));
             assertTrue(near.isLocalLocked(1, true));
@@ -258,7 +256,7 @@ public class GridCacheNearOneNodeSelfTest extends 
GridCommonAbstractTest {
                 assertEquals("1", near.getAndRemove(1));
 
                 assertNull(near.localPeek(1, CachePeekMode.ONHEAP));
-                assertNull(dht().peek(1));
+                assertNull(dhtPeek(1));
 
                 assertTrue(near.isLocalLocked(1, false));
                 assertTrue(near.isLocalLocked(1, true));
@@ -284,7 +282,7 @@ public class GridCacheNearOneNodeSelfTest extends 
GridCommonAbstractTest {
 
         cache.put(1, "val1");
 
-        assertEquals("val1", dht().peek(1));
+        assertEquals("val1", dhtPeek(1));
         assertNull(near().peekNearOnly(1));
 
         Transaction tx = grid().transactions().txStart(PESSIMISTIC, 
REPEATABLE_READ);
@@ -293,7 +291,7 @@ public class GridCacheNearOneNodeSelfTest extends 
GridCommonAbstractTest {
 
         tx.commit();
 
-        assertEquals("val1", dht().peek(1));
+        assertEquals("val1", dhtPeek(1));
         assertNull(near().peekNearOnly(1));
     }
 
@@ -303,7 +301,7 @@ public class GridCacheNearOneNodeSelfTest extends 
GridCommonAbstractTest {
 
         cache.put(1, "val1");
 
-        assertEquals("val1", dht().peek(1));
+        assertEquals("val1", dhtPeek(1));
         assertNull(near().peekNearOnly(1));
 
         Transaction tx = grid().transactions().txStart(PESSIMISTIC, 
REPEATABLE_READ);
@@ -314,7 +312,7 @@ public class GridCacheNearOneNodeSelfTest extends 
GridCommonAbstractTest {
 
         tx.commit();
 
-        assertNull(dht().peek(1));
+        assertNull(dhtPeek(1));
         assertNull(near().peekNearOnly(1));
     }
 
@@ -337,11 +335,6 @@ public class GridCacheNearOneNodeSelfTest extends 
GridCommonAbstractTest {
             create = true;
         }
 
-        /** @param create Create flag. */
-        void create(boolean create) {
-            this.create = create;
-        }
-
         /** @return Create flag. */
         boolean isCreate() {
             return create;

Reply via email to