http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridCachePartitionFairAffinityNodesSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridCachePartitionFairAffinityNodesSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridCachePartitionFairAffinityNodesSelfTest.java
deleted file mode 100644
index 9893e70..0000000
--- 
a/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridCachePartitionFairAffinityNodesSelfTest.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.affinity.fair;
-
-import org.apache.ignite.cache.*;
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import java.util.*;
-
-/**
- * Tests partition fair affinity in real grid.
- */
-public class GridCachePartitionFairAffinityNodesSelfTest extends 
GridCommonAbstractTest {
-    /** IP finder. */
-    private static final TcpDiscoveryIpFinder IP_FINDER = new 
TcpDiscoveryVmIpFinder(true);
-
-    /** Number of backups. */
-    private int backups;
-
-    /** Number of partitions. */
-    private int parts = 512;
-
-    /** Add nodes test. */
-    private static final boolean[] ADD_ONLY = new boolean[] {true, true, true, 
true, true, true};
-
-    /** Add nodes test. */
-    private static final boolean[] ADD_REMOVE = new boolean[]
-        {
-            true,  true,  true,  true,  true, true,
-            false, false, false, false, false
-        };
-
-    /** */
-    private static final boolean[] MIXED1 = new boolean[]
-        {
-            // 1     2     3      2     3     4      3     4     5      4      
3      2
-            true, true, true, false, true, true, false, true, true, false, 
false, false
-        };
-
-    /** */
-    private static final boolean[] MIXED2 = new boolean[]
-        {
-            // 1     2     3      2      1     2      1     2     3      2     
 1     2
-            true, true, true, false, false, true, false, true, true, false, 
false, true
-        };
-
-    /** */
-    private static final boolean[] MIXED3 = new boolean[]
-        {
-            // 1     2     3     4     5     6      5     6     7     8     9  
    8      7     8     9
-            true, true, true, true, true, true, false, true, true, true, true, 
false, false, true, true,
-            //  8      7      6
-            false, false, false
-        };
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        CacheConfiguration ccfg = cacheConfiguration();
-
-        cfg.setCacheConfiguration(ccfg);
-
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-        discoSpi.setIpFinder(IP_FINDER);
-
-        cfg.setDiscoverySpi(discoSpi);
-
-        return cfg;
-    }
-
-    /**
-     * @return Cache configuration.
-     */
-    private CacheConfiguration cacheConfiguration() {
-        CacheConfiguration cfg = new CacheConfiguration();
-
-        cfg.setBackups(backups);
-
-        cfg.setCacheMode(CacheMode.PARTITIONED);
-
-        cfg.setNearConfiguration(null);
-
-        cfg.setAffinity(new CachePartitionFairAffinity(parts));
-
-        return cfg;
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testAdd() throws Exception {
-        checkSequence(ADD_ONLY);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testAddRemove() throws Exception {
-        checkSequence(ADD_REMOVE);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testMixed1() throws Exception {
-        checkSequence(MIXED1);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testMixed2() throws Exception {
-        checkSequence(MIXED2);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testMixed3() throws Exception {
-        checkSequence(MIXED3);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    private void checkSequence(boolean[] seq) throws Exception {
-        for (int b = 0; b < 3; b++) {
-            backups = b;
-
-            info(">>>>>>>>>>>>>>>> Checking backups: " + backups);
-
-            checkSequence0(seq);
-
-            info(">>>>>>>>>>>>>>>> Finished check: " + backups);
-        }
-    }
-
-    /**
-     * @param seq Start/stop sequence.
-     * @throws Exception If failed.
-     */
-    private void checkSequence0(boolean[] seq) throws Exception {
-        try {
-            startGrid(0);
-
-            TreeSet<Integer> started = new TreeSet<>();
-
-            started.add(0);
-
-            int topVer = 1;
-
-            for (boolean start : seq) {
-                if (start) {
-                    int nextIdx = nextIndex(started);
-
-                    startGrid(nextIdx);
-
-                    started.add(nextIdx);
-                }
-                else {
-                    int idx = started.last();
-
-                    stopGrid(idx);
-
-                    started.remove(idx);
-                }
-
-                topVer++;
-
-                info("Grid 0: " + grid(0).localNode().id());
-
-                
((IgniteKernal)grid(0)).internalCache().context().affinity().affinityReadyFuture(topVer).get();
-
-                for (int i : started) {
-                    if (i != 0) {
-                        IgniteEx grid = grid(i);
-
-                        
((IgniteKernal)grid).internalCache().context().affinity().affinityReadyFuture(topVer).get();
-
-                        info("Grid " + i + ": " + grid.localNode().id());
-
-                        for (int part = 0; part < parts; part++) {
-                            List<ClusterNode> firstNodes = 
(List<ClusterNode>)grid(0).affinity(null)
-                                .mapPartitionToPrimaryAndBackups(part);
-
-                            List<ClusterNode> secondNodes = 
(List<ClusterNode>)grid.affinity(null)
-                                .mapPartitionToPrimaryAndBackups(part);
-
-                            assertEquals(firstNodes.size(), 
secondNodes.size());
-
-                            for (int n = 0; n < firstNodes.size(); n++)
-                                assertEquals(firstNodes.get(n), 
secondNodes.get(n));
-                        }
-                    }
-                }
-            }
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * First positive integer that is not present in started set.
-     *
-     * @param started Already started indices.
-     * @return First positive integer that is not present in started set.
-     */
-    private int nextIndex(Collection<Integer> started) {
-        assert started.contains(0);
-
-        for (int i = 1; i < 10000; i++) {
-            if (!started.contains(i))
-                return i;
-        }
-
-        throw new IllegalStateException();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/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
deleted file mode 100644
index bc84e3d..0000000
--- 
a/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridCachePartitionFairAffinitySelfTest.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.affinity.fair;
-
-import org.apache.ignite.cache.affinity.*;
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.events.*;
-import org.apache.ignite.internal.processors.affinity.*;
-import org.apache.ignite.testframework.*;
-import org.apache.ignite.testframework.junits.common.*;
-
-import java.util.*;
-
-/**
- *
- */
-public class GridCachePartitionFairAffinitySelfTest extends 
GridCommonAbstractTest {
-    /**
-     * @throws Exception If failed.
-     */
-    public void testNodeRemovedNoBackups() throws Exception {
-        checkNodeRemoved(0);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testNodeRemovedOneBackup() throws Exception {
-        checkNodeRemoved(1);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testNodeRemovedTwoBackups() throws Exception {
-        checkNodeRemoved(2);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testNodeRemovedThreeBackups() throws Exception {
-        checkNodeRemoved(3);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testRandomReassignmentNoBackups() throws Exception {
-        checkRandomReassignment(0);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testRandomReassignmentOneBackup() throws Exception {
-        checkRandomReassignment(1);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testRandomReassignmentTwoBackups() throws Exception {
-        checkRandomReassignment(2);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testRandomReassignmentThreeBackups() throws Exception {
-        checkRandomReassignment(3);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    private void checkNodeRemoved(int backups) throws Exception {
-        int parts = 256;
-
-        CacheAffinityFunction aff = new CachePartitionFairAffinity(parts);
-
-        int nodesCnt = 50;
-
-        List<ClusterNode> nodes = new ArrayList<>(nodesCnt);
-
-        List<List<ClusterNode>> prev = null;
-
-        for (int i = 0; i < nodesCnt; i++) {
-            info("======================================");
-            info("Assigning partitions: " + i);
-            info("======================================");
-
-            ClusterNode node = new GridTestNode(UUID.randomUUID());
-
-            nodes.add(node);
-
-            DiscoveryEvent discoEvt = new DiscoveryEvent(node, "", 
EventType.EVT_NODE_JOINED,
-                node);
-
-            List<List<ClusterNode>> assignment = aff.assignPartitions(
-                new GridCacheAffinityFunctionContextImpl(nodes, prev, 
discoEvt, new AffinityTopologyVersion(i),
-                    backups));
-
-            info("Assigned.");
-
-            verifyAssignment(assignment, backups, parts, nodes.size());
-
-            prev = assignment;
-        }
-
-        info("======================================");
-        info("Will remove nodes.");
-        info("======================================");
-
-        for (int i = 0; i < nodesCnt - 1; i++) {
-            info("======================================");
-            info("Assigning partitions: " + i);
-            info("======================================");
-
-            ClusterNode rmv = nodes.remove(nodes.size() - 1);
-
-            DiscoveryEvent discoEvt = new DiscoveryEvent(rmv, "", 
EventType.EVT_NODE_LEFT, rmv);
-
-            List<List<ClusterNode>> assignment = aff.assignPartitions(
-                new GridCacheAffinityFunctionContextImpl(nodes, prev, 
discoEvt, new AffinityTopologyVersion(i),
-                    backups));
-
-            info("Assigned.");
-
-            verifyAssignment(assignment, backups, parts, nodes.size());
-
-            prev = assignment;
-        }
-    }
-
-    @SuppressWarnings("IfMayBeConditional")
-    private void checkRandomReassignment(int backups) {
-        int parts = 256;
-
-        CacheAffinityFunction aff = new CachePartitionFairAffinity(parts);
-
-        Random rnd = new Random();
-
-        int maxNodes = 50;
-
-        List<ClusterNode> nodes = new ArrayList<>(maxNodes);
-
-        List<List<ClusterNode>> prev = null;
-
-        int state = 0;
-
-        int i = 0;
-
-        while (true) {
-            boolean add;
-
-            if (nodes.size() < 2) {
-                // Returned back to one node?
-                if (state == 1)
-                    return;
-
-                add = true;
-            }
-            else if (nodes.size() == maxNodes) {
-                if (state == 0)
-                    state = 1;
-
-                add = false;
-            }
-            else {
-                // Nodes size in [2, maxNodes - 1].
-                if (state == 0)
-                    add = rnd.nextInt(3) != 0; // 66% to add, 33% to remove.
-                else
-                    add = rnd.nextInt(3) == 0; // 33% to add, 66% to remove.
-            }
-
-            DiscoveryEvent discoEvt;
-
-            if (add) {
-                ClusterNode addedNode = new GridTestNode(UUID.randomUUID());
-
-                nodes.add(addedNode);
-
-                discoEvt = new DiscoveryEvent(addedNode, "", 
EventType.EVT_NODE_JOINED, addedNode);
-            }
-            else {
-                ClusterNode rmvNode = nodes.remove(rnd.nextInt(nodes.size()));
-
-                discoEvt = new DiscoveryEvent(rmvNode, "", 
EventType.EVT_NODE_LEFT, rmvNode);
-            }
-
-            info("======================================");
-            info("Assigning partitions [iter=" + i + ", discoEvt=" + discoEvt 
+ ", nodesSize=" + nodes.size() + ']');
-            info("======================================");
-
-            List<List<ClusterNode>> assignment = aff.assignPartitions(
-                new GridCacheAffinityFunctionContextImpl(nodes, prev, 
discoEvt, new AffinityTopologyVersion(i),
-                    backups));
-
-            verifyAssignment(assignment, backups, parts, nodes.size());
-
-            prev = assignment;
-
-            i++;
-        }
-    }
-
-    /**
-     * @param assignment Assignment to verify.
-     */
-    private void verifyAssignment(List<List<ClusterNode>> assignment, int 
keyBackups, int partsCnt, int topSize) {
-        Map<UUID, Collection<Integer>> mapping = new HashMap<>();
-
-        int ideal = Math.round((float)partsCnt / topSize * Math.min(keyBackups 
+ 1, topSize));
-
-        for (int part = 0; part < assignment.size(); part++) {
-            for (ClusterNode node : assignment.get(part)) {
-                assert node != null;
-
-                Collection<Integer> parts = mapping.get(node.id());
-
-                if (parts == null) {
-                    parts = new HashSet<>();
-
-                    mapping.put(node.id(), parts);
-                }
-
-                assertTrue(parts.add(part));
-            }
-        }
-
-        int max = -1, min = Integer.MAX_VALUE;
-
-        for (Collection<Integer> parts : mapping.values()) {
-            max = Math.max(max, parts.size());
-            min = Math.min(min, parts.size());
-        }
-
-        log().warning("max=" + max + ", min=" + min + ", ideal=" + ideal + ", 
minDev=" + deviation(min, ideal) + "%, " +
-            "maxDev=" + deviation(max, ideal) + "%");
-
-        assertTrue("max=" + max + ", min=" + min, max - min < (keyBackups + 1) 
* topSize);
-    }
-
-    private static int deviation(int val, int ideal) {
-        return Math.round(Math.abs(((float)val - ideal) / ideal * 100));
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridFairAffinityFunctionNodesSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridFairAffinityFunctionNodesSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridFairAffinityFunctionNodesSelfTest.java
new file mode 100644
index 0000000..b000b8d
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridFairAffinityFunctionNodesSelfTest.java
@@ -0,0 +1,242 @@
+/*
+ * 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.cache.affinity.fair;
+
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.*;
+
+/**
+ * Tests partition fair affinity in real grid.
+ */
+public class GridFairAffinityFunctionNodesSelfTest extends 
GridCommonAbstractTest {
+    /** IP finder. */
+    private static final TcpDiscoveryIpFinder IP_FINDER = new 
TcpDiscoveryVmIpFinder(true);
+
+    /** Number of backups. */
+    private int backups;
+
+    /** Number of partitions. */
+    private int parts = 512;
+
+    /** Add nodes test. */
+    private static final boolean[] ADD_ONLY = new boolean[] {true, true, true, 
true, true, true};
+
+    /** Add nodes test. */
+    private static final boolean[] ADD_REMOVE = new boolean[]
+        {
+            true,  true,  true,  true,  true, true,
+            false, false, false, false, false
+        };
+
+    /** */
+    private static final boolean[] MIXED1 = new boolean[]
+        {
+            // 1     2     3      2     3     4      3     4     5      4      
3      2
+            true, true, true, false, true, true, false, true, true, false, 
false, false
+        };
+
+    /** */
+    private static final boolean[] MIXED2 = new boolean[]
+        {
+            // 1     2     3      2      1     2      1     2     3      2     
 1     2
+            true, true, true, false, false, true, false, true, true, false, 
false, true
+        };
+
+    /** */
+    private static final boolean[] MIXED3 = new boolean[]
+        {
+            // 1     2     3     4     5     6      5     6     7     8     9  
    8      7     8     9
+            true, true, true, true, true, true, false, true, true, true, true, 
false, false, true, true,
+            //  8      7      6
+            false, false, false
+        };
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) 
throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        CacheConfiguration ccfg = cacheConfiguration();
+
+        cfg.setCacheConfiguration(ccfg);
+
+        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
+
+        discoSpi.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(discoSpi);
+
+        return cfg;
+    }
+
+    /**
+     * @return Cache configuration.
+     */
+    private CacheConfiguration cacheConfiguration() {
+        CacheConfiguration cfg = new CacheConfiguration();
+
+        cfg.setBackups(backups);
+
+        cfg.setCacheMode(CacheMode.PARTITIONED);
+
+        cfg.setNearConfiguration(null);
+
+        cfg.setAffinity(new FairAffinityFunction(parts));
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testAdd() throws Exception {
+        checkSequence(ADD_ONLY);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testAddRemove() throws Exception {
+        checkSequence(ADD_REMOVE);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMixed1() throws Exception {
+        checkSequence(MIXED1);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMixed2() throws Exception {
+        checkSequence(MIXED2);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testMixed3() throws Exception {
+        checkSequence(MIXED3);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void checkSequence(boolean[] seq) throws Exception {
+        for (int b = 0; b < 3; b++) {
+            backups = b;
+
+            info(">>>>>>>>>>>>>>>> Checking backups: " + backups);
+
+            checkSequence0(seq);
+
+            info(">>>>>>>>>>>>>>>> Finished check: " + backups);
+        }
+    }
+
+    /**
+     * @param seq Start/stop sequence.
+     * @throws Exception If failed.
+     */
+    private void checkSequence0(boolean[] seq) throws Exception {
+        try {
+            startGrid(0);
+
+            TreeSet<Integer> started = new TreeSet<>();
+
+            started.add(0);
+
+            int topVer = 1;
+
+            for (boolean start : seq) {
+                if (start) {
+                    int nextIdx = nextIndex(started);
+
+                    startGrid(nextIdx);
+
+                    started.add(nextIdx);
+                }
+                else {
+                    int idx = started.last();
+
+                    stopGrid(idx);
+
+                    started.remove(idx);
+                }
+
+                topVer++;
+
+                info("Grid 0: " + grid(0).localNode().id());
+
+                
((IgniteKernal)grid(0)).internalCache().context().affinity().affinityReadyFuture(topVer).get();
+
+                for (int i : started) {
+                    if (i != 0) {
+                        IgniteEx grid = grid(i);
+
+                        
((IgniteKernal)grid).internalCache().context().affinity().affinityReadyFuture(topVer).get();
+
+                        info("Grid " + i + ": " + grid.localNode().id());
+
+                        for (int part = 0; part < parts; part++) {
+                            List<ClusterNode> firstNodes = 
(List<ClusterNode>)grid(0).affinity(null)
+                                .mapPartitionToPrimaryAndBackups(part);
+
+                            List<ClusterNode> secondNodes = 
(List<ClusterNode>)grid.affinity(null)
+                                .mapPartitionToPrimaryAndBackups(part);
+
+                            assertEquals(firstNodes.size(), 
secondNodes.size());
+
+                            for (int n = 0; n < firstNodes.size(); n++)
+                                assertEquals(firstNodes.get(n), 
secondNodes.get(n));
+                        }
+                    }
+                }
+            }
+        }
+        finally {
+            stopAllGrids();
+        }
+    }
+
+    /**
+     * First positive integer that is not present in started set.
+     *
+     * @param started Already started indices.
+     * @return First positive integer that is not present in started set.
+     */
+    private int nextIndex(Collection<Integer> started) {
+        assert started.contains(0);
+
+        for (int i = 1; i < 10000; i++) {
+            if (!started.contains(i))
+                return i;
+        }
+
+        throw new IllegalStateException();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridFairAffinityFunctionSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridFairAffinityFunctionSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridFairAffinityFunctionSelfTest.java
new file mode 100644
index 0000000..2dd2a8c
--- /dev/null
+++ 
b/modules/core/src/test/java/org/apache/ignite/cache/affinity/fair/GridFairAffinityFunctionSelfTest.java
@@ -0,0 +1,264 @@
+/*
+ * 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.cache.affinity.fair;
+
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.events.*;
+import org.apache.ignite.internal.processors.affinity.*;
+import org.apache.ignite.testframework.*;
+import org.apache.ignite.testframework.junits.common.*;
+
+import java.util.*;
+
+/**
+ *
+ */
+public class GridFairAffinityFunctionSelfTest extends GridCommonAbstractTest {
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNodeRemovedNoBackups() throws Exception {
+        checkNodeRemoved(0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNodeRemovedOneBackup() throws Exception {
+        checkNodeRemoved(1);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNodeRemovedTwoBackups() throws Exception {
+        checkNodeRemoved(2);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNodeRemovedThreeBackups() throws Exception {
+        checkNodeRemoved(3);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRandomReassignmentNoBackups() throws Exception {
+        checkRandomReassignment(0);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRandomReassignmentOneBackup() throws Exception {
+        checkRandomReassignment(1);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRandomReassignmentTwoBackups() throws Exception {
+        checkRandomReassignment(2);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testRandomReassignmentThreeBackups() throws Exception {
+        checkRandomReassignment(3);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void checkNodeRemoved(int backups) throws Exception {
+        int parts = 256;
+
+        AffinityFunction aff = new FairAffinityFunction(parts);
+
+        int nodesCnt = 50;
+
+        List<ClusterNode> nodes = new ArrayList<>(nodesCnt);
+
+        List<List<ClusterNode>> prev = null;
+
+        for (int i = 0; i < nodesCnt; i++) {
+            info("======================================");
+            info("Assigning partitions: " + i);
+            info("======================================");
+
+            ClusterNode node = new GridTestNode(UUID.randomUUID());
+
+            nodes.add(node);
+
+            DiscoveryEvent discoEvt = new DiscoveryEvent(node, "", 
EventType.EVT_NODE_JOINED,
+                node);
+
+            List<List<ClusterNode>> assignment = aff.assignPartitions(
+                new GridAffinityFunctionContextImpl(nodes, prev, discoEvt, new 
AffinityTopologyVersion(i),
+                    backups));
+
+            info("Assigned.");
+
+            verifyAssignment(assignment, backups, parts, nodes.size());
+
+            prev = assignment;
+        }
+
+        info("======================================");
+        info("Will remove nodes.");
+        info("======================================");
+
+        for (int i = 0; i < nodesCnt - 1; i++) {
+            info("======================================");
+            info("Assigning partitions: " + i);
+            info("======================================");
+
+            ClusterNode rmv = nodes.remove(nodes.size() - 1);
+
+            DiscoveryEvent discoEvt = new DiscoveryEvent(rmv, "", 
EventType.EVT_NODE_LEFT, rmv);
+
+            List<List<ClusterNode>> assignment = aff.assignPartitions(
+                new GridAffinityFunctionContextImpl(nodes, prev, discoEvt, new 
AffinityTopologyVersion(i),
+                    backups));
+
+            info("Assigned.");
+
+            verifyAssignment(assignment, backups, parts, nodes.size());
+
+            prev = assignment;
+        }
+    }
+
+    @SuppressWarnings("IfMayBeConditional")
+    private void checkRandomReassignment(int backups) {
+        int parts = 256;
+
+        AffinityFunction aff = new FairAffinityFunction(parts);
+
+        Random rnd = new Random();
+
+        int maxNodes = 50;
+
+        List<ClusterNode> nodes = new ArrayList<>(maxNodes);
+
+        List<List<ClusterNode>> prev = null;
+
+        int state = 0;
+
+        int i = 0;
+
+        while (true) {
+            boolean add;
+
+            if (nodes.size() < 2) {
+                // Returned back to one node?
+                if (state == 1)
+                    return;
+
+                add = true;
+            }
+            else if (nodes.size() == maxNodes) {
+                if (state == 0)
+                    state = 1;
+
+                add = false;
+            }
+            else {
+                // Nodes size in [2, maxNodes - 1].
+                if (state == 0)
+                    add = rnd.nextInt(3) != 0; // 66% to add, 33% to remove.
+                else
+                    add = rnd.nextInt(3) == 0; // 33% to add, 66% to remove.
+            }
+
+            DiscoveryEvent discoEvt;
+
+            if (add) {
+                ClusterNode addedNode = new GridTestNode(UUID.randomUUID());
+
+                nodes.add(addedNode);
+
+                discoEvt = new DiscoveryEvent(addedNode, "", 
EventType.EVT_NODE_JOINED, addedNode);
+            }
+            else {
+                ClusterNode rmvNode = nodes.remove(rnd.nextInt(nodes.size()));
+
+                discoEvt = new DiscoveryEvent(rmvNode, "", 
EventType.EVT_NODE_LEFT, rmvNode);
+            }
+
+            info("======================================");
+            info("Assigning partitions [iter=" + i + ", discoEvt=" + discoEvt 
+ ", nodesSize=" + nodes.size() + ']');
+            info("======================================");
+
+            List<List<ClusterNode>> assignment = aff.assignPartitions(
+                new GridAffinityFunctionContextImpl(nodes, prev, discoEvt, new 
AffinityTopologyVersion(i),
+                    backups));
+
+            verifyAssignment(assignment, backups, parts, nodes.size());
+
+            prev = assignment;
+
+            i++;
+        }
+    }
+
+    /**
+     * @param assignment Assignment to verify.
+     */
+    private void verifyAssignment(List<List<ClusterNode>> assignment, int 
keyBackups, int partsCnt, int topSize) {
+        Map<UUID, Collection<Integer>> mapping = new HashMap<>();
+
+        int ideal = Math.round((float)partsCnt / topSize * Math.min(keyBackups 
+ 1, topSize));
+
+        for (int part = 0; part < assignment.size(); part++) {
+            for (ClusterNode node : assignment.get(part)) {
+                assert node != null;
+
+                Collection<Integer> parts = mapping.get(node.id());
+
+                if (parts == null) {
+                    parts = new HashSet<>();
+
+                    mapping.put(node.id(), parts);
+                }
+
+                assertTrue(parts.add(part));
+            }
+        }
+
+        int max = -1, min = Integer.MAX_VALUE;
+
+        for (Collection<Integer> parts : mapping.values()) {
+            max = Math.max(max, parts.size());
+            min = Math.min(min, parts.size());
+        }
+
+        log().warning("max=" + max + ", min=" + min + ", ideal=" + ideal + ", 
minDev=" + deviation(min, ideal) + "%, " +
+            "maxDev=" + deviation(max, ideal) + "%");
+
+        assertTrue("max=" + max + ", min=" + min, max - min < (keyBackups + 1) 
* topSize);
+    }
+
+    private static int deviation(int val, int ideal) {
+        return Math.round(Math.abs(((float)val - ideal) / ideal * 100));
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java
index ff770d8..22e878b 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityMappedTest.java
@@ -33,7 +33,7 @@ import java.util.*;
 import static org.apache.ignite.cache.CacheMode.*;
 
 /**
- * Tests affinity mapping when {@link 
org.apache.ignite.cache.affinity.CacheAffinityKeyMapper} is used.
+ * Tests affinity mapping when {@link AffinityKeyMapper} is used.
  */
 public class GridAffinityMappedTest extends GridCommonAbstractTest {
     /** VM ip finder for TCP discovery. */
@@ -149,7 +149,7 @@ public class GridAffinityMappedTest extends 
GridCommonAbstractTest {
     /**
      * Mock affinity mapper implementation that substitutes values other than 
0 and 1 with 0.
      */
-    private static class MockCacheAffinityKeyMapper implements 
CacheAffinityKeyMapper {
+    private static class MockCacheAffinityKeyMapper implements 
AffinityKeyMapper {
         /** {@inheritDoc} */
         @Override public Object affinityKey(Object key) {
             return key instanceof Integer ? 1 == (Integer)key ? key : 0 : key;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java
index 4a021e1..8c7ef46 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/GridAffinityP2PSelfTest.java
@@ -98,8 +98,8 @@ public class GridAffinityP2PSelfTest extends 
GridCommonAbstractTest {
 
             GridTestExternalClassLoader ldr = new 
GridTestExternalClassLoader(URLS);
 
-            
cc.setAffinity((CacheAffinityFunction)ldr.loadClass(EXT_AFFINITY_CLS_NAME).newInstance());
-            
cc.setAffinityMapper((CacheAffinityKeyMapper)ldr.loadClass(EXT_AFFINITY_MAPPER_CLS_NAME)
+            
cc.setAffinity((AffinityFunction)ldr.loadClass(EXT_AFFINITY_CLS_NAME).newInstance());
+            
cc.setAffinityMapper((AffinityKeyMapper)ldr.loadClass(EXT_AFFINITY_MAPPER_CLS_NAME)
                 .newInstance());
 
             c.setCacheConfiguration(cc);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java
index fc5cf26..3af9b56 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/GridJobMasterLeaveAwareSelfTest.java
@@ -441,7 +441,7 @@ public class GridJobMasterLeaveAwareSelfTest extends 
GridCommonAbstractTest {
             @Override public IgniteFuture<?> applyx(ClusterGroup prj) {
                 IgniteCompute comp = compute(prj).withAsync();
 
-                CacheAffinity<Object> aff = prj.ignite().affinity(null);
+                Affinity<Object> aff = prj.ignite().affinity(null);
 
                 ClusterNode node = F.first(prj.nodes());
 
@@ -460,7 +460,7 @@ public class GridJobMasterLeaveAwareSelfTest extends 
GridCommonAbstractTest {
             @Override public IgniteFuture<?> applyx(ClusterGroup prj) {
                 IgniteCompute comp = compute(prj).withAsync();
 
-                CacheAffinity<Object> aff = prj.ignite().affinity(null);
+                Affinity<Object> aff = prj.ignite().affinity(null);
 
                 ClusterNode node = F.first(prj.nodes());
 
@@ -476,7 +476,7 @@ public class GridJobMasterLeaveAwareSelfTest extends 
GridCommonAbstractTest {
      * @param node Node.
      * @return Finds some cache key for which given node is primary.
      */
-    private Object keyForNode(CacheAffinity<Object> aff, ClusterNode node) {
+    private Object keyForNode(Affinity<Object> aff, ClusterNode node) {
         assertNotNull(node);
 
         Object key = null;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java
index 62ade4e..c889baa 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/GridMultipleJobsSelfTest.java
@@ -223,7 +223,7 @@ public class GridMultipleJobsSelfTest extends 
GridCommonAbstractTest {
         /**
          * @return Affinity key.
          */
-        @CacheAffinityKeyMapped
+        @AffinityKeyMapped
         public String affinityKey() {
             return "key";
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorAbstractSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorAbstractSelfTest.java
index 09a24b4..e7fab8e 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorAbstractSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorAbstractSelfTest.java
@@ -79,7 +79,7 @@ public abstract class GridAffinityProcessorAbstractSelfTest 
extends GridCommonAb
      *
      * @return Affinity function.
      */
-    protected abstract CacheAffinityFunction affinityFunction();
+    protected abstract AffinityFunction affinityFunction();
 
     /** {@inheritDoc} */
     @SuppressWarnings({"ConstantConditions"})

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorRendezvousSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorRendezvousSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorRendezvousSelfTest.java
index 028948f..a55eb26 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorRendezvousSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/affinity/GridAffinityProcessorRendezvousSelfTest.java
@@ -25,7 +25,7 @@ import org.apache.ignite.cache.affinity.rendezvous.*;
  */
 public class GridAffinityProcessorRendezvousSelfTest extends 
GridAffinityProcessorAbstractSelfTest {
     /** {@inheritDoc} */
-    @Override protected CacheAffinityFunction affinityFunction() {
-        return new CacheRendezvousAffinityFunction();
+    @Override protected AffinityFunction affinityFunction() {
+        return new RendezvousAffinityFunction();
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearUpdateTopologyChangeAbstractTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearUpdateTopologyChangeAbstractTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearUpdateTopologyChangeAbstractTest.java
index 9200612..5adde52 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearUpdateTopologyChangeAbstractTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheNearUpdateTopologyChangeAbstractTest.java
@@ -52,7 +52,7 @@ public abstract class 
CacheNearUpdateTopologyChangeAbstractTest extends IgniteCa
      * @throws Exception If failed.
      */
     public void testNearUpdateTopologyChange() throws Exception {
-        final CacheAffinity<Integer> aff = grid(0).affinity(null);
+        final Affinity<Integer> aff = grid(0).affinity(null);
 
         final Integer key = 9;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/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 60d2cc5..e4f4427 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
@@ -3076,7 +3076,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         load(cache, key, true);
 
-        CacheAffinity<String> aff = ignite(0).affinity(null);
+        Affinity<String> aff = ignite(0).affinity(null);
 
         for (int i = 0; i < gridCount(); i++) {
             if (aff.isPrimary(grid(i).cluster().localNode(), key))
@@ -3453,7 +3453,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
 
         loadAll(cache, ImmutableSet.of(key1, key2), true);
 
-        CacheAffinity<String> aff = ignite(0).affinity(null);
+        Affinity<String> aff = ignite(0).affinity(null);
 
         for (int i = 0; i < gridCount(); i++) {
             if (aff.isPrimaryOrBackup(grid(i).cluster().localNode(), key1))
@@ -3919,7 +3919,7 @@ public abstract class GridCacheAbstractFullApiSelfTest 
extends GridCacheAbstract
         List<String> found = new ArrayList<>(cnt);
 
         Ignite ignite = cache.unwrap(Ignite.class);
-        CacheAffinity<Object> affinity = ignite.affinity(cache.getName());
+        Affinity<Object> affinity = ignite.affinity(cache.getName());
 
         for (int i = startFrom; i < startFrom + 100_000; i++) {
             String key = "key" + i;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractUsersAffinityMapperSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractUsersAffinityMapperSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractUsersAffinityMapperSelfTest.java
index 639ecca..533d702 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractUsersAffinityMapperSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAbstractUsersAffinityMapperSelfTest.java
@@ -43,7 +43,7 @@ public abstract class 
GridCacheAbstractUsersAffinityMapperSelfTest extends GridC
     private static final TcpDiscoveryIpFinder IP_FINDER = new 
TcpDiscoveryVmIpFinder(true);
 
     /** */
-    public static final CacheAffinityKeyMapper AFFINITY_MAPPER = new 
UsersAffinityKeyMapper();
+    public static final AffinityKeyMapper AFFINITY_MAPPER = new 
UsersAffinityKeyMapper();
 
     /** */
     protected GridCacheAbstractUsersAffinityMapperSelfTest() {
@@ -125,7 +125,7 @@ public abstract class 
GridCacheAbstractUsersAffinityMapperSelfTest extends GridC
         private int key;
 
         /** Affinity key. */
-        @CacheAffinityKeyMapped
+        @AffinityKeyMapped
         private String affKey;
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/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 bec0893..2ad42c3 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
@@ -59,14 +59,14 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
     /**
      * @return Affinity.
      */
-    private CacheAffinityFunction affinity() {
+    private AffinityFunction affinity() {
         return 
((IgniteKernal)grid(0)).internalCache().configuration().getAffinity();
     }
 
     /**
      * @return Affinity mapper.
      */
-    private CacheAffinityKeyMapper affinityMapper() {
+    private AffinityKeyMapper affinityMapper() {
         return 
((IgniteKernal)grid(0)).internalCache().configuration().getAffinityMapper();
     }
 
@@ -96,8 +96,8 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
      * @throws Exception If failed.
      */
     public void testPrimaryPartitionsOneNode() throws Exception {
-        CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+        AffinityFunctionContext ctx =
+            new GridAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
                 new AffinityTopologyVersion(1), 1);
 
         List<List<ClusterNode>> assignment = affinity().assignPartitions(ctx);
@@ -139,8 +139,8 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
 
         assert !F.isEmpty(parts);
 
-        CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+        AffinityFunctionContext ctx =
+            new GridAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
                 new AffinityTopologyVersion(1), 1);
 
         List<List<ClusterNode>> assignment = affinity().assignPartitions(ctx);
@@ -170,8 +170,8 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
 
         assert !F.isEmpty(parts);
 
-        CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+        AffinityFunctionContext ctx =
+            new GridAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
                 new AffinityTopologyVersion(1), 1);
 
         List<List<ClusterNode>> assignment = affinity().assignPartitions(ctx);
@@ -204,8 +204,8 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
 
         assert !F.isEmpty(parts);
 
-        CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+        AffinityFunctionContext ctx =
+            new GridAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
                 new AffinityTopologyVersion(1), 1);
 
         List<List<ClusterNode>> assignment = affinity().assignPartitions(ctx);
@@ -227,11 +227,11 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
     public void testMapPartitionToNode() throws Exception {
         int part = RND.nextInt(affinity().partitions());
 
-        CacheAffinityFunctionContext ctx =
-            new GridCacheAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
+        AffinityFunctionContext ctx =
+            new GridAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
                 new AffinityTopologyVersion(1), 1);
 
-        CacheAffinityFunction aff = affinity();
+        AffinityFunction aff = affinity();
 
         List<List<ClusterNode>> assignment = aff.assignPartitions(ctx);
 
@@ -246,11 +246,11 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
     public void testMapPartitionsToNode() throws Exception {
         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,
+        AffinityFunctionContext ctx =
+            new GridAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
                 new AffinityTopologyVersion(1), 1);
 
-        CacheAffinityFunction aff = affinity();
+        AffinityFunction aff = affinity();
 
         List<List<ClusterNode>> assignment = aff.assignPartitions(ctx);
 
@@ -266,11 +266,11 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
     public void testMapPartitionsToNodeArray() throws Exception {
         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,
+        AffinityFunctionContext ctx =
+            new GridAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
                 new AffinityTopologyVersion(1), 1);
 
-        CacheAffinityFunction aff = affinity();
+        AffinityFunction aff = affinity();
 
         List<List<ClusterNode>> assignment = aff.assignPartitions(ctx);
 
@@ -291,11 +291,11 @@ 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,
+        AffinityFunctionContext ctx =
+            new GridAffinityFunctionContextImpl(new 
ArrayList<>(grid(0).cluster().nodes()), null, null,
                 new AffinityTopologyVersion(1), 1);
 
-        CacheAffinityFunction aff = affinity();
+        AffinityFunction aff = affinity();
 
         List<List<ClusterNode>> assignment = aff.assignPartitions(ctx);
 
@@ -320,7 +320,7 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
      * @param key Affinity key.
      * @return Affinity nodes.
      */
-    private Iterable<ClusterNode> nodes(List<List<ClusterNode>> assignment, 
CacheAffinityFunction aff, Object key) {
+    private Iterable<ClusterNode> nodes(List<List<ClusterNode>> assignment, 
AffinityFunction aff, Object key) {
         return assignment.get(aff.partition(key));
     }
 
@@ -328,7 +328,7 @@ public class GridCacheAffinityApiSelfTest extends 
GridCacheAbstractSelfTest {
      * @throws Exception If failed.
      */
     public void testPartitionWithAffinityMapper() throws Exception {
-        CacheAffinityKey<Integer> key = new CacheAffinityKey<>(1, 2);
+        AffinityKey<Integer> key = new AffinityKey<>(1, 2);
 
         int expPart = affinity().partition(affinityMapper().affinityKey(key));
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java
index 060491a..943605d 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityMapperSelfTest.java
@@ -41,18 +41,18 @@ public class GridCacheAffinityMapperSelfTest extends 
GridCommonAbstractTest {
      *
      */
     public void testMethodAffinityMapper() {
-        CacheAffinityKeyMapper mapper =
+        AffinityKeyMapper mapper =
             new GridCacheDefaultAffinityKeyMapper();
 
         GridTestUtils.setFieldValue(mapper, "ignite", grid());
 
-        List<CacheAffinityKey<Integer>> keys = new ArrayList<>();
+        List<AffinityKey<Integer>> keys = new ArrayList<>();
 
         for (int i = 1; i <= 10; i++)
-            keys.add(new CacheAffinityKey<>(i, Integer.toString(i)));
+            keys.add(new AffinityKey<>(i, Integer.toString(i)));
 
         for (int i = 1; i <= 10; i++) {
-            CacheAffinityKey<Integer> key = keys.get(i - 1);
+            AffinityKey<Integer> key = keys.get(i - 1);
 
             Object mapped = mapper.affinityKey(key);
 
@@ -67,7 +67,7 @@ public class GridCacheAffinityMapperSelfTest extends 
GridCommonAbstractTest {
      *
      */
     public void testFieldAffinityMapper() {
-        CacheAffinityKeyMapper mapper =
+        AffinityKeyMapper mapper =
             new GridCacheDefaultAffinityKeyMapper();
 
         GridTestUtils.setFieldValue(mapper, "ignite", grid());
@@ -93,7 +93,7 @@ public class GridCacheAffinityMapperSelfTest extends 
GridCommonAbstractTest {
      *
      */
     public void testFieldAffinityMapperWithWrongClass() {
-        CacheAffinityKeyMapper mapper =
+        AffinityKeyMapper mapper =
             new GridCacheDefaultAffinityKeyMapper();
 
         GridTestUtils.setFieldValue(mapper, "ignite", grid());
@@ -118,7 +118,7 @@ public class GridCacheAffinityMapperSelfTest extends 
GridCommonAbstractTest {
         private K key;
 
         /** Affinity key. */
-        @CacheAffinityKeyMapped
+        @AffinityKeyMapped
         private Object affKey;
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
index 28b427f..5efe270 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAffinityRoutingSelfTest.java
@@ -173,7 +173,7 @@ public class GridCacheAffinityRoutingSelfTest extends 
GridCommonAbstractTest {
      */
     private static class AffinityTestKey {
         /** Affinity key. */
-        @CacheAffinityKeyMapped
+        @AffinityKeyMapped
         private final int affKey;
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAlwaysEvictionPolicy.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAlwaysEvictionPolicy.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAlwaysEvictionPolicy.java
index 34db6d0..7ee82e4 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAlwaysEvictionPolicy.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAlwaysEvictionPolicy.java
@@ -26,9 +26,9 @@ import java.io.*;
  * This eviction policy can be used whenever one cache is used to front another
  * and its size should be kept at {@code 0}.
  */
-public class GridCacheAlwaysEvictionPolicy<K, V> implements 
CacheEvictionPolicy<K, V>, Externalizable {
+public class GridCacheAlwaysEvictionPolicy<K, V> implements EvictionPolicy<K, 
V>, Externalizable {
     /** {@inheritDoc} */
-    @Override public void onEntryAccessed(boolean rmv, CacheEvictableEntry<K, 
V> entry) {
+    @Override public void onEntryAccessed(boolean rmv, EvictableEntry<K, V> 
entry) {
         if (!rmv && entry.isCached())
             entry.evict();
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java
index 16d07d8..da2b81c 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheAtomicMessageCountSelfTest.java
@@ -142,7 +142,7 @@ public class GridCacheAtomicMessageCountSelfTest extends 
GridCommonAbstractTest
             for (int i = 0; i < putCnt; i++) {
                 ClusterNode locNode = grid(0).localNode();
 
-                CacheAffinity<Object> affinity = ignite(0).affinity(null);
+                Affinity<Object> affinity = ignite(0).affinity(null);
 
                 if (writeOrderMode == CLOCK) {
                     if (affinity.isPrimary(locNode, i) || 
affinity.isBackup(locNode, i))

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeTest.java
index 3f94228..c2f69ce 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentTxMultiNodeTest.java
@@ -110,7 +110,7 @@ public class GridCacheConcurrentTxMultiNodeTest extends 
GridCommonAbstractTest {
             CacheConfiguration cc = defaultCacheConfiguration();
 
             cc.setCacheMode(mode);
-            cc.setEvictionPolicy(new CacheLruEvictionPolicy(1000));
+            cc.setEvictionPolicy(new LruEvictionPolicy(1000));
             cc.setEvictSynchronized(false);
             cc.setSwapEnabled(false);
             cc.setWriteSynchronizationMode(FULL_SYNC);
@@ -422,7 +422,7 @@ public class GridCacheConcurrentTxMultiNodeTest extends 
GridCommonAbstractTest {
         /**
          * @return Terminal ID.
          */
-        @CacheAffinityKeyMapped
+        @AffinityKeyMapped
         public String terminalId() {
             return message().getTerminalId();
         }
@@ -495,7 +495,7 @@ public class GridCacheConcurrentTxMultiNodeTest extends 
GridCommonAbstractTest {
             t.set1(System.currentTimeMillis());
             t.set2(0L);
             t.set4(xid);
-            t.set5(key == null ? null : new CacheAffinityKey<String>(key, 
termId) {});
+            t.set5(key == null ? null : new AffinityKey<String>(key, termId) 
{});
         }
 
         /**
@@ -527,7 +527,7 @@ public class GridCacheConcurrentTxMultiNodeTest extends 
GridCommonAbstractTest {
             if (lastPrint.get() + PRINT_FREQ < now && 
lastPrint.setIfGreater(now)) {
                 Map<String, Long> maxes = new HashMap<>();
 
-                Set<CacheAffinityKey<String>> keys = null;
+                Set<AffinityKey<String>> keys = null;
 
                 for (Map.Entry<Thread, ConcurrentMap<String, T5<Long, Long, 
Long, IgniteUuid, Object>>> e1 : timers.entrySet()) {
                     for (Map.Entry<String, T5<Long, Long, Long, IgniteUuid, 
Object>> e2 : e1.getValue().entrySet()) {
@@ -550,7 +550,7 @@ public class GridCacheConcurrentTxMultiNodeTest extends 
GridCommonAbstractTest {
                                 ", duration=" + duration + ", ongoing=" + (end 
== 0) +
                                 ", thread=" + e1.getKey().getName() + ", xid=" 
+ xid + ']');
 
-                            CacheAffinityKey<String> key = 
(CacheAffinityKey<String>)t.get5();
+                            AffinityKey<String> key = 
(AffinityKey<String>)t.get5();
 
                             if (key != null) {
                                 if (keys == null)
@@ -572,12 +572,12 @@ public class GridCacheConcurrentTxMultiNodeTest extends 
GridCommonAbstractTest {
                 if (!F.isEmpty(keys)) {
                     for (Ignite g : G.allGrids()) {
                         if (g.name().contains("server")) {
-                            GridNearCacheAdapter<CacheAffinityKey<String>, 
Object> near =
-                                
(GridNearCacheAdapter<CacheAffinityKey<String>, Object>)((IgniteKernal)g).
-                                    <CacheAffinityKey<String>, 
Object>internalCache();
-                            GridDhtCacheAdapter<CacheAffinityKey<String>, 
Object> dht = near.dht();
+                            GridNearCacheAdapter<AffinityKey<String>, Object> 
near =
+                                (GridNearCacheAdapter<AffinityKey<String>, 
Object>)((IgniteKernal)g).
+                                    <AffinityKey<String>, 
Object>internalCache();
+                            GridDhtCacheAdapter<AffinityKey<String>, Object> 
dht = near.dht();
 
-                            for (CacheAffinityKey<String> k : keys) {
+                            for (AffinityKey<String> k : keys) {
                                 GridNearCacheEntry nearEntry = 
(GridNearCacheEntry)near.peekEx(k);
                                 GridDhtCacheEntry dhtEntry = 
(GridDhtCacheEntry)dht.peekEx(k);
 
@@ -703,11 +703,11 @@ public class GridCacheConcurrentTxMultiNodeTest extends 
GridCommonAbstractTest {
          * @param terminalId Terminal ID.
          */
         private void put(Object o, String cacheKey, String terminalId) {
-//            GridCache<CacheAffinityKey<String>, Object> cache = 
((IgniteKernal)ignite).cache(null);
+//            GridCache<AffinityKey<String>, Object> cache = 
((IgniteKernal)ignite).cache(null);
 //
-//            CacheAffinityKey<String> affinityKey = new 
CacheAffinityKey<>(cacheKey, terminalId);
+//            AffinityKey<String> affinityKey = new AffinityKey<>(cacheKey, 
terminalId);
 //
-//            Entry<CacheAffinityKey<String>, Object> entry = 
cache.entry(affinityKey);
+//            Entry<AffinityKey<String>, Object> entry = 
cache.entry(affinityKey);
 //
 //            entry.setx(o);
             assert false;
@@ -720,7 +720,7 @@ public class GridCacheConcurrentTxMultiNodeTest extends 
GridCommonAbstractTest {
          */
         @SuppressWarnings({"RedundantCast"})
         private <T> Object get(String cacheKey, String terminalId) {
-            Object key = new CacheAffinityKey<>(cacheKey, terminalId);
+            Object key = new AffinityKey<>(cacheKey, terminalId);
 
             return (T) ignite.cache(null).get(key);
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
index 992f040..3737f46 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationConsistencySelfTest.java
@@ -78,7 +78,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
     private GridStringLogger strLog;
 
     /** */
-    private CacheAffinityFunction aff;
+    private AffinityFunction aff;
 
     /** */
     private int backups;
@@ -315,7 +315,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
             new C1<CacheConfiguration, Void>() {
                 /** {@inheritDoc} */
                 @Override public Void apply(CacheConfiguration cfg) {
-                    cfg.setAffinity(new CacheRendezvousAffinityFunction());
+                    cfg.setAffinity(new RendezvousAffinityFunction());
                     return null;
                 }
             }
@@ -352,7 +352,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
             new C1<CacheConfiguration, Void>() {
                 /** {@inheritDoc} */
                 @Override public Void apply(CacheConfiguration cfg) {
-                    cfg.setEvictionPolicy(new CacheFifoEvictionPolicy());
+                    cfg.setEvictionPolicy(new FifoEvictionPolicy());
                     return null;
                 }
             },
@@ -373,14 +373,14 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
             new C1<CacheConfiguration, Void>() {
                 /** {@inheritDoc} */
                 @Override public Void apply(CacheConfiguration cfg) {
-                    cfg.setEvictionPolicy(new CacheRandomEvictionPolicy());
+                    cfg.setEvictionPolicy(new RandomEvictionPolicy());
                     return null;
                 }
             },
             new C1<CacheConfiguration, Void>() {
                 /** {@inheritDoc} */
                 @Override public Void apply(CacheConfiguration cfg) {
-                    cfg.setEvictionPolicy(new CacheFifoEvictionPolicy());
+                    cfg.setEvictionPolicy(new FifoEvictionPolicy());
                     return null;
                 }
             }
@@ -442,7 +442,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
                 /** {@inheritDoc} */
                 @Override public Void apply(CacheConfiguration cfg) {
                     cfg.setEvictSynchronized(true);
-                    cfg.setEvictionPolicy(new CacheFifoEvictionPolicy(100));
+                    cfg.setEvictionPolicy(new FifoEvictionPolicy(100));
                     return null;
                 }
             },
@@ -450,7 +450,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
                 /** {@inheritDoc} */
                 @Override public Void apply(CacheConfiguration cfg) {
                     cfg.setEvictSynchronized(false);
-                    cfg.setEvictionPolicy(new CacheFifoEvictionPolicy(100));
+                    cfg.setEvictionPolicy(new FifoEvictionPolicy(100));
                     return null;
                 }
             }
@@ -516,13 +516,13 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
 
         backups = 1;
 
-        aff = new CacheRendezvousAffinityFunction(false, 100);
+        aff = new RendezvousAffinityFunction(false, 100);
 
         startGrid(1);
 
         // 2nd grid with another affinity.
         // Check include neighbors.
-        aff = new CacheRendezvousAffinityFunction(true, 100);
+        aff = new RendezvousAffinityFunction(true, 100);
 
         GridTestUtils.assertThrows(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -533,7 +533,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
         backups = 2;
 
         // Check backups.
-        aff = new CacheRendezvousAffinityFunction(false, 100);
+        aff = new RendezvousAffinityFunction(false, 100);
 
         GridTestUtils.assertThrows(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -544,7 +544,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
         backups = 1;
 
         // Partitions count.
-        aff = new CacheRendezvousAffinityFunction(false, 1000);
+        aff = new RendezvousAffinityFunction(false, 1000);
 
         GridTestUtils.assertThrows(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -553,9 +553,9 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
         }, IgniteCheckedException.class, "Affinity partitions count mismatch");
 
         // Different hash ID resolver.
-        CacheRendezvousAffinityFunction aff0 = new 
CacheRendezvousAffinityFunction(false, 100);
+        RendezvousAffinityFunction aff0 = new 
RendezvousAffinityFunction(false, 100);
 
-        aff0.setHashIdResolver(new CacheAffinityNodeIdHashResolver());
+        aff0.setHashIdResolver(new AffinityNodeIdHashResolver());
 
         aff = aff0;
 
@@ -616,7 +616,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
             @Override public Void apply(CacheConfiguration cfg) {
                 NearCacheConfiguration nearCfg = new NearCacheConfiguration();
 
-                nearCfg.setNearEvictionPolicy(new CacheRandomEvictionPolicy());
+                nearCfg.setNearEvictionPolicy(new RandomEvictionPolicy());
 
                 cfg.setNearConfiguration(nearCfg);
 
@@ -630,7 +630,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
             @Override public Void apply(CacheConfiguration cfg) {
                 NearCacheConfiguration nearCfg = new NearCacheConfiguration();
 
-                nearCfg.setNearEvictionPolicy(new CacheFifoEvictionPolicy());
+                nearCfg.setNearEvictionPolicy(new FifoEvictionPolicy());
 
                 cfg.setNearConfiguration(nearCfg);
 
@@ -655,7 +655,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
             @Override public Void apply(CacheConfiguration cfg) {
                 cfg.setAffinity(new TestRendezvousAffinityFunction());
 
-                cfg.setEvictionPolicy(new CacheFifoEvictionPolicy());
+                cfg.setEvictionPolicy(new FifoEvictionPolicy());
 
                 cfg.setCacheStoreFactory(new 
IgniteCacheAbstractTest.TestStoreFactory());
                 cfg.setReadThrough(true);
@@ -671,9 +671,9 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
         initCache = new C1<CacheConfiguration, Void>() {
             /** {@inheritDoc} */
             @Override public Void apply(CacheConfiguration cfg) {
-                cfg.setAffinity(new CacheRendezvousAffinityFunction());
+                cfg.setAffinity(new RendezvousAffinityFunction());
 
-                cfg.setEvictionPolicy(new CacheLruEvictionPolicy());
+                cfg.setEvictionPolicy(new LruEvictionPolicy());
 
                 cfg.setCacheStoreFactory(null);
 
@@ -782,7 +782,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
     public void testAffinityForReplicatedCache() throws Exception {
         cacheEnabled = true;
 
-        aff = new CachePartitionFairAffinity(); // Check cannot use 
CachePartitionFairAffinity.
+        aff = new FairAffinityFunction(); // Check cannot use 
FairAffinityFunction.
 
         GridTestUtils.assertThrows(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -790,7 +790,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
             }
         }, IgniteCheckedException.class, null);
 
-        aff = new CacheRendezvousAffinityFunction(true); // Check cannot set 
'excludeNeighbors' flag.
+        aff = new RendezvousAffinityFunction(true); // Check cannot set 
'excludeNeighbors' flag.
         backups = Integer.MAX_VALUE;
 
         GridTestUtils.assertThrows(log, new Callable<Object>() {
@@ -799,12 +799,12 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
             }
         }, IgniteCheckedException.class, null);
 
-        aff = new CacheRendezvousAffinityFunction(false, 100);
+        aff = new RendezvousAffinityFunction(false, 100);
 
         startGrid(1);
 
         // Try to start node with  different number of partitions.
-        aff = new CacheRendezvousAffinityFunction(false, 200);
+        aff = new RendezvousAffinityFunction(false, 200);
 
         GridTestUtils.assertThrows(log, new Callable<Object>() {
             @Override public Object call() throws Exception {
@@ -819,15 +819,13 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
     public void testDifferentInterceptors() throws Exception {
         cacheMode = PARTITIONED;
 
-        checkSecondGridStartFails(
-            new C1<CacheConfiguration, Void>() {
+        checkSecondGridStartFails(new C1<CacheConfiguration, Void>() {
                 @Override public Void apply(CacheConfiguration cfg) {
                     cfg.setInterceptor(new TestCacheInterceptor());
 
                     return null;
                 }
-            },
-            new C1<CacheConfiguration, Void>() {
+            }, new C1<CacheConfiguration, Void>() {
                 @Override public Void apply(CacheConfiguration cfg) {
                     return null;
                 }
@@ -900,7 +898,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
         }
     }
 
-    private static class TestRendezvousAffinityFunction extends 
CacheRendezvousAffinityFunction {
+    private static class TestRendezvousAffinityFunction extends 
RendezvousAffinityFunction {
         /**
          * Empty constructor required by {@link Externalizable}.
          */
@@ -912,7 +910,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
     /**
      *
      */
-    private static class FirstCacheEvictionFilter implements 
CacheEvictionFilter<Object, Object> {
+    private static class FirstCacheEvictionFilter implements 
EvictionFilter<Object, Object> {
         /** {@inheritDoc} */
         @Override public boolean evictAllowed(Cache.Entry<Object, Object> 
entry) {
             return false;
@@ -922,7 +920,7 @@ public class GridCacheConfigurationConsistencySelfTest 
extends GridCommonAbstrac
     /**
      *
      */
-    private static class SecondCacheEvictionFilter implements 
CacheEvictionFilter<Object, Object> {
+    private static class SecondCacheEvictionFilter implements 
EvictionFilter<Object, Object> {
         /** {@inheritDoc} */
         @Override public boolean evictAllowed(Cache.Entry<Object, Object> 
entry) {
             return true;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java
index dbaaa79..10926eb 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheConfigurationValidationSelfTest.java
@@ -83,7 +83,7 @@ public class GridCacheConfigurationValidationSelfTest extends 
GridCommonAbstract
         dfltCacheCfg.setCacheMode(PARTITIONED);
         dfltCacheCfg.setRebalanceMode(ASYNC);
         dfltCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
-        dfltCacheCfg.setAffinity(new CacheRendezvousAffinityFunction());
+        dfltCacheCfg.setAffinity(new RendezvousAffinityFunction());
         dfltCacheCfg.setIndexedTypes(
             Integer.class, String.class
         );
@@ -95,7 +95,7 @@ public class GridCacheConfigurationValidationSelfTest extends 
GridCommonAbstract
         namedCacheCfg.setRebalanceMode(ASYNC);
         namedCacheCfg.setWriteSynchronizationMode(FULL_SYNC);
         namedCacheCfg.setName(NON_DFLT_CACHE_NAME);
-        namedCacheCfg.setAffinity(new CacheRendezvousAffinityFunction());
+        namedCacheCfg.setAffinity(new RendezvousAffinityFunction());
 
         // Modify cache config according to test parameters.
         if (gridName.contains(WRONG_PRELOAD_MODE_GRID_NAME))
@@ -193,7 +193,7 @@ public class GridCacheConfigurationValidationSelfTest 
extends GridCommonAbstract
     /**
      *
      */
-    private static class TestRendezvousAffinityFunction extends 
CacheRendezvousAffinityFunction {
+    private static class TestRendezvousAffinityFunction extends 
RendezvousAffinityFunction {
         // No-op. Just to have another class name.
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
index d191c56..a30e3dd 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheInterceptorAbstractSelfTest.java
@@ -1264,7 +1264,7 @@ public abstract class 
GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
     private List<String> primaryKeys(int idx, int cnt) {
         assert cnt > 0;
 
-        CacheAffinity aff = ignite(0).affinity(null);
+        Affinity aff = ignite(0).affinity(null);
 
         List<String> keys = new ArrayList<>(cnt);
 
@@ -1289,7 +1289,7 @@ public abstract class 
GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
      * @return Primary key for grid.
      */
     private String backupKey(int idx) {
-        CacheAffinity aff = ignite(0).affinity(null);
+        Affinity aff = ignite(0).affinity(null);
 
         String key = null;
 
@@ -1311,7 +1311,7 @@ public abstract class 
GridCacheInterceptorAbstractSelfTest extends GridCacheAbst
      * @return Key which does not belong to the grid.
      */
     private String nearKey(int idx) {
-        CacheAffinity aff = ignite(0).affinity(null);
+        Affinity aff = ignite(0).affinity(null);
 
         String key = null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLeakTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLeakTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLeakTest.java
index c7af84e..c5b1abb 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLeakTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLeakTest.java
@@ -71,7 +71,7 @@ public class GridCacheLeakTest extends GridCommonAbstractTest 
{
 
         cfg.setName(CACHE_NAME);
 
-        cfg.setAffinity(new CacheRendezvousAffinityFunction(false, 128));
+        cfg.setAffinity(new RendezvousAffinityFunction(false, 128));
 
         cfg.setCacheMode(PARTITIONED);
         cfg.setBackups(1);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLifecycleAwareSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLifecycleAwareSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLifecycleAwareSelfTest.java
index 6379ec0..de5899d 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLifecycleAwareSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheLifecycleAwareSelfTest.java
@@ -117,7 +117,7 @@ public class GridCacheLifecycleAwareSelfTest extends 
GridAbstractLifecycleAwareS
 
     /**
      */
-    public static class TestAffinityFunction extends TestLifecycleAware 
implements CacheAffinityFunction {
+    public static class TestAffinityFunction extends TestLifecycleAware 
implements AffinityFunction {
         /**
          */
         public TestAffinityFunction() {
@@ -140,7 +140,7 @@ public class GridCacheLifecycleAwareSelfTest extends 
GridAbstractLifecycleAwareS
         }
 
         /** {@inheritDoc} */
-        @Override public List<List<ClusterNode>> 
assignPartitions(CacheAffinityFunctionContext affCtx) {
+        @Override public List<List<ClusterNode>> 
assignPartitions(AffinityFunctionContext affCtx) {
             List<List<ClusterNode>> res = new ArrayList<>();
 
             res.add(nodes(0, affCtx.currentTopologySnapshot()));
@@ -161,7 +161,7 @@ public class GridCacheLifecycleAwareSelfTest extends 
GridAbstractLifecycleAwareS
 
     /**
      */
-    public static class TestEvictionPolicy extends TestLifecycleAware 
implements CacheEvictionPolicy, Serializable {
+    public static class TestEvictionPolicy extends TestLifecycleAware 
implements EvictionPolicy, Serializable {
         /**
          */
         public TestEvictionPolicy() {
@@ -169,14 +169,14 @@ public class GridCacheLifecycleAwareSelfTest extends 
GridAbstractLifecycleAwareS
         }
 
         /** {@inheritDoc} */
-        @Override public void onEntryAccessed(boolean rmv, CacheEvictableEntry 
entry) {
+        @Override public void onEntryAccessed(boolean rmv, EvictableEntry 
entry) {
             // No-op.
         }
     }
 
     /**
      */
-    private static class TestEvictionFilter extends TestLifecycleAware 
implements CacheEvictionFilter {
+    private static class TestEvictionFilter extends TestLifecycleAware 
implements EvictionFilter {
         /**
          */
         TestEvictionFilter() {
@@ -191,7 +191,7 @@ public class GridCacheLifecycleAwareSelfTest extends 
GridAbstractLifecycleAwareS
 
     /**
      */
-    private static class TestAffinityKeyMapper extends TestLifecycleAware 
implements CacheAffinityKeyMapper {
+    private static class TestAffinityKeyMapper extends TestLifecycleAware 
implements AffinityKeyMapper {
         /**
          */
         TestAffinityKeyMapper() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/4ba0b01a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java
index dc696d0..4884b81 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheMemoryModeSelfTest.java
@@ -82,8 +82,7 @@ public class GridCacheMemoryModeSelfTest extends 
GridCommonAbstractTest {
         cacheCfg.setSwapEnabled(swapEnabled);
         cacheCfg.setCacheMode(mode);
         cacheCfg.setMemoryMode(memoryMode);
-        cacheCfg.setEvictionPolicy(maxOnheapSize == Integer.MAX_VALUE ? null :
-            new CacheLruEvictionPolicy(maxOnheapSize));
+        cacheCfg.setEvictionPolicy(maxOnheapSize == Integer.MAX_VALUE ? null : 
new LruEvictionPolicy(maxOnheapSize));
         cacheCfg.setAtomicityMode(atomicity);
         cacheCfg.setOffHeapMaxMemory(offheapSize);
 

Reply via email to