http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
index 116bf0d..c9b2e45 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
@@ -36,7 +36,7 @@ import java.util.concurrent.atomic.*;
  * See {@link GridCacheVersionManager#next()} for information on how lock IDs 
are
  * generated to prevent starvation.
  */
-public final class GridCacheMvcc<K> {
+public final class GridCacheMvcc {
     /** Logger reference. */
     private static final AtomicReference<IgniteLogger> logRef = new 
AtomicReference<>();
 
@@ -45,20 +45,20 @@ public final class GridCacheMvcc<K> {
 
     /** Cache context. */
     @GridToStringExclude
-    private final GridCacheContext<K, ?> cctx;
+    private final GridCacheContext<?, ?> cctx;
 
     /** Local queue. */
     @GridToStringInclude
-    private LinkedList<GridCacheMvccCandidate<K>> locs;
+    private LinkedList<GridCacheMvccCandidate> locs;
 
     /** Remote queue. */
     @GridToStringInclude
-    private LinkedList<GridCacheMvccCandidate<K>> rmts;
+    private LinkedList<GridCacheMvccCandidate> rmts;
 
     /**
      * @param cctx Cache context.
      */
-    public GridCacheMvcc(GridCacheContext<K, ?> cctx) {
+    public GridCacheMvcc(GridCacheContext<?, ?> cctx) {
         assert cctx != null;
 
         this.cctx = cctx;
@@ -69,8 +69,8 @@ public final class GridCacheMvcc<K> {
     /**
      * @return Any owner.
      */
-    @Nullable public GridCacheMvccCandidate<K> anyOwner() {
-        GridCacheMvccCandidate<K> owner = localOwner();
+    @Nullable public GridCacheMvccCandidate anyOwner() {
+        GridCacheMvccCandidate owner = localOwner();
 
         if (owner == null)
             owner = remoteOwner();
@@ -82,11 +82,11 @@ public final class GridCacheMvcc<K> {
      * @return Remote candidate only if it's first in the list and is marked
      *      as <tt>'used'</tt>.
      */
-    @Nullable public GridCacheMvccCandidate<K> remoteOwner() {
+    @Nullable public GridCacheMvccCandidate remoteOwner() {
         if (rmts != null) {
             assert !rmts.isEmpty();
 
-            GridCacheMvccCandidate<K> first = rmts.getFirst();
+            GridCacheMvccCandidate first = rmts.getFirst();
 
             return first.used() && first.owner() ? first : null;
         }
@@ -98,11 +98,11 @@ public final class GridCacheMvcc<K> {
      * @return Local candidate only if it's first in the list and is marked
      *      as <tt>'owner'</tt>.
      */
-    @Nullable public GridCacheMvccCandidate<K> localOwner() {
+    @Nullable public GridCacheMvccCandidate localOwner() {
         if (locs != null) {
             assert !locs.isEmpty();
 
-            GridCacheMvccCandidate<K> first = locs.getFirst();
+            GridCacheMvccCandidate first = locs.getFirst();
 
             return first.owner() ? first : null;
         }
@@ -115,12 +115,12 @@ public final class GridCacheMvcc<K> {
      * @param ver Version.
      * @return Candidate for the version.
      */
-    @Nullable private GridCacheMvccCandidate<K> 
candidate(Iterable<GridCacheMvccCandidate<K>> cands,
+    @Nullable private GridCacheMvccCandidate 
candidate(Iterable<GridCacheMvccCandidate> cands,
         GridCacheVersion ver) {
         assert ver != null;
 
         if (cands != null)
-            for (GridCacheMvccCandidate<K> c : cands)
+            for (GridCacheMvccCandidate c : cands)
                 if (c.version().equals(ver))
                     return c;
 
@@ -133,9 +133,9 @@ public final class GridCacheMvcc<K> {
      * @param reentry Reentry flag.
      * @return Local candidate for the thread.
      */
-    @Nullable private GridCacheMvccCandidate<K> localCandidate(long threadId, 
boolean reentry) {
+    @Nullable private GridCacheMvccCandidate localCandidate(long threadId, 
boolean reentry) {
         if (locs != null)
-            for (GridCacheMvccCandidate<K> cand : locs) {
+            for (GridCacheMvccCandidate cand : locs) {
                 if (cand.threadId() == threadId) {
                     if (cand.reentry() && !reentry)
                         continue;
@@ -150,7 +150,7 @@ public final class GridCacheMvcc<K> {
     /**
      * @param cand Candidate to add.
      */
-    private void add0(GridCacheMvccCandidate<K> cand) {
+    private void add0(GridCacheMvccCandidate cand) {
         assert cand != null;
 
         // Local.
@@ -160,7 +160,7 @@ public final class GridCacheMvcc<K> {
 
             if (!cand.nearLocal()) {
                 if (!locs.isEmpty()) {
-                    GridCacheMvccCandidate<K> c = locs.getFirst();
+                    GridCacheMvccCandidate c = locs.getFirst();
 
                     if (c.owner()) {
                         // If reentry, add at the beginning. Note that
@@ -177,7 +177,7 @@ public final class GridCacheMvcc<K> {
                     }
 
                     // Iterate in reverse order.
-                    for (ListIterator<GridCacheMvccCandidate<K>> it = 
locs.listIterator(locs.size()); it.hasPrevious(); ) {
+                    for (ListIterator<GridCacheMvccCandidate> it = 
locs.listIterator(locs.size()); it.hasPrevious(); ) {
                         c = it.previous();
 
                         assert !c.version().equals(cand.version()) : "Versions 
can't match [existing=" + c +
@@ -223,7 +223,7 @@ public final class GridCacheMvcc<K> {
             assert !cand.owner() || localOwner() == null : "Cannot have local 
and remote owners " +
                 "at the same time [cand=" + cand + ", locs=" + locs + ", 
rmts=" + rmts + ']';
 
-            GridCacheMvccCandidate<K> cur = candidate(rmts, cand.version());
+            GridCacheMvccCandidate cur = candidate(rmts, cand.version());
 
             // For existing candidates, we only care about owners and keys.
             if (cur != null) {
@@ -264,10 +264,10 @@ public final class GridCacheMvcc<K> {
      * @param ver Version of the candidate to remove.
      * @return {@code True} if candidate was removed.
      */
-    private boolean remove0(Collection<GridCacheMvccCandidate<K>> col, 
GridCacheVersion ver) {
+    private boolean remove0(Collection<GridCacheMvccCandidate> col, 
GridCacheVersion ver) {
         if (col != null) {
-            for (Iterator<GridCacheMvccCandidate<K>> it = col.iterator(); 
it.hasNext(); ) {
-                GridCacheMvccCandidate<K> cand = it.next();
+            for (Iterator<GridCacheMvccCandidate> it = col.iterator(); 
it.hasNext(); ) {
+                GridCacheMvccCandidate cand = it.next();
 
                 if (cand.version().equals(ver)) {
                     cand.setUsed();
@@ -303,7 +303,7 @@ public final class GridCacheMvcc<K> {
             if (F.isEmpty(exclude))
                 return false;
 
-            for (GridCacheMvccCandidate<K> cand : locs)
+            for (GridCacheMvccCandidate cand : locs)
                 if (!U.containsObjectArray(exclude, cand.version()))
                     return false;
         }
@@ -314,7 +314,7 @@ public final class GridCacheMvcc<K> {
             if (F.isEmpty(exclude))
                 return false;
 
-            for (GridCacheMvccCandidate<K> cand : rmts)
+            for (GridCacheMvccCandidate cand : rmts)
                 if (!U.containsObjectArray(exclude, cand.version()))
                     return false;
         }
@@ -332,17 +332,17 @@ public final class GridCacheMvcc<K> {
      * @param rolledbackVers Rolled back versions relative to base.
      * @return Lock owner.
      */
-    @Nullable public GridCacheMvccCandidate<K> orderCompleted(GridCacheVersion 
baseVer,
+    @Nullable public GridCacheMvccCandidate orderCompleted(GridCacheVersion 
baseVer,
         Collection<GridCacheVersion> committedVers, 
Collection<GridCacheVersion> rolledbackVers) {
         assert baseVer != null;
 
         if (rmts != null && !F.isEmpty(committedVers)) {
-            Deque<GridCacheMvccCandidate<K>> mvAfter = null;
+            Deque<GridCacheMvccCandidate> mvAfter = null;
 
             int maxIdx = -1;
 
-            for (ListIterator<GridCacheMvccCandidate<K>> it = 
rmts.listIterator(rmts.size()); it.hasPrevious(); ) {
-                GridCacheMvccCandidate<K> cur = it.previous();
+            for (ListIterator<GridCacheMvccCandidate> it = 
rmts.listIterator(rmts.size()); it.hasPrevious(); ) {
+                GridCacheMvccCandidate cur = it.previous();
 
                 if (!cur.version().equals(baseVer) && 
committedVers.contains(cur.version())) {
                     cur.setOwner();
@@ -372,16 +372,16 @@ public final class GridCacheMvcc<K> {
             }
 
             if (maxIdx >= 0 && mvAfter != null) {
-                ListIterator<GridCacheMvccCandidate<K>> it = 
rmts.listIterator(maxIdx + 1);
+                ListIterator<GridCacheMvccCandidate> it = 
rmts.listIterator(maxIdx + 1);
 
-                for (GridCacheMvccCandidate<K> cand : mvAfter)
+                for (GridCacheMvccCandidate cand : mvAfter)
                     it.add(cand);
             }
 
             // Remove rolled back versions.
             if (!F.isEmpty(rolledbackVers)) {
-                for (Iterator<GridCacheMvccCandidate<K>> it = rmts.iterator(); 
it.hasNext(); ) {
-                    GridCacheMvccCandidate<K> cand = it.next();
+                for (Iterator<GridCacheMvccCandidate> it = rmts.iterator(); 
it.hasNext(); ) {
+                    GridCacheMvccCandidate cand = it.next();
 
                     if (rolledbackVers.contains(cand.version())) {
                         cand.setUsed(); // Mark as used to be consistent, even 
though we are about to remove it.
@@ -405,12 +405,12 @@ public final class GridCacheMvcc<K> {
      * @param owned Owned list.
      * @return Current owner.
      */
-    @Nullable public GridCacheMvccCandidate<K> markOwned(GridCacheVersion 
baseVer, GridCacheVersion owned) {
+    @Nullable public GridCacheMvccCandidate markOwned(GridCacheVersion 
baseVer, GridCacheVersion owned) {
         if (owned == null)
             return anyOwner();
 
         if (rmts != null) {
-            GridCacheMvccCandidate<K> baseCand = candidate(rmts, baseVer);
+            GridCacheMvccCandidate baseCand = candidate(rmts, baseVer);
 
             if (baseCand != null)
                 baseCand.ownerVersion(owned);
@@ -430,8 +430,8 @@ public final class GridCacheMvcc<K> {
      * @return New lock candidate if lock was added, or current owner if lock 
was reentered,
      *      or <tt>null</tt> if lock was owned by another thread and timeout 
is negative.
      */
-    @Nullable public GridCacheMvccCandidate<K> addLocal(
-        GridCacheEntryEx<K, ?> parent,
+    @Nullable public GridCacheMvccCandidate addLocal(
+        GridCacheEntryEx parent,
         long threadId,
         GridCacheVersion ver,
         long timeout,
@@ -466,8 +466,8 @@ public final class GridCacheMvcc<K> {
      * @return New lock candidate if lock was added, or current owner if lock 
was reentered,
      *      or <tt>null</tt> if lock was owned by another thread and timeout 
is negative.
      */
-    @Nullable public GridCacheMvccCandidate<K> addLocal(
-        GridCacheEntryEx<K, ?> parent,
+    @Nullable public GridCacheMvccCandidate addLocal(
+        GridCacheEntryEx parent,
         @Nullable UUID nearNodeId,
         @Nullable GridCacheVersion nearVer,
         long threadId,
@@ -483,7 +483,7 @@ public final class GridCacheMvcc<K> {
 
         // Don't check reenter for DHT candidates.
         if (!dhtLoc && !reenter) {
-            GridCacheMvccCandidate<K> owner = localOwner();
+            GridCacheMvccCandidate owner = localOwner();
 
             if (owner != null && owner.threadId() == threadId)
                 return null;
@@ -493,7 +493,7 @@ public final class GridCacheMvcc<K> {
         // then we give up right away.
         if (timeout < 0) {
             if (locs != null || rmts != null) {
-                GridCacheMvccCandidate<K> owner = localOwner();
+                GridCacheMvccCandidate owner = localOwner();
 
                 // Only proceed if this is a re-entry.
                 if (owner == null || owner.threadId() != threadId)
@@ -504,7 +504,7 @@ public final class GridCacheMvcc<K> {
         UUID locNodeId = cctx.nodeId();
 
         // If this is a reentry, then reentry flag will be flipped within 
'add0(..)' method.
-        GridCacheMvccCandidate<K> cand = new GridCacheMvccCandidate<>(
+        GridCacheMvccCandidate cand = new GridCacheMvccCandidate(
             parent,
             locNodeId,
             nearNodeId,
@@ -540,8 +540,8 @@ public final class GridCacheMvcc<K> {
      * @param nearLoc Near local flag.
      * @return Add remote candidate.
      */
-    public GridCacheMvccCandidate<K> addRemote(
-        GridCacheEntryEx<K, ?> parent,
+    public GridCacheMvccCandidate addRemote(
+        GridCacheEntryEx parent,
         UUID nodeId,
         @Nullable UUID otherNodeId,
         long threadId,
@@ -550,7 +550,7 @@ public final class GridCacheMvcc<K> {
         boolean tx,
         boolean implicitSingle,
         boolean nearLoc) {
-        GridCacheMvccCandidate<K> cand = new GridCacheMvccCandidate<>(
+        GridCacheMvccCandidate cand = new GridCacheMvccCandidate(
             parent,
             nodeId,
             otherNodeId,
@@ -584,10 +584,10 @@ public final class GridCacheMvcc<K> {
      * @param implicitSingle Implicit flag.
      * @return Add remote candidate.
      */
-    public GridCacheMvccCandidate<K> addNearLocal(GridCacheEntryEx<K, ?> 
parent, UUID nodeId,
+    public GridCacheMvccCandidate addNearLocal(GridCacheEntryEx parent, UUID 
nodeId,
         @Nullable UUID otherNodeId, long threadId, GridCacheVersion ver, long 
timeout, boolean tx,
         boolean implicitSingle) {
-        GridCacheMvccCandidate<K> cand = new GridCacheMvccCandidate<>(parent, 
nodeId, otherNodeId, null, threadId, ver,
+        GridCacheMvccCandidate cand = new GridCacheMvccCandidate(parent, 
nodeId, otherNodeId, null, threadId, ver,
             timeout, /*local*/true, /*reentry*/false, tx, implicitSingle, 
/*near loc*/true, /*dht loc*/false);
 
         add0(cand);
@@ -598,7 +598,7 @@ public final class GridCacheMvcc<K> {
     /**
      * @param cand Remote candidate.
      */
-    public void addRemote(GridCacheMvccCandidate<K> cand) {
+    public void addRemote(GridCacheMvccCandidate cand) {
         assert !cand.local();
 
         if (log.isDebugEnabled())
@@ -613,8 +613,8 @@ public final class GridCacheMvcc<K> {
      * @param ver Lock version to acquire or set to ready.
      * @return Current owner.
      */
-    @Nullable public GridCacheMvccCandidate<K> readyLocal(GridCacheVersion 
ver) {
-        GridCacheMvccCandidate<K> cand = candidate(ver);
+    @Nullable public GridCacheMvccCandidate readyLocal(GridCacheVersion ver) {
+        GridCacheMvccCandidate cand = candidate(ver);
 
         if (cand == null)
             return anyOwner();
@@ -628,7 +628,7 @@ public final class GridCacheMvcc<K> {
      * @param cand Local candidate added in any of the {@code addLocal(..)} 
methods.
      * @return Current lock owner.
      */
-    @Nullable public GridCacheMvccCandidate<K> 
readyLocal(GridCacheMvccCandidate<K> cand) {
+    @Nullable public GridCacheMvccCandidate readyLocal(GridCacheMvccCandidate 
cand) {
         assert cand.local();
 
         cand.setReady();
@@ -654,10 +654,10 @@ public final class GridCacheMvcc<K> {
      * @param pending Pending dht versions that are not owned and which 
version is less then mapped.
      * @return Lock owner after reassignment.
      */
-    @Nullable public GridCacheMvccCandidate<K> readyNearLocal(GridCacheVersion 
ver, GridCacheVersion mappedVer,
+    @Nullable public GridCacheMvccCandidate readyNearLocal(GridCacheVersion 
ver, GridCacheVersion mappedVer,
         Collection<GridCacheVersion> committedVers, 
Collection<GridCacheVersion> rolledBackVers,
         Collection<GridCacheVersion> pending) {
-        GridCacheMvccCandidate<K> cand = candidate(locs, ver);
+        GridCacheMvccCandidate cand = candidate(locs, ver);
 
         if (cand != null) {
             assert cand.nearLocal() : "Near local candidate is not marked as 
near local: " + cand;
@@ -670,16 +670,16 @@ public final class GridCacheMvcc<K> {
                 mappedVer + ", cand=" + cand + ']';
 
             // For near locals we move all not owned candidates after this one.
-            List<GridCacheMvccCandidate<K>> mvAfter = null;
+            List<GridCacheMvccCandidate> mvAfter = null;
 
-            for (ListIterator<GridCacheMvccCandidate<K>> it = 
locs.listIterator(); it.hasNext(); ) {
-                GridCacheMvccCandidate<K> c = it.next();
+            for (ListIterator<GridCacheMvccCandidate> it = 
locs.listIterator(); it.hasNext(); ) {
+                GridCacheMvccCandidate c = it.next();
 
                 assert c.nearLocal() : "Near local candidate is not marked as 
near local: " + c;
 
                 if (c == cand) {
                     if (mvAfter != null)
-                        for (GridCacheMvccCandidate<K> mv : mvAfter)
+                        for (GridCacheMvccCandidate mv : mvAfter)
                             it.add(mv);
 
                     break;
@@ -703,7 +703,7 @@ public final class GridCacheMvcc<K> {
 
             // Mark all remote candidates with less version as owner unless it 
is pending.
             if (rmts != null) {
-                for (GridCacheMvccCandidate<K> rmt : rmts) {
+                for (GridCacheMvccCandidate rmt : rmts) {
                     GridCacheVersion rmtVer = rmt.version();
 
                     if (rmtVer.isLess(mappedVer)) {
@@ -734,7 +734,7 @@ public final class GridCacheMvcc<K> {
      * @param rolledback Rolledback versions.
      * @return Lock owner.
      */
-    @Nullable public GridCacheMvccCandidate<K> doneRemote(
+    @Nullable public GridCacheMvccCandidate doneRemote(
         GridCacheVersion ver,
         Collection<GridCacheVersion> pending,
         Collection<GridCacheVersion> committed,
@@ -745,7 +745,7 @@ public final class GridCacheMvcc<K> {
             log.debug("Setting remote candidate to done [mvcc=" + this + ", 
ver=" + ver + "]");
 
         // Check remote candidate.
-        GridCacheMvccCandidate<K> cand = candidate(rmts, ver);
+        GridCacheMvccCandidate cand = candidate(rmts, ver);
 
         if (cand != null) {
             assert rmts != null;
@@ -756,16 +756,16 @@ public final class GridCacheMvcc<K> {
             cand.setOwner();
             cand.setUsed();
 
-            List<GridCacheMvccCandidate<K>> mvAfter = null;
+            List<GridCacheMvccCandidate> mvAfter = null;
 
-            for (ListIterator<GridCacheMvccCandidate<K>> it = 
rmts.listIterator(); it.hasNext(); ) {
-                GridCacheMvccCandidate<K> c = it.next();
+            for (ListIterator<GridCacheMvccCandidate> it = 
rmts.listIterator(); it.hasNext(); ) {
+                GridCacheMvccCandidate c = it.next();
 
                 assert !c.nearLocal() : "Remote candidate marked as near 
local: " + c;
 
                 if (c == cand) {
                     if (mvAfter != null)
-                        for (GridCacheMvccCandidate<K> mv : mvAfter)
+                        for (GridCacheMvccCandidate mv : mvAfter)
                             it.add(mv);
 
                     break;
@@ -794,14 +794,14 @@ public final class GridCacheMvcc<K> {
     public void salvageRemote(GridCacheVersion ver) {
         assert ver != null;
 
-        GridCacheMvccCandidate<K> cand = candidate(rmts, ver);
+        GridCacheMvccCandidate cand = candidate(rmts, ver);
 
         if (cand != null) {
             assert rmts != null;
             assert !rmts.isEmpty();
 
-            for (Iterator<GridCacheMvccCandidate<K>> iter = rmts.iterator(); 
iter.hasNext(); ) {
-                GridCacheMvccCandidate<K> rmt = iter.next();
+            for (Iterator<GridCacheMvccCandidate> iter = rmts.iterator(); 
iter.hasNext(); ) {
+                GridCacheMvccCandidate rmt = iter.next();
 
                 // For salvaged candidate doneRemote will be called explicitly.
                 if (rmt == cand)
@@ -828,10 +828,10 @@ public final class GridCacheMvcc<K> {
      * Assigns local lock.
      */
     private void reassign() {
-        GridCacheMvccCandidate<K> firstRmt = null;
+        GridCacheMvccCandidate firstRmt = null;
 
         if (rmts != null) {
-            for (GridCacheMvccCandidate<K> cand : rmts) {
+            for (GridCacheMvccCandidate cand : rmts) {
                 if (firstRmt == null)
                     firstRmt = cand;
 
@@ -843,14 +843,14 @@ public final class GridCacheMvcc<K> {
         }
 
         if (locs != null) {
-            for (ListIterator<GridCacheMvccCandidate<K>> it = 
locs.listIterator(); it.hasNext(); ) {
-                GridCacheMvccCandidate<K> cand = it.next();
+            for (ListIterator<GridCacheMvccCandidate> it = 
locs.listIterator(); it.hasNext(); ) {
+                GridCacheMvccCandidate cand = it.next();
 
                 if (cand.owner())
                     return;
 
                 if (cand.ready()) {
-                    GridCacheMvccCandidate<K> prev = nonRollbackPrevious(cand);
+                    GridCacheMvccCandidate prev = nonRollbackPrevious(cand);
 
                     // If previous has not been acquired, this candidate 
cannot acquire lock either,
                     // so we move on to the next one.
@@ -871,7 +871,7 @@ public final class GridCacheMvcc<K> {
                         //    remote version have the same key as the previous 
owner. In
                         //    that case, we can safely set this candidate to 
owner as well.
                         while (prev != null && prev.owner()) {
-                            for (GridCacheMvccCandidate<K> c : 
prev.parent().remoteMvccSnapshot()) {
+                            for (GridCacheMvccCandidate c : 
prev.parent().remoteMvccSnapshot()) {
                                 if (c.version().equals(firstRmt.version())) {
                                     cand.setOwner();
 
@@ -882,11 +882,11 @@ public final class GridCacheMvcc<K> {
                             }
 
                             if (!assigned) {
-                                for (GridCacheMvccCandidate<K> c : locs) {
+                                for (GridCacheMvccCandidate c : locs) {
                                     if (c == cand || 
c.version().isGreater(firstRmt.version()))
                                         break;
 
-                                    for (GridCacheMvccCandidate<K> p = 
c.previous(); p != null; p = p.previous()) {
+                                    for (GridCacheMvccCandidate p = 
c.previous(); p != null; p = p.previous()) {
                                         if (p.key().equals(prev.key())) {
                                             cand.setOwner();
 
@@ -942,8 +942,8 @@ public final class GridCacheMvcc<K> {
      * @param cand Candidate to check.
      * @return First predecessor that is owner or is not used.
      */
-    @Nullable private GridCacheMvccCandidate<K> 
nonRollbackPrevious(GridCacheMvccCandidate<K> cand) {
-        for (GridCacheMvccCandidate<K> c = cand.previous(); c != null; c = 
c.previous()) {
+    @Nullable private GridCacheMvccCandidate 
nonRollbackPrevious(GridCacheMvccCandidate cand) {
+        for (GridCacheMvccCandidate c = cand.previous(); c != null; c = 
c.previous()) {
             if (c.owner() || !c.used())
                 return c;
         }
@@ -956,7 +956,7 @@ public final class GridCacheMvcc<K> {
      *
      * @return Owner.
      */
-    @Nullable public GridCacheMvccCandidate<K> recheck() {
+    @Nullable public GridCacheMvccCandidate recheck() {
         reassign();
 
         return anyOwner();
@@ -966,7 +966,7 @@ public final class GridCacheMvcc<K> {
      * Local local release.
      * @return Removed lock candidate or <tt>null</tt> if candidate was not 
removed.
      */
-    @Nullable public GridCacheMvccCandidate<K> releaseLocal() {
+    @Nullable public GridCacheMvccCandidate releaseLocal() {
         return releaseLocal(Thread.currentThread().getId());
     }
 
@@ -976,8 +976,8 @@ public final class GridCacheMvcc<K> {
      * @param threadId ID of the thread.
      * @return Current owner.
      */
-    @Nullable public GridCacheMvccCandidate<K> releaseLocal(long threadId) {
-        GridCacheMvccCandidate<K> owner = localOwner();
+    @Nullable public GridCacheMvccCandidate releaseLocal(long threadId) {
+        GridCacheMvccCandidate owner = localOwner();
 
         if (owner == null || owner.threadId() != threadId)
             // Release had no effect.
@@ -996,7 +996,7 @@ public final class GridCacheMvcc<K> {
      * @param ver Lock version.
      * @return Current owner.
      */
-    @Nullable public GridCacheMvccCandidate<K> remove(GridCacheVersion ver) {
+    @Nullable public GridCacheMvccCandidate remove(GridCacheVersion ver) {
         remove0(ver, false);
 
         return anyOwner();
@@ -1008,10 +1008,10 @@ public final class GridCacheMvcc<K> {
      * @param nodeId Node ID.
      * @return Current owner.
      */
-    @Nullable public GridCacheMvccCandidate<K> 
removeExplicitNodeCandidates(UUID nodeId) {
+    @Nullable public GridCacheMvccCandidate removeExplicitNodeCandidates(UUID 
nodeId) {
         if (rmts != null) {
-            for (Iterator<GridCacheMvccCandidate<K>> it = rmts.iterator(); 
it.hasNext(); ) {
-                GridCacheMvccCandidate<K> cand = it.next();
+            for (Iterator<GridCacheMvccCandidate> it = rmts.iterator(); 
it.hasNext(); ) {
+                GridCacheMvccCandidate cand = it.next();
 
                 if (!cand.tx() && nodeId.equals(cand.nodeId())) {
                     cand.setUsed(); // Mark as used to be consistent.
@@ -1026,8 +1026,8 @@ public final class GridCacheMvcc<K> {
         }
 
         if (locs != null) {
-            for (Iterator<GridCacheMvccCandidate<K>> it = locs.iterator(); 
it.hasNext(); ) {
-                GridCacheMvccCandidate<K> cand = it.next();
+            for (Iterator<GridCacheMvccCandidate> it = locs.iterator(); 
it.hasNext(); ) {
+                GridCacheMvccCandidate cand = it.next();
 
                 if (!cand.tx() && nodeId.equals(cand.otherNodeId()) && 
cand.dhtLocal()) {
                     cand.setUsed(); // Mark as used to be consistent.
@@ -1052,8 +1052,8 @@ public final class GridCacheMvcc<K> {
      * @param ver Lock version.
      * @return Candidate or <tt>null</tt> if there is no candidate for given 
ID.
      */
-    @Nullable public GridCacheMvccCandidate<K> candidate(GridCacheVersion ver) 
{
-        GridCacheMvccCandidate<K> cand = candidate(locs, ver);
+    @Nullable public GridCacheMvccCandidate candidate(GridCacheVersion ver) {
+        GridCacheMvccCandidate cand = candidate(locs, ver);
 
         if (cand == null)
             cand = candidate(rmts, ver);
@@ -1067,7 +1067,7 @@ public final class GridCacheMvcc<K> {
      * @param threadId Thread ID.
      * @return Candidate or <tt>null</tt> if there is no candidate for given 
ID.
      */
-    @Nullable public GridCacheMvccCandidate<K> localCandidate(long threadId) {
+    @Nullable public GridCacheMvccCandidate localCandidate(long threadId) {
         // Don't return reentries.
         return localCandidate(threadId, false);
     }
@@ -1077,9 +1077,9 @@ public final class GridCacheMvcc<K> {
      * @param threadId Thread ID.
      * @return Remote candidate.
      */
-    @Nullable public GridCacheMvccCandidate<K> remoteCandidate(UUID nodeId, 
long threadId) {
+    @Nullable public GridCacheMvccCandidate remoteCandidate(UUID nodeId, long 
threadId) {
         if (rmts != null)
-            for (GridCacheMvccCandidate<K> c : rmts)
+            for (GridCacheMvccCandidate c : rmts)
                 if (c.nodeId().equals(nodeId) && c.threadId() == threadId)
                     return c;
 
@@ -1093,9 +1093,9 @@ public final class GridCacheMvcc<K> {
      * @param threadId Thread ID.
      * @return Remote candidate.
      */
-    @Nullable public GridCacheMvccCandidate<K> localCandidate(UUID nodeId, 
long threadId) {
+    @Nullable public GridCacheMvccCandidate localCandidate(UUID nodeId, long 
threadId) {
         if (locs != null)
-            for (GridCacheMvccCandidate<K> c : locs)
+            for (GridCacheMvccCandidate c : locs)
                 if (c.nodeId().equals(nodeId) && c.threadId() == threadId)
                     return c;
 
@@ -1115,7 +1115,7 @@ public final class GridCacheMvcc<K> {
      * @param reentry Reentry flag.
      * @return Collection of local candidates.
      */
-    public List<GridCacheMvccCandidate<K>> localCandidatesNoCopy(boolean 
reentry) {
+    public List<GridCacheMvccCandidate> localCandidatesNoCopy(boolean reentry) 
{
         return candidates(locs, reentry, false, cctx.emptyVersion());
     }
 
@@ -1123,7 +1123,7 @@ public final class GridCacheMvcc<K> {
      * @param excludeVers Exclude versions.
      * @return Collection of local candidates.
      */
-    public Collection<GridCacheMvccCandidate<K>> 
localCandidates(GridCacheVersion... excludeVers) {
+    public Collection<GridCacheMvccCandidate> 
localCandidates(GridCacheVersion... excludeVers) {
         return candidates(locs, false, true, excludeVers);
     }
 
@@ -1132,7 +1132,7 @@ public final class GridCacheMvcc<K> {
      * @param excludeVers Exclude versions.
      * @return Collection of local candidates.
      */
-    public List<GridCacheMvccCandidate<K>> localCandidates(boolean reentries,
+    public List<GridCacheMvccCandidate> localCandidates(boolean reentries,
         GridCacheVersion... excludeVers) {
         return candidates(locs, reentries, true, excludeVers);
     }
@@ -1141,7 +1141,7 @@ public final class GridCacheMvcc<K> {
      * @param excludeVers Exclude versions.
      * @return Collection of remote candidates.
      */
-    public List<GridCacheMvccCandidate<K>> 
remoteCandidates(GridCacheVersion... excludeVers) {
+    public List<GridCacheMvccCandidate> remoteCandidates(GridCacheVersion... 
excludeVers) {
         return candidates(rmts, false, true, excludeVers);
     }
 
@@ -1152,7 +1152,7 @@ public final class GridCacheMvcc<K> {
      * @param excludeVers Exclude versions.
      * @return Collection of candidates minus the exclude versions.
      */
-    private List<GridCacheMvccCandidate<K>> 
candidates(List<GridCacheMvccCandidate<K>> col,
+    private List<GridCacheMvccCandidate> 
candidates(List<GridCacheMvccCandidate> col,
         boolean reentries, boolean cp, GridCacheVersion... excludeVers) {
         if (col == null)
             return Collections.emptyList();
@@ -1162,9 +1162,9 @@ public final class GridCacheMvcc<K> {
         if (!cp && F.isEmpty(excludeVers))
             return col;
 
-        List<GridCacheMvccCandidate<K>> cands = new ArrayList<>(col.size());
+        List<GridCacheMvccCandidate> cands = new ArrayList<>(col.size());
 
-        for (GridCacheMvccCandidate<K> c : col) {
+        for (GridCacheMvccCandidate c : col) {
             // Don't include reentries.
             if ((!c.reentry() || (reentries && c.reentry())) && 
!U.containsObjectArray(excludeVers, c.version()))
                 cands.add(c);
@@ -1186,7 +1186,7 @@ public final class GridCacheMvcc<K> {
      * @return {@code True} if lock is owned by the thread with given ID.
      */
     public boolean isLocallyOwnedByThread(long threadId, boolean allowDhtLoc, 
GridCacheVersion... exclude) {
-        GridCacheMvccCandidate<K> owner = localOwner();
+        GridCacheMvccCandidate owner = localOwner();
 
         return owner != null && owner.threadId() == threadId && 
owner.nodeId().equals(cctx.nodeId()) &&
             (allowDhtLoc || !owner.dhtLocal()) && 
!U.containsObjectArray(exclude, owner.version());
@@ -1198,7 +1198,7 @@ public final class GridCacheMvcc<K> {
      * @return {@code True} if lock is held by given thread and node IDs.
      */
     public boolean isLockedByThread(long threadId, UUID nodeId) {
-        GridCacheMvccCandidate<K> owner = anyOwner();
+        GridCacheMvccCandidate owner = anyOwner();
 
         return owner != null && owner.threadId() == threadId && 
owner.nodeId().equals(nodeId);
     }
@@ -1216,7 +1216,7 @@ public final class GridCacheMvcc<K> {
      * @return {@code True} if candidate is owner.
      */
     public boolean isLocallyOwned(GridCacheVersion lockVer) {
-        GridCacheMvccCandidate<K> owner = localOwner();
+        GridCacheMvccCandidate owner = localOwner();
 
         return owner != null && owner.version().equals(lockVer);
     }
@@ -1227,7 +1227,7 @@ public final class GridCacheMvcc<K> {
      * @return {@code True} if locked by lock ID or thread ID.
      */
     public boolean isLocallyOwnedByIdOrThread(GridCacheVersion lockVer, long 
threadId) {
-        GridCacheMvccCandidate<K> owner = localOwner();
+        GridCacheMvccCandidate owner = localOwner();
 
         return owner != null && (owner.version().equals(lockVer) || 
owner.threadId() == threadId);
     }
@@ -1235,14 +1235,14 @@ public final class GridCacheMvcc<K> {
     /**
      * @return First remote entry or <tt>null</tt>.
      */
-    @Nullable public GridCacheMvccCandidate<K> firstRemote() {
+    @Nullable public GridCacheMvccCandidate firstRemote() {
         return rmts == null ? null : rmts.getFirst();
     }
 
     /**
      * @return First local entry or <tt>null</tt>.
      */
-    @Nullable public GridCacheMvccCandidate<K> firstLocal() {
+    @Nullable public GridCacheMvccCandidate firstLocal() {
         return locs == null ? null : locs.getFirst();
     }
 
@@ -1251,7 +1251,7 @@ public final class GridCacheMvcc<K> {
      * @return {@code True} if lock is owned by the specified version.
      */
     public boolean isOwnedBy(GridCacheVersion ver) {
-        GridCacheMvccCandidate<K> cand = anyOwner();
+        GridCacheMvccCandidate cand = anyOwner();
 
         return cand != null && cand.version().equals(ver);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
index 7bb513e..f2f513b 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvccCandidate.java
@@ -32,8 +32,8 @@ import static 
org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate
 /**
  * Lock candidate.
  */
-public class GridCacheMvccCandidate<K> implements Externalizable,
-    Comparable<GridCacheMvccCandidate<K>> {
+public class GridCacheMvccCandidate implements Externalizable,
+    Comparable<GridCacheMvccCandidate> {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -73,19 +73,19 @@ public class GridCacheMvccCandidate<K> implements 
Externalizable,
     private transient volatile long topVer = -1;
 
     /** Linked reentry. */
-    private GridCacheMvccCandidate<K> reentry;
+    private GridCacheMvccCandidate reentry;
 
     /** Previous lock for the thread. */
     @GridToStringExclude
-    private transient volatile GridCacheMvccCandidate<K> prev;
+    private transient volatile GridCacheMvccCandidate prev;
 
     /** Next lock for the thread. */
     @GridToStringExclude
-    private transient volatile GridCacheMvccCandidate<K> next;
+    private transient volatile GridCacheMvccCandidate next;
 
     /** Parent entry. */
     @GridToStringExclude
-    private transient GridCacheEntryEx<K, ?> parent;
+    private transient GridCacheEntryEx parent;
 
     /** Alternate node ID specifying additional node involved in this lock. */
     private transient volatile UUID otherNodeId;
@@ -120,7 +120,7 @@ public class GridCacheMvccCandidate<K> implements 
Externalizable,
      * @param dhtLoc DHT local flag.
      */
     public GridCacheMvccCandidate(
-        GridCacheEntryEx<K, ?> parent,
+        GridCacheEntryEx parent,
         UUID nodeId,
         @Nullable UUID otherNodeId,
         @Nullable GridCacheVersion otherVer,
@@ -178,8 +178,8 @@ public class GridCacheMvccCandidate<K> implements 
Externalizable,
      * @return Parent entry.
      */
     @SuppressWarnings({"unchecked"})
-    public <V> GridCacheEntryEx<K, V> parent() {
-        return (GridCacheEntryEx<K, V>)parent;
+    public <V> GridCacheEntryEx parent() {
+        return parent;
     }
 
     /**
@@ -199,10 +199,10 @@ public class GridCacheMvccCandidate<K> implements 
Externalizable,
     /**
      * @return Reentry candidate.
      */
-    public GridCacheMvccCandidate<K> reenter() {
-        GridCacheMvccCandidate<K> old = reentry;
+    public GridCacheMvccCandidate reenter() {
+        GridCacheMvccCandidate old = reentry;
 
-        GridCacheMvccCandidate<K> reentry = new GridCacheMvccCandidate<>(
+        GridCacheMvccCandidate reentry = new GridCacheMvccCandidate(
             parent,
             nodeId,
             otherNodeId,
@@ -237,9 +237,9 @@ public class GridCacheMvccCandidate<K> implements 
Externalizable,
     /**
      * @return Removed reentry candidate or {@code null}.
      */
-    @Nullable public GridCacheMvccCandidate<K> unenter() {
+    @Nullable public GridCacheMvccCandidate unenter() {
         if (reentry != null) {
-            GridCacheMvccCandidate<K> old = reentry;
+            GridCacheMvccCandidate old = reentry;
 
             // Link to next.
             reentry = reentry.reentry;
@@ -253,7 +253,7 @@ public class GridCacheMvccCandidate<K> implements 
Externalizable,
     /**
      * @param parent Sets locks parent entry.
      */
-    public void parent(GridCacheEntryEx<K, ?> parent) {
+    public void parent(GridCacheEntryEx parent) {
         assert parent != null;
 
         this.parent = parent;
@@ -469,14 +469,14 @@ public class GridCacheMvccCandidate<K> implements 
Externalizable,
     /**
      * @return Lock that comes before in the same thread, possibly 
<tt>null</tt>.
      */
-    public GridCacheMvccCandidate<K> previous() {
+    public GridCacheMvccCandidate previous() {
         return prev;
     }
 
     /**
      * @param prev Lock that comes before in the same thread, possibly 
<tt>null</tt>.
      */
-    public void previous(GridCacheMvccCandidate<K> prev) {
+    public void previous(GridCacheMvccCandidate prev) {
         this.prev = prev;
     }
 
@@ -484,22 +484,22 @@ public class GridCacheMvccCandidate<K> implements 
Externalizable,
      *
      * @return Gets next candidate in this thread.
      */
-    public GridCacheMvccCandidate<K> next() {
+    public GridCacheMvccCandidate next() {
         return next;
     }
 
     /**
      * @param next Next candidate in this thread.
      */
-    public void next(GridCacheMvccCandidate<K> next) {
+    public void next(GridCacheMvccCandidate next) {
         this.next = next;
     }
 
     /**
      * @return Key.
      */
-    public K key() {
-        GridCacheEntryEx<K, ?> parent0 = parent;
+    public KeyCacheObject key() {
+        GridCacheEntryEx parent0 = parent;
 
         if (parent0 == null)
             throw new IllegalStateException("Parent entry was not initialized 
for MVCC candidate: " + this);
@@ -551,7 +551,7 @@ public class GridCacheMvccCandidate<K> implements 
Externalizable,
     }
 
     /** {@inheritDoc} */
-    @Override public int compareTo(GridCacheMvccCandidate<K> o) {
+    @Override public int compareTo(GridCacheMvccCandidate o) {
         if (o == this)
             return 0;
 
@@ -573,7 +573,7 @@ public class GridCacheMvccCandidate<K> implements 
Externalizable,
         if (o == this)
             return true;
 
-        GridCacheMvccCandidate<K> other = (GridCacheMvccCandidate<K>)o;
+        GridCacheMvccCandidate other = (GridCacheMvccCandidate)o;
 
         assert key() != null && other.key() != null : "Key is null [this=" + 
this + ", other=" + o + ']';
 
@@ -587,8 +587,8 @@ public class GridCacheMvccCandidate<K> implements 
Externalizable,
 
     /** {@inheritDoc} */
     @Override public String toString() {
-        GridCacheMvccCandidate<?> prev = previous();
-        GridCacheMvccCandidate<?> next = next();
+        GridCacheMvccCandidate prev = previous();
+        GridCacheMvccCandidate next = next();
 
         return S.toString(GridCacheMvccCandidate.class, this,
             "key", parent == null ? null : parent.key(),

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
index 6b17038..2154d0f 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSharedContext.java
@@ -400,7 +400,7 @@ public class GridCacheSharedContext<K, V> {
      * @param cacheCtx Cache context.
      * @return {@code True} if cross-cache transaction can include this new 
cache.
      */
-    public boolean txCompatible(IgniteInternalTx<K, V> tx, Iterable<Integer> 
activeCacheIds, GridCacheContext<K, V> cacheCtx) {
+    public boolean txCompatible(IgniteInternalTx tx, Iterable<Integer> 
activeCacheIds, GridCacheContext<K, V> cacheCtx) {
         if (cacheCtx.system() ^ tx.system())
             return false;
 
@@ -447,7 +447,7 @@ public class GridCacheSharedContext<K, V> {
      * @param tx Transaction to close.
      * @throws IgniteCheckedException If failed.
      */
-    public void endTx(IgniteInternalTx<K, V> tx) throws IgniteCheckedException 
{
+    public void endTx(IgniteInternalTx tx) throws IgniteCheckedException {
         Collection<Integer> cacheIds = tx.activeCacheIds();
 
         if (!cacheIds.isEmpty()) {
@@ -462,7 +462,7 @@ public class GridCacheSharedContext<K, V> {
      * @param tx Transaction to commit.
      * @return Commit future.
      */
-    public IgniteInternalFuture<IgniteInternalTx> 
commitTxAsync(IgniteInternalTx<K, V> tx) {
+    public IgniteInternalFuture<IgniteInternalTx> 
commitTxAsync(IgniteInternalTx tx) {
         Collection<Integer> cacheIds = tx.activeCacheIds();
 
         if (cacheIds.isEmpty())
@@ -484,7 +484,7 @@ public class GridCacheSharedContext<K, V> {
      * @param tx Transaction to rollback.
      * @throws IgniteCheckedException If failed.
      */
-    public IgniteInternalFuture rollbackTxAsync(IgniteInternalTx<K, V> tx) 
throws IgniteCheckedException {
+    public IgniteInternalFuture rollbackTxAsync(IgniteInternalTx tx) throws 
IgniteCheckedException {
         Collection<Integer> cacheIds = tx.activeCacheIds();
 
         if (!cacheIds.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/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 fac6ea3..065ddb4 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
@@ -43,18 +43,18 @@ import java.util.*;
  * Store manager.
  */
 @SuppressWarnings("AssignmentToCatchBlockParameter")
-public class GridCacheStoreManager<K, V> extends GridCacheManagerAdapter<K, V> 
{
+public class GridCacheStoreManager extends GridCacheManagerAdapter {
     /** */
     private static final String SES_ATTR = "STORE_SES";
 
     /** */
-    private final CacheStore<K, Object> store;
+    private final CacheStore<Object, Object> store;
 
     /** */
     private final CacheStore<?, ?> cfgStore;
 
     /** */
-    private final CacheStoreBalancingWrapper<K, Object> singleThreadGate;
+    private final CacheStoreBalancingWrapper<Object, Object> singleThreadGate;
 
     /** */
     private final ThreadLocal<SessionData> sesHolder;
@@ -82,7 +82,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
     @SuppressWarnings("unchecked")
     public GridCacheStoreManager(GridKernalContext ctx,
         Map<CacheStore, ThreadLocal> sesHolders,
-        @Nullable CacheStore<K, Object> cfgStore,
+        @Nullable CacheStore<Object, Object> cfgStore,
         CacheConfiguration cfg) throws IgniteCheckedException {
         this.cfgStore = cfgStore;
 
@@ -243,8 +243,9 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @throws IgniteCheckedException If data loading failed.
      */
     @SuppressWarnings("unchecked")
-    @Nullable public V loadFromStore(@Nullable IgniteInternalTx tx, K key) 
throws IgniteCheckedException {
-        return (V)loadFromStore(tx, key, true);
+    @Nullable public Object loadFromStore(@Nullable IgniteInternalTx tx, 
KeyCacheObject key)
+        throws IgniteCheckedException {
+        return loadFromStore(tx, key, true);
     }
 
     /**
@@ -258,26 +259,28 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      */
     @SuppressWarnings("unchecked")
     @Nullable private Object loadFromStore(@Nullable IgniteInternalTx tx,
-        K key,
+        KeyCacheObject key,
         boolean convert)
         throws IgniteCheckedException {
         if (store != null) {
-            if (key instanceof GridCacheInternal)
+            if (key.internal())
                 // Never load internal keys from store as they are never 
persisted.
                 return null;
 
+            Object storeKey = key.value(cctx);
+
             if (convertPortable)
-                key = (K)cctx.unwrapPortableIfNeeded(key, false);
+                storeKey = cctx.unwrapPortableIfNeeded(storeKey, false);
 
             if (log.isDebugEnabled())
-                log.debug("Loading value from store for key: " + key);
+                log.debug("Loading value from store for key: " + storeKey);
 
             boolean ses = initSession(tx);
 
             Object val = null;
 
             try {
-                val = singleThreadGate.load(key);
+                val = singleThreadGate.load(storeKey);
             }
             catch (ClassCastException e) {
                 handleClassCastException(e);
@@ -313,11 +316,11 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @return User value.
      */
     @SuppressWarnings("unchecked")
-    private V convert(Object val) {
+    private Object convert(Object val) {
         if (val == null)
             return null;
 
-        return locStore ? ((IgniteBiTuple<V, GridCacheVersion>)val).get1() : 
(V)val;
+        return locStore ? ((IgniteBiTuple<Object, 
GridCacheVersion>)val).get1() : val;
     }
 
     /**
@@ -334,8 +337,8 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @throws IgniteCheckedException If data loading failed.
      */
     public void localStoreLoadAll(@Nullable IgniteInternalTx tx,
-        Collection<? extends K> keys,
-        final GridInClosure3<K, V, GridCacheVersion> vis)
+        Collection<? extends KeyCacheObject> keys,
+        final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> vis)
         throws IgniteCheckedException {
         assert store != null;
         assert locStore;
@@ -354,15 +357,15 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      */
     @SuppressWarnings({"unchecked"})
     public boolean loadAllFromStore(@Nullable IgniteInternalTx tx,
-        Collection<? extends K> keys,
-        final IgniteBiInClosure<K, V> vis) throws IgniteCheckedException {
+        Collection<? extends KeyCacheObject> keys,
+        final IgniteBiInClosure<Object, Object> vis) throws 
IgniteCheckedException {
         if (store != null) {
             loadAllFromStore(tx, keys, vis, null);
 
             return true;
         }
         else {
-            for (K key : keys)
+            for (KeyCacheObject key : keys)
                 vis.apply(key, null);
         }
 
@@ -378,9 +381,9 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      */
     @SuppressWarnings("unchecked")
     private void loadAllFromStore(@Nullable IgniteInternalTx tx,
-        Collection<? extends K> keys,
-        @Nullable final IgniteBiInClosure<K, V> vis,
-        @Nullable final GridInClosure3<K, V, GridCacheVersion> verVis)
+        Collection<Object> keys,
+        @Nullable final IgniteBiInClosure<Object, Object> vis,
+        @Nullable final GridInClosure3<Object, Object, GridCacheVersion> 
verVis)
         throws IgniteCheckedException {
         assert vis != null ^ verVis != null;
         assert verVis == null || locStore;
@@ -389,13 +392,13 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
 
         if (!keys.isEmpty()) {
             if (keys.size() == 1) {
-                K key = F.first(keys);
+                KeyCacheObject key = F.first(keys);
 
                 if (convert)
                     vis.apply(key, loadFromStore(tx, key));
                 else {
-                    IgniteBiTuple<V, GridCacheVersion> t =
-                        (IgniteBiTuple<V, GridCacheVersion>)loadFromStore(tx, 
key, false);
+                    IgniteBiTuple<Object, GridCacheVersion> t =
+                        (IgniteBiTuple<Object, 
GridCacheVersion>)loadFromStore(tx, key, false);
 
                     if (t != null)
                         verVis.apply(key, t.get1(), t.get2());
@@ -404,13 +407,22 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
                 return;
             }
 
-            Collection<? extends K> keys0 = convertPortable ?
-                F.viewReadOnly(keys, new C1<K, K>() {
-                    @Override public K apply(K k) {
-                        return (K)cctx.unwrapPortableIfNeeded(k, false);
+            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), 
false);
+                    }
+                });
+            }
+            else {
+                keys0 = F.viewReadOnly(keys, new C1<KeyCacheObject, Object>() {
+                    @Override public Object apply(KeyCacheObject key) {
+                        return key.value(cctx);
                     }
-                }) :
-                keys;
+                });
+            }
 
             if (log.isDebugEnabled())
                 log.debug("Loading values from store for keys: " + keys0);
@@ -418,34 +430,35 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             boolean ses = initSession(tx);
 
             try {
-                IgniteBiInClosure<K,Object> c = new CI2<K, Object>() {
+                IgniteBiInClosure<Object, Object> c = new CI2<Object, 
Object>() {
                     @SuppressWarnings("ConstantConditions")
-                    @Override public void apply(K k, Object val) {
+                    @Override public void apply(Object k, Object val) {
                         if (convert) {
-                            V v = convert(val);
+                            Object v = convert(val);
 
-                            if (cctx.portableEnabled()) {
-                                k = (K)cctx.marshalToPortable(k);
-                                v = (V)cctx.marshalToPortable(v);
-                            }
+// TODO IGNITE-51
+//                            if (cctx.portableEnabled()) {
+//                                k = (K)cctx.marshalToPortable(k);
+//                                v = (V)cctx.marshalToPortable(v);
+//                            }
 
-                            vis.apply(k, v);
+                            vis.apply(cctx.toCacheKeyObject(k), v);
                         }
                         else {
-                            IgniteBiTuple<V, GridCacheVersion> v = 
(IgniteBiTuple<V, GridCacheVersion>)val;
+                            IgniteBiTuple<Object, GridCacheVersion> v = 
(IgniteBiTuple<Object, GridCacheVersion>)val;
 
                             if (v != null)
-                                verVis.apply(k, v.get1(), v.get2());
+                                verVis.apply(cctx.toCacheKeyObject(k), 
v.get1(), v.get2());
                         }
                     }
                 };
 
                 if (keys.size() > singleThreadGate.loadAllThreshold()) {
-                    Map<K, Object> map = store.loadAll(keys0);
+                    Map<Object, Object> map = store.loadAll(keys0);
 
                     if (map != null) {
-                        for (Map.Entry<K, Object> e : map.entrySet())
-                            c.apply(e.getKey(), e.getValue());
+                        for (Map.Entry<Object, Object> e : map.entrySet())
+                            c.apply(cctx.toCacheKeyObject(e.getKey()), 
e.getValue());
                     }
                 }
                 else
@@ -479,7 +492,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @throws IgniteCheckedException If data loading failed.
      */
     @SuppressWarnings({"ErrorNotRethrown", "unchecked"})
-    public boolean loadCache(final GridInClosure3<K, V, GridCacheVersion> vis, 
Object[] args)
+    public boolean loadCache(final GridInClosure3<Object, Object, 
GridCacheVersion> vis, Object[] args)
         throws IgniteCheckedException {
         if (store != null) {
             if (log.isDebugEnabled())
@@ -488,19 +501,19 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             boolean ses = initSession(null);
 
             try {
-                store.loadCache(new IgniteBiInClosure<K, Object>() {
-                    @Override public void apply(K k, Object o) {
-                        V v;
+                store.loadCache(new IgniteBiInClosure<Object, Object>() {
+                    @Override public void apply(Object k, Object o) {
+                        Object v;
                         GridCacheVersion ver = null;
 
                         if (locStore) {
-                            IgniteBiTuple<V, GridCacheVersion> t = 
(IgniteBiTuple<V, GridCacheVersion>)o;
+                            IgniteBiTuple<Object, GridCacheVersion> t = 
(IgniteBiTuple<Object, GridCacheVersion>)o;
 
                             v = t.get1();
                             ver = t.get2();
                         }
                         else
-                            v = (V)o;
+                            v = o;
 
                         vis.apply(k, v, ver);
                     }
@@ -540,16 +553,19 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @throws IgniteCheckedException If storage failed.
      */
     @SuppressWarnings("unchecked")
-    public boolean putToStore(@Nullable IgniteInternalTx tx, K key, V val, 
GridCacheVersion ver)
+    public boolean putToStore(@Nullable IgniteInternalTx tx, KeyCacheObject 
key, CacheObject val, GridCacheVersion ver)
         throws IgniteCheckedException {
         if (store != null) {
             // Never persist internal keys.
-            if (key instanceof GridCacheInternal)
+            if (key.internal())
                 return true;
 
+            Object storeKey = key.value(cctx);
+            Object storeVal = val.value(cctx);
+
             if (convertPortable) {
-                key = (K)cctx.unwrapPortableIfNeeded(key, false);
-                val = (V)cctx.unwrapPortableIfNeeded(val, false);
+                storeKey = cctx.unwrapPortableIfNeeded(storeKey, false);
+                storeVal = cctx.unwrapPortableIfNeeded(storeVal, false);
             }
 
             if (log.isDebugEnabled())
@@ -558,7 +574,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             boolean ses = initSession(tx);
 
             try {
-                store.write(new CacheEntryImpl<>(key, locStore ? F.t(val, ver) 
: val));
+                store.write(new CacheEntryImpl<>(storeKey, locStore ? 
F.t(storeVal, ver) : storeVal));
             }
             catch (ClassCastException e) {
                 handleClassCastException(e);
@@ -575,7 +591,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             }
 
             if (log.isDebugEnabled())
-                log.debug("Stored value in cache store [key=" + key + ", val=" 
+ val + ']');
+                log.debug("Stored value in cache store [key=" + storeKey + ", 
val=" + storeVal + ']');
 
             return true;
         }
@@ -591,13 +607,14 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @return {@code True} if there is a persistent storage.
      * @throws IgniteCheckedException If storage failed.
      */
-    public boolean putAllToStore(@Nullable IgniteInternalTx tx, Map<K, 
IgniteBiTuple<V, GridCacheVersion>> map)
+    public boolean putAllToStore(@Nullable IgniteInternalTx tx,
+        Map<KeyCacheObject, IgniteBiTuple<CacheObject, GridCacheVersion>> map)
         throws IgniteCheckedException {
         if (F.isEmpty(map))
             return true;
 
         if (map.size() == 1) {
-            Map.Entry<K, IgniteBiTuple<V, GridCacheVersion>> e = 
map.entrySet().iterator().next();
+            Map.Entry<KeyCacheObject, IgniteBiTuple<CacheObject, 
GridCacheVersion>> e = map.entrySet().iterator().next();
 
             return putToStore(tx, e.getKey(), e.getValue().get1(), 
e.getValue().get2());
         }
@@ -611,7 +628,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
                 boolean ses = initSession(tx);
 
                 try {
-                    store.writeAll(entries);
+                    store.writeAll((Collection<Cache.Entry<? extends Object, ? 
extends Object>>)entries);
                 }
                 catch (ClassCastException e) {
                     handleClassCastException(e);
@@ -653,14 +670,16 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @throws IgniteCheckedException If storage failed.
      */
     @SuppressWarnings("unchecked")
-    public boolean removeFromStore(@Nullable IgniteInternalTx tx, K key) 
throws IgniteCheckedException {
+    public boolean removeFromStore(@Nullable IgniteInternalTx tx, 
KeyCacheObject key) throws IgniteCheckedException {
         if (store != null) {
             // Never remove internal key from store as it is never persisted.
-            if (key instanceof GridCacheInternal)
+            if (key.internal())
                 return false;
 
+            Object storeKey = key.value(cctx);
+
             if (convertPortable)
-                key = (K)cctx.unwrapPortableIfNeeded(key, false);
+                storeKey = cctx.unwrapPortableIfNeeded(storeKey, false);
 
             if (log.isDebugEnabled())
                 log.debug("Removing value from cache store [key=" + key + ']');
@@ -668,7 +687,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             boolean ses = initSession(tx);
 
             try {
-                store.delete(key);
+                store.delete(storeKey);
             }
             catch (ClassCastException e) {
                 handleClassCastException(e);
@@ -700,19 +719,34 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @throws IgniteCheckedException If storage failed.
      */
     @SuppressWarnings("unchecked")
-    public boolean removeAllFromStore(@Nullable IgniteInternalTx tx, 
Collection<?> keys) throws IgniteCheckedException {
+    public boolean removeAllFromStore(@Nullable IgniteInternalTx tx, 
Collection<KeyCacheObject> keys)
+        throws IgniteCheckedException {
         if (F.isEmpty(keys))
             return true;
 
         if (keys.size() == 1) {
-            Object key = keys.iterator().next();
+            KeyCacheObject key = keys.iterator().next();
 
-            return removeFromStore(tx, (K)key);
+            return removeFromStore(tx, key);
         }
 
         if (store != null) {
-            Collection<Object> keys0 = convertPortable ?
-                cctx.unwrapPortablesIfNeeded((Collection<Object>)keys, false) 
: (Collection<Object>)keys;
+            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), 
false);
+                    }
+                });
+            }
+            else {
+                keys0 = F.viewReadOnly(keys, new C1<KeyCacheObject, Object>() {
+                    @Override public Object apply(KeyCacheObject key) {
+                        return key.value(cctx);
+                    }
+                });
+            }
 
             if (log.isDebugEnabled())
                 log.debug("Removing values from cache store [keys=" + keys0 + 
']');
@@ -751,7 +785,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
     /**
      * @return Store.
      */
-    public CacheStore<K, Object> store() {
+    public CacheStore<Object, Object> store() {
         return store;
     }
 
@@ -804,7 +838,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @param tx Current transaction.
      * @return {@code True} if session was initialized.
      */
-    private boolean initSession(@Nullable IgniteInternalTx<?, ?> tx) {
+    private boolean initSession(@Nullable IgniteInternalTx tx) {
         if (!sesEnabled)
             return false;
 
@@ -937,12 +971,12 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      *
      */
     @SuppressWarnings("unchecked")
-    private class EntriesView extends AbstractCollection<Cache.Entry<? extends 
K, ?>> {
+    private class EntriesView extends AbstractCollection<Cache.Entry<?, ?>> {
         /** */
-        private final Map<K, IgniteBiTuple<V, GridCacheVersion>> map;
+        private final Map<KeyCacheObject, IgniteBiTuple<CacheObject, 
GridCacheVersion>> map;
 
         /** */
-        private Set<K> rmvd;
+        private Set<KeyCacheObject> rmvd;
 
         /** */
         private boolean cleared;
@@ -950,7 +984,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
         /**
          * @param map Map.
          */
-        private EntriesView(Map<K, IgniteBiTuple<V, GridCacheVersion>> map) {
+        private EntriesView(Map<KeyCacheObject, IgniteBiTuple<CacheObject, 
GridCacheVersion>> map) {
             assert map != null;
 
             this.map = map;
@@ -971,24 +1005,28 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             if (cleared || !(o instanceof Cache.Entry))
                 return false;
 
-            Cache.Entry<? extends K, ?> e = (Cache.Entry<? extends K, ?>)o;
+            if (o instanceof EntryImpl)
+                return map.containsKey(((EntryImpl)o).keyObj);
 
-            return map.containsKey(e.getKey());
+            Cache.Entry<Object, Object> e = (Cache.Entry<Object, Object>)o;
+
+            return map.containsKey(cctx.toCacheKeyObject(e.getKey()));
         }
 
         /** {@inheritDoc} */
-        @NotNull @Override public Iterator<Cache.Entry<? extends K, ?>> 
iterator() {
+        @NotNull @Override public Iterator<Cache.Entry<?, ?>> iterator() {
             if (cleared)
                 return F.emptyIterator();
 
-            final Iterator<Map.Entry<K, IgniteBiTuple<V, GridCacheVersion>>> 
it0 = map.entrySet().iterator();
+            final Iterator<Map.Entry<KeyCacheObject, 
IgniteBiTuple<CacheObject, GridCacheVersion>>> it0 =
+                map.entrySet().iterator();
 
-            return new Iterator<Cache.Entry<? extends K, ?>>() {
+            return new Iterator<Cache.Entry<?, ?>>() {
                 /** */
-                private Cache.Entry<? extends K, ?> cur;
+                private Cache.Entry<Object, Object> cur;
 
                 /** */
-                private Cache.Entry<? extends K, ?> next;
+                private Cache.Entry<Object, Object> next;
 
                 /**
                  *
@@ -1002,21 +1040,22 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
                  */
                 private void checkNext() {
                     while (it0.hasNext()) {
-                        Map.Entry<K, IgniteBiTuple<V, GridCacheVersion>> e = 
it0.next();
+                        Map.Entry<KeyCacheObject, IgniteBiTuple<CacheObject, 
GridCacheVersion>> e = it0.next();
 
-                        K k = e.getKey();
+                        KeyCacheObject k = e.getKey();
 
                         if (rmvd != null && rmvd.contains(k))
                             continue;
 
-                        Object v = locStore ? e.getValue() : 
e.getValue().get1();
+                        Object storeKey = e.getKey().value(cctx);
+                        Object storeVal = e.getValue().get1().value(cctx);
 
                         if (convertPortable) {
-                            k = (K)cctx.unwrapPortableIfNeeded(k, false);
-                            v = cctx.unwrapPortableIfNeeded(v, false);
+                            storeKey = cctx.unwrapPortableIfNeeded(storeKey, 
false);
+                            storeVal = cctx.unwrapPortableIfNeeded(storeVal, 
false);
                         }
 
-                        next = new CacheEntryImpl<>(k, v);
+                        next = new EntryImpl<>(k, storeKey, storeVal);
 
                         break;
                     }
@@ -1026,7 +1065,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
                     return next != null;
                 }
 
-                @Override public Cache.Entry<? extends K, ?> next() {
+                @Override public Cache.Entry<Object, Object> next() {
                     if (next == null)
                         throw new NoSuchElementException();
 
@@ -1051,12 +1090,12 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
         }
 
         /** {@inheritDoc} */
-        @Override public boolean add(Cache.Entry<? extends K, ?> entry) {
+        @Override public boolean add(Cache.Entry<?, ?> entry) {
             throw new UnsupportedOperationException();
         }
 
         /** {@inheritDoc} */
-        @Override public boolean addAll(Collection<? extends Cache.Entry<? 
extends K, ?>> col) {
+        @Override public boolean addAll(Collection<? extends Cache.Entry<?, 
?>> col) {
             throw new UnsupportedOperationException();
         }
 
@@ -1065,16 +1104,20 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             if (cleared || !(o instanceof Cache.Entry))
                 return false;
 
-            Cache.Entry<? extends K, ?> e = (Cache.Entry<? extends K, ?>)o;
+            Cache.Entry<Object, Object> e = (Cache.Entry<Object, Object>)o;
 
-            if (rmvd != null && rmvd.contains(e.getKey()))
-                return false;
+            KeyCacheObject key;
+
+            if (e instanceof EntryImpl)
+                key = ((EntryImpl)e).keyObj;
+            else
+                key = cctx.toCacheKeyObject(e.getKey());
 
-            if (mapContains(e)) {
-                addRemoved(e);
+            if (rmvd != null && rmvd.contains(key))
+                return false;
 
-                return true;
-            }
+            if (map.containsKey(key))
+                rmvd.add(key);
 
             return false;
         }
@@ -1114,7 +1157,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
 
             boolean modified = false;
 
-            for (Cache.Entry<? extends K, ?> e : this) {
+            for (Cache.Entry<?, ?> e : this) {
                 if (!col.contains(e)) {
                     addRemoved(e);
 
@@ -1133,27 +1176,30 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
         /**
          * @param e Entry.
          */
-        private void addRemoved(Cache.Entry<? extends K, ?> e) {
+        private void addRemoved(Cache.Entry<?, ?> e) {
             if (rmvd == null)
                 rmvd = new HashSet<>();
 
-            rmvd.add(e.getKey());
+            if (e instanceof EntryImpl)
+                rmvd.add(((EntryImpl)e).keyObj);
+            else
+                rmvd.add(cctx.toCacheKeyObject(e.getKey()));
         }
 
         /**
          * @param e Entry.
          * @return {@code True} if original map contains entry.
          */
-        private boolean mapContains(Cache.Entry<? extends K, ?> e) {
-            K key = (K)(convertPortable ? cctx.marshalToPortable(e.getKey()) : 
e.getKey());
-
-            return map.containsKey(key);
+        private boolean mapContains(Cache.Entry<Object, Object> e) {
+            if (e instanceof EntryImpl)
+                return map.containsKey(((EntryImpl)e).keyObj);
 
+            return map.containsKey(cctx.toCacheKeyObject(e.getKey()));
         }
 
         /** {@inheritDoc} */
         public String toString() {
-            Iterator<Cache.Entry<? extends K, ?>> it = iterator();
+            Iterator<Cache.Entry<?, ?>> it = iterator();
 
             if (!it.hasNext())
                 return "[]";
@@ -1161,7 +1207,7 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             SB sb = new SB("[");
 
             while (true) {
-                Cache.Entry<? extends K, ?> e = it.next();
+                Cache.Entry<?, ?> e = it.next();
 
                 sb.a(e.toString());
 
@@ -1172,4 +1218,53 @@ public class GridCacheStoreManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             }
         }
     }
+
+    /**
+     *
+     */
+    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/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java
index afac629..72524dd 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntry.java
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.*;
 /**
  * Swap entry.
  */
-public interface GridCacheSwapEntry<V> {
+public interface GridCacheSwapEntry {
     /**
      * @return Value bytes.
      */
@@ -38,12 +38,12 @@ public interface GridCacheSwapEntry<V> {
     /**
      * @return Value.
      */
-    public V value();
+    public CacheObject value();
 
     /**
      * @param val Value.
      */
-    void value(V val);
+    void value(CacheObject val);
 
     /**
      * @return Whether value is byte array.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
index 24750d4..c07f083 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapEntryImpl.java
@@ -29,7 +29,7 @@ import java.nio.*;
 /**
  * Swap entry.
  */
-public class GridCacheSwapEntryImpl<V> implements GridCacheSwapEntry<V> {
+public class GridCacheSwapEntryImpl implements GridCacheSwapEntry {
     /** */
     private static final Unsafe UNSAFE = GridUnsafe.unsafe();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index 0a7b768..d8e0809 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -44,7 +44,7 @@ import static org.apache.ignite.events.EventType.*;
 /**
  * Handles all swap operations.
  */
-public class GridCacheSwapManager<K, V> extends GridCacheManagerAdapter<K, V> {
+public class GridCacheSwapManager extends GridCacheManagerAdapter {
     /** Swap manager. */
     private GridSwapSpaceManager swapMgr;
 
@@ -238,7 +238,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @param keyBytes Key bytes.
      * @param e Entry.
      */
-    private void onOffHeaped(int part, K key, byte[] keyBytes, 
GridCacheSwapEntry<V> e) {
+    private void onOffHeaped(int part, KeyCacheObject key, byte[] keyBytes, 
GridCacheSwapEntry e) {
         onEntryUnswapped(offheapLsnrs, part, key, keyBytes, e);
     }
 
@@ -474,7 +474,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings({"unchecked"})
-    @Nullable private GridCacheSwapEntry<V> read(K key,
+    @Nullable private GridCacheSwapEntry read(KeyCacheObject key,
         byte[] keyBytes,
         int part,
         boolean entryLocked,
@@ -531,7 +531,8 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings({"unchecked"})
-    @Nullable GridCacheSwapEntry<V> readAndRemove(final K key, final byte[] 
keyBytes) throws IgniteCheckedException {
+    @Nullable GridCacheSwapEntry readAndRemove(final KeyCacheObject key, final 
byte[] keyBytes)
+        throws IgniteCheckedException {
         if (!offheapEnabled && !swapEnabled)
             return null;
 
@@ -544,7 +545,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
             byte[] entryBytes = offheap.remove(spaceName, part, key, keyBytes);
 
             if (entryBytes != null) {
-                GridCacheSwapEntry<V> entry = 
swapEntry(unmarshalSwapEntry(entryBytes));
+                GridCacheSwapEntry entry = 
swapEntry(unmarshalSwapEntry(entryBytes));
 
                 if (entry == null)
                     return null;
@@ -694,7 +695,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @return Read value.
      * @throws IgniteCheckedException If read failed.
      */
-    @Nullable public GridCacheSwapEntry<V> read(K key,
+    @Nullable public GridCacheSwapEntry read(KeyCacheObject key,
         boolean readOffheap,
         boolean readSwap)
         throws IgniteCheckedException
@@ -724,7 +725,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @return Collection of swap entries.
      * @throws IgniteCheckedException If failed,
      */
-    public Collection<GridCacheBatchSwapEntry<K, V>> 
readAndRemove(Collection<? extends K> keys)
+    public Collection<GridCacheBatchSwapEntry> readAndRemove(Collection<? 
extends KeyCacheObject> keys)
         throws IgniteCheckedException {
         if (!offheapEnabled && !swapEnabled)
             return Collections.emptyList();
@@ -734,11 +735,11 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
         final GridCacheQueryManager<K, V> qryMgr = cctx.queries();
 
         Collection<SwapKey> unprocessedKeys = null;
-        final Collection<GridCacheBatchSwapEntry<K, V>> res = new 
ArrayList<>(keys.size());
+        final Collection<GridCacheBatchSwapEntry> res = new 
ArrayList<>(keys.size());
 
         // First try removing from offheap.
         if (offheapEnabled) {
-            for (K key : keys) {
+            for (KeyCacheObject key : keys) {
                 int part = cctx.affinity().partition(key);
 
                 byte[] keyBytes = CU.marshal(cctx.shared(), key);
@@ -746,7 +747,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
                 byte[] entryBytes = offheap.remove(spaceName, part, key, 
keyBytes);
 
                 if (entryBytes != null) {
-                    GridCacheSwapEntry<V> entry = 
swapEntry(unmarshalSwapEntry(entryBytes));
+                    GridCacheSwapEntry entry = 
swapEntry(unmarshalSwapEntry(entryBytes));
 
                     if (entry != null) {
                         // Always fire this event, since preloading depends on 
it.
@@ -861,7 +862,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @return Read value.
      * @throws IgniteCheckedException If read failed.
      */
-    @Nullable GridCacheSwapEntry<V> readAndRemove(K key) throws 
IgniteCheckedException {
+    @Nullable GridCacheSwapEntry readAndRemove(KeyCacheObject key) throws 
IgniteCheckedException {
         if (!offheapEnabled && !swapEnabled)
             return null;
 
@@ -1275,7 +1276,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @return Lazy swap iterator.
      * @throws IgniteCheckedException If failed.
      */
-    public Iterator<Map.Entry<K, V>> lazySwapIterator() throws 
IgniteCheckedException {
+    public <K, V> Iterator<Map.Entry<K, V>> lazySwapIterator() throws 
IgniteCheckedException {
         if (!swapEnabled)
             return new GridEmptyIterator<>();
 
@@ -1285,7 +1286,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
     /**
      * @return Lazy off-heap iterator.
      */
-    public Iterator<Map.Entry<K, V>> lazyOffHeapIterator() {
+    public <K, V> Iterator<Map.Entry<K, V>> lazyOffHeapIterator() {
         if (!offheapEnabled)
             return new GridEmptyCloseableIterator<>();
 
@@ -1316,7 +1317,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @param it Closeable iterator.
      * @return Lazy iterator.
      */
-    private Iterator<Map.Entry<K, V>> lazyIterator(
+    private <K, V> Iterator<Map.Entry<K, V>> lazyIterator(
         final GridCloseableIterator<? extends Map.Entry<byte[], byte[]>> it) {
         if (it == null)
             return new GridEmptyIterator<>();
@@ -1342,7 +1343,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
 
                     @Override public V getValue() {
                         try {
-                            GridCacheSwapEntry<V> e = 
unmarshalSwapEntry(cur0.getValue());
+                            GridCacheSwapEntry e = 
unmarshalSwapEntry(cur0.getValue());
 
                             swapEntry(e);
 
@@ -1515,7 +1516,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @return Swap entries iterator.
      * @throws IgniteCheckedException If failed.
      */
-    public Iterator<Cache.Entry<K, V>> swapIterator(boolean primary, boolean 
backup, long topVer)
+    public <K, V> Iterator<Cache.Entry<K, V>> swapIterator(boolean primary, 
boolean backup, long topVer)
         throws IgniteCheckedException
     {
         assert primary || backup;
@@ -1545,7 +1546,7 @@ public class GridCacheSwapManager<K, V> extends 
GridCacheManagerAdapter<K, V> {
      * @return Offheap entries iterator.
      * @throws IgniteCheckedException If failed.
      */
-    public Iterator<Cache.Entry<K, V>> offheapIterator(boolean primary, 
boolean backup, long topVer)
+    public <K, V> Iterator<Cache.Entry<K, V>> offheapIterator(boolean primary, 
boolean backup, long topVer)
         throws IgniteCheckedException
     {
         assert primary || backup;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java
index b5596d1..af96e0c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUpdateAtomicResult.java
@@ -27,17 +27,17 @@ import javax.cache.processor.*;
 /**
  * Cache entry atomic update result.
  */
-public class GridCacheUpdateAtomicResult<K, V> {
+public class GridCacheUpdateAtomicResult {
     /** Success flag.*/
     private final boolean success;
 
     /** Old value. */
     @GridToStringInclude
-    private final V oldVal;
+    private final CacheObject oldVal;
 
     /** New value. */
     @GridToStringInclude
-    private final V newVal;
+    private final CacheObject newVal;
 
     /** New TTL. */
     private final long newTtl;
@@ -51,7 +51,7 @@ public class GridCacheUpdateAtomicResult<K, V> {
 
     /** DR resolution result. */
     @GridToStringInclude
-    private final GridCacheVersionConflictContext<K, V> conflictRes;
+    private final GridCacheVersionConflictContext<?, ?> conflictRes;
 
     /** Whether update should be propagated to DHT node. */
     private final boolean sndToDht;
@@ -73,13 +73,13 @@ public class GridCacheUpdateAtomicResult<K, V> {
      * @param sndToDht Whether update should be propagated to DHT node.
      */
     public GridCacheUpdateAtomicResult(boolean success,
-        @Nullable V oldVal,
-        @Nullable V newVal,
+        @Nullable CacheObject oldVal,
+        @Nullable CacheObject newVal,
         @Nullable EntryProcessorResult<?> res,
         long newTtl,
         long conflictExpireTime,
         @Nullable GridCacheVersion rmvVer,
-        @Nullable GridCacheVersionConflictContext<K, V> conflictRes,
+        @Nullable GridCacheVersionConflictContext<?, ?> conflictRes,
         boolean sndToDht) {
         this.success = success;
         this.oldVal = oldVal;
@@ -109,14 +109,14 @@ public class GridCacheUpdateAtomicResult<K, V> {
     /**
      * @return Old value.
      */
-    @Nullable public V oldValue() {
+    @Nullable public CacheObject oldValue() {
         return oldVal;
     }
 
     /**
      * @return New value.
      */
-    @Nullable public V newValue() {
+    @Nullable public CacheObject newValue() {
         return newVal;
     }
 
@@ -145,7 +145,7 @@ public class GridCacheUpdateAtomicResult<K, V> {
     /**
      * @return DR conflict resolution context.
      */
-    @Nullable public GridCacheVersionConflictContext<K, V> 
conflictResolveResult() {
+    @Nullable public GridCacheVersionConflictContext<?, ?> 
conflictResolveResult() {
         return conflictRes;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObject.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObject.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObject.java
new file mode 100644
index 0000000..8a96a32
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/KeyCacheObject.java
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+/**
+ *
+ */
+public interface KeyCacheObject extends CacheObject {
+    /**
+     * @return Key hash code.
+     */
+    public int hashCode();
+
+    public boolean internal();
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b7ea910f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java
index d6f175e..db0d39c 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheOptimisticCheckPreparedTxRequest.java
@@ -30,7 +30,7 @@ import java.nio.*;
  * Message sent to check that transactions related to some optimistic 
transaction
  * were prepared on remote node.
  */
-public class GridCacheOptimisticCheckPreparedTxRequest<K, V> extends 
GridDistributedBaseMessage<K, V> {
+public class GridCacheOptimisticCheckPreparedTxRequest extends 
GridDistributedBaseMessage {
     /** */
     private static final long serialVersionUID = 0L;
 
@@ -62,7 +62,7 @@ public class GridCacheOptimisticCheckPreparedTxRequest<K, V> 
extends GridDistrib
      * @param futId Future ID.
      * @param miniId Mini future ID.
      */
-    public GridCacheOptimisticCheckPreparedTxRequest(IgniteInternalTx<K, V> 
tx, int txNum, IgniteUuid futId,
+    public GridCacheOptimisticCheckPreparedTxRequest(IgniteInternalTx tx, int 
txNum, IgniteUuid futId,
         IgniteUuid miniId) {
         super(tx.xidVersion(), 0);
 

Reply via email to