http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/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 8bc5230..ac50450 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
@@ -20,6 +20,7 @@ package 
org.apache.ignite.internal.processors.cache.transactions;
 import org.apache.ignite.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
 import org.apache.ignite.internal.processors.cache.dr.*;
@@ -467,7 +468,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends 
IgniteTxAdapter<K, V>
      * @param topVer Topology version.
      * @return Cache entry.
      */
-    protected GridCacheEntryEx<K, V> entryEx(GridCacheContext<K, V> cacheCtx, 
IgniteTxKey<K> key, long topVer) {
+    protected GridCacheEntryEx<K, V> entryEx(GridCacheContext<K, V> cacheCtx, 
IgniteTxKey<K> key, AffinityTopologyVersion topVer) {
         return cacheCtx.cache().entryEx(key.key(), topVer);
     }
 
@@ -672,7 +673,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends 
IgniteTxAdapter<K, V>
             try {
                 cctx.tm().txContext(this);
 
-                long topVer = topologyVersion();
+                AffinityTopologyVersion topVer = topologyVersion();
 
                 /*
                  * Commit to cache. Note that for 'near' transaction we loop 
through all the entries.
@@ -1138,7 +1139,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends 
IgniteTxAdapter<K, V>
 
         Collection<K> lockKeys = null;
 
-        long topVer = topologyVersion();
+        AffinityTopologyVersion topVer = topologyVersion();
 
         // In this loop we cover only read-committed or optimistic 
transactions.
         // Transactions that are pessimistic and not read-committed are covered

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index cf32dcc..42e4c0d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -21,6 +21,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.managers.eventstorage.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.distributed.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
@@ -496,7 +497,7 @@ public class IgniteTxManager<K, V> extends 
GridCacheSharedManagerAdapter<K, V> {
      * @param topVer Topology version.
      * @return Future that will be completed when all ongoing transactions are 
finished.
      */
-    public IgniteInternalFuture<Boolean> finishTxs(long topVer) {
+    public IgniteInternalFuture<Boolean> finishTxs(AffinityTopologyVersion 
topVer) {
         GridCompoundFuture<IgniteInternalTx, Boolean> res =
             new GridCompoundFuture<>(context().kernalContext(),
                 new IgniteReducer<IgniteInternalTx, Boolean>() {
@@ -514,7 +515,8 @@ public class IgniteTxManager<K, V> extends 
GridCacheSharedManagerAdapter<K, V> {
             // values pending to be overwritten by prepared transaction.
 
             if (tx.concurrency() == PESSIMISTIC) {
-                if (tx.topologyVersion() > 0 && tx.topologyVersion() < topVer)
+                if 
(tx.topologyVersion().compareTo(AffinityTopologyVersion.ZERO) > 0
+                    && tx.topologyVersion().compareTo(topVer) < 0)
                     // For PESSIMISTIC mode we must wait for all uncompleted 
txs
                     // as we do not know in advance which keys will 
participate in tx.
                     res.add(tx.finishFuture());
@@ -523,10 +525,10 @@ public class IgniteTxManager<K, V> extends 
GridCacheSharedManagerAdapter<K, V> {
                 // For OPTIMISTIC mode we wait only for txs in PREPARING state 
that
                 // have keys for given partitions.
                 TransactionState state = tx.state();
-                long txTopVer = tx.topologyVersion();
+                AffinityTopologyVersion txTopVer = tx.topologyVersion();
 
                 if ((state == PREPARING || state == PREPARED || state == 
COMMITTING)
-                    && txTopVer > 0 && txTopVer < topVer) {
+                    && txTopVer.compareTo(AffinityTopologyVersion.ZERO) > 0 && 
txTopVer.compareTo(topVer) < 0) {
                     res.add(tx.finishFuture());
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java
index 74b38f9..337f316 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionManager.java
@@ -21,6 +21,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.managers.eventstorage.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
@@ -166,8 +167,8 @@ public class GridCacheVersionManager<K, V> extends 
GridCacheSharedManagerAdapter
      * @param topVer Topology version for which new version should be obtained.
      * @return Next version based on given topology version.
      */
-    public GridCacheVersion next(long topVer) {
-        return next(topVer, true, false);
+    public GridCacheVersion next(AffinityTopologyVersion topVer) {
+        return next(topVer.topologyVersion(), true, false);
     }
 
     /**
@@ -184,8 +185,8 @@ public class GridCacheVersionManager<K, V> extends 
GridCacheSharedManagerAdapter
      *
      * @return Next version for cache store operations.
      */
-    public GridCacheVersion nextForLoad(long topVer) {
-        return next(topVer, true, true);
+    public GridCacheVersion nextForLoad(AffinityTopologyVersion topVer) {
+        return next(topVer.topologyVersion(), true, true);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
index ced8d1d..340edfc 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/dataload/IgniteDataLoaderImpl.java
@@ -1399,7 +1399,7 @@ public class IgniteDataLoaderImpl<K, V> implements 
IgniteDataLoader<K, V>, Delay
 
             GridCacheContext<K, V> cctx = internalCache.context();
 
-            long topVer = cctx.affinity().affinityTopologyVersion();
+            AffinityTopologyVersion topVer = 
cctx.affinity().affinityTopologyVersion();
 
             GridCacheVersion ver = cctx.versions().next(topVer);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
index 5d96086..0caf4aa 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/datastructures/GridCacheSetImpl.java
@@ -21,6 +21,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.affinity.*;
 import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.internal.util.*;
@@ -422,7 +423,7 @@ public class GridCacheSetImpl<T> extends 
AbstractCollection<T> implements Ignite
      * @throws IgniteCheckedException If all cache nodes left grid.
      */
     @SuppressWarnings("unchecked")
-    private Collection<ClusterNode> dataNodes(long topVer) throws 
IgniteCheckedException {
+    private Collection<ClusterNode> dataNodes(AffinityTopologyVersion topVer) 
throws IgniteCheckedException {
         if (ctx.isLocal() || ctx.isReplicated())
             return Collections.singleton(ctx.localNode());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
index 1793beb..9cf3b15 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/service/GridServiceProcessor.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.cluster.*;
 import org.apache.ignite.internal.managers.eventstorage.*;
 import org.apache.ignite.internal.processors.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.transactions.*;
 import org.apache.ignite.internal.processors.timeout.*;
@@ -620,7 +621,7 @@ public class GridServiceProcessor extends 
GridProcessorAdapter {
                 Map<UUID, Integer> cnts = new HashMap<>();
 
                 if (affKey != null) {
-                    ClusterNode n = ctx.affinity().mapKeyToNode(cacheName, 
affKey, topVer);
+                    ClusterNode n = ctx.affinity().mapKeyToNode(cacheName, 
affKey, new AffinityTopologyVersion(topVer));
 
                     if (n != null) {
                         int cnt = maxPerNodeCnt == 0 ? totalCnt == 0 ? 1 : 
totalCnt : maxPerNodeCnt;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
index 72a93e0..858882d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java
@@ -22,6 +22,7 @@ import org.apache.ignite.cache.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*;
@@ -153,7 +154,7 @@ public class VisorCache implements Serializable {
 
                     int sz = part.size();
 
-                    if (part.primary(-1)) // Pass -1 as topology version in 
order not to wait for topology version.
+                    if (part.primary(AffinityTopologyVersion.NONE)) // Pass -1 
as topology version in order not to wait for topology version.
                         pps.add(new IgnitePair<>(p, sz));
                     else
                         bps.add(new IgnitePair<>(p, sz));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridCachePartitionFairAffinitySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridCachePartitionFairAffinitySelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridCachePartitionFairAffinitySelfTest.java
index 40e654b..bc84e3d 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridCachePartitionFairAffinitySelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridCachePartitionFairAffinitySelfTest.java
@@ -113,7 +113,8 @@ public class GridCachePartitionFairAffinitySelfTest extends 
GridCommonAbstractTe
                 node);
 
             List<List<ClusterNode>> assignment = aff.assignPartitions(
-                new GridCacheAffinityFunctionContextImpl(nodes, prev, 
discoEvt, i, backups));
+                new GridCacheAffinityFunctionContextImpl(nodes, prev, 
discoEvt, new AffinityTopologyVersion(i),
+                    backups));
 
             info("Assigned.");
 
@@ -136,7 +137,8 @@ public class GridCachePartitionFairAffinitySelfTest extends 
GridCommonAbstractTe
             DiscoveryEvent discoEvt = new DiscoveryEvent(rmv, "", 
EventType.EVT_NODE_LEFT, rmv);
 
             List<List<ClusterNode>> assignment = aff.assignPartitions(
-                new GridCacheAffinityFunctionContextImpl(nodes, prev, 
discoEvt, i, backups));
+                new GridCacheAffinityFunctionContextImpl(nodes, prev, 
discoEvt, new AffinityTopologyVersion(i),
+                    backups));
 
             info("Assigned.");
 
@@ -208,7 +210,8 @@ public class GridCachePartitionFairAffinitySelfTest extends 
GridCommonAbstractTe
             info("======================================");
 
             List<List<ClusterNode>> assignment = aff.assignPartitions(
-                new GridCacheAffinityFunctionContextImpl(nodes, prev, 
discoEvt, i, backups));
+                new GridCacheAffinityFunctionContextImpl(nodes, prev, 
discoEvt, new AffinityTopologyVersion(i),
+                    backups));
 
             verifyAssignment(assignment, backups, parts, nodes.size());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
index c5b4dc8..dea19a4 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractFullApiSelfTest.java
@@ -26,6 +26,7 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
@@ -214,7 +215,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
             int sum = 0;
 
             for (String key : map.keySet())
-                if (ctx.affinity().localNode(key, 
ctx.discovery().topologyVersion()))
+                if (ctx.affinity().localNode(key, new 
AffinityTopologyVersion(ctx.discovery().topologyVersion())))
                     sum++;
 
             assertEquals("Incorrect key size on cache #" + i, sum, 
jcache(i).localSize());
@@ -3668,7 +3669,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
                 int size = 0;
 
                 for (String key : keys) {
-                    if (ctx.affinity().localNode(key, 
ctx.discovery().topologyVersion())) {
+                    if (ctx.affinity().localNode(key, new 
AffinityTopologyVersion(ctx.discovery().topologyVersion()))) {
                         GridCacheEntryEx<String, Integer> e =
                             ctx.isNear() ? ctx.near().dht().peekEx(key) : 
ctx.cache().peekEx(key);
 
@@ -3698,7 +3699,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
                 int size = 0;
 
                 for (String key : keys)
-                    if (ctx.affinity().localNode(key, 
ctx.discovery().topologyVersion()))
+                    if (ctx.affinity().localNode(key, new 
AffinityTopologyVersion(ctx.discovery().topologyVersion())))
                         size++;
 
                 assertEquals("Incorrect key size on cache #" + i, size, 
jcache(i).localSize());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityApiSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityApiSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityApiSelfTest.java
index a82b923..bec0893 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityApiSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityApiSelfTest.java
@@ -97,7 +97,8 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
      */
     public void testPrimaryPartitionsOneNode() throws Exception {
         CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null, 1, 1);
+            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+                new AffinityTopologyVersion(1), 1);
 
         List<List<ClusterNode>> assignment = affinity().assignPartitions(ctx);
 
@@ -139,7 +140,8 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
         assert !F.isEmpty(parts);
 
         CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null, 1, 1);
+            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+                new AffinityTopologyVersion(1), 1);
 
         List<List<ClusterNode>> assignment = affinity().assignPartitions(ctx);
 
@@ -169,7 +171,8 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
         assert !F.isEmpty(parts);
 
         CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null, 1, 1);
+            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+                new AffinityTopologyVersion(1), 1);
 
         List<List<ClusterNode>> assignment = affinity().assignPartitions(ctx);
 
@@ -202,7 +205,8 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
         assert !F.isEmpty(parts);
 
         CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null, 1, 1);
+            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+                new AffinityTopologyVersion(1), 1);
 
         List<List<ClusterNode>> assignment = affinity().assignPartitions(ctx);
 
@@ -224,7 +228,8 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
         int part = RND.nextInt(affinity().partitions());
 
         CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null, 1, 1);
+            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+                new AffinityTopologyVersion(1), 1);
 
         CacheAffinityFunction aff = affinity();
 
@@ -242,7 +247,8 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
         Map<Integer, ClusterNode> map = 
grid(0).affinity(null).mapPartitionsToNodes(F.asList(0, 1, 5, 19, 12));
 
         CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null, 1, 1);
+            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+                new AffinityTopologyVersion(1), 1);
 
         CacheAffinityFunction aff = affinity();
 
@@ -261,7 +267,8 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
         Map<Integer, ClusterNode> map = 
grid(0).affinity(null).mapPartitionsToNodes(F.asList(0, 1, 5, 19, 12));
 
         CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null, 1, 1);
+            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+                new AffinityTopologyVersion(1), 1);
 
         CacheAffinityFunction aff = affinity();
 
@@ -285,7 +292,8 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
         Map<Integer, ClusterNode> map = 
grid(0).affinity(null).mapPartitionsToNodes(parts);
 
         CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null, 1, 1);
+            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+                new AffinityTopologyVersion(1), 1);
 
         CacheAffinityFunction aff = affinity();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java
index 178ded8..0a10244 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheFinishPartitionsSelfTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.testframework.*;
 import org.apache.ignite.transactions.*;
@@ -132,7 +133,8 @@ public class GridCacheFinishPartitionsSelfTest extends 
GridCacheAbstractSelfTest
 
                 cache.get(key);
 
-                IgniteInternalFuture<?> fut = 
grid.context().cache().context().partitionReleaseFuture(GRID_CNT + 1);
+                IgniteInternalFuture<?> fut = 
grid.context().cache().context().partitionReleaseFuture(
+                    new AffinityTopologyVersion(GRID_CNT + 1));
 
                 fut.listenAsync(new CI1<IgniteInternalFuture<?>>() {
                     @Override public void apply(IgniteInternalFuture<?> e) {
@@ -155,7 +157,8 @@ public class GridCacheFinishPartitionsSelfTest extends 
GridCacheAbstractSelfTest
     }
 
     /**
-     * Tests method {@link 
GridCacheMvccManager#finishLocks(org.apache.ignite.lang.IgnitePredicate, long)}.
+     * Tests method {@link 
GridCacheMvccManager#finishLocks(org.apache.ignite.lang.IgnitePredicate,
+     * AffinityTopologyVersion)}.
      *
      * @throws Exception If failed.
      */
@@ -195,10 +198,11 @@ public class GridCacheFinishPartitionsSelfTest extends 
GridCacheAbstractSelfTest
 
             GridCacheAdapter<String, Integer> internal = grid.internalCache();
 
-            IgniteInternalFuture<?> nearFut = 
internal.context().mvcc().finishKeys(Collections.singletonList(key), 2);
+            IgniteInternalFuture<?> nearFut = 
internal.context().mvcc().finishKeys(Collections.singletonList(key),
+                new AffinityTopologyVersion(2));
 
             IgniteInternalFuture<?> dhtFut = 
internal.context().near().dht().context().mvcc().finishKeys(
-                Collections.singletonList(key), 2);
+                Collections.singletonList(key), new 
AffinityTopologyVersion(2));
 
             assert !nearFut.isDone();
             assert !dhtFut.isDone();
@@ -231,7 +235,7 @@ public class GridCacheFinishPartitionsSelfTest extends 
GridCacheAbstractSelfTest
 
         info("Start time: " + start);
 
-        IgniteInternalFuture<?> fut = ctx.partitionReleaseFuture(GRID_CNT + 1);
+        IgniteInternalFuture<?> fut = ctx.partitionReleaseFuture(new 
AffinityTopologyVersion(GRID_CNT + 1));
 
         assert fut != null;
 
@@ -291,7 +295,7 @@ public class GridCacheFinishPartitionsSelfTest extends 
GridCacheAbstractSelfTest
 
             info("Start time: " + start);
 
-            IgniteInternalFuture<?> fut = ctx.partitionReleaseFuture(GRID_CNT 
+ 1);
+            IgniteInternalFuture<?> fut = ctx.partitionReleaseFuture(new 
AffinityTopologyVersion(GRID_CNT + 1));
 
             assert fut != null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java
index fc6bb98..ec97d35 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMixedPartitionExchangeSelfTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.testframework.*;
@@ -129,9 +130,9 @@ public class GridCacheMixedPartitionExchangeSelfTest 
extends GridCommonAbstractT
 
             fut.get();
 
-            long topVer = grid(0).cluster().topologyVersion();
+            AffinityTopologyVersion topVer = new 
AffinityTopologyVersion(grid(0).cluster().topologyVersion());
 
-            assertEquals(29, topVer);
+            assertEquals(29, topVer.topologyVersion());
 
             // Check all grids have all exchange futures completed.
             for (int i = 0; i < 4; i++) {
@@ -139,10 +140,10 @@ public class GridCacheMixedPartitionExchangeSelfTest 
extends GridCommonAbstractT
 
                 GridCacheContext<Object, Object> cctx = 
grid.internalCache(null).context();
 
-                IgniteInternalFuture<Long> verFut = 
cctx.affinity().affinityReadyFuture(topVer);
+                IgniteInternalFuture<AffinityTopologyVersion> verFut = 
cctx.affinity().affinityReadyFuture(topVer);
 
-                assertEquals((Long)topVer, verFut.get());
-                assertEquals((Long)topVer, cctx.topologyVersionFuture().get());
+                assertEquals(topVer, verFut.get());
+                assertEquals(topVer, cctx.topologyVersionFuture().get());
             }
         }
         finally {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultiUpdateLockSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultiUpdateLockSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultiUpdateLockSelfTest.java
index 750daef..838bc79 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultiUpdateLockSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMultiUpdateLockSelfTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.processors.cache;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.spi.checkpoint.noop.*;
@@ -112,12 +113,12 @@ public class GridCacheMultiUpdateLockSelfTest extends 
GridCommonAbstractTest {
 
             GridDhtCacheAdapter cache = nearEnabled ? cctx.near().dht() : 
cctx.colocated();
 
-            long topVer = cache.beginMultiUpdate();
+            AffinityTopologyVersion topVer = cache.beginMultiUpdate();
 
             IgniteInternalFuture<?> startFut;
 
             try {
-                assertEquals(3, topVer);
+                assertEquals(3, topVer.topologyVersion());
 
                 final AtomicBoolean started = new AtomicBoolean();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index b5e226f..466c3e9 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.eviction.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.transactions.*;
 import org.apache.ignite.internal.processors.cache.version.*;
 import org.apache.ignite.internal.processors.dr.*;
@@ -298,7 +299,7 @@ public class GridCacheTestEntryEx<K, V> extends 
GridMetadataAwareAdapter impleme
     }
 
     /** {@inheritDoc} */
-    @Override public boolean valid(long topVer) {
+    @Override public boolean valid(AffinityTopologyVersion topVer) {
         return true;
     }
 
@@ -434,10 +435,11 @@ public class GridCacheTestEntryEx<K, V> extends 
GridMetadataAwareAdapter impleme
     }
 
     /** @inheritDoc */
-    @Override public GridCacheUpdateTxResult<V> innerSet(@Nullable 
IgniteInternalTx<K, V> tx, UUID evtNodeId, UUID affNodeId,
-        @Nullable V val, @Nullable byte[] valBytes, boolean writeThrough, 
boolean retval, long ttl,
-        boolean evt, boolean metrics, long topVer, 
IgnitePredicate<Cache.Entry<K, V>>[] filter, GridDrType drType,
-        long drExpireTime, @Nullable GridCacheVersion drVer, UUID subjId, 
String taskName) throws IgniteCheckedException,
+    @Override public GridCacheUpdateTxResult<V> innerSet(@Nullable 
IgniteInternalTx<K, V> tx, UUID evtNodeId,
+        UUID affNodeId, @Nullable V val, @Nullable byte[] valBytes, boolean 
writeThrough, boolean retval, long ttl,
+        boolean evt, boolean metrics, AffinityTopologyVersion topVer, 
IgnitePredicate<Cache.Entry<K, V>>[] filter,
+        GridDrType drType, long drExpireTime, @Nullable GridCacheVersion 
drVer, UUID subjId, String taskName)
+        throws IgniteCheckedException,
         GridCacheEntryRemovedException {
         return new GridCacheUpdateTxResult<>(true, rawPut(val, ttl));
     }
@@ -499,9 +501,9 @@ public class GridCacheTestEntryEx<K, V> extends 
GridMetadataAwareAdapter impleme
 
     /** @inheritDoc */
     @Override public GridCacheUpdateTxResult<V> innerRemove(@Nullable 
IgniteInternalTx<K, V> tx, UUID evtNodeId,
-        UUID affNodeId, boolean writeThrough, boolean retval, boolean evt, 
boolean metrics, long topVer,
-        IgnitePredicate<Cache.Entry<K, V>>[] filter, GridDrType drType, 
@Nullable GridCacheVersion drVer, UUID subjId,
-        String taskName)
+        UUID affNodeId, boolean writeThrough, boolean retval, boolean evt, 
boolean metrics,
+        AffinityTopologyVersion topVer, IgnitePredicate<Cache.Entry<K, V>>[] 
filter, GridDrType drType,
+        @Nullable GridCacheVersion drVer, UUID subjId, String taskName)
         throws IgniteCheckedException, GridCacheEntryRemovedException {
         obsoleteVer = ver;
 
@@ -630,7 +632,7 @@ public class GridCacheTestEntryEx<K, V> extends 
GridMetadataAwareAdapter impleme
 
     /** @inheritDoc */
     @Override public boolean initialValue(V val, @Nullable byte[] valBytes, 
GridCacheVersion ver, long ttl,
-        long expireTime, boolean preload, long topVer, GridDrType drType) 
throws IgniteCheckedException,
+        long expireTime, boolean preload, AffinityTopologyVersion topVer, 
GridDrType drType) throws IgniteCheckedException,
         GridCacheEntryRemovedException {
         assert false; return false;
     }
@@ -838,7 +840,7 @@ public class GridCacheTestEntryEx<K, V> extends 
GridMetadataAwareAdapter impleme
     @Nullable @Override public V peek(boolean heap,
         boolean offheap,
         boolean swap,
-        long topVer,
+        AffinityTopologyVersion topVer,
         @Nullable IgniteCacheExpiryPolicy plc)
     {
         return null;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java
index 02f622f..87fa0c0 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheAbstractQueueFailoverDataConsistencySelfTest.java
@@ -21,6 +21,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.datastructures.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -357,7 +358,8 @@ public abstract class 
GridCacheAbstractQueueFailoverDataConsistencySelfTest exte
 
         for (int i = 0; i < gridCount(); i++) {
             for (GridCacheEntryEx e : 
((IgniteKernal)grid(i)).context().cache().internalCache(cctx.name()).map().allEntries0())
 {
-                if (aff.primary(grid(i).localNode(), e.key(), -1) && e.key() 
instanceof GridCacheQueueHeaderKey)
+                if (aff.primary(grid(i).localNode(), e.key(), 
AffinityTopologyVersion.NONE)
+                    && e.key() instanceof GridCacheQueueHeaderKey)
                     return i;
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java
index e6039a8..0fcf95f 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueEntryMoveSelfTest.java
@@ -250,7 +250,8 @@ public class GridCachePartitionedQueueEntryMoveSelfTest 
extends IgniteCollection
      */
     private Collection<ClusterNode> nodes(CacheAffinityFunction aff, int part, 
Collection<ClusterNode> nodes) {
         List<List<ClusterNode>> assignment = aff.assignPartitions(
-            new GridCacheAffinityFunctionContextImpl(new ArrayList<>(nodes), 
null, null, 1, BACKUP_CNT));
+            new GridCacheAffinityFunctionContextImpl(new ArrayList<>(nodes), 
null, null, new AffinityTopologyVersion(1),
+                BACKUP_CNT));
 
         return assignment.get(part);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
index 1248770..a5d7ad8 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
@@ -23,6 +23,7 @@ import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -133,7 +134,7 @@ public class GridCacheDhtPreloadDisabledSelfTest extends 
GridCommonAbstractTest
                 List<Collection<ClusterNode>> mappings = new 
ArrayList<>(nodeCnt);
 
                 for (int i = 0; i < nodeCnt; i++) {
-                    Collection<ClusterNode> nodes = topology(i).nodes(p, -1);
+                    Collection<ClusterNode> nodes = topology(i).nodes(p, 
AffinityTopologyVersion.NONE);
                     List<ClusterNode> owners = topology(i).owners(p);
 
                     int size = backups + 1;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java
index 0cf6684..82dc76a 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java
@@ -22,6 +22,7 @@ import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.affinity.*;
 import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.apache.ignite.cluster.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.preloader.*;
 import org.apache.ignite.internal.util.typedef.*;
@@ -68,9 +69,9 @@ public class GridCacheDhtTestUtils {
         GridDhtPartitionTopology<Integer,String> top = dht.topology();
 
         for (int i = 0; i < keyCnt; i++) {
-            cacheMap.putEntry(-1, i, "value" + i, 0);
+            cacheMap.putEntry(AffinityTopologyVersion.NONE, i, "value" + i, 0);
 
-            dht.preloader().request(Collections.singleton(i), -1);
+            dht.preloader().request(Collections.singleton(i), 
AffinityTopologyVersion.NONE);
 
             GridDhtLocalPartition part = top.localPartition(aff.partition(i), 
false);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
index 3d67051..ac538e9 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
@@ -24,6 +24,7 @@ import org.apache.ignite.cache.store.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.distributed.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.util.typedef.*;
@@ -668,7 +669,7 @@ public class GridCacheNearMultiNodeSelfTest extends 
GridCommonAbstractTest {
         lock.lock();
 
         try {
-            long topVer = grid(0).cluster().topologyVersion();
+            AffinityTopologyVersion topVer = new 
AffinityTopologyVersion(grid(0).cluster().topologyVersion());
 
             GridNearCacheEntry<Integer, String> nearEntry1 = nearEntry(0, key);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
index 9cc7ed9..b107e5a 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
@@ -22,6 +22,7 @@ import org.apache.ignite.cache.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.distributed.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.util.typedef.*;
@@ -215,8 +216,8 @@ public class GridCacheNearReadersSelfTest extends 
GridCommonAbstractTest {
 
         awaitPartitionMapExchange();
 
-        ((IgniteKernal)g1).internalCache(null).preloader().request(F.asList(1, 
2), 2).get();
-        ((IgniteKernal)g2).internalCache(null).preloader().request(F.asList(1, 
2), 2).get();
+        ((IgniteKernal)g1).internalCache(null).preloader().request(F.asList(1, 
2), new AffinityTopologyVersion(2)).get();
+        ((IgniteKernal)g2).internalCache(null).preloader().request(F.asList(1, 
2), new AffinityTopologyVersion(2)).get();
 
         IgniteCache<Integer, String> cache1 = g1.jcache(null);
         IgniteCache<Integer, String> cache2 = g2.jcache(null);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
index 685f9d2..15b13c2 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
@@ -22,6 +22,7 @@ import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.transactions.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
@@ -246,7 +247,7 @@ public class GridCachePartitionedTxSalvageSelfTest extends 
GridCommonAbstractTes
         GridCacheAffinityManager<Object, Object> affMgr = 
kernal.internalCache().context().affinity();
 
         for (int i = 0; i < KEY_CNT * GRID_CNT * 1.5; i++) {
-            if (!affMgr.localNode((Object)i, 
kernal.context().discovery().topologyVersion())) {
+            if (!affMgr.localNode((Object)i, new 
AffinityTopologyVersion(kernal.context().discovery().topologyVersion()))) {
                 keys.add(i);
 
                 if (keys.size() == KEY_CNT)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java 
b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
index 45fb430..3a245f7 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
@@ -24,6 +24,7 @@ import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.internal.*;
 import org.apache.ignite.internal.client.ssl.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.distributed.near.*;
@@ -901,7 +902,7 @@ public final class GridTestUtils {
                 boolean wait = false;
 
                 for (int p = 0; p < affinity(cache).partitions(); p++) {
-                    Collection<ClusterNode> nodes = top.nodes(p, -1);
+                    Collection<ClusterNode> nodes = top.nodes(p, 
AffinityTopologyVersion.NONE);
 
                     if (nodes.size() > backups + 1) {
                         LT.warn(log, null, "Partition map was not updated yet 
(will wait) [grid=" + g.name() +

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
 
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
index f1e813f..fa06ef4 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/common/GridCommonAbstractTest.java
@@ -25,6 +25,7 @@ import org.apache.ignite.compute.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.*;
 import org.apache.ignite.internal.processors.cache.distributed.dht.colocated.*;
@@ -381,7 +382,7 @@ public abstract class GridCommonAbstractTest extends 
GridAbstractTest {
 
                             int exp = affNodes.size();
 
-                            Collection<ClusterNode> owners = top.nodes(p, -1);
+                            Collection<ClusterNode> owners = top.nodes(p, 
AffinityTopologyVersion.NONE);
 
                             int actual = owners.size();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index e3da0b7..497c428 100644
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -22,6 +22,7 @@ import org.apache.ignite.cache.*;
 import org.apache.ignite.cache.query.annotations.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.internal.processors.query.*;
@@ -1465,7 +1466,8 @@ public class IgniteH2Indexing implements 
GridQueryIndexing {
 
                 return new IgniteBiPredicate<K, V>() {
                     @Override public boolean apply(K k, V v) {
-                        return 
cache.context().affinity().primary(ctx.discovery().localNode(), k, -1);
+                        return 
cache.context().affinity().primary(ctx.discovery().localNode(), k,
+                            AffinityTopologyVersion.NONE);
                     }
                 };
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4362085a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
----------------------------------------------------------------------
diff --git 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
index 6030cda..bc73bbe 100644
--- 
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
+++ 
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/twostep/GridMapQueryExecutor.java
@@ -20,6 +20,7 @@ package 
org.apache.ignite.internal.processors.query.h2.twostep;
 import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.internal.*;
+import org.apache.ignite.internal.processors.affinity.*;
 import org.apache.ignite.internal.processors.cache.*;
 import org.apache.ignite.internal.processors.cache.query.*;
 import org.apache.ignite.internal.processors.query.h2.*;
@@ -114,7 +115,8 @@ public class GridMapQueryExecutor {
 
                 return new IgniteBiPredicate<K, V>() {
                     @Override public boolean apply(K k, V v) {
-                        return 
cache.context().affinity().primary(ctx.discovery().localNode(), k, -1);
+                        return 
cache.context().affinity().primary(ctx.discovery().localNode(), k,
+                            AffinityTopologyVersion.NONE);
                     }
                 };
             }

Reply via email to