Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-51 31f2c0de2 -> ed11001f8


# ignite-51


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

Branch: refs/heads/ignite-51
Commit: ed11001f8968b2e6982f5d4de32e51fdafd71440
Parents: 31f2c0d
Author: sboikov <sboi...@gridgain.com>
Authored: Fri Mar 6 10:37:36 2015 +0300
Committer: sboikov <sboi...@gridgain.com>
Committed: Fri Mar 6 12:36:43 2015 +0300

----------------------------------------------------------------------
 .../cache/CacheStoreBalancingWrapper.java       |   2 +
 .../processors/cache/GridCacheEntryInfo.java    |   9 +-
 .../GridCacheEntryInfoCollectSwapListener.java  |  53 ++----
 .../processors/cache/GridCacheMapEntry.java     |  30 ++--
 .../processors/cache/GridCacheMessage.java      |   4 +-
 .../processors/cache/GridCacheStoreManager.java | 176 +++++--------------
 .../distributed/dht/GridDhtCacheEntry.java      |   2 +-
 .../distributed/dht/GridDhtLocalPartition.java  |   2 +-
 .../dht/atomic/GridDhtAtomicCache.java          |  55 +++---
 .../GridDhtPartitionSupplyMessage.java          |  29 +--
 .../preloader/GridDhtPartitionSupplyPool.java   |   2 +-
 .../local/atomic/GridLocalAtomicCache.java      |  42 +++--
 .../transactions/IgniteTxLocalAdapter.java      |  16 +-
 .../GridCacheReturnValueTransferSelfTest.java   |   1 +
 .../cache/GridCacheSwapPreloadSelfTest.java     |   6 +-
 15 files changed, 175 insertions(+), 254 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheStoreBalancingWrapper.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheStoreBalancingWrapper.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheStoreBalancingWrapper.java
index 394bcfb..8d28ac7 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheStoreBalancingWrapper.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheStoreBalancingWrapper.java
@@ -270,7 +270,9 @@ public class CacheStoreBalancingWrapper<K, V> implements 
CacheStore<K, V> {
          * @param err Error.
          */
         public void onError(K key, Throwable err) {
+            this.keys = Collections.singletonList(key);
 
+            onDone(err);
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
index 00bc332..a1b1a2e 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfo.java
@@ -38,7 +38,7 @@ public class GridCacheEntryInfo implements Externalizable, 
Message {
     @GridToStringInclude
     private KeyCacheObject key;
 
-    /** */
+    /** Key bytes, set when entry is read from swap and there is no key 
instance. */
     private byte[] keyBytes;
 
     /** Cache ID. */
@@ -93,6 +93,13 @@ public class GridCacheEntryInfo implements Externalizable, 
Message {
     }
 
     /**
+     * @return Key bytes.
+     */
+    public byte[] keyBytes() {
+        return keyBytes;
+    }
+
+    /**
      * @return Entry key.
      */
     public KeyCacheObject key() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfoCollectSwapListener.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfoCollectSwapListener.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfoCollectSwapListener.java
index 9a43797..162b65c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfoCollectSwapListener.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryInfoCollectSwapListener.java
@@ -33,16 +33,11 @@ public class GridCacheEntryInfoCollectSwapListener 
implements GridCacheSwapListe
     /** */
     private final IgniteLogger log;
 
-    /** */
-    private final GridCacheContext ctx;
-
     /**
      * @param log Logger.
-     * @param ctx Context.
      */
-    public GridCacheEntryInfoCollectSwapListener(IgniteLogger log, 
GridCacheContext ctx) {
+    public GridCacheEntryInfoCollectSwapListener(IgniteLogger log) {
         this.log = log;
-        this.ctx = ctx;
     }
 
     /** {@inheritDoc} */
@@ -50,37 +45,21 @@ public class GridCacheEntryInfoCollectSwapListener 
implements GridCacheSwapListe
         KeyCacheObject key,
         GridCacheSwapEntry swapEntry)
     {
-// TODO IGNITE-51.
-//        try {
-//            if (log.isDebugEnabled())
-//                log.debug("Received unswapped event for key: " + key);
-//
-//            assert key != null;
-//            assert swapEntry != null;
-//
-//            GridCacheEntryInfo info = new GridCacheEntryInfo();
-//
-//            info.keyBytes(keyBytes);
-//            info.ttl(swapEntry.ttl());
-//            info.expireTime(swapEntry.expireTime());
-//            info.version(swapEntry.version());
-//
-//            if (!swapEntry.valueIsByteArray()) {
-//                boolean convertPortable = ctx.portableEnabled() && 
ctx.offheapTiered();
-//
-//                if (convertPortable)
-//                    
info.valueBytes(ctx.convertPortableBytes(swapEntry.valueBytes()));
-//                else
-//                    info.valueBytes(swapEntry.valueBytes());
-//            }
-//            else
-//                swapEntry.value(swapEntry.value());
-//
-//            swappedEntries.put(key, info);
-//        }
-//        catch (IgniteCheckedException e) {
-//            U.error(log, "Failed to process unswapped entry", e);
-//        }
+        if (log.isDebugEnabled())
+            log.debug("Received unswapped event for key: " + key);
+
+        assert key != null;
+        assert swapEntry != null;
+
+        GridCacheEntryInfo info = new GridCacheEntryInfo();
+
+        info.key(key);
+        info.ttl(swapEntry.ttl());
+        info.expireTime(swapEntry.expireTime());
+        info.version(swapEntry.version());
+        info.value(swapEntry.value());
+
+        swappedEntries.put(key, info);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/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 2d94ac3..0b22485 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
@@ -1083,7 +1083,7 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
         // Persist outside of synchronization. The correctness of the
         // value will be handled by current transaction.
         if (writeThrough)
-            cctx.store().putToStore(tx, key, val, newVer);
+            cctx.store().putToStore(tx, keyValue(false), CU.value(val, cctx, 
false), newVer);
 
         if (intercept)
             cctx.config().getInterceptor().onAfterPut(new CacheLazyEntry(cctx, 
key, key0, val, val0));
@@ -1092,6 +1092,14 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
             new GridCacheUpdateTxResult(false, null);
     }
 
+    /**
+     * @param cpy Copy flag.
+     * @return Key value.
+     */
+    protected Object keyValue(boolean cpy) {
+        return key.value(cctx.cacheObjectContext(), cpy);
+    }
+
     /** {@inheritDoc} */
     @Override public final GridCacheUpdateTxResult innerRemove(
         @Nullable IgniteInternalTx tx,
@@ -1233,7 +1241,7 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
         // Persist outside of synchronization. The correctness of the
         // value will be handled by current transaction.
         if (writeThrough)
-            cctx.store().removeFromStore(tx, key);
+            cctx.store().removeFromStore(tx, keyValue(false));
 
         if (!cctx.deferredDelete()) {
             boolean marked = false;
@@ -1487,7 +1495,7 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
 
                 if (writeThrough)
                     // Must persist inside synchronization in non-tx mode.
-                    cctx.store().putToStore(null, key, updated, ver);
+                    cctx.store().putToStore(null, keyValue(false), 
CU.value(updated, cctx, false), ver);
 
                 // Update index inside synchronization since it can be updated
                 // in load methods without actually holding entry lock.
@@ -1521,7 +1529,7 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
             else {
                 if (writeThrough)
                     // Must persist inside synchronization in non-tx mode.
-                    cctx.store().removeFromStore(null, key);
+                    cctx.store().removeFromStore(null, keyValue(false));
 
                 boolean hasValPtr = valPtr != 0;
 
@@ -1689,10 +1697,10 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
                             if (val == null) {
                                 assert deletedUnlocked();
 
-                                cctx.store().removeFromStore(null, key());
+                                cctx.store().removeFromStore(null, 
keyValue(false));
                             }
                             else
-                                cctx.store().putToStore(null, key(), val, ver);
+                                cctx.store().putToStore(null, keyValue(false), 
CU.value(val, cctx, false), ver);
                         }
 
                         return new GridCacheUpdateAtomicResult(false,
@@ -1739,10 +1747,10 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
                             if (val == null) {
                                 assert deletedUnlocked();
 
-                                cctx.store().removeFromStore(null, key());
+                                cctx.store().removeFromStore(null, 
keyValue(false));
                             }
                             else
-                                cctx.store().putToStore(null, key(), val, ver);
+                                cctx.store().putToStore(null, keyValue(false), 
CU.value(val, cctx, false), ver);
                         }
                         else {
                             if (log.isDebugEnabled())
@@ -1996,7 +2004,7 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
                 // Try write-through.
                 if (writeThrough)
                     // Must persist inside synchronization in non-tx mode.
-                    cctx.store().putToStore(null, key, updated, newVer);
+                    cctx.store().putToStore(null, keyValue(false), 
CU.value(updated, cctx, false), newVer);
 
                 if (!hadVal) {
                     boolean new0 = isNew();
@@ -2066,7 +2074,7 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
 
                 if (writeThrough)
                     // Must persist inside synchronization in non-tx mode.
-                    cctx.store().removeFromStore(null, key);
+                    cctx.store().removeFromStore(null, keyValue(false));
 
                 // Update index inside synchronization since it can be updated
                 // in load methods without actually holding entry lock.
@@ -3230,7 +3238,7 @@ public abstract class GridCacheMapEntry implements 
GridCacheEntryEx {
 
                 if (cctx.store().isLocalStore()) {
                     if (val != null)
-                        cctx.store().putToStore(null, key, val, ver);
+                        cctx.store().putToStore(null, keyValue(false), 
CU.value(val, cctx, false), ver);
                 }
 
                 return true;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
index b67ccc6..3b5ec4d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMessage.java
@@ -254,7 +254,9 @@ public abstract class GridCacheMessage implements Message {
             info.marshal(ctx);
 
             if (ctx.deploymentEnabled()) {
-                prepareObject(info.key().value(ctx.cacheObjectContext(), 
false), ctx.shared());
+                if (info.key() != null)
+                    prepareObject(info.key().value(ctx.cacheObjectContext(), 
false), ctx.shared());
+
                 prepareObject(CU.value(info.value(), ctx, false), 
ctx.shared());
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
index a6dd765..1c872a0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
@@ -554,19 +554,16 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
      * @throws IgniteCheckedException If storage failed.
      */
     @SuppressWarnings("unchecked")
-    public boolean putToStore(@Nullable IgniteInternalTx tx, KeyCacheObject 
key, CacheObject val, GridCacheVersion ver)
+    public boolean putToStore(@Nullable IgniteInternalTx tx, Object key, 
Object val, GridCacheVersion ver)
         throws IgniteCheckedException {
         if (store != null) {
             // Never persist internal keys.
-            if (key.internal())
+            if (key instanceof GridCacheInternal)
                 return true;
 
-            Object storeKey = key.value(cctx.cacheObjectContext(), false);
-            Object storeVal = val.value(cctx.cacheObjectContext(), false);
-
             if (convertPortable) {
-                storeKey = cctx.unwrapPortableIfNeeded(storeKey, false);
-                storeVal = cctx.unwrapPortableIfNeeded(storeVal, false);
+                key = cctx.unwrapPortableIfNeeded(key, false);
+                val = cctx.unwrapPortableIfNeeded(val, false);
             }
 
             if (log.isDebugEnabled())
@@ -575,7 +572,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
             boolean ses = initSession(tx);
 
             try {
-                store.write(new CacheEntryImpl<>(storeKey, locStore ? 
F.t(storeVal, ver) : storeVal));
+                store.write(new CacheEntryImpl<>(key, locStore ? F.t(val, ver) 
: val));
             }
             catch (ClassCastException e) {
                 handleClassCastException(e);
@@ -592,7 +589,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
             }
 
             if (log.isDebugEnabled())
-                log.debug("Stored value in cache store [key=" + storeKey + ", 
val=" + storeVal + ']');
+                log.debug("Stored value in cache store [key=" + key + ", val=" 
+ val + ']');
 
             return true;
         }
@@ -609,19 +606,20 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
      * @throws IgniteCheckedException If storage failed.
      */
     public boolean putAllToStore(@Nullable IgniteInternalTx tx,
-        Map<KeyCacheObject, IgniteBiTuple<CacheObject, GridCacheVersion>> map)
-        throws IgniteCheckedException {
+        Map<Object, IgniteBiTuple<Object, GridCacheVersion>> map)
+        throws IgniteCheckedException
+    {
         if (F.isEmpty(map))
             return true;
 
         if (map.size() == 1) {
-            Map.Entry<KeyCacheObject, IgniteBiTuple<CacheObject, 
GridCacheVersion>> e = map.entrySet().iterator().next();
+            Map.Entry<Object, IgniteBiTuple<Object, GridCacheVersion>> e = 
map.entrySet().iterator().next();
 
             return putToStore(tx, e.getKey(), e.getValue().get1(), 
e.getValue().get2());
         }
         else {
             if (store != null) {
-                EntriesView entries = new EntriesView(map);
+                EntriesView entries = new EntriesView((Map)map);
 
                 if (log.isDebugEnabled())
                     log.debug("Storing values in cache store [entries=" + 
entries + ']');
@@ -629,7 +627,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
                 boolean ses = initSession(tx);
 
                 try {
-                    store.writeAll((Collection<Cache.Entry<? extends Object, ? 
extends Object>>)entries);
+                    store.writeAll(entries);
                 }
                 catch (ClassCastException e) {
                     handleClassCastException(e);
@@ -671,16 +669,14 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
      * @throws IgniteCheckedException If storage failed.
      */
     @SuppressWarnings("unchecked")
-    public boolean removeFromStore(@Nullable IgniteInternalTx tx, 
KeyCacheObject key) throws IgniteCheckedException {
+    public boolean removeFromStore(@Nullable IgniteInternalTx tx, Object key) 
throws IgniteCheckedException {
         if (store != null) {
             // Never remove internal key from store as it is never persisted.
-            if (key.internal())
+            if (key instanceof GridCacheInternal)
                 return false;
 
-            Object storeKey = key.value(cctx.cacheObjectContext(), false);
-
             if (convertPortable)
-                storeKey = cctx.unwrapPortableIfNeeded(storeKey, false);
+                key = cctx.unwrapPortableIfNeeded(key, false);
 
             if (log.isDebugEnabled())
                 log.debug("Removing value from cache store [key=" + key + ']');
@@ -688,7 +684,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
             boolean ses = initSession(tx);
 
             try {
-                store.delete(storeKey);
+                store.delete(key);
             }
             catch (ClassCastException e) {
                 handleClassCastException(e);
@@ -720,34 +716,19 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
      * @throws IgniteCheckedException If storage failed.
      */
     @SuppressWarnings("unchecked")
-    public boolean removeAllFromStore(@Nullable IgniteInternalTx tx, 
Collection<KeyCacheObject> keys)
+    public boolean removeAllFromStore(@Nullable IgniteInternalTx tx, 
Collection<Object> keys)
         throws IgniteCheckedException {
         if (F.isEmpty(keys))
             return true;
 
         if (keys.size() == 1) {
-            KeyCacheObject key = keys.iterator().next();
+            Object key = keys.iterator().next();
 
             return removeFromStore(tx, key);
         }
 
         if (store != null) {
-            Collection<Object> keys0;
-
-            if (convertPortable) {
-                keys0 = F.viewReadOnly(keys, new C1<KeyCacheObject, Object>() {
-                    @Override public Object apply(KeyCacheObject key) {
-                        return 
cctx.unwrapPortableIfNeeded(key.value(cctx.cacheObjectContext(), false), false);
-                    }
-                });
-            }
-            else {
-                keys0 = F.viewReadOnly(keys, new C1<KeyCacheObject, Object>() {
-                    @Override public Object apply(KeyCacheObject key) {
-                        return key.value(cctx.cacheObjectContext(), false);
-                    }
-                });
-            }
+            Collection<Object> keys0 = convertPortable ? 
cctx.unwrapPortablesIfNeeded(keys, false) : keys;
 
             if (log.isDebugEnabled())
                 log.debug("Removing values from cache store [keys=" + keys0 + 
']');
@@ -979,10 +960,10 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
     @SuppressWarnings("unchecked")
     private class EntriesView extends AbstractCollection<Cache.Entry<?, ?>> {
         /** */
-        private final Map<KeyCacheObject, IgniteBiTuple<CacheObject, 
GridCacheVersion>> map;
+        private final Map<?, IgniteBiTuple<?, GridCacheVersion>> map;
 
         /** */
-        private Set<KeyCacheObject> rmvd;
+        private Set<Object> rmvd;
 
         /** */
         private boolean cleared;
@@ -990,7 +971,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
         /**
          * @param map Map.
          */
-        private EntriesView(Map<KeyCacheObject, IgniteBiTuple<CacheObject, 
GridCacheVersion>> map) {
+        private EntriesView(Map<?, IgniteBiTuple<?, GridCacheVersion>> map) {
             assert map != null;
 
             this.map = map;
@@ -1011,12 +992,9 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
             if (cleared || !(o instanceof Cache.Entry))
                 return false;
 
-            if (o instanceof EntryImpl)
-                return map.containsKey(((EntryImpl)o).keyObj);
-
-            Cache.Entry<Object, Object> e = (Cache.Entry<Object, Object>)o;
+            Cache.Entry<?, ?> e = (Cache.Entry<?, ?>)o;
 
-            return map.containsKey(cctx.toCacheKeyObject(e.getKey()));
+            return map.containsKey(e.getKey());
         }
 
         /** {@inheritDoc} */
@@ -1024,15 +1002,14 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
             if (cleared)
                 return F.emptyIterator();
 
-            final Iterator<Map.Entry<KeyCacheObject, 
IgniteBiTuple<CacheObject, GridCacheVersion>>> it0 =
-                map.entrySet().iterator();
+            final Iterator<Map.Entry<?, IgniteBiTuple<?, GridCacheVersion>>> 
it0 = (Iterator)map.entrySet().iterator();
 
             return new Iterator<Cache.Entry<?, ?>>() {
                 /** */
-                private Cache.Entry<Object, Object> cur;
+                private Cache.Entry<?, ?> cur;
 
                 /** */
-                private Cache.Entry<Object, Object> next;
+                private Cache.Entry<?, ?> next;
 
                 /**
                  *
@@ -1046,22 +1023,21 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
                  */
                 private void checkNext() {
                     while (it0.hasNext()) {
-                        Map.Entry<KeyCacheObject, IgniteBiTuple<CacheObject, 
GridCacheVersion>> e = it0.next();
+                        Map.Entry<?, IgniteBiTuple<?, GridCacheVersion>> e = 
it0.next();
 
-                        KeyCacheObject k = e.getKey();
+                        Object k = e.getKey();
 
                         if (rmvd != null && rmvd.contains(k))
                             continue;
 
-                        Object storeKey = 
e.getKey().value(cctx.cacheObjectContext(), false);
-                        Object storeVal = CU.value(e.getValue().get1(), cctx, 
false);
+                        Object v = locStore ? e.getValue() : 
e.getValue().get1();
 
                         if (convertPortable) {
-                            storeKey = cctx.unwrapPortableIfNeeded(storeKey, 
false);
-                            storeVal = cctx.unwrapPortableIfNeeded(storeVal, 
false);
+                            k = cctx.unwrapPortableIfNeeded(k, false);
+                            v = cctx.unwrapPortableIfNeeded(v, false);
                         }
 
-                        next = new EntryImpl<>(k, storeKey, storeVal);
+                        next = new CacheEntryImpl<>(k, v);
 
                         break;
                     }
@@ -1071,7 +1047,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
                     return next != null;
                 }
 
-                @Override public Cache.Entry<Object, Object> next() {
+                @Override public Cache.Entry<?, ?> next() {
                     if (next == null)
                         throw new NoSuchElementException();
 
@@ -1110,20 +1086,16 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
             if (cleared || !(o instanceof Cache.Entry))
                 return false;
 
-            Cache.Entry<Object, Object> e = (Cache.Entry<Object, Object>)o;
-
-            KeyCacheObject key;
-
-            if (e instanceof EntryImpl)
-                key = ((EntryImpl)e).keyObj;
-            else
-                key = cctx.toCacheKeyObject(e.getKey());
+            Cache.Entry<?, ?> e = (Cache.Entry<?, ?>)o;
 
-            if (rmvd != null && rmvd.contains(key))
+            if (rmvd != null && rmvd.contains(e.getKey()))
                 return false;
 
-            if (map.containsKey(key))
-                rmvd.add(key);
+            if (mapContains(e)) {
+                addRemoved(e);
+
+                return true;
+            }
 
             return false;
         }
@@ -1149,8 +1121,8 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
             boolean modified = false;
 
             for (Object o : col) {
-                 if (remove(o))
-                     modified = true;
+                if (remove(o))
+                    modified = true;
             }
 
             return modified;
@@ -1186,21 +1158,18 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
             if (rmvd == null)
                 rmvd = new HashSet<>();
 
-            if (e instanceof EntryImpl)
-                rmvd.add(((EntryImpl)e).keyObj);
-            else
-                rmvd.add(cctx.toCacheKeyObject(e.getKey()));
+            rmvd.add(e.getKey());
         }
 
         /**
          * @param e Entry.
          * @return {@code True} if original map contains entry.
          */
-        private boolean mapContains(Cache.Entry<Object, Object> e) {
-            if (e instanceof EntryImpl)
-                return map.containsKey(((EntryImpl)e).keyObj);
+        private boolean mapContains(Cache.Entry<?, ?> e) {
+            Object key = convertPortable ? cctx.marshalToPortable(e.getKey()) 
: e.getKey();
+
+            return map.containsKey(key);
 
-            return map.containsKey(cctx.toCacheKeyObject(e.getKey()));
         }
 
         /** {@inheritDoc} */
@@ -1224,53 +1193,4 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
             }
         }
     }
-
-    /**
-     *
-     */
-    private static class EntryImpl<K, V> implements Cache.Entry<K, V> {
-        /** */
-        private final KeyCacheObject keyObj;
-
-        /** */
-        private final K key;
-
-        /** */
-        private final V val;
-
-        /**
-         * @param keyObj Key object.
-         * @param key Key.
-         * @param val Value.
-         */
-        public EntryImpl(KeyCacheObject keyObj, K key, V val) {
-            this.keyObj = keyObj;
-            this.key = key;
-            this.val = val;
-        }
-
-        /** {@inheritDoc} */
-        @Override public K getKey() {
-            return key;
-        }
-
-        /** {@inheritDoc} */
-        @Override public V getValue() {
-            return val;
-        }
-
-        /** {@inheritDoc} */
-        @SuppressWarnings("unchecked")
-        @Override public <T> T unwrap(Class<T> cls) {
-            if(cls.isAssignableFrom(getClass()))
-                return cls.cast(this);
-
-            throw new IllegalArgumentException("Unwrapping to class is not 
supported: " + cls);
-        }
-
-        /** {@inheritDoc} */
-        public String toString() {
-            return "Entry [key=" + key + ", val=" + val + ']';
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/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 09bda15..bb80c17 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
@@ -560,7 +560,7 @@ public class GridDhtCacheEntry extends 
GridDistributedCacheEntry {
                 }
 
                 if (cctx.store().isLocalStore())
-                    cctx.store().removeFromStore(null, key());
+                    cctx.store().removeFromStore(null, keyValue(false));
 
                 rmv = true;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/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 2af9a3f..d59b793 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
@@ -502,7 +502,7 @@ public class GridDhtLocalPartition implements 
Comparable<GridDhtLocalPartition>
                     cctx.swap().remove(key);
 
                     if (isLocStore)
-                        cctx.store().removeFromStore(null, key);
+                        cctx.store().removeFromStore(null, 
key.value(cctx.cacheObjectContext(), false));
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/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 f32f927..6ab670d 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
@@ -1254,11 +1254,13 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
 
         int size = req.keys().size();
 
-        Map<KeyCacheObject, CacheObject> putMap = null;
+        Map<Object, Object> putMap = null;
 
         Map<KeyCacheObject, EntryProcessor<Object, Object, Object>> 
entryProcessorMap = null;
 
-        Collection<KeyCacheObject> rmvKeys = null;
+        Collection<Object> rmvKeys = null;
+
+        List<CacheObject> writeVals = null;
 
         UpdateBatchResult updRes = new UpdateBatchResult();
 
@@ -1367,6 +1369,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                                 filtered,
                                 ver,
                                 node,
+                                writeVals,
                                 putMap,
                                 null,
                                 entryProcessorMap,
@@ -1382,6 +1385,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                             firstEntryIdx = i;
 
                             putMap = null;
+                            writeVals = null;
                             entryProcessorMap = null;
 
                             filtered = new ArrayList<>();
@@ -1391,7 +1395,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                         if (rmvKeys == null)
                             rmvKeys = new ArrayList<>(size);
 
-                        rmvKeys.add(entry.key());
+                        
rmvKeys.add(entry.key().value(ctx.cacheObjectContext(), false));
                     }
                     else {
                         if (intercept) {
@@ -1414,6 +1418,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                                 ver,
                                 node,
                                 null,
+                                null,
                                 rmvKeys,
                                 entryProcessorMap,
                                 dhtFut,
@@ -1433,10 +1438,13 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                             filtered = new ArrayList<>();
                         }
 
-                        if (putMap == null)
+                        if (putMap == null) {
                             putMap = new LinkedHashMap<>(size, 1.0f);
+                            writeVals = new ArrayList<>(size);
+                        }
 
-                        putMap.put(entry.key(), updated);
+                        putMap.put(CU.value(entry.key(), ctx, false), 
CU.value(updated, ctx, false));
+                        writeVals.add(updated);
                     }
 
                     if (entryProcessorMap == null)
@@ -1474,10 +1482,13 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
 
                     assert updated != null;
 
-                    if (putMap == null)
+                    if (putMap == null) {
                         putMap = new LinkedHashMap<>(size, 1.0f);
+                        writeVals = new ArrayList<>(size);
+                    }
 
-                    putMap.put(entry.key(), updated);
+                    putMap.put(CU.value(entry.key(), ctx, false), 
CU.value(updated, ctx, false));
+                    writeVals.add(updated);
                 }
                 else {
                     assert op == DELETE;
@@ -1507,7 +1518,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                     if (rmvKeys == null)
                         rmvKeys = new ArrayList<>(size);
 
-                    rmvKeys.add(entry.key());
+                    rmvKeys.add(entry.key().value(ctx.cacheObjectContext(), 
false));
                 }
 
                 filtered.add(entry);
@@ -1525,6 +1536,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                 filtered,
                 ver,
                 node,
+                writeVals,
                 putMap,
                 rmvKeys,
                 entryProcessorMap,
@@ -1836,8 +1848,9 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
         List<GridDhtCacheEntry> entries,
         final GridCacheVersion ver,
         ClusterNode node,
-        @Nullable Map<KeyCacheObject, CacheObject> putMap,
-        @Nullable Collection<KeyCacheObject> rmvKeys,
+        @Nullable List<CacheObject> writeVals,
+        @Nullable Map<Object, Object> putMap,
+        @Nullable Collection<Object> rmvKeys,
         @Nullable Map<KeyCacheObject, EntryProcessor<Object, Object, Object>> 
entryProcessorMap,
         @Nullable GridDhtAtomicUpdateFuture dhtFut,
         CI2<GridNearAtomicUpdateRequest, GridNearAtomicUpdateResponse> 
completionCb,
@@ -1863,17 +1876,17 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
 
             if (putMap != null) {
                 // If fast mapping, filter primary keys for write to store.
-                Map<KeyCacheObject, CacheObject> storeMap = req.fastMap() ?
-                    F.view(putMap, new P1<KeyCacheObject>() {
-                        @Override public boolean apply(KeyCacheObject key) {
+                Map<Object, Object> storeMap = req.fastMap() ?
+                    F.view(putMap, new P1<Object>() {
+                        @Override public boolean apply(Object key) {
                             return ctx.affinity().primary(ctx.localNode(), 
key, req.topologyVersion());
                         }
                     }) :
                     putMap;
 
                 try {
-                    ctx.store().putAllToStore(null, F.viewReadOnly(storeMap, 
new C1<CacheObject, IgniteBiTuple<CacheObject, GridCacheVersion>>() {
-                        @Override public IgniteBiTuple<CacheObject, 
GridCacheVersion> apply(CacheObject v) {
+                    ctx.store().putAllToStore(null, F.viewReadOnly(storeMap, 
new C1<Object, IgniteBiTuple<Object, GridCacheVersion>>() {
+                        @Override public IgniteBiTuple<Object, 
GridCacheVersion> apply(Object v) {
                             return F.t(v, ver);
                         }
                     }));
@@ -1886,9 +1899,9 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
             }
             else {
                 // If fast mapping, filter primary keys for write to store.
-                Collection<KeyCacheObject> storeKeys = req.fastMap() ?
-                    F.view(rmvKeys, new P1<KeyCacheObject>() {
-                        @Override public boolean apply(KeyCacheObject key) {
+                Collection<Object> storeKeys = req.fastMap() ?
+                    F.view(rmvKeys, new P1<Object>() {
+                        @Override public boolean apply(Object key) {
                             return ctx.affinity().primary(ctx.localNode(), 
key, req.topologyVersion());
                         }
                     }) :
@@ -1923,7 +1936,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
 
                 try {
                     // We are holding java-level locks on entries at this 
point.
-                    CacheObject writeVal = op == UPDATE ? 
putMap.get(entry.key()) : null;
+                    CacheObject writeVal = op == UPDATE ? writeVals.get(i) : 
null;
 
                     assert writeVal != null || op == DELETE : "null write 
value found.";
 
@@ -1967,7 +1980,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
                     if (intercept) {
                         if (op == UPDATE) {
                             ctx.config().getInterceptor().onAfterPut(new 
CacheLazyEntry(
-                                ctx, 
+                                ctx,
                                 entry.key(),
                                 updRes.newValue()));
                         }
@@ -2045,7 +2058,7 @@ public class GridDhtAtomicCache<K, V> extends 
GridDhtCacheAdapter<K, V> {
             }
         }
         catch (IgniteCheckedException e) {
-            res.addFailedKeys(putMap != null ? putMap.keySet() : rmvKeys, e);
+            res.addFailedKeys(putMap != null ? putMap.keySet() : rmvKeys, e, 
ctx);
         }
 
         if (storeErr != null)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
index 6129ee0..75846a1 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyMessage.java
@@ -64,6 +64,7 @@ public class GridDhtPartitionSupplyMessage extends 
GridCacheMessage implements G
     /**
      * @param workerId Worker ID.
      * @param updateSeq Update sequence for this node.
+     * @param cacheId Cache ID.
      */
     GridDhtPartitionSupplyMessage(int workerId, long updateSeq, int cacheId) {
         assert workerId >= 0;
@@ -213,7 +214,7 @@ public class GridDhtPartitionSupplyMessage extends 
GridCacheMessage implements G
      */
     void addEntry0(int p, GridCacheEntryInfo info, GridCacheContext ctx) 
throws IgniteCheckedException {
         assert info != null;
-        assert info.key() != null;
+        assert (info.key() != null || info.keyBytes() != null);
         assert info.value() != null;
 
         // Need to call this method to initialize info properly.
@@ -232,21 +233,6 @@ public class GridDhtPartitionSupplyMessage extends 
GridCacheMessage implements G
         }
 
         infoCol.add(info);
-
-// TODO IGNITE-51.
-//        byte[] bytes = CU.marshal(ctx, info);
-//
-//        msgSize += bytes.length;
-//
-//        Collection<byte[]> serInfo = infoBytesMap.get(p);
-//
-//        if (serInfo == null) {
-//            msgSize += 4;
-//
-//            infoBytesMap.put(p, serInfo = new LinkedList<>());
-//        }
-//
-//        serInfo.add(bytes);
     }
 
     /** {@inheritDoc} */
@@ -262,17 +248,6 @@ public class GridDhtPartitionSupplyMessage extends 
GridCacheMessage implements G
             for (int i = 0; i < entries.size(); i++)
                 entries.get(i).unmarshal(cacheCtx, ldr);
         }
-
-// TODO IGNITE-51.
-        // infoBytesMap = ctx.marshaller().unmarshal(infoBytes, ldr);
-
-//        for (Map.Entry<Integer, Collection<byte[]>> e : 
infoBytesMap.entrySet()) {
-//            Collection<GridCacheEntryInfo> entries = 
unmarshalCollection(e.getValue(), ctx, ldr);
-//
-//            unmarshalInfos(entries, cacheCtx, ldr);
-//
-//            infos.put(e.getKey(), entries);
-//        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
index 2ba161e..96c2cb1 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplyPool.java
@@ -274,7 +274,7 @@ class GridDhtPartitionSupplyPool<K, V> {
 
                     try {
                         if (cctx.isSwapOrOffheapEnabled()) {
-                            swapLsnr = new 
GridCacheEntryInfoCollectSwapListener(log, cctx);
+                            swapLsnr = new 
GridCacheEntryInfoCollectSwapListener(log);
 
                             cctx.swap().addOffHeapListener(part, swapLsnr);
                             cctx.swap().addSwapListener(part, swapLsnr);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/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 4a1db42..27447d9 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
@@ -1075,9 +1075,11 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
         try {
             int size = locked.size();
 
-            Map<KeyCacheObject, CacheObject> putMap = null;
+            Map<Object, Object> putMap = null;
 
-            Collection<KeyCacheObject> rmvKeys = null;
+            Collection<Object> rmvKeys = null;
+
+            List<CacheObject> writeVals = null;
 
             Map<K, EntryProcessorResult> invokeResMap =
                 op == TRANSFORM ? U.<K, EntryProcessorResult>newHashMap(size) 
: null;
@@ -1164,7 +1166,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                         if (updated == null) {
                             if (intercept) {
                                 IgniteBiTuple<Boolean, ?> interceptorRes = 
ctx.config().getInterceptor()
-                                    .onBeforeRemove(new CacheLazyEntry(ctx, 
entry.key(), invokeEntry.key(), 
+                                    .onBeforeRemove(new CacheLazyEntry(ctx, 
entry.key(), invokeEntry.key(),
                                         old, oldVal));
 
                                 if (ctx.cancelRemove(interceptorRes))
@@ -1176,6 +1178,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                                 err = updatePartialBatch(
                                     filtered,
                                     ver,
+                                    writeVals,
                                     putMap,
                                     null,
                                     expiryPlc,
@@ -1184,6 +1187,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                                     taskName);
 
                                 putMap = null;
+                                writeVals = null;
 
                                 filtered = new ArrayList<>();
                             }
@@ -1192,7 +1196,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                             if (rmvKeys == null)
                                 rmvKeys = new ArrayList<>(size);
 
-                            rmvKeys.add(entry.key());
+                            
rmvKeys.add(entry.key().value(ctx.cacheObjectContext(), false));
                         }
                         else {
                             if (intercept) {
@@ -1212,6 +1216,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                                     filtered,
                                     ver,
                                     null,
+                                    null,
                                     rmvKeys,
                                     expiryPlc,
                                     err,
@@ -1223,10 +1228,13 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                                 filtered = new ArrayList<>();
                             }
 
-                            if (putMap == null)
+                            if (putMap == null) {
                                 putMap = new LinkedHashMap<>(size, 1.0f);
+                                writeVals = new ArrayList<>(size);
+                            }
 
-                            putMap.put(entry.key(), updated);
+                            putMap.put(CU.value(entry.key(), ctx, false), 
CU.value(updated, ctx, false));
+                            writeVals.add(updated);
                         }
                     }
                     else if (op == UPDATE) {
@@ -1255,10 +1263,13 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                             cacheVal = 
ctx.toCacheObject(ctx.unwrapTemporary(interceptorVal));
                         }
 
-                        if (putMap == null)
+                        if (putMap == null) {
                             putMap = new LinkedHashMap<>(size, 1.0f);
+                            writeVals = new ArrayList<>(size);
+                        }
 
-                        putMap.put(entry.key(), cacheVal);
+                        putMap.put(CU.value(entry.key(), ctx, false), 
CU.value(cacheVal, ctx, false));
+                        writeVals.add(cacheVal);
                     }
                     else {
                         assert op == DELETE;
@@ -1287,7 +1298,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                         if (rmvKeys == null)
                             rmvKeys = new ArrayList<>(size);
 
-                        rmvKeys.add(entry.key());
+                        
rmvKeys.add(entry.key().value(ctx.cacheObjectContext(), false));
                     }
 
                     filtered.add(entry);
@@ -1311,6 +1322,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
                 err = updatePartialBatch(
                     filtered,
                     ver,
+                    writeVals,
                     putMap,
                     rmvKeys,
                     expiryPlc,
@@ -1334,6 +1346,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
     /**
      * @param entries Entries to update.
      * @param ver Cache version.
+     * @param writeVals Cache values.
      * @param putMap Values to put.
      * @param rmvKeys Keys to remove.
      * @param expiryPlc Expiry policy.
@@ -1346,8 +1359,9 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
     @Nullable private CachePartialUpdateCheckedException updatePartialBatch(
         List<GridCacheEntryEx> entries,
         final GridCacheVersion ver,
-        @Nullable Map<KeyCacheObject, CacheObject> putMap,
-        @Nullable Collection<KeyCacheObject> rmvKeys,
+        @Nullable List<CacheObject> writeVals,
+        @Nullable Map<Object, Object> putMap,
+        @Nullable Collection<Object> rmvKeys,
         @Nullable ExpiryPolicy expiryPlc,
         @Nullable CachePartialUpdateCheckedException err,
         UUID subjId,
@@ -1361,8 +1375,8 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
         try {
             if (putMap != null) {
                 try {
-                    ctx.store().putAllToStore(null, F.viewReadOnly(putMap, new 
C1<CacheObject, IgniteBiTuple<CacheObject, GridCacheVersion>>() {
-                        @Override public IgniteBiTuple<CacheObject, 
GridCacheVersion> apply(CacheObject v) {
+                    ctx.store().putAllToStore(null, F.viewReadOnly(putMap, new 
C1<Object, IgniteBiTuple<Object, GridCacheVersion>>() {
+                        @Override public IgniteBiTuple<Object, 
GridCacheVersion> apply(Object v) {
                             return F.t(v, ver);
                         }
                     }));
@@ -1405,7 +1419,7 @@ public class GridLocalAtomicCache<K, V> extends 
GridCacheAdapter<K, V> {
 
             try {
                 // We are holding java-level locks on entries at this point.
-                CacheObject writeVal = op == UPDATE ? putMap.get(entry.key()) 
: null;
+                CacheObject writeVal = op == UPDATE ? writeVals.get(i) : null;
 
                 assert writeVal != null || op == DELETE : "null write value 
found.";
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/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 35673c3..21bde1d 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
@@ -488,8 +488,8 @@ public abstract class IgniteTxLocalAdapter extends 
IgniteTxAdapter
             (!internal() || groupLock()) && (near() || 
store.writeToStoreFromDht())) {
             try {
                 if (writeEntries != null) {
-                    Map<KeyCacheObject, IgniteBiTuple<CacheObject, 
GridCacheVersion>> putMap = null;
-                    List<KeyCacheObject> rmvCol = null;
+                    Map<Object, IgniteBiTuple<Object, GridCacheVersion>> 
putMap = null;
+                    List<Object> rmvCol = null;
                     GridCacheStoreManager writeStore = null;
 
                     boolean skipNear = near() && store.writeToStoreFromDht();
@@ -549,7 +549,7 @@ public abstract class IgniteTxLocalAdapter extends 
IgniteTxAdapter
                             if (putMap == null)
                                 putMap = new 
LinkedHashMap<>(writeMap().size(), 1.0f);
 
-                            putMap.put(key, F.t(val, ver));
+                            putMap.put(CU.value(key, cacheCtx, false), 
F.t(CU.value(val, cacheCtx, false), ver));
 
                             writeStore = cacheCtx.store();
                         }
@@ -576,10 +576,8 @@ public abstract class IgniteTxLocalAdapter extends 
IgniteTxAdapter
                             }
 
                             if (intercept) {
-                                IgniteBiTuple<Boolean, Object> t = 
cacheCtx.config().getInterceptor()
-                                    .onBeforeRemove(new 
CacheLazyEntry(cacheCtx,
-                                        key,
-                                        e.cached().rawGetOrUnmarshal(true)));
+                                IgniteBiTuple<Boolean, Object> t = 
cacheCtx.config().getInterceptor().onBeforeRemove(
+                                    new CacheLazyEntry(cacheCtx, key, 
e.cached().rawGetOrUnmarshal(true)));
 
                                 if (cacheCtx.cancelRemove(t))
                                     continue;
@@ -588,7 +586,7 @@ public abstract class IgniteTxLocalAdapter extends 
IgniteTxAdapter
                             if (rmvCol == null)
                                 rmvCol = new ArrayList<>();
 
-                            rmvCol.add(key);
+                            
rmvCol.add(key.value(cacheCtx.cacheObjectContext(), false));
 
                             writeStore = cacheCtx.store();
                         }
@@ -2481,7 +2479,7 @@ public abstract class IgniteTxLocalAdapter extends 
IgniteTxAdapter
             if (res != null) {
                 if (key0 == null)
                     key0 = txEntry.key().value(ctx.cacheObjectContext(), true);
-                
+
                 ret.addEntryProcessResult(key0, new CacheInvokeResult<>(res));
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java
index 45d28ac..c4fa1f5 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReturnValueTransferSelfTest.java
@@ -185,6 +185,7 @@ public class GridCacheReturnValueTransferSelfTest extends 
GridCommonAbstractTest
     /**
      *
      */
+    @IgniteImmutable
     private static class TestObject implements Externalizable {
         /**
          *

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ed11001f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapPreloadSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapPreloadSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapPreloadSelfTest.java
index 85a7838..e980e7b 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapPreloadSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheSwapPreloadSelfTest.java
@@ -201,11 +201,13 @@ public class GridCacheSwapPreloadSelfTest extends 
GridCommonAbstractTest {
             info("New node cache size: " + size);
 
             if (size != ENTRY_CNT) {
-                Iterable<Integer> keySet = new 
TreeSet<>(((IgniteKernal)grid(1))
-                    .<Integer, Integer>cache(null).keySet());
+                Set<Integer> keySet = new TreeSet<>();
 
                 int next = 0;
 
+                for (IgniteCache.Entry<Integer, Integer> e : grid(1).<Integer, 
Integer>jcache(null).localEntries())
+                    keySet.add(e.getKey());
+
                 for (Integer i : keySet) {
                     while (next < i)
                         info("Missing key: " + next++);

Reply via email to