ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [03/12] incubator-ignite git commit: #IGNITE-99: Refactoring. Move GridCache.affinity() to Ignite.affinity(String cacheName).
Date Fri, 16 Jan 2015 15:43:06 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java
index 5cb1c69..f71c575 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridCacheAtomicInvalidPartitionHandlingSelfTest.java
@@ -229,7 +229,7 @@ public class GridCacheAtomicInvalidPartitionHandlingSelfTest extends GridCommonA
             fut.get();
 
             for (int k = 0; k < range; k++) {
-                Collection<ClusterNode> affNodes = cache.affinity().mapKeyToPrimaryAndBackups(k);
+                Collection<ClusterNode> affNodes = grid(0).affinity(cache.name()).mapKeyToPrimaryAndBackups(k);
 
                 // Test is valid with at least one backup.
                 assert affNodes.size() >= 2;
@@ -248,9 +248,9 @@ public class GridCacheAtomicInvalidPartitionHandlingSelfTest extends GridCommonA
                     for (int r = 0; r < 3; r++) {
                         try {
                             if (affNodes.contains(locNode)) {
-                                assert c.affinity().isPrimaryOrBackup(locNode, k);
+                                assert grid(i).affinity(c.name()).isPrimaryOrBackup(locNode, k);
 
-                                boolean primary = c.affinity().isPrimary(locNode, k);
+                                boolean primary = grid(i).affinity(c.name()).isPrimary(locNode, k);
 
                                 assertNotNull("Failed to find entry on node for key [locNode=" + locNode.id() +
                                     ", key=" + k + ']', entry);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridCacheAtomicPreloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridCacheAtomicPreloadSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridCacheAtomicPreloadSelfTest.java
index 5e7c021..0397c76 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridCacheAtomicPreloadSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/atomic/GridCacheAtomicPreloadSelfTest.java
@@ -22,7 +22,6 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.transactions.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.transactions.*;
 import org.gridgain.testframework.junits.common.*;
@@ -99,7 +98,7 @@ public class GridCacheAtomicPreloadSelfTest extends GridCommonAbstractTest {
 
             GridCache<Object, Object> cache = grid(0).cache(null);
 
-            List<Integer> keys = generateKeys(grid(0).localNode(), cache);
+            List<Integer> keys = generateKeys(grid(0).localNode(), cache, grid(0));
 
             IgniteTransactions txs = grid(0).transactions();
 
@@ -168,8 +167,8 @@ public class GridCacheAtomicPreloadSelfTest extends GridCommonAbstractTest {
 
             GridCache<Object, Object> cache = grid.cache(null);
 
-            boolean primary = cache.affinity().isPrimary(node, key);
-            boolean backup = cache.affinity().isBackup(node, key);
+            boolean primary = grid.affinity(cache.name()).isPrimary(node, key);
+            boolean backup = grid.affinity(cache.name()).isBackup(node, key);
 
             if (primary || backup)
                 assertEquals("Invalid cache value [nodeId=" + node.id() + ", primary=" + primary +
@@ -182,12 +181,13 @@ public class GridCacheAtomicPreloadSelfTest extends GridCommonAbstractTest {
      *
      * @param node Node for which keys are generated.
      * @param cache Cache to get affinity for.
+     * @param ignite Ignite.
      * @return Collection of keys.
      */
-    private List<Integer> generateKeys(ClusterNode node, GridCache<Object, Object> cache) {
+    private List<Integer> generateKeys(ClusterNode node, GridCache<Object, Object> cache, Ignite ignite) {
         List<Integer> keys = new ArrayList<>(3);
 
-        GridCacheAffinity<Object> aff = cache.affinity();
+        IgniteCacheAffinity<Object> aff = ignite.affinity(cache.name());
 
         int base = 0;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/CacheConsistentHashAffinityFunctionExcludeNeighborsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/CacheConsistentHashAffinityFunctionExcludeNeighborsSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/CacheConsistentHashAffinityFunctionExcludeNeighborsSelfTest.java
new file mode 100644
index 0000000..4778522
--- /dev/null
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/CacheConsistentHashAffinityFunctionExcludeNeighborsSelfTest.java
@@ -0,0 +1,32 @@
+/*
+ * 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.gridgain.grid.kernal.processors.cache.distributed.near;
+
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cache.affinity.consistenthash.*;
+
+/**
+ * Tests exclude neighbors flag for consistent hash affinity function.
+ */
+public class CacheConsistentHashAffinityFunctionExcludeNeighborsSelfTest extends
+        IgniteCacheAffinityFunctionExcludeNeighborsAbstractSelfTest {
+    /** {@inheritDoc} */
+    @Override protected CacheAffinityFunction affinityFunction() {
+        return new CacheConsistentHashAffinityFunction(true);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest.java
deleted file mode 100644
index ed37e75..0000000
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest.java
+++ /dev/null
@@ -1,184 +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.gridgain.grid.kernal.processors.cache.distributed.near;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.product.*;
-import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
-import org.gridgain.grid.kernal.*;
-import org.apache.ignite.spi.discovery.tcp.*;
-import org.apache.ignite.spi.discovery.tcp.internal.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
-import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
-import org.gridgain.grid.util.typedef.internal.*;
-import org.gridgain.testframework.junits.common.*;
-
-import java.util.*;
-
-import static org.gridgain.grid.cache.GridCacheMode.*;
-import static org.gridgain.grid.cache.GridCachePreloadMode.*;
-
-/**
- * Partitioned affinity test.
- */
-@SuppressWarnings({"PointlessArithmeticExpression", "FieldCanBeLocal"})
-public abstract class GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest extends GridCommonAbstractTest {
-    /** Number of backups. */
-    private int backups = 2;
-
-    /** */
-    private int gridInstanceNum;
-
-    /** */
-    private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(final String gridName) throws Exception {
-        IgniteConfiguration c = super.getConfiguration(gridName);
-
-        TcpDiscoverySpi spi = new TcpDiscoverySpi() {
-            @Override public void setNodeAttributes(Map<String, Object> attrs, IgniteProductVersion ver) {
-                super.setNodeAttributes(attrs, ver);
-
-                // Set unique mac addresses for every group of three nodes.
-                String macAddrs = "MOCK_MACS_" + (gridInstanceNum / 3);
-
-                attrs.put(GridNodeAttributes.ATTR_MACS, macAddrs);
-
-                gridInstanceNum++;
-            }
-        };
-
-        spi.setIpFinder(ipFinder);
-
-        c.setDiscoverySpi(spi);
-
-        GridCacheConfiguration cc = defaultCacheConfiguration();
-
-        cc.setCacheMode(PARTITIONED);
-
-        cc.setBackups(backups);
-
-        cc.setAffinity(affinityFunction());
-
-        cc.setPreloadMode(NONE);
-
-        c.setCacheConfiguration(cc);
-
-        return c;
-    }
-
-    /**
-     * @return Affinity function for test.
-     */
-    protected abstract GridCacheAffinityFunction affinityFunction();
-
-    /**
-     * @param ignite Grid.
-     * @return Affinity.
-     */
-    static GridCacheAffinity<Object> affinity(Ignite ignite) {
-        return ignite.cache(null).affinity();
-    }
-
-    /**
-     * @param aff Affinity.
-     * @param key Key.
-     * @return Nodes.
-     */
-    private static Collection<? extends ClusterNode> nodes(GridCacheAffinity<Object> aff, Object key) {
-        return aff.mapKeyToPrimaryAndBackups(key);
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testAffinityMultiNode() throws Exception {
-        int grids = 9;
-
-        startGrids(grids);
-
-        try {
-            Object key = 12345;
-
-            int copies = backups + 1;
-
-            for (int i = 0; i < grids; i++) {
-                final Ignite g = grid(i);
-
-                GridCacheAffinity<Object> aff = affinity(g);
-
-                List<TcpDiscoveryNode> top = new ArrayList<>();
-
-                for (ClusterNode node : g.cluster().nodes())
-                    top.add((TcpDiscoveryNode) node);
-
-                Collections.sort(top);
-
-                assertEquals(grids, top.size());
-
-                int idx = 1;
-
-                for (ClusterNode n : top) {
-                    assertEquals(idx, n.order());
-
-                    idx++;
-                }
-
-                Collection<? extends ClusterNode> affNodes = nodes(aff, key);
-
-                info("Affinity picture for grid [i=" + i + ", aff=" + U.toShortString(affNodes));
-
-                assertEquals(copies, affNodes.size());
-
-                Set<String> macs = new HashSet<>();
-
-                for (ClusterNode node : affNodes)
-                    macs.add((String)node.attribute(GridNodeAttributes.ATTR_MACS));
-
-                assertEquals(copies, macs.size());
-            }
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testAffinitySingleNode() throws Exception {
-        Ignite g = startGrid();
-
-        try {
-            Object key = 12345;
-
-            Collection<? extends ClusterNode> affNodes = nodes(affinity(g), key);
-
-            info("Affinity picture for grid: " + U.toShortString(affNodes));
-
-            assertEquals(1, affNodes.size());
-        }
-        finally {
-            stopAllGrids();
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheConsistentHashAffinityFunctionExcludeNeighborsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheConsistentHashAffinityFunctionExcludeNeighborsSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheConsistentHashAffinityFunctionExcludeNeighborsSelfTest.java
deleted file mode 100644
index 5edd7ee..0000000
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheConsistentHashAffinityFunctionExcludeNeighborsSelfTest.java
+++ /dev/null
@@ -1,32 +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.gridgain.grid.kernal.processors.cache.distributed.near;
-
-import org.gridgain.grid.cache.affinity.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
-
-/**
- * Tests exclude neighbors flag for consistent hash affinity function.
- */
-public class GridCacheConsistentHashAffinityFunctionExcludeNeighborsSelfTest extends
-    GridCacheAffinityFunctionExcludeNeighborsAbstractSelfTest {
-    /** {@inheritDoc} */
-    @Override protected GridCacheAffinityFunction affinityFunction() {
-        return new GridCacheConsistentHashAffinityFunction(true);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java
index 5fbcd9f..ecc3c30 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMetricsSelfTest.java
@@ -95,7 +95,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
         // Put and get a few keys.
         for (int i = 0; ; i++) {
-            if (cache0.affinity().isPrimary(g0.cluster().localNode(), i)) {
+            if (g0.affinity(cache0.name()).isPrimary(g0.cluster().localNode(), i)) {
                 cache0.put(i, i); // +1 read
 
                 cache0.get(i); // +1 read.
@@ -104,7 +104,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
                 info("Writes: " + cache0.metrics().writes());
                 info("Reads: " + cache0.metrics().reads());
-                info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i)));
+                info("Affinity nodes: " + U.nodes2names(g0.affinity(cache0.name()).mapKeyToPrimaryAndBackups(i)));
 
                 break;
             }
@@ -118,12 +118,12 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
             info("Writes: " + g.cache(null).metrics().writes());
             info("Reads: " + g.cache(null).metrics().reads());
 
-            if (g.cache(null).affinity().isPrimaryOrBackup(g.cluster().localNode(), key))
+            if (g.affinity(null).isPrimaryOrBackup(g.cluster().localNode(), key))
                 assertEquals(1, g.cache(null).metrics().writes());
             else
                 assertEquals(0, g.cache(null).metrics().writes());
 
-            if (g.cache(null).affinity().isPrimary(g.cluster().localNode(), key)) {
+            if (g.affinity(null).isPrimary(g.cluster().localNode(), key)) {
                 assertEquals(2, g.cache(null).metrics().reads());
                 assertEquals(1, g.cache(null).metrics().hits());
                 assertEquals(1, g.cache(null).metrics().misses());
@@ -148,7 +148,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
         // Put and get a few keys.
         for (int i = 0; ; i++) {
-            if (cache0.affinity().isBackup(g0.cluster().localNode(), i)) {
+            if (g0.affinity(cache0.name()).isBackup(g0.cluster().localNode(), i)) {
                 cache0.put(i, i); // +1 read.
 
                 cache0.get(i); // +1 read.
@@ -157,7 +157,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
                 info("Writes: " + cache0.metrics().writes());
                 info("Reads: " + cache0.metrics().reads());
-                info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i)));
+                info("Affinity nodes: " + U.nodes2names(g0.affinity(cache0.name()).mapKeyToPrimaryAndBackups(i)));
 
                 break;
             }
@@ -166,17 +166,17 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
         for (int j = 0; j < gridCount(); j++) {
             Ignite g = grid(j);
 
-            if (g.cache(null).affinity().isPrimaryOrBackup(g.cluster().localNode(), key))
+            if (g.affinity(null).isPrimaryOrBackup(g.cluster().localNode(), key))
                 assertEquals(1, g.cache(null).metrics().writes());
             else
                 assertEquals(0, g.cache(null).metrics().writes());
 
-            if (g.cache(null).affinity().isPrimary(g.cluster().localNode(), key)) {
+            if (g.affinity(null).isPrimary(g.cluster().localNode(), key)) {
                 assertEquals(1, g.cache(null).metrics().reads());
                 assertEquals(0, g.cache(null).metrics().hits());
                 assertEquals(1, g.cache(null).metrics().misses());
             }
-            else if (g.cache(null).affinity().isBackup(g.cluster().localNode(), key)){
+            else if (g.affinity(null).isBackup(g.cluster().localNode(), key)){
                 assertEquals(2, g.cache(null).metrics().reads());
                 assertEquals(1, g.cache(null).metrics().hits());
                 assertEquals(1, g.cache(null).metrics().misses());
@@ -201,7 +201,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
         // Put and get a few keys.
         for (int i = 0; ; i++) {
-            if (!cache0.affinity().isPrimaryOrBackup(g0.cluster().localNode(), i)) {
+            if (!g0.affinity(cache0.name()).isPrimaryOrBackup(g0.cluster().localNode(), i)) {
                 cache0.put(i, i); // +1 read.
 
                 cache0.get(i); // +1 read.
@@ -210,7 +210,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
                 info("Writes: " + cache0.metrics().writes());
                 info("Reads: " + cache0.metrics().reads());
-                info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i)));
+                info("Affinity nodes: " + U.nodes2names(g0.affinity(cache0.name()).mapKeyToPrimaryAndBackups(i)));
 
                 break;
             }
@@ -221,12 +221,12 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
             assertEquals(1, g.cache(null).metrics().writes());
 
-            if (g.cache(null).affinity().isPrimary(g.cluster().localNode(), key)) {
+            if (g.affinity(null).isPrimary(g.cluster().localNode(), key)) {
                 assertEquals(1, g.cache(null).metrics().reads());
                 assertEquals(0, g.cache(null).metrics().hits());
                 assertEquals(1, g.cache(null).metrics().misses());
             }
-            else if (g.cache(null).affinity().isBackup(g.cluster().localNode(), key)){
+            else if (g.affinity(null).isBackup(g.cluster().localNode(), key)){
                 assertEquals(0, g.cache(null).metrics().reads());
                 assertEquals(0, g.cache(null).metrics().hits());
                 assertEquals(0, g.cache(null).metrics().misses());
@@ -251,20 +251,20 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
         // Put and get a few keys.
         for (int i = 0; ; i++) {
-            if (cache0.affinity().isPrimary(g0.cluster().localNode(), i)) {
+            if (g0.affinity(cache0.name()).isPrimary(g0.cluster().localNode(), i)) {
                 cache0.get(i); // +1 read.
 
                 key = i;
 
                 info("Writes: " + cache0.metrics().writes());
                 info("Reads: " + cache0.metrics().reads());
-                info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i)));
+                info("Affinity nodes: " + U.nodes2names(g0.affinity(cache0.name()).mapKeyToPrimaryAndBackups(i)));
 
                 cache0.get(i); // +1 read.
 
                 info("Writes: " + cache0.metrics().writes());
                 info("Reads: " + cache0.metrics().reads());
-                info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i)));
+                info("Affinity nodes: " + U.nodes2names(g0.affinity(cache0.name()).mapKeyToPrimaryAndBackups(i)));
 
                 break;
             }
@@ -280,7 +280,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
             assertEquals(0, g.cache(null).metrics().writes());
 
-            if (g.cache(null).affinity().isPrimary(g.cluster().localNode(), key)) {
+            if (g.affinity(null).isPrimary(g.cluster().localNode(), key)) {
                 assertEquals(2, g.cache(null).metrics().reads());
                 assertEquals(0, g.cache(null).metrics().hits());
                 assertEquals(2, g.cache(null).metrics().misses());
@@ -305,20 +305,20 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
         // Put and get a few keys.
         for (int i = 0; ; i++) {
-            if (cache0.affinity().isBackup(g0.cluster().localNode(), i)) {
+            if (g0.affinity(cache0.name()).isBackup(g0.cluster().localNode(), i)) {
                 cache0.get(i); // +1 read.
 
                 key = i;
 
                 info("Writes: " + cache0.metrics().writes());
                 info("Reads: " + cache0.metrics().reads());
-                info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i)));
+                info("Affinity nodes: " + U.nodes2names(g0.affinity(cache0.name()).mapKeyToPrimaryAndBackups(i)));
 
                 cache0.get(i); // +1 read.
 
                 info("Writes: " + cache0.metrics().writes());
                 info("Reads: " + cache0.metrics().reads());
-                info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i)));
+                info("Affinity nodes: " + U.nodes2names(g0.affinity(cache0.name()).mapKeyToPrimaryAndBackups(i)));
 
                 break;
             }
@@ -329,7 +329,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
             assertEquals(0, g.cache(null).metrics().writes());
 
-            if (g.cache(null).affinity().isPrimaryOrBackup(g.cluster().localNode(), key)) {
+            if (g.affinity(null).isPrimaryOrBackup(g.cluster().localNode(), key)) {
                 assertEquals(2, g.cache(null).metrics().reads());
                 assertEquals(0, g.cache(null).metrics().hits());
                 assertEquals(2, g.cache(null).metrics().misses());
@@ -354,7 +354,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
         // Put and get a few keys.
         for (int i = 0; ; i++) {
-            if (!cache0.affinity().isPrimaryOrBackup(g0.cluster().localNode(), i)) {
+            if (!g0.affinity(cache0.name()).isPrimaryOrBackup(g0.cluster().localNode(), i)) {
                 cache0.get(i); // +1 read.
                 cache0.get(i); // +1 read.
 
@@ -364,7 +364,7 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
                 info("Reads: " + cache0.metrics().reads());
                 info("Hits: " + cache0.metrics().hits());
                 info("Misses: " + cache0.metrics().misses());
-                info("Affinity nodes: " + U.nodes2names(cache0.affinity().mapKeyToPrimaryAndBackups(i)));
+                info("Affinity nodes: " + U.nodes2names(g0.affinity(cache0.name()).mapKeyToPrimaryAndBackups(i)));
 
                 break;
             }
@@ -375,12 +375,12 @@ public class GridCacheNearMetricsSelfTest extends GridCacheAbstractSelfTest {
 
             assertEquals(0, g.cache(null).metrics().writes());
 
-            if (g.cache(null).affinity().isPrimary(g.cluster().localNode(), key)) {
+            if (g.affinity(null).isPrimary(g.cluster().localNode(), key)) {
                 assertEquals(2, g.cache(null).metrics().reads());
                 assertEquals(0, g.cache(null).metrics().hits());
                 assertEquals(2, g.cache(null).metrics().misses());
             }
-            else if (g.cache(null).affinity().isBackup(g.cluster().localNode(), key)){
+            else if (g.affinity(null).isBackup(g.cluster().localNode(), key)){
                 assertEquals(0, g.cache(null).metrics().reads());
                 assertEquals(0, g.cache(null).metrics().hits());
                 assertEquals(0, g.cache(null).metrics().misses());

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java
index 7025a7b..3a6901e 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiGetSelfTest.java
@@ -22,7 +22,6 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.transactions.*;
 import org.apache.log4j.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
 import org.gridgain.grid.kernal.processors.cache.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
@@ -221,6 +220,7 @@ public class GridCacheNearMultiGetSelfTest extends GridCommonAbstractTest {
     private void checkDoubleGet(IgniteTxConcurrency concurrency, IgniteTxIsolation isolation, boolean put)
         throws Exception {
         GridCache<Integer, String> cache = grid(0).cache(null);
+        IgniteCacheAffinity<Integer> aff = grid(0).affinity(cache.name());
 
         Integer key = 1;
 
@@ -235,8 +235,6 @@ public class GridCacheNearMultiGetSelfTest extends GridCommonAbstractTest {
             if (isTestDebug()) {
                 info("Started transaction.");
 
-                GridCacheAffinity<Integer> aff = cache.affinity();
-
                 int part = aff.partition(key);
 
                 if (isTestDebug())

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
index 2145a30..091b534 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearMultiNodeSelfTest.java
@@ -22,7 +22,7 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.transactions.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
+import org.apache.ignite.cache.affinity.*;
 import org.gridgain.grid.cache.store.*;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.*;
@@ -66,7 +66,7 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest {
     private AtomicInteger cntr = new AtomicInteger(0);
 
     /** Affinity based on node index mode. */
-    private GridCacheAffinityFunction aff = new GridCacheModuloAffinityFunction(GRID_CNT, BACKUPS);
+    private CacheAffinityFunction aff = new CacheModuloAffinityFunction(GRID_CNT, BACKUPS);
 
     /** Debug flag for mappings. */
     private boolean mapDebug = true;
@@ -101,7 +101,7 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest {
 
         cfg.setCacheConfiguration(cacheCfg);
 
-        cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, cntr.getAndIncrement()));
+        cfg.setUserAttributes(F.asMap(CacheModuloAffinityFunction.IDX_ATTR, cntr.getAndIncrement()));
 
         return cfg;
     }
@@ -200,13 +200,13 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest {
      * @param idx Index.
      * @return Affinity.
      */
-    private GridCacheAffinity<Object> affinity(int idx) {
-        return grid(idx).cache(null).affinity();
+    protected IgniteCacheAffinity<Object> affinity(int idx) {
+        return grid(idx).affinity(null);
     }
 
     /** @param cnt Count. */
     private void mapKeys(int cnt) {
-        GridCacheAffinity<Object> aff = affinity(0);
+        IgniteCacheAffinity<Object> aff = affinity(0);
 
         for (int key = 1; key <= cnt; key++) {
             Integer part = aff.partition(key);
@@ -650,7 +650,7 @@ public class GridCacheNearMultiNodeSelfTest extends GridCommonAbstractTest {
 
         String val = Integer.toString(key);
 
-        Collection<ClusterNode> affNodes = cache.affinity().mapKeyToPrimaryAndBackups(key);
+        Collection<ClusterNode> affNodes = affinity(0).mapKeyToPrimaryAndBackups(key);
 
         info("Affinity for key [nodeId=" + U.nodeIds(affNodes) + ", key=" + key + ']');
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java
index 8c73b7c..5ddef87 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearOnlyTopologySelfTest.java
@@ -112,7 +112,7 @@ public class GridCacheNearOnlyTopologySelfTest extends GridCommonAbstractTest {
             }
 
             for (int i = 0; i < 100; i++)
-                assertFalse("For key: " + i, grid(0).cache(null).affinity().isPrimaryOrBackup(grid(0).localNode(), i));
+                assertFalse("For key: " + i, grid(0).affinity(null).isPrimaryOrBackup(grid(0).localNode(), i));
         }
         finally {
             stopAllGrids();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
index d86cc95..c109c6c 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearPartitionedClearSelfTest.java
@@ -131,7 +131,7 @@ public class GridCacheNearPartitionedClearSelfTest extends GridCommonAbstractTes
         ClusterNode locNode = ignite.cluster().localNode();
 
         for (int i = 0; i < Integer.MAX_VALUE; i++) {
-            if (cache.affinity().isPrimary(locNode, i))
+            if (ignite.affinity(cache.name()).isPrimary(locNode, i))
                 return i;
         }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java
index 0be4bb1..865e0eb 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearReaderPreloadSelfTest.java
@@ -20,11 +20,11 @@ package org.gridgain.grid.kernal.processors.cache.distributed.near;
 import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
-import org.gridgain.grid.*;
 import org.gridgain.grid.cache.*;
 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.IgniteCacheAffinity;
 import org.gridgain.grid.util.typedef.*;
 import org.gridgain.testframework.junits.common.*;
 
@@ -60,6 +60,15 @@ public class GridCacheNearReaderPreloadSelfTest extends GridCommonAbstractTest {
     /** Cache on backup node. */
     private GridCache<Integer, Integer> cache3;
 
+    /** Affinity for cache1 */
+    private IgniteCacheAffinity<Integer> aff1;
+
+    /** Affinity for cache2 */
+    private IgniteCacheAffinity<Integer> aff2;
+
+    /** Affinity for cache3 */
+    private IgniteCacheAffinity<Integer> aff3;
+
     /** {@inheritDoc} */
     @Override protected void afterTest() throws Exception {
         cache1 = null;
@@ -109,6 +118,10 @@ public class GridCacheNearReaderPreloadSelfTest extends GridCommonAbstractTest {
         cache1 = node1.cache(CACHE_NAME);
         cache2 = node2.cache(CACHE_NAME);
         cache3 = node3.cache(CACHE_NAME);
+
+        aff1 = node1.affinity(CACHE_NAME);
+        aff2 = node2.affinity(CACHE_NAME);
+        aff3 = node3.affinity(CACHE_NAME);
     }
 
     /**
@@ -154,7 +167,7 @@ public class GridCacheNearReaderPreloadSelfTest extends GridCommonAbstractTest {
         int key = 0;
 
         while (true) {
-            Collection<ClusterNode> affNodes = cache1.affinity().mapKeyToPrimaryAndBackups(key);
+            Collection<ClusterNode> affNodes = aff1.mapKeyToPrimaryAndBackups(key);
 
             assert !F.isEmpty(affNodes);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
index 88b27f3..2fd2f52 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearReadersSelfTest.java
@@ -21,6 +21,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.gridgain.grid.cache.*;
+import org.apache.ignite.IgniteCacheAffinity;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.dht.*;
@@ -53,7 +54,7 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest {
     private static AtomicInteger cntr = new AtomicInteger(0);
 
     /** Test cache affinity. */
-    private GridCacheModuloAffinityFunction aff = new GridCacheModuloAffinityFunction();
+    private CacheModuloAffinityFunction aff = new CacheModuloAffinityFunction();
 
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
@@ -81,7 +82,7 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest {
 
         cfg.setDiscoverySpi(disco);
 
-        cfg.setUserAttributes(F.asMap(GridCacheModuloAffinityFunction.IDX_ATTR, cntr.getAndIncrement()));
+        cfg.setUserAttributes(F.asMap(CacheModuloAffinityFunction.IDX_ATTR, cntr.getAndIncrement()));
 
         return cfg;
     }
@@ -220,11 +221,14 @@ public class GridCacheNearReadersSelfTest extends GridCommonAbstractTest {
         GridCache<Integer, String> cache1 = g1.cache(null);
         GridCache<Integer, String> cache2 = g2.cache(null);
 
-        assertEquals(cache1.affinity().mapKeyToNode(1), g1.cluster().localNode());
-        assertFalse(cache1.affinity().mapKeyToNode(2).equals(g1.cluster().localNode()));
+        IgniteCacheAffinity<Integer> affinity1 = g1.affinity(cache1.name());
+        IgniteCacheAffinity<Integer> affinity2 = g2.affinity(cache2.name());
 
-        assertEquals(cache2.affinity().mapKeyToNode(2), g2.cluster().localNode());
-        assertFalse(cache2.affinity().mapKeyToNode(1).equals(g2.cluster().localNode()));
+        assertEquals(affinity1.mapKeyToNode(1), g1.cluster().localNode());
+        assertFalse(affinity1.mapKeyToNode(2).equals(g1.cluster().localNode()));
+
+        assertEquals(affinity2.mapKeyToNode(2), g2.cluster().localNode());
+        assertFalse(affinity2.mapKeyToNode(1).equals(g2.cluster().localNode()));
 
         // Store first value in cache.
         assertNull(cache1.put(1, "v1"));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearRemoveFailureTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearRemoveFailureTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearRemoveFailureTest.java
index 73c9209..544e874 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearRemoveFailureTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearRemoveFailureTest.java
@@ -18,7 +18,6 @@
 package org.gridgain.grid.kernal.processors.cache.distributed.near;
 
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
 import org.gridgain.grid.kernal.processors.cache.*;
 
 import static org.gridgain.grid.cache.GridCacheMode.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java
index 0cba0d5..c4dcdc8 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheNearTxMultiNodeSelfTest.java
@@ -22,7 +22,7 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.transactions.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
+import org.apache.ignite.cache.affinity.*;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.dht.*;
 import org.apache.ignite.spi.discovery.tcp.*;
@@ -98,7 +98,7 @@ public class GridCacheNearTxMultiNodeSelfTest extends GridCommonAbstractTest {
             Integer mainKey = 0;
 
             ClusterNode priNode = ignite.cluster().mapKeyToNode(null, mainKey);
-            ClusterNode backupNode = F.first(F.view(ignite.cache(null).affinity().mapKeyToPrimaryAndBackups(mainKey),
+            ClusterNode backupNode = F.first(F.view(ignite.affinity(ignite.cache(null).name()).mapKeyToPrimaryAndBackups(mainKey),
                 F.notIn(F.asList(priNode))));
             ClusterNode otherNode = F.first(ignite.cluster().forPredicate(F.notIn(F.asList(priNode, backupNode))).nodes());
 
@@ -130,7 +130,7 @@ public class GridCacheNearTxMultiNodeSelfTest extends GridCommonAbstractTest {
 
                 Ignite g = F.rand(ignites);
 
-                g.cache(null).put(new GridCacheAffinityKey<>(i, mainKey), Integer.toString(cntr++));
+                g.cache(null).put(new CacheAffinityKey<>(i, mainKey), Integer.toString(cntr++));
             }
 
             GridCacheProjection cache = priIgnite.cache(null).flagsOn(GridCacheFlag.CLONE);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java
index 8e4b443..5e83d16 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinityExcludeNeighborsPerformanceTest.java
@@ -21,8 +21,8 @@ import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
@@ -70,7 +70,7 @@ public class GridCachePartitionedAffinityExcludeNeighborsPerformanceTest extends
 
         cc.setBackups(2);
 
-        GridCacheAffinityFunction aff = new GridCacheConsistentHashAffinityFunction(excNeighbores);
+        CacheAffinityFunction aff = new CacheConsistentHashAffinityFunction(excNeighbores);
 
         cc.setAffinity(aff);
 
@@ -90,8 +90,8 @@ public class GridCachePartitionedAffinityExcludeNeighborsPerformanceTest extends
      * @param ignite Grid.
      * @return Affinity.
      */
-    static GridCacheAffinity<Object> affinity(Ignite ignite) {
-        return ignite.cache(null).affinity();
+    static IgniteCacheAffinity<Object> affinity(Ignite ignite) {
+        return ignite.affinity(ignite.cache(null).name());
     }
 
     /**
@@ -99,7 +99,7 @@ public class GridCachePartitionedAffinityExcludeNeighborsPerformanceTest extends
      * @param key Key.
      * @return Nodes.
      */
-    private static Collection<? extends ClusterNode> nodes(GridCacheAffinity<Object> aff, Object key) {
+    private static Collection<? extends ClusterNode> nodes(IgniteCacheAffinity<Object> aff, Object key) {
         return aff.mapKeyToPrimaryAndBackups(key);
     }
 
@@ -167,7 +167,7 @@ public class GridCachePartitionedAffinityExcludeNeighborsPerformanceTest extends
      * @throws Exception If failed.
      */
     private long checkCountPerformance0(Ignite g, int cnt) throws Exception {
-        GridCacheAffinity<Object> aff = affinity(g);
+        IgniteCacheAffinity<Object> aff = affinity(g);
 
         GridTimer timer = new GridTimer("test");
 
@@ -218,7 +218,7 @@ public class GridCachePartitionedAffinityExcludeNeighborsPerformanceTest extends
         try {
             Ignite g = grid(0);
 
-            GridCacheAffinity<Object> aff = affinity(g);
+            IgniteCacheAffinity<Object> aff = affinity(g);
 
             // Warmup.
             checkCountPerformance0(g, 10000);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinityHashIdResolverSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinityHashIdResolverSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinityHashIdResolverSelfTest.java
index c6cc8dd..4ecf9b6 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinityHashIdResolverSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinityHashIdResolverSelfTest.java
@@ -24,8 +24,8 @@ 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.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.gridgain.testframework.*;
 import org.gridgain.testframework.junits.common.*;
 
@@ -41,11 +41,11 @@ public class GridCachePartitionedAffinityHashIdResolverSelfTest extends GridComm
     private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
 
     /** Hash ID resolver. */
-    private GridCacheAffinityNodeHashResolver rslvr;
+    private CacheAffinityNodeHashResolver rslvr;
 
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        GridCacheConsistentHashAffinityFunction aff = new GridCacheConsistentHashAffinityFunction();
+        CacheConsistentHashAffinityFunction aff = new CacheConsistentHashAffinityFunction();
 
         aff.setHashIdResolver(rslvr);
 
@@ -77,7 +77,7 @@ public class GridCachePartitionedAffinityHashIdResolverSelfTest extends GridComm
      * @throws Exception If failed.
      */
     public void testDuplicateId() throws Exception {
-        rslvr = new GridCacheAffinityNodeHashResolver() {
+        rslvr = new CacheAffinityNodeHashResolver() {
             @Override public Object resolve(ClusterNode node) {
                 return 1;
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java
index 949d961..b74b315 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedAffinitySelfTest.java
@@ -23,10 +23,9 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.resources.*;
-import org.gridgain.grid.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
@@ -44,7 +43,7 @@ import static org.gridgain.grid.cache.GridCacheAtomicityMode.*;
 import static org.gridgain.grid.cache.GridCacheMode.*;
 import static org.gridgain.grid.cache.GridCacheDistributionMode.*;
 import static org.gridgain.grid.cache.GridCachePreloadMode.*;
-import static org.gridgain.grid.cache.affinity.consistenthash.GridCacheConsistentHashAffinityFunction.*;
+import static org.apache.ignite.cache.affinity.consistenthash.CacheConsistentHashAffinityFunction.*;
 
 /**
  * Partitioned affinity test.
@@ -100,8 +99,8 @@ public class GridCachePartitionedAffinitySelfTest extends GridCommonAbstractTest
      * @param ignite Grid.
      * @return Affinity.
      */
-    static GridCacheAffinity<Object> affinity(Ignite ignite) {
-        return ignite.cache(null).affinity();
+    static IgniteCacheAffinity<Object> affinity(Ignite ignite) {
+        return ignite.affinity(ignite.cache(null).name());
     }
 
     /**
@@ -109,18 +108,18 @@ public class GridCachePartitionedAffinitySelfTest extends GridCommonAbstractTest
      * @param key Key.
      * @return Nodes.
      */
-    private static Collection<? extends ClusterNode> nodes(GridCacheAffinity<Object> aff, Object key) {
+    private static Collection<? extends ClusterNode> nodes(IgniteCacheAffinity<Object> aff, Object key) {
         return aff.mapKeyToPrimaryAndBackups(key);
     }
 
     /** Test predefined affinity - must be ported to all clients. */
     @SuppressWarnings("UnaryPlus")
     public void testPredefined() throws IgniteCheckedException {
-        GridCacheConsistentHashAffinityFunction aff = new GridCacheConsistentHashAffinityFunction();
+        CacheConsistentHashAffinityFunction aff = new CacheConsistentHashAffinityFunction();
 
         getTestResources().inject(aff);
 
-        aff.setHashIdResolver(new GridCacheAffinityNodeIdHashResolver());
+        aff.setHashIdResolver(new CacheAffinityNodeIdHashResolver());
 
         List<ClusterNode> nodes = new ArrayList<>();
 
@@ -219,11 +218,11 @@ public class GridCachePartitionedAffinitySelfTest extends GridCommonAbstractTest
     @SuppressWarnings("UnaryPlus")
     public void testPredefinedHashIdResolver() throws IgniteCheckedException {
         // Use Md5 hasher for this test.
-        GridCacheConsistentHashAffinityFunction aff = new GridCacheConsistentHashAffinityFunction();
+        CacheConsistentHashAffinityFunction aff = new CacheConsistentHashAffinityFunction();
 
         getTestResources().inject(aff);
 
-        aff.setHashIdResolver(new GridCacheAffinityNodeHashResolver() {
+        aff.setHashIdResolver(new CacheAffinityNodeHashResolver() {
             @Override public Object resolve(ClusterNode node) {
                 return node.attribute(DFLT_REPLICA_COUNT_ATTR_NAME);
             }
@@ -365,7 +364,7 @@ public class GridCachePartitionedAffinitySelfTest extends GridCommonAbstractTest
         X.println(">>>");
         X.println(">>> Printing affinity for node: " + g.name());
 
-        GridCacheAffinity<Object> aff = affinity(g);
+        IgniteCacheAffinity<Object> aff = affinity(g);
 
         for (int i = 0; i < keyCnt; i++) {
             Collection<? extends ClusterNode> affNodes = nodes(aff, i);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
index 4164c86..e562a61 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedBasicStoreMultiNodeSelfTest.java
@@ -117,7 +117,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA
             boolean found = false;
 
             for (ClusterNode n : grid(0).nodes()) {
-                if (cache.affinity().isPrimary(n, key)) {
+                if (affinity(0).isPrimary(n, key)) {
                     found = true;
 
                     break;
@@ -150,7 +150,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA
             boolean found = false;
 
             for (ClusterNode n : grid(0).nodes()) {
-                if (cache.affinity().isBackup(n, key)) {
+                if (affinity(0).isBackup(n, key)) {
                     found = true;
 
                     break;
@@ -183,7 +183,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA
             boolean found = false;
 
             for (ClusterNode n : grid(0).nodes()) {
-                if (!cache.affinity().isPrimaryOrBackup(n, key)) {
+                if (!affinity(0).isPrimaryOrBackup(n, key)) {
                     found = true;
 
                     break;
@@ -216,7 +216,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA
             boolean found = false;
 
             for (ClusterNode n : grid(0).nodes()) {
-                if (cache.affinity().isPrimary(n, key)) {
+                if (affinity(0).isPrimary(n, key)) {
                     found = true;
 
                     break;
@@ -249,7 +249,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA
             boolean found = false;
 
             for (ClusterNode n : grid(0).nodes()) {
-                if (cache.affinity().isBackup(n, key)) {
+                if (affinity(0).isBackup(n, key)) {
                     found = true;
 
                     break;
@@ -282,7 +282,7 @@ public class GridCachePartitionedBasicStoreMultiNodeSelfTest extends GridCommonA
             boolean found = false;
 
             for (ClusterNode n : grid(0).nodes()) {
-                if (!cache.affinity().isPrimaryOrBackup(n, key)) {
+                if (!affinity(0).isPrimaryOrBackup(n, key)) {
                     found = true;
 
                     break;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest.java
index 9026f6b..22affa3 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest.java
@@ -38,14 +38,14 @@ public class GridCachePartitionedClientOnlyNoPrimaryFullApiSelfTest extends Grid
      *
      */
     public void testMapKeysToNodes() {
-        cache().affinity().mapKeysToNodes(Arrays.asList("1", "2"));
+        affinity(0).mapKeysToNodes(Arrays.asList("1", "2"));
     }
 
     /**
      *
      */
     public void testMapKeyToNode() {
-        assert cache().affinity().mapKeyToNode("1") == null;
+        assert affinity(0).mapKeyToNode("1") == null;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedEventSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedEventSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedEventSelfTest.java
index c037556..274569b 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedEventSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedEventSelfTest.java
@@ -18,7 +18,6 @@
 package org.gridgain.grid.kernal.processors.cache.distributed.near;
 
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.*;
 
 import static org.gridgain.grid.cache.GridCacheAtomicityMode.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java
index 38d76a2..e91edc9 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedEvictionSelfTest.java
@@ -22,7 +22,6 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.transactions.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
 import org.gridgain.grid.cache.eviction.fifo.*;
 import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.dht.*;
@@ -169,7 +168,7 @@ public class GridCachePartitionedEvictionSelfTest extends GridCacheAbstractSelfT
         GridDhtCacheAdapter<String, Integer> dht0 = dht(cache(0));
         GridDhtCacheAdapter<String, Integer> dht1 = dht(cache(1));
 
-        GridCacheAffinity<String> aff = dht0.affinity();
+        IgniteCacheAffinity<String> aff = dht0.context().grid().affinity(dht0.name());
 
         TouchedExpiryPolicy plc = new TouchedExpiryPolicy(new Duration(MILLISECONDS, 10));
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java
index b8d3c80..5ce1aef 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedFullApiSelfTest.java
@@ -20,7 +20,8 @@ package org.gridgain.grid.kernal.processors.cache.distributed.near;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+import org.apache.ignite.IgniteCacheAffinity;
+import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.util.typedef.*;
@@ -72,7 +73,7 @@ public class GridCachePartitionedFullApiSelfTest extends GridCacheAbstractFullAp
             cache.put(key, i);
         }
 
-        GridCacheConsistentHashAffinityFunction aff = (GridCacheConsistentHashAffinityFunction)cache.configuration().getAffinity();
+        CacheConsistentHashAffinityFunction aff = (CacheConsistentHashAffinityFunction)cache.configuration().getAffinity();
 
         for (int i = 0 ; i < aff.getPartitions(); i++)
             String.valueOf(cache.entrySet(i));
@@ -83,13 +84,14 @@ public class GridCachePartitionedFullApiSelfTest extends GridCacheAbstractFullAp
      */
     public void testPartitionEntrySetIterator() throws Exception {
         GridCacheAdapter<String, Integer> cache = ((GridKernal)grid(0)).internalCache();
+        IgniteCacheAffinity<String> aff = grid(0).affinity(cache.name());
 
         Map<Integer, Collection<String>> partMap = new HashMap<>();
 
         for (int i = 0; i < 1000; i++) {
             String key = String.valueOf(i);
 
-            int part = cache.affinity().partition(key);
+            int part = aff.partition(key);
 
             cache.put(key, i);
 
@@ -121,7 +123,7 @@ public class GridCachePartitionedFullApiSelfTest extends GridCacheAbstractFullAp
 
                 Set<GridCacheEntry<String, Integer>> partEntrySet = nodeCache.entrySet(part);
 
-                if (nodeCache.affinity().isPrimaryOrBackup(g.cluster().localNode(), key)) {
+                if (g.affinity(nodeCache.name()).isPrimaryOrBackup(g.cluster().localNode(), key)) {
                     Collection<String> cp = new LinkedList<>(vals);
 
                     for (GridCacheEntry<String, Integer> e : partEntrySet) {
@@ -162,7 +164,7 @@ public class GridCachePartitionedFullApiSelfTest extends GridCacheAbstractFullAp
                     continue;
 
                 // First node with this partition will remove first key from partition.
-                if (nodeCache.affinity().isPrimaryOrBackup(g.cluster().localNode(), key)) {
+                if (g.affinity(nodeCache.name()).isPrimaryOrBackup(g.cluster().localNode(), key)) {
                     Set<GridCacheEntry<String, Integer>> partEntrySet = nodeCache.entrySet(part);
 
                     Iterator<GridCacheEntry<String, Integer>> it = partEntrySet.iterator();
@@ -197,7 +199,7 @@ public class GridCachePartitionedFullApiSelfTest extends GridCacheAbstractFullAp
         for (int i = 0; i < 1000; i++) {
             String key = String.valueOf(i);
 
-            int part = cache.affinity().partition(key);
+            int part = affinity(0).partition(key);
 
             cache.put(key, i);
 
@@ -231,7 +233,7 @@ public class GridCachePartitionedFullApiSelfTest extends GridCacheAbstractFullAp
 
                 Set<GridCacheEntry<String, Integer>> partEntrySet = nodeCache.entrySet(part);
 
-                if (nodeCache.affinity().isPrimaryOrBackup(g.cluster().localNode(), key)) {
+                if (g.affinity(nodeCache.name()).isPrimaryOrBackup(g.cluster().localNode(), key)) {
                     assertTrue(partEntrySet.contains(nodeCache.entry(key)));
 
                     deleted.add(key);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
index 3197890..f7abe49 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedLoadCacheSelfTest.java
@@ -25,7 +25,6 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.transactions.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
 import org.gridgain.grid.cache.store.*;
 import org.gridgain.grid.util.typedef.internal.*;
 import org.gridgain.testframework.junits.common.*;
@@ -82,7 +81,7 @@ public class GridCachePartitionedLoadCacheSelfTest extends GridCommonAbstractTes
 
             GridCache<Integer, String> cache0 = cache(0);
 
-            GridCacheAffinity aff = cache0.affinity();
+            IgniteCacheAffinity aff = affinity(0);
 
             int[] parts = aff.allPartitions(grid(0).localNode());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java
index 86a7910..f73f7d5 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeCounterSelfTest.java
@@ -24,7 +24,6 @@ import org.apache.ignite.lang.*;
 import org.apache.ignite.resources.*;
 import org.apache.ignite.transactions.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.dht.*;
@@ -117,11 +116,12 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst
     }
 
     /**
+     * @param ignite Ignite
      * @param cache Cache.
      * @return Affinity.
      */
-    private static GridCacheAffinity<String> affinity(GridCache<String, Integer> cache) {
-        return cache.affinity();
+    private static IgniteCacheAffinity<String> affinity(Ignite ignite, GridCache<String, Integer> cache) {
+        return ignite.affinity(cache.name());
     }
 
     /**
@@ -241,7 +241,7 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst
         X.println("*** Retries: " + RETRIES);
         X.println("*** Log frequency: " + LOG_FREQ);
 
-        GridCacheAffinity<String> aff = affinity(grid(0).<String, Integer>cache(null));
+        IgniteCacheAffinity<String> aff = affinity(grid(0), grid(0).<String, Integer>cache(null));
 
         Collection<ClusterNode> affNodes = aff.mapKeyToPrimaryAndBackups(CNTR_KEY);
 
@@ -543,7 +543,7 @@ public class GridCachePartitionedMultiNodeCounterSelfTest extends GridCommonAbst
      * @throws Exception If failed.
      */
     private void checkNearAndPrimaryMultiNode(int gridCnt) throws Exception {
-        GridCacheAffinity<String> aff = affinity(grid(0).<String, Integer>cache(null));
+        IgniteCacheAffinity<String> aff = affinity(grid(0), grid(0).<String, Integer>cache(null));
 
         Collection<ClusterNode> affNodes = aff.mapKeyToPrimaryAndBackups(CNTR_KEY);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
index 0c65c7a..dbed16f 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedMultiNodeFullApiSelfTest.java
@@ -22,7 +22,7 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.lang.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
+import org.apache.ignite.cache.affinity.*;
 import org.gridgain.grid.util.typedef.*;
 import org.gridgain.grid.util.typedef.internal.*;
 
@@ -152,7 +152,7 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
             ClusterNode node = grid(i).localNode();
 
             for (int k = 0; k < size; k++) {
-                if (cache.affinity().isPrimaryOrBackup(node, k))
+                if (grid(i).affinity(cache.name()).isPrimaryOrBackup(node, k))
                     assertEquals("Check failed for node: " + node.id(), k, cache.peek(k));
             }
         }
@@ -307,8 +307,8 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
             while (true) {
                 String key = UUID.randomUUID().toString();
 
-                if (cache().affinity().isPrimary(grid(0).localNode(), key) &&
-                    cache().affinity().isBackup(grid(1).localNode(), key)) {
+                if (affinity(0).isPrimary(grid(0).localNode(), key) &&
+                    affinity(0).isBackup(grid(1).localNode(), key)) {
                     keys.add(key);
 
                     assertTrue(cache(0).putx(key, i));
@@ -360,7 +360,7 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
         if (!lockingEnabled())
             return;
 
-        ClusterNode node = CU.primary(cache().affinity().mapKeyToPrimaryAndBackups("key"));
+        ClusterNode node = CU.primary(affinity(0).mapKeyToPrimaryAndBackups("key"));
 
         assert node != null;
 
@@ -378,7 +378,7 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
         if (!lockingEnabled())
             return;
 
-        ClusterNode node = F.first(CU.backups(cache().affinity().mapKeyToPrimaryAndBackups("key")));
+        ClusterNode node = F.first(CU.backups(affinity(0).mapKeyToPrimaryAndBackups("key")));
 
         assert node != null;
 
@@ -396,7 +396,7 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
         if (!lockingEnabled())
             return;
 
-        Collection<ClusterNode> affNodes = cache().affinity().mapKeyToPrimaryAndBackups("key");
+        Collection<ClusterNode> affNodes = affinity(0).mapKeyToPrimaryAndBackups("key");
 
         ClusterNode node = null;
 
@@ -528,7 +528,7 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
         Object key = new Object() {
             /** */
             @SuppressWarnings("UnusedDeclaration")
-            @GridCacheAffinityKeyMapped
+            @CacheAffinityKeyMapped
             private final Object key0 = affKey;
 
             @Override public boolean equals(Object obj) {
@@ -544,9 +544,9 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
 
         GridCache<Object, Object> cache = grid(0).cache(null);
 
-        info("Cache affinity nodes: " + cache.affinity().mapKeyToPrimaryAndBackups(key));
+        IgniteCacheAffinity<Object> aff = grid(0).affinity(cache.name());
 
-        GridCacheAffinity<Object> aff = cache.affinity();
+        info("Cache affinity nodes: " + aff.mapKeyToPrimaryAndBackups(key));
 
         Collection<ClusterNode> nodes = aff.mapKeyToPrimaryAndBackups(key);
 
@@ -578,19 +578,19 @@ public class GridCachePartitionedMultiNodeFullApiSelfTest extends GridCacheParti
         assertNotNull(backup);
         assertNotNull(other);
 
-        assertTrue(cache.affinity().isPrimary(primary, key));
-        assertFalse(cache.affinity().isBackup(primary, key));
-        assertTrue(cache.affinity().isPrimaryOrBackup(primary, key));
+        assertTrue(aff.isPrimary(primary, key));
+        assertFalse(aff.isBackup(primary, key));
+        assertTrue(aff.isPrimaryOrBackup(primary, key));
 
-        assertFalse(cache.affinity().isPrimary(backup, key));
-        assertTrue(cache.affinity().isBackup(backup, key));
-        assertTrue(cache.affinity().isPrimaryOrBackup(backup, key));
+        assertFalse(aff.isPrimary(backup, key));
+        assertTrue(aff.isBackup(backup, key));
+        assertTrue(aff.isPrimaryOrBackup(backup, key));
 
-        assertFalse(cache.affinity().isPrimary(other, key));
+        assertFalse(aff.isPrimary(other, key));
 
         if (cacheMode() == PARTITIONED) {
-            assertFalse(cache.affinity().isBackup(other, key));
-            assertFalse(cache.affinity().isPrimaryOrBackup(other, key));
+            assertFalse(aff.isBackup(other, key));
+            assertFalse(aff.isPrimaryOrBackup(other, key));
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedNodeRestartTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedNodeRestartTest.java
index cd3e5af..fdb8742 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedNodeRestartTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedNodeRestartTest.java
@@ -19,7 +19,7 @@ package org.gridgain.grid.kernal.processors.cache.distributed.near;
 
 import org.apache.ignite.configuration.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.*;
 
 import static org.gridgain.grid.cache.GridCacheMode.*;
@@ -46,7 +46,7 @@ public class GridCachePartitionedNodeRestartTest extends GridCacheAbstractNodeRe
         cc.setStartSize(20);
         cc.setPreloadMode(preloadMode);
         cc.setPreloadBatchSize(preloadBatchSize);
-        cc.setAffinity(new GridCacheConsistentHashAffinityFunction(false, partitions));
+        cc.setAffinity(new CacheConsistentHashAffinityFunction(false, partitions));
         cc.setBackups(backups);
 
         c.setCacheConfiguration(cc);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedOptimisticTxNodeRestartTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedOptimisticTxNodeRestartTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedOptimisticTxNodeRestartTest.java
index 7769582..560ab38 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedOptimisticTxNodeRestartTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedOptimisticTxNodeRestartTest.java
@@ -20,7 +20,7 @@ package org.gridgain.grid.kernal.processors.cache.distributed.near;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.transactions.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.*;
 
 import static org.gridgain.grid.cache.GridCacheMode.*;
@@ -45,7 +45,7 @@ public class GridCachePartitionedOptimisticTxNodeRestartTest extends GridCacheAb
         cc.setStartSize(20);
         cc.setPreloadMode(preloadMode);
         cc.setPreloadBatchSize(preloadBatchSize);
-        cc.setAffinity(new GridCacheConsistentHashAffinityFunction(false, partitions));
+        cc.setAffinity(new CacheConsistentHashAffinityFunction(false, partitions));
         cc.setBackups(backups);
 
         c.setCacheConfiguration(cc);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedProjectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedProjectionSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedProjectionSelfTest.java
index 8fd94d4..ade1897 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedProjectionSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedProjectionSelfTest.java
@@ -63,9 +63,9 @@ public class GridCachePartitionedProjectionSelfTest extends GridCacheAbstractPro
             String key = "1";
             Integer val = Integer.valueOf(key);
 
-            Ignite primary = G.ignite(cache(0).affinity().mapKeyToNode(key).id());
+            Ignite primary = G.ignite(affinity(0).mapKeyToNode(key).id());
 
-            Collection<ClusterNode> affNodes = cache(0).affinity().mapKeyToPrimaryAndBackups(key);
+            Collection<ClusterNode> affNodes = affinity(0).mapKeyToPrimaryAndBackups(key);
 
             Ignite near = G.ignite(F.first(F.view(grid(0).nodes(), F.notIn(affNodes))).id());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java
index 3fdd09c..a430451 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedStorePutSelfTest.java
@@ -35,7 +35,7 @@ import java.util.concurrent.atomic.*;
 
 import static org.gridgain.grid.cache.GridCacheMode.*;
 import static org.gridgain.grid.cache.GridCacheWriteSynchronizationMode.*;
-import static org.gridgain.grid.kernal.processors.cache.distributed.GridCacheModuloAffinityFunction.*;
+import static org.gridgain.grid.kernal.processors.cache.distributed.CacheModuloAffinityFunction.*;
 
 /**
  * Test that store is called correctly on puts.
@@ -86,7 +86,7 @@ public class GridCachePartitionedStorePutSelfTest extends GridCommonAbstractTest
 
         cfg.setCacheMode(PARTITIONED);
         cfg.setStore(new TestStore());
-        cfg.setAffinity(new GridCacheModuloAffinityFunction(3, 1));
+        cfg.setAffinity(new CacheModuloAffinityFunction(3, 1));
         cfg.setWriteSynchronizationMode(FULL_SYNC);
 
         return cfg;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
index 00bbc82..f5668e4 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePartitionedTxSalvageSelfTest.java
@@ -22,7 +22,7 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.transactions.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.*;
 import org.apache.ignite.spi.discovery.tcp.*;
@@ -77,7 +77,7 @@ public class GridCachePartitionedTxSalvageSelfTest extends GridCommonAbstractTes
         GridCacheConfiguration cc = defaultCacheConfiguration();
 
         cc.setCacheMode(GridCacheMode.PARTITIONED);
-        cc.setAffinity(new GridCacheConsistentHashAffinityFunction(false, 18));
+        cc.setAffinity(new CacheConsistentHashAffinityFunction(false, 18));
         cc.setBackups(1);
         cc.setPreloadMode(GridCachePreloadMode.SYNC);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePutArrayValueSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePutArrayValueSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePutArrayValueSelfTest.java
index 99a66e8..e22e367 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePutArrayValueSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCachePutArrayValueSelfTest.java
@@ -55,7 +55,7 @@ public class GridCachePutArrayValueSelfTest extends GridCacheAbstractSelfTest {
         final InternalKey key = new InternalKey(0); // Hangs on the first remote put.
 
         // Make key belongs to remote node.
-        while (prj.affinity().mapKeyToPrimaryAndBackups(key).iterator().next().isLocal())
+        while (grid(0).affinity(prj.name()).mapKeyToPrimaryAndBackups(key).iterator().next().isLocal())
             key.key++;
 
         // Put bytes array(!), for integer numbers it works correctly.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheRendezvousAffinityClientSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheRendezvousAffinityClientSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheRendezvousAffinityClientSelfTest.java
index ddc8fe0..3583650 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheRendezvousAffinityClientSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/near/GridCacheRendezvousAffinityClientSelfTest.java
@@ -17,11 +17,11 @@
 
 package org.gridgain.grid.kernal.processors.cache.distributed.near;
 
+import org.apache.ignite.IgniteCacheAffinity;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
-import org.gridgain.grid.cache.affinity.rendezvous.*;
+import org.apache.ignite.cache.affinity.rendezvous.*;
 import org.gridgain.grid.util.typedef.*;
 import org.gridgain.testframework.junits.common.*;
 
@@ -43,7 +43,7 @@ public class GridCacheRendezvousAffinityClientSelfTest extends GridCommonAbstrac
 
         ccfg.setCacheMode(GridCacheMode.PARTITIONED);
         ccfg.setBackups(1);
-        ccfg.setAffinity(new GridCacheRendezvousAffinityFunction());
+        ccfg.setAffinity(new CacheRendezvousAffinityFunction());
 
         if (client)
             ccfg.setDistributionMode(CLIENT_ONLY);
@@ -73,7 +73,7 @@ public class GridCacheRendezvousAffinityClientSelfTest extends GridCommonAbstrac
             for (int i = 0; i < 4; i++) {
                 GridCache<Object, Object> cache = grid(i).cache(null);
 
-                GridCacheAffinity<Object> aff = cache.affinity();
+                IgniteCacheAffinity<Object> aff = grid(i).affinity(cache.name());
 
                 int parts = aff.partitions();
 


Mime
View raw message