ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [04/12] incubator-ignite git commit: #IGNITE-99: Refactoring. Move GridCache.affinity() to Ignite.affinity(String cacheName).
Date Fri, 16 Jan 2015 15:43:07 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/GridCacheModuloAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheModuloAffinityFunction.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheModuloAffinityFunction.java
deleted file mode 100644
index 57fe2ce..0000000
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheModuloAffinityFunction.java
+++ /dev/null
@@ -1,200 +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;
-
-import org.apache.ignite.cluster.*;
-import org.gridgain.grid.cache.affinity.*;
-import org.gridgain.grid.util.typedef.*;
-import org.gridgain.grid.util.typedef.internal.*;
-
-import java.util.*;
-
-/**
- * Affinity which controls where nodes end up using mod operation.
- */
-public class GridCacheModuloAffinityFunction implements GridCacheAffinityFunction {
-    /** Node attribute for index. */
-    public static final String IDX_ATTR = "nodeIndex";
-
-    /** Number of backups. */
-    private int backups = -1;
-
-    /** Number of partitions. */
-    private int parts = -1;
-
-    /**
-     * Empty constructor.
-     */
-    public GridCacheModuloAffinityFunction() {
-        // No-op.
-    }
-
-    /**
-     * @param parts Number of partitions.
-     * @param backups Number of backups.
-     */
-    public GridCacheModuloAffinityFunction(int parts, int backups) {
-        assert parts > 0;
-        assert backups >= 0;
-
-        this.parts = parts;
-        this.backups = backups;
-    }
-
-    /**
-     * @param parts Number of partitions.
-     */
-    public void partitions(int parts) {
-        assert parts > 0;
-
-        this.parts = parts;
-    }
-
-    /**
-     * @param backups Number of backups.
-     */
-    public void backups(int backups) {
-        assert backups >= 0;
-
-        this.backups = backups;
-    }
-
-    /**
-     * @return Number of backups.
-     */
-    public int backups() {
-        return backups;
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Override public List<List<ClusterNode>> assignPartitions(GridCacheAffinityFunctionContext ctx) {
-        List<List<ClusterNode>> res = new ArrayList<>(parts);
-
-        Collection<ClusterNode> topSnapshot = ctx.currentTopologySnapshot();
-
-        for (int part = 0; part < parts; part++) {
-            res.add(F.isEmpty(topSnapshot) ?
-                Collections.<ClusterNode>emptyList() :
-                // Wrap affinity nodes with unmodifiable list since unmodifiable generic collection
-                // doesn't provide equals and hashCode implementations.
-                U.sealList(nodes(part, topSnapshot)));
-        }
-
-        return Collections.unmodifiableList(res);
-    }
-
-    /** {@inheritDoc} */
-    public Collection<ClusterNode> nodes(int part, Collection<ClusterNode> nodes) {
-        List<ClusterNode> sorted = new ArrayList<>(nodes);
-
-        Collections.sort(sorted, new Comparator<ClusterNode>() {
-            @Override public int compare(ClusterNode n1, ClusterNode n2) {
-                int idx1 = n1.<Integer>attribute(IDX_ATTR);
-                int idx2 = n2.<Integer>attribute(IDX_ATTR);
-
-                return idx1 < idx2 ? -1 : idx1 == idx2 ? 0 : 1;
-            }
-        });
-
-        int max = 1 + backups;
-
-        if (max > nodes.size())
-            max = nodes.size();
-
-        Collection<ClusterNode> ret = new ArrayList<>(max);
-
-        Iterator<ClusterNode> it = sorted.iterator();
-
-        for (int i = 0; i < max; i++) {
-            ClusterNode n = null;
-
-            if (i == 0) {
-                while (it.hasNext()) {
-                    n = it.next();
-
-                    int nodeIdx = n.<Integer>attribute(IDX_ATTR);
-
-                    if (part <= nodeIdx)
-                        break;
-                    else
-                        n = null;
-                }
-            }
-            else {
-                if (it.hasNext())
-                    n = it.next();
-                else {
-                    it = sorted.iterator();
-
-                    assert it.hasNext();
-
-                    n = it.next();
-                }
-            }
-
-            assert n != null || nodes.size() < parts;
-
-            if (n == null)
-                n = (it = sorted.iterator()).next();
-
-
-            ret.add(n);
-        }
-
-        return ret;
-    }
-
-    /**
-     * @param parts Number of partitions.
-     * @param backups Number of backups.
-     */
-    public void reset(int parts, int backups) {
-        this.parts = parts;
-        this.backups = backups;
-    }
-
-    /** {@inheritDoc} */
-    @Override public void reset() {
-        parts = -1;
-        backups = -1;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int partitions() {
-        return parts;
-    }
-
-    /** {@inheritDoc} */
-    @Override public int partition(Object key) {
-        if (key instanceof Number)
-            return ((Number)key).intValue() % parts;
-
-        return key == null ? 0 : U.safeAbs(key.hashCode() % parts);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void removeNode(UUID nodeId) {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(GridCacheModuloAffinityFunction.class, this);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java
index ac0567f..5a53b52 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheNodeFailureAbstractTest.java
@@ -234,7 +234,7 @@ public abstract class GridCacheNodeFailureAbstractTest extends GridCommonAbstrac
 
         info("Grid will be stopped: " + idx);
 
-        info("Nodes for key [id=" + grid(idx).cache(null).affinity().mapKeyToPrimaryAndBackups(KEY) +
+        info("Nodes for key [id=" + grid(idx).affinity(null).mapKeyToPrimaryAndBackups(KEY) +
             ", key=" + KEY + ']');
 
         GridCache<Integer, String> cache = cache(idx);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePartitionedAffinityFilterSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePartitionedAffinityFilterSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePartitionedAffinityFilterSelfTest.java
index 3f45121..9907017 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePartitionedAffinityFilterSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePartitionedAffinityFilterSelfTest.java
@@ -21,8 +21,8 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.lang.*;
 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.*;
@@ -66,7 +66,7 @@ public class GridCachePartitionedAffinityFilterSelfTest extends GridCommonAbstra
 
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        GridCacheConsistentHashAffinityFunction aff = new GridCacheConsistentHashAffinityFunction();
+        CacheConsistentHashAffinityFunction aff = new CacheConsistentHashAffinityFunction();
 
         aff.setBackupFilter(backupFilter);
 
@@ -122,16 +122,16 @@ public class GridCachePartitionedAffinityFilterSelfTest extends GridCommonAbstra
      * @throws Exception If failed.
      */
     private void checkPartitions() throws Exception {
-        int partCnt = GridCacheConsistentHashAffinityFunction.DFLT_PARTITION_COUNT;
+        int partCnt = CacheConsistentHashAffinityFunction.DFLT_PARTITION_COUNT;
 
-        GridCacheAffinityFunction aff = cacheConfiguration(grid(0).configuration(), null).getAffinity();
+        CacheAffinityFunction aff = cacheConfiguration(grid(0).configuration(), null).getAffinity();
 
         GridCache<Object, Object> cache = grid(0).cache(null);
 
         for (int i = 0; i < partCnt; i++) {
             assertEquals(i, aff.partition(i));
 
-            Collection<ClusterNode> nodes = cache.affinity().mapKeyToPrimaryAndBackups(i);
+            Collection<ClusterNode> nodes = grid(0).affinity(null).mapKeyToPrimaryAndBackups(i);
 
             assertEquals(2, nodes.size());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePreloadRestartAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePreloadRestartAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePreloadRestartAbstractSelfTest.java
index 56e3cb5..8142f11 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePreloadRestartAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCachePreloadRestartAbstractSelfTest.java
@@ -20,8 +20,8 @@ package org.gridgain.grid.kernal.processors.cache.distributed;
 import org.apache.ignite.*;
 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.*;
@@ -114,7 +114,7 @@ public abstract class GridCachePreloadRestartAbstractSelfTest extends GridCommon
         cc.setStartSize(20);
         cc.setPreloadMode(preloadMode);
         cc.setPreloadBatchSize(preloadBatchSize);
-        cc.setAffinity(new GridCacheConsistentHashAffinityFunction(false, partitions));
+        cc.setAffinity(new CacheConsistentHashAffinityFunction(false, partitions));
         cc.setBackups(backups);
         cc.setAtomicityMode(TRANSACTIONAL);
 
@@ -210,32 +210,32 @@ public abstract class GridCachePreloadRestartAbstractSelfTest extends GridCommon
      * @return Affinity.
      */
     @SuppressWarnings({"unchecked"})
-    private GridCacheAffinityFunction affinity(GridCache<Integer, ?> cache) {
+    private CacheAffinityFunction affinity(GridCache<Integer, ?> cache) {
         return cache.configuration().getAffinity();
     }
 
     /**
-     * @param c Cache projection.
+     * @param a Cache affinity.
      */
-    private void affinityBeforeStop(GridCache<Integer, String> c) {
+    private void affinityBeforeStop(IgniteCacheAffinity<Integer> a) {
         for (int key = 0; key < keyCnt; key++) {
-            int part = affinity(c).partition(key);
+            int part = a.partition(key);
 
             info("Affinity nodes before stop [key=" + key + ", partition" + part + ", nodes=" +
-                U.nodeIds(c.affinity().mapPartitionToPrimaryAndBackups(part)) + ']');
+                U.nodeIds(a.mapPartitionToPrimaryAndBackups(part)) + ']');
         }
     }
 
     /**
-     * @param c Cache projection.
+     * @param a Cache affinity.
      */
-    private void affinityAfterStart(GridCache<Integer, String> c) {
+    private void affinityAfterStart(IgniteCacheAffinity<Integer> a) {
         if (DEBUG) {
             for (int key = 0; key < keyCnt; key++) {
-                int part = affinity(c).partition(key);
+                int part = a.partition(key);
 
                 info("Affinity odes after start [key=" + key + ", partition" + part + ", nodes=" +
-                    U.nodeIds(c.affinity().mapPartitionToPrimaryAndBackups(part)) + ']');
+                    U.nodeIds(a.mapPartitionToPrimaryAndBackups(part)) + ']');
             }
         }
     }
@@ -250,6 +250,7 @@ public abstract class GridCachePreloadRestartAbstractSelfTest extends GridCommon
 
         try {
             GridCache<Integer, String> c = grid(idx).cache(CACHE_NAME);
+            IgniteCacheAffinity<Integer> aff = grid(idx).affinity(CACHE_NAME);
 
             for (int j = 0; j < retries; j++) {
                 for (int i = 0; i < keyCnt; i++)
@@ -261,7 +262,7 @@ public abstract class GridCachePreloadRestartAbstractSelfTest extends GridCommon
 
                 info("Stopping node: " + idx);
 
-                affinityBeforeStop(c);
+                affinityBeforeStop(aff);
 
                 stopGrid(idx);
 
@@ -271,7 +272,7 @@ public abstract class GridCachePreloadRestartAbstractSelfTest extends GridCommon
 
                 c = ignite.cache(CACHE_NAME);
 
-                affinityAfterStart(c);
+                affinityAfterStart(aff);
 
                 checkGet(c, j);
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheTransformEventSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheTransformEventSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheTransformEventSelfTest.java
index c02930a..a03fd25 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheTransformEventSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/GridCacheTransformEventSelfTest.java
@@ -27,7 +27,6 @@ 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.gridgain.grid.cache.affinity.*;
 import org.gridgain.grid.util.typedef.*;
 import org.gridgain.testframework.junits.common.*;
 
@@ -242,7 +241,7 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
      * @return {@code True} if grid is primary for given key.
      */
     private boolean primary(int gridIdx, Object key) {
-        GridCacheAffinity<Object> aff = grid(0).cache(CACHE_NAME).affinity();
+        IgniteCacheAffinity<Object> aff = grid(0).affinity(CACHE_NAME);
 
         return aff.isPrimary(grid(gridIdx).cluster().localNode(), key);
     }
@@ -253,7 +252,7 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
      * @return {@code True} if grid is primary for given key.
      */
     private boolean backup(int gridIdx, Object key) {
-        GridCacheAffinity<Object> aff = grid(0).cache(CACHE_NAME).affinity();
+        IgniteCacheAffinity<Object> aff = grid(0).affinity(CACHE_NAME);
 
         return aff.isBackup(grid(gridIdx).cluster().localNode(), key);
     }
@@ -541,7 +540,7 @@ public class GridCacheTransformEventSelfTest extends GridCommonAbstractTest {
         else if (cacheMode == REPLICATED) {
             for (int key : keys) {
                 if (primaryOnly)
-                    res.add(grid(0).cache(CACHE_NAME).affinity().mapKeyToNode(key).id());
+                    res.add(grid(0).affinity(CACHE_NAME).mapKeyToNode(key).id());
                 else
                     res.addAll(Arrays.asList(ids));
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxConsistencyRestartAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxConsistencyRestartAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxConsistencyRestartAbstractSelfTest.java
index ae7b504..d6ab1a5 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxConsistencyRestartAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxConsistencyRestartAbstractSelfTest.java
@@ -185,7 +185,7 @@ public abstract class IgniteTxConsistencyRestartAbstractSelfTest extends GridCom
 
                 GridCache<Integer, Integer> cache = grid.cache(null);
 
-                if (cache.affinity().isPrimaryOrBackup(grid.localNode(), k)) {
+                if (grid.affinity(cache.name()).isPrimaryOrBackup(grid.localNode(), k)) {
                     if (val == null) {
                         val = cache.peek(k);
 
@@ -193,7 +193,7 @@ public abstract class IgniteTxConsistencyRestartAbstractSelfTest extends GridCom
                     }
                     else
                         assertEquals("Failed to find value in cache [primary=" +
-                            cache.affinity().isPrimary(grid.localNode(), k) + ']',
+                                        grid.affinity(cache.name()).isPrimary(grid.localNode(), k) + ']',
                             val, cache.peek(k));
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
index 06a882b..1f7f690 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxOriginatingNodeFailureAbstractSelfTest.java
@@ -135,7 +135,7 @@ public abstract class IgniteTxOriginatingNodeFailureAbstractSelfTest extends Gri
         for (Integer key : keys) {
             Collection<ClusterNode> nodes = new ArrayList<>();
 
-            nodes.addAll(cache.affinity().mapKeyToPrimaryAndBackups(key));
+            nodes.addAll(grid(1).affinity(cache.name()).mapKeyToPrimaryAndBackups(key));
 
             nodes.remove(txNode);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/25609651/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
index be741a6..c990b29 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest.java
@@ -156,7 +156,7 @@ public abstract class IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest
         for (Integer key : keys) {
             Collection<ClusterNode> nodes = new ArrayList<>();
 
-            nodes.addAll(cache.affinity().mapKeyToPrimaryAndBackups(key));
+            nodes.addAll(grid(1).affinity(cache.name()).mapKeyToPrimaryAndBackups(key));
 
             nodes.remove(txNode);
 
@@ -312,7 +312,7 @@ public abstract class IgniteTxPessimisticOriginatingNodeFailureAbstractSelfTest
         for (Integer key : keys) {
             Collection<ClusterNode> nodes = new ArrayList<>();
 
-            nodes.addAll(cache.affinity().mapKeyToPrimaryAndBackups(key));
+            nodes.addAll(grid(0).affinity(null).mapKeyToPrimaryAndBackups(key));
 
             nodes.remove(primaryNode);
 

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/GridCacheAbstractTransformWriteThroughSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
index a06f7f6..fff60fc 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAbstractTransformWriteThroughSelfTest.java
@@ -311,15 +311,15 @@ public abstract class GridCacheAbstractTransformWriteThroughSelfTest extends Gri
             String key = String.valueOf(numKey);
 
             if (nodeType == NEAR_NODE) {
-                if (!cache(0).affinity().isPrimaryOrBackup(grid(0).localNode(), key))
+                if (!affinity(0).isPrimaryOrBackup(grid(0).localNode(), key))
                     keys.add(key);
             }
             else if (nodeType == PRIMARY_NODE) {
-                if (cache(0).affinity().isPrimary(grid(0).localNode(), key))
+                if (affinity(0).isPrimary(grid(0).localNode(), key))
                     keys.add(key);
             }
             else if (nodeType == BACKUP_NODE) {
-                if (cache(0).affinity().isBackup(grid(0).localNode(), key))
+                if (affinity(0).isBackup(grid(0).localNode(), key))
                     keys.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/dht/GridCacheAtomicNearCacheSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java
index 1ee86af..89d925e 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheAtomicNearCacheSelfTest.java
@@ -20,7 +20,6 @@ package org.gridgain.grid.kernal.processors.cache.distributed.dht;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 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.near.*;
@@ -163,7 +162,7 @@ public class GridCacheAtomicNearCacheSelfTest extends GridCommonAbstractTest {
 
         GridCache<Integer, Integer> cache0 = ignite0.cache(null);
 
-        GridCacheAffinity<Integer> aff = cache0.affinity();
+        IgniteCacheAffinity<Integer> aff = ignite0.affinity(cache0.name());
 
         UUID id0 = ignite0.cluster().localNode().id();
 
@@ -265,7 +264,7 @@ public class GridCacheAtomicNearCacheSelfTest extends GridCommonAbstractTest {
 
         IgniteCache<Integer, Integer> cache0 = ignite0.jcache(null);
 
-        GridCacheAffinity<Object> aff = cache(0).affinity();
+        IgniteCacheAffinity<Object> aff = affinity(0);
 
         UUID id0 = ignite0.cluster().localNode().id();
 
@@ -342,7 +341,7 @@ public class GridCacheAtomicNearCacheSelfTest extends GridCommonAbstractTest {
 
         IgniteCache<Integer, Integer> cache0 = ignite0.jcache(null);
 
-        GridCacheAffinity<Object> aff = ignite0.cache(null).affinity();
+        IgniteCacheAffinity<Object> aff = ignite0.affinity(null);
 
         UUID id0 = ignite0.cluster().localNode().id();
 
@@ -479,7 +478,7 @@ public class GridCacheAtomicNearCacheSelfTest extends GridCommonAbstractTest {
 
         GridCache<Integer, Integer> cache0 = ignite0.cache(null);
 
-        GridCacheAffinity<Integer> aff = cache0.affinity();
+        IgniteCacheAffinity<Integer> aff = ignite0.affinity(cache0.name());
 
         UUID id0 = ignite0.cluster().localNode().id();
 
@@ -602,7 +601,7 @@ public class GridCacheAtomicNearCacheSelfTest extends GridCommonAbstractTest {
 
         GridCache<Integer, Integer> cache0 = ignite0.cache(null);
 
-        GridCacheAffinity<Integer> aff = cache0.affinity();
+        IgniteCacheAffinity<Integer> aff = ignite0.affinity(cache0.name());
 
         UUID id0 = ignite0.cluster().localNode().id();
 
@@ -652,7 +651,7 @@ public class GridCacheAtomicNearCacheSelfTest extends GridCommonAbstractTest {
 
         GridCache<Integer, Integer> cache0 = ignite0.cache(null);
 
-        GridCacheAffinity<Integer> aff = cache0.affinity();
+        IgniteCacheAffinity<Integer> aff = ignite0.affinity(cache0.name());
 
         UUID id0 = ignite0.cluster().localNode().id();
 
@@ -711,7 +710,7 @@ public class GridCacheAtomicNearCacheSelfTest extends GridCommonAbstractTest {
 
         GridDhtCacheEntry<Integer, Integer> dhtEntry = (GridDhtCacheEntry<Integer, Integer>)dht.peekEx(key);
 
-        boolean expectDht = near.affinity().isPrimaryOrBackup(ignite.cluster().localNode(), key);
+        boolean expectDht = ignite.affinity(near.name()).isPrimaryOrBackup(ignite.cluster().localNode(), key);
 
         if (expectDht) {
             assertNotNull("No dht entry for: " + key + ", grid: " + ignite.name(), dhtEntry);
@@ -737,7 +736,7 @@ public class GridCacheAtomicNearCacheSelfTest extends GridCommonAbstractTest {
     private Integer key(Ignite ignite, int mode) {
         GridCache<Integer, Integer> cache = ignite.cache(null);
 
-        GridCacheAffinity<Integer> aff = cache.affinity();
+        IgniteCacheAffinity<Integer> aff = ignite.affinity(cache.name());
 
         Integer key = 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/dht/GridCacheColocatedDebugTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
index 6f81490..6245282 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheColocatedDebugTest.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.cache.store.*;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.*;
@@ -70,7 +70,7 @@ public class GridCacheColocatedDebugTest extends GridCommonAbstractTest {
 
         cacheCfg.setCacheMode(PARTITIONED);
         cacheCfg.setDistributionMode(PARTITIONED_ONLY);
-        cacheCfg.setAffinity(new GridCacheConsistentHashAffinityFunction(false, 30));
+        cacheCfg.setAffinity(new CacheConsistentHashAffinityFunction(false, 30));
         cacheCfg.setBackups(1);
         cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
         cacheCfg.setSwapEnabled(false);
@@ -949,7 +949,7 @@ public class GridCacheColocatedDebugTest extends GridCommonAbstractTest {
      */
     private static Integer forPrimary(Ignite g, int prev) {
         for (int i = prev + 1; i < 10000; i++) {
-            if (g.cache(null).affinity().mapKeyToNode(i).id().equals(g.cluster().localNode().id()))
+            if (g.affinity(null).mapKeyToNode(i).id().equals(g.cluster().localNode().id()))
                 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/dht/GridCacheDhtAtomicRemoveFailureTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtAtomicRemoveFailureTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtAtomicRemoveFailureTest.java
index cc6c8b8..5691d8a 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtAtomicRemoveFailureTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtAtomicRemoveFailureTest.java
@@ -18,7 +18,6 @@
 package org.gridgain.grid.kernal.processors.cache.distributed.dht;
 
 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.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/dht/GridCacheDhtEntrySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
index 19c643a..53bda88 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySelfTest.java
@@ -23,8 +23,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.*;
-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.distributed.near.*;
 import org.apache.ignite.spi.discovery.tcp.*;
@@ -62,7 +61,7 @@ public class GridCacheDhtEntrySelfTest extends GridCommonAbstractTest {
         GridCacheConfiguration cacheCfg = defaultCacheConfiguration();
 
         cacheCfg.setCacheMode(PARTITIONED);
-        cacheCfg.setAffinity(new GridCacheConsistentHashAffinityFunction(false, 10));
+        cacheCfg.setAffinity(new CacheConsistentHashAffinityFunction(false, 10));
         cacheCfg.setBackups(0);
         cacheCfg.setWriteSynchronizationMode(GridCacheWriteSynchronizationMode.FULL_SYNC);
         cacheCfg.setSwapEnabled(false);
@@ -291,7 +290,7 @@ public class GridCacheDhtEntrySelfTest extends GridCommonAbstractTest {
      * @return For the given key pair {primary node, some other node}.
      */
     private IgniteBiTuple<ClusterNode, ClusterNode> getNodes(Integer key) {
-        GridCacheAffinity<Integer> aff = grid(0).<Integer, Object>cache(null).affinity();
+        IgniteCacheAffinity<Integer> aff = grid(0).affinity(null);
 
         int part = aff.partition(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/dht/GridCacheDhtEntrySetSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySetSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySetSelfTest.java
index a59f499..4756458 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySetSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEntrySetSelfTest.java
@@ -18,7 +18,6 @@
 package org.gridgain.grid.kernal.processors.cache.distributed.dht;
 
 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.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/dht/GridCacheDhtEvictionNearReadersSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
index 86f99da..8b5d314 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEvictionNearReadersSelfTest.java
@@ -22,9 +22,8 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.lang.*;
-import org.gridgain.grid.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.gridgain.grid.cache.eviction.fifo.*;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.near.*;
@@ -165,19 +164,11 @@ public class GridCacheDhtEvictionNearReadersSelfTest extends GridCommonAbstractT
     }
 
     /**
-     * @param idx Index.
-     * @return Affinity.
-     */
-    private GridCacheConsistentHashAffinityFunction affinity(int idx) {
-        return (GridCacheConsistentHashAffinityFunction)grid(idx).cache(null).configuration().getAffinity();
-    }
-
-    /**
      * @param key Key.
      * @return Primary node for the given key.
      */
     private Collection<ClusterNode> keyNodes(Object key) {
-        GridCacheConsistentHashAffinityFunction aff = affinity(0);
+        CacheConsistentHashAffinityFunction aff = (CacheConsistentHashAffinityFunction)grid(0).cache(null).configuration().getAffinity();;
 
         return aff.nodes(aff.partition(key), grid(0).nodes(), 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/dht/GridCacheDhtEvictionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEvictionSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEvictionSelfTest.java
index 25e289c..7ab2f33 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEvictionSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEvictionSelfTest.java
@@ -22,9 +22,8 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.lang.*;
-import org.gridgain.grid.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.gridgain.grid.cache.eviction.fifo.*;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.near.*;
@@ -159,19 +158,11 @@ public class GridCacheDhtEvictionSelfTest extends GridCommonAbstractTest {
     }
 
     /**
-     * @param idx Index.
-     * @return Affinity.
-     */
-    private GridCacheConsistentHashAffinityFunction affinity(int idx) {
-        return (GridCacheConsistentHashAffinityFunction)grid(idx).cache(null).configuration().getAffinity();
-    }
-
-    /**
      * @param key Key.
      * @return Primary node for the given key.
      */
     private Collection<ClusterNode> keyNodes(Object key) {
-        GridCacheConsistentHashAffinityFunction aff = affinity(0);
+        CacheConsistentHashAffinityFunction aff =  (CacheConsistentHashAffinityFunction)grid(0).cache(null).configuration().getAffinity();
 
         return aff.nodes(aff.partition(key), grid(0).nodes(), 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/dht/GridCacheDhtEvictionsDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java
index 4e73318..6e084d6 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtEvictionsDisabledSelfTest.java
@@ -116,7 +116,7 @@ public class GridCacheDhtEvictionsDisabledSelfTest extends GridCommonAbstractTes
             assertNotNull(v1);
             assertNotNull(v2);
 
-            if (cache.affinity().mapKeyToNode(key).isLocal())
+            if (g.affinity(cache.name()).mapKeyToNode(key).isLocal())
                 assertSame(v1, v2);
             else
                 assertEquals(v1, v2);

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/GridCacheDhtInternalEntrySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java
index 47ecfa3..eba6dfc 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtInternalEntrySelfTest.java
@@ -21,10 +21,8 @@ import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.lang.*;
-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.consistenthash.*;
 import org.gridgain.grid.cache.datastructures.*;
 import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.kernal.processors.cache.datastructures.*;
@@ -68,7 +66,7 @@ public class GridCacheDhtInternalEntrySelfTest extends GridCommonAbstractTest {
 
         cacheCfg.setCacheMode(PARTITIONED);
         cacheCfg.setPreloadMode(SYNC);
-        cacheCfg.setAffinity(new GridCacheConsistentHashAffinityFunction(false, 2));
+        cacheCfg.setAffinity(new CacheConsistentHashAffinityFunction(false, 2));
         cacheCfg.setBackups(0);
         cacheCfg.setWriteSynchronizationMode(GridCacheWriteSynchronizationMode.FULL_SYNC);
         cacheCfg.setDistributionMode(GridCacheDistributionMode.NEAR_PARTITIONED);
@@ -197,7 +195,7 @@ public class GridCacheDhtInternalEntrySelfTest extends GridCommonAbstractTest {
      * @return Pair {primary node, some other node}.
      */
     private IgniteBiTuple<ClusterNode, ClusterNode> getNodes(String key) {
-        GridCacheAffinity<Object> aff = grid(0).cache(null).affinity();
+        IgniteCacheAffinity<Object> aff = grid(0).affinity(null);
 
         ClusterNode primary = aff.mapKeyToNode(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/dht/GridCacheDhtPreloadBigDataSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java
index cd6b5d4..ed1b1b9 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadBigDataSelfTest.java
@@ -21,9 +21,8 @@ import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.lifecycle.*;
 import org.apache.ignite.resources.*;
-import org.gridgain.grid.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+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.*;
@@ -86,7 +85,7 @@ public class GridCacheDhtPreloadBigDataSelfTest extends GridCommonAbstractTest {
         cc.setPreloadBatchSize(preloadBatchSize);
         cc.setWriteSynchronizationMode(FULL_SYNC);
         cc.setPreloadMode(preloadMode);
-        cc.setAffinity(new GridCacheConsistentHashAffinityFunction(false, partitions));
+        cc.setAffinity(new CacheConsistentHashAffinityFunction(false, partitions));
         cc.setBackups(backups);
 
         TcpDiscoverySpi disco = new TcpDiscoverySpi();

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/GridCacheDhtPreloadDelayedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
index 53ca0b7..90b0592 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadDelayedSelfTest.java
@@ -24,8 +24,7 @@ import org.apache.ignite.events.*;
 import org.apache.ignite.lang.*;
 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.consistenthash.*;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.dht.preloader.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.near.*;
@@ -79,7 +78,7 @@ public class GridCacheDhtPreloadDelayedSelfTest extends GridCommonAbstractTest {
         cc.setWriteSynchronizationMode(GridCacheWriteSynchronizationMode.FULL_SYNC);
         cc.setPreloadMode(preloadMode);
         cc.setPreloadPartitionedDelay(delay);
-        cc.setAffinity(new GridCacheConsistentHashAffinityFunction(false, 128));
+        cc.setAffinity(new CacheConsistentHashAffinityFunction(false, 128));
         cc.setBackups(1);
         cc.setAtomicityMode(TRANSACTIONAL);
         cc.setDistributionMode(NEAR_PARTITIONED);
@@ -377,8 +376,8 @@ public class GridCacheDhtPreloadDelayedSelfTest extends GridCommonAbstractTest {
      * @param g Grid.
      * @return Affinity.
      */
-    private GridCacheAffinity<Object> affinity(Ignite g) {
-        return g.cache(null).affinity();
+    private IgniteCacheAffinity<Object> affinity(Ignite g) {
+        return g.affinity(null);
     }
 
     /**
@@ -402,7 +401,7 @@ public class GridCacheDhtPreloadDelayedSelfTest extends GridCommonAbstractTest {
         for (int i = 0; i < keyCnt; i++) {
             String key = Integer.toString(i);
 
-            if (c.affinity().isPrimaryOrBackup(g.cluster().localNode(), key))
+            if (g.affinity(c.name()).isPrimaryOrBackup(g.cluster().localNode(), key))
                 assertEquals(Integer.valueOf(i), c.peek(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/dht/GridCacheDhtPreloadDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
index 921bbf1..9d8b82b 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadDisabledSelfTest.java
@@ -22,9 +22,8 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.lang.*;
-import org.gridgain.grid.*;
 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.dht.preloader.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
@@ -83,7 +82,7 @@ public class GridCacheDhtPreloadDisabledSelfTest extends GridCommonAbstractTest
         cacheCfg.setCacheMode(PARTITIONED);
         cacheCfg.setWriteSynchronizationMode(GridCacheWriteSynchronizationMode.FULL_ASYNC);
         cacheCfg.setPreloadMode(NONE);
-        cacheCfg.setAffinity(new GridCacheConsistentHashAffinityFunction(false, partitions));
+        cacheCfg.setAffinity(new CacheConsistentHashAffinityFunction(false, partitions));
         cacheCfg.setBackups(backups);
         cacheCfg.setAtomicityMode(TRANSACTIONAL);
         cacheCfg.setDistributionMode(NEAR_PARTITIONED);
@@ -203,7 +202,7 @@ public class GridCacheDhtPreloadDisabledSelfTest extends GridCommonAbstractTest
             Collection<Integer> keys = new LinkedList<>();
 
             for (int i = 0; i < keyCnt; i++)
-                if (cache1.affinity().mapKeyToNode(i).equals(ignite1.cluster().localNode()))
+                if (ignite1.affinity(cache1.name()).mapKeyToNode(i).equals(ignite1.cluster().localNode()))
                     keys.add(i);
 
             info(">>> Finished checking nodes [keyCnt=" + keyCnt + ", nodeCnt=" + nodeCnt + ", grids=" +

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/GridCacheDhtPreloadMessageCountTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java
index a174271..7b8af3e 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadMessageCountTest.java
@@ -22,7 +22,7 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.spi.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+import org.apache.ignite.cache.affinity.consistenthash.*;
 import org.gridgain.grid.kernal.managers.communication.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.dht.preloader.*;
 import org.apache.ignite.spi.communication.tcp.*;
@@ -67,7 +67,7 @@ public class GridCacheDhtPreloadMessageCountTest extends GridCommonAbstractTest
         cc.setCacheMode(PARTITIONED);
         cc.setWriteSynchronizationMode(FULL_SYNC);
         cc.setPreloadMode(preloadMode);
-        cc.setAffinity(new GridCacheConsistentHashAffinityFunction(false, 521));
+        cc.setAffinity(new CacheConsistentHashAffinityFunction(false, 521));
         cc.setBackups(1);
 
         TcpDiscoverySpi disco = new TcpDiscoverySpi();
@@ -132,7 +132,7 @@ public class GridCacheDhtPreloadMessageCountTest extends GridCommonAbstractTest
         for (int i = 0; i < keyCnt; i++) {
             String key = Integer.toString(i);
 
-            if (c.affinity().isPrimaryOrBackup(g.cluster().localNode(), key))
+            if (g.affinity(c.name()).isPrimaryOrBackup(g.cluster().localNode(), key))
                 assertEquals(Integer.valueOf(i), c.peek(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/dht/GridCacheDhtPreloadMultiThreadedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadMultiThreadedSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadMultiThreadedSelfTest.java
index db07bab..8a99524 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadMultiThreadedSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadMultiThreadedSelfTest.java
@@ -22,7 +22,7 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.lang.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+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.*;
@@ -163,7 +163,7 @@ public class GridCacheDhtPreloadMultiThreadedSelfTest extends GridCommonAbstract
 
         for (GridCacheConfiguration cCfg : cfg.getCacheConfiguration()) {
             if (cCfg.getCacheMode() == GridCacheMode.PARTITIONED) {
-                cCfg.setAffinity(new GridCacheConsistentHashAffinityFunction(2048, null));
+                cCfg.setAffinity(new CacheConsistentHashAffinityFunction(2048, null));
                 cCfg.setBackups(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/dht/GridCacheDhtPreloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java
index 196e4b9..b99b8f9 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadSelfTest.java
@@ -22,10 +22,8 @@ import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.lang.*;
-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.consistenthash.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.dht.preloader.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
@@ -113,7 +111,7 @@ public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest {
         cacheCfg.setPreloadBatchSize(preloadBatchSize);
         cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
         cacheCfg.setPreloadMode(preloadMode);
-        cacheCfg.setAffinity(new GridCacheConsistentHashAffinityFunction(false, partitions));
+        cacheCfg.setAffinity(new CacheConsistentHashAffinityFunction(false, partitions));
         cacheCfg.setBackups(backups);
 
         return cacheCfg;
@@ -142,12 +140,13 @@ public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @param ignite Ignite.
      * @param cache Cache.
      * @return Affinity.
      */
     @SuppressWarnings({"unchecked"})
-    private GridCacheAffinity<Integer> affinity(GridCache<Integer, ?> cache) {
-        return cache.affinity();
+    private IgniteCacheAffinity<Integer> affinity(Ignite ignite, GridCache<Integer, ?> cache) {
+        return ignite.affinity(cache.name());
     }
 
     /**
@@ -227,7 +226,7 @@ public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest {
             GridCache<Integer, String> cache1 = ignite1.cache(null);
 
             putKeys(cache1, keyCnt);
-            checkKeys(cache1, keyCnt, F.asList(ignite1));
+            checkKeys(ignite1, cache1, keyCnt, F.asList(ignite1));
 
             List<Ignite> ignites = new ArrayList<>(nodeCnt + 1);
 
@@ -237,7 +236,7 @@ public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest {
             for (Ignite g : ignites) {
                 GridCache<Integer, String> c = g.cache(null);
 
-                checkKeys(c, keyCnt, ignites);
+                checkKeys(g, c, keyCnt, ignites);
             }
 
             if (shuffle)
@@ -310,7 +309,7 @@ public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest {
 
             GridDhtCacheAdapter<Integer, String> dht = dht(lastCache);
 
-            GridCacheAffinity<Integer> aff = affinity(lastCache);
+            IgniteCacheAffinity<Integer> aff = affinity(last, lastCache);
 
             info("Finished waiting for all exchange futures...");
 
@@ -493,7 +492,7 @@ public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest {
             GridCache<Integer, String> cache1 = ignite1.cache(null);
 
             putKeys(cache1, keyCnt);
-            checkKeys(cache1, keyCnt, F.asList(ignite1));
+            checkKeys(ignite1, cache1, keyCnt, F.asList(ignite1));
 
             List<Ignite> ignites = new ArrayList<>(nodeCnt + 1);
 
@@ -503,7 +502,7 @@ public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest {
             for (Ignite g : ignites) {
                 GridCache<Integer, String> c = g.cache(null);
 
-                checkKeys(c, keyCnt, ignites);
+                checkKeys(g, c, keyCnt, ignites);
             }
 
             if (shuffle)
@@ -566,7 +565,7 @@ public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest {
                 for (Ignite gg : ignites) {
                     GridCache<Integer, String> c = gg.cache(null);
 
-                    checkKeys(c, keyCnt, ignites);
+                    checkKeys(gg, c, keyCnt, ignites);
                 }
             }
 
@@ -576,7 +575,7 @@ public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest {
 
             GridDhtCacheAdapter<Integer, String> dht = dht(lastCache);
 
-            GridCacheAffinity<Integer> aff = affinity(lastCache);
+            IgniteCacheAffinity<Integer> aff = affinity(last, lastCache);
 
             for (int i = 0; i < keyCnt; i++) {
                 if (aff.mapPartitionToPrimaryAndBackups(aff.partition(i)).contains(last.cluster().localNode())) {
@@ -614,15 +613,14 @@ public class GridCacheDhtPreloadSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @param ignite Ignite.
      * @param cache Cache.
      * @param cnt Key count.
      * @param grids Grids.
      * @throws IgniteCheckedException If failed.
      */
-    private void checkKeys(GridCache<Integer, String> cache, int cnt, Iterable<Ignite> grids) throws IgniteCheckedException {
-        GridCacheAffinity<Integer> aff = affinity(cache);
-
-        Ignite ignite = cache.gridProjection().ignite();
+    private void checkKeys(Ignite ignite, GridCache<Integer, String> cache, int cnt, Iterable<Ignite> grids) throws IgniteCheckedException {
+        IgniteCacheAffinity<Integer> aff = affinity(ignite, cache);
 
         ClusterNode loc = ignite.cluster().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/dht/GridCacheDhtPreloadStartStopSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java
index 9d21843..74c0dd5 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadStartStopSelfTest.java
@@ -20,10 +20,8 @@ package org.gridgain.grid.kernal.processors.cache.distributed.dht;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.lang.*;
-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.consistenthash.*;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.dht.preloader.*;
@@ -100,7 +98,7 @@ public class GridCacheDhtPreloadStartStopSelfTest extends GridCommonAbstractTest
             cacheCfg.setPreloadBatchSize(preloadBatchSize);
             cacheCfg.setWriteSynchronizationMode(GridCacheWriteSynchronizationMode.FULL_SYNC);
             cacheCfg.setPreloadMode(preloadMode);
-            cacheCfg.setAffinity(new GridCacheConsistentHashAffinityFunction(false, partitions));
+            cacheCfg.setAffinity(new CacheConsistentHashAffinityFunction(false, partitions));
             cacheCfg.setBackups(backups);
             cacheCfg.setAtomicityMode(TRANSACTIONAL);
 
@@ -136,8 +134,8 @@ public class GridCacheDhtPreloadStartStopSelfTest extends GridCommonAbstractTest
      * @param cache Cache.
      * @return Affinity.
      */
-    private GridCacheAffinity<Integer> affinity(GridCache<Integer, ?> cache) {
-        return cache.affinity();
+    private IgniteCacheAffinity<Integer> affinity(GridCache<Integer, ?> cache) {
+        return cache.gridProjection().ignite().affinity(cache.name());
     }
 
     /**
@@ -220,7 +218,7 @@ public class GridCacheDhtPreloadStartStopSelfTest extends GridCommonAbstractTest
             for (IgniteFuture<?> fut : exchMgr.exchangeFutures())
                 fut.get();
 
-            GridCacheAffinity<Integer> aff = affinity(c1);
+            IgniteCacheAffinity<Integer> aff = affinity(c1);
 
             for (int i = 0; i < keyCnt; i++) {
                 if (aff.mapPartitionToPrimaryAndBackups(aff.partition(i)).contains(g1.cluster().localNode())) {
@@ -252,7 +250,7 @@ public class GridCacheDhtPreloadStartStopSelfTest extends GridCommonAbstractTest
      * @throws IgniteCheckedException If failed.
      */
     private void checkKeys(GridCache<Integer, String> c, int cnt) throws IgniteCheckedException {
-        GridCacheAffinity<Integer> aff = affinity(c);
+        IgniteCacheAffinity<Integer> aff = affinity(c);
 
         boolean sync = isSync(c);
 

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/GridCacheDhtPreloadUnloadSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadUnloadSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadUnloadSelfTest.java
index 8c617f6..b5133e9 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadUnloadSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtPreloadUnloadSelfTest.java
@@ -21,9 +21,8 @@ import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.lifecycle.*;
 import org.apache.ignite.resources.*;
-import org.gridgain.grid.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+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.*;
@@ -87,7 +86,7 @@ public class GridCacheDhtPreloadUnloadSelfTest extends GridCommonAbstractTest {
         cc.setPreloadBatchSize(preloadBatchSize);
         cc.setWriteSynchronizationMode(GridCacheWriteSynchronizationMode.FULL_SYNC);
         cc.setPreloadMode(preloadMode);
-        cc.setAffinity(new GridCacheConsistentHashAffinityFunction(false, partitions));
+        cc.setAffinity(new CacheConsistentHashAffinityFunction(false, partitions));
         cc.setBackups(backups);
         cc.setAtomicityMode(TRANSACTIONAL);
 

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/GridCacheDhtTestUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java
index f570443..c24e0a5 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheDhtTestUtils.java
@@ -19,10 +19,9 @@ package org.gridgain.grid.kernal.processors.cache.distributed.dht;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
-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.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.dht.preloader.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.near.*;
@@ -60,7 +59,7 @@ public class GridCacheDhtTestUtils {
      */
     @SuppressWarnings({"UnusedAssignment", "unchecked"})
     static void prepareKeys(GridDhtCache<Integer, String> dht, int keyCnt) throws IgniteCheckedException {
-        GridCacheAffinityFunction aff = dht.context().config().getAffinity();
+        CacheAffinityFunction aff = dht.context().config().getAffinity();
 
         GridCacheConcurrentMap<Integer, String> cacheMap;
 
@@ -94,8 +93,8 @@ public class GridCacheDhtTestUtils {
      * @param cache Dht cache.
      */
     static void printAffinityInfo(GridCache<?, ?> cache) {
-        GridCacheConsistentHashAffinityFunction aff =
-            (GridCacheConsistentHashAffinityFunction)cache.configuration().getAffinity();
+        CacheConsistentHashAffinityFunction aff =
+            (CacheConsistentHashAffinityFunction)cache.configuration().getAffinity();
 
         System.out.println("Affinity info.");
         System.out.println("----------------------------------");
@@ -108,10 +107,9 @@ public class GridCacheDhtTestUtils {
      * @param idx Cache index
      */
     static void printDhtTopology(GridDhtCache<Integer, String> dht, int idx) {
-        final GridCacheAffinity<Integer> aff = dht.affinity();
-
         Ignite ignite = dht.context().grid();
         ClusterNode locNode = ignite.cluster().localNode();
+        final IgniteCacheAffinity<Integer> aff = ignite.affinity(dht.name());
 
         GridDhtPartitionTopology<Integer, String> top = dht.topology();
 
@@ -178,10 +176,9 @@ public class GridCacheDhtTestUtils {
 
         log.info("Checking balanced state of cache #" + idx);
 
-        GridCacheAffinity<Integer> aff = dht.affinity();
-
         Ignite ignite = dht.context().grid();
         ClusterNode locNode = ignite.cluster().localNode();
+        IgniteCacheAffinity<Integer> aff = ignite.affinity(dht.name());
 
         GridDhtPartitionTopology<Integer,String> top = dht.topology();
 

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/GridCacheGroupLockPartitionedAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedAbstractSelfTest.java
index a974e30..9a71a33 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedAbstractSelfTest.java
@@ -20,7 +20,7 @@ package org.gridgain.grid.kernal.processors.cache.distributed.dht;
 import org.apache.ignite.*;
 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.processors.cache.*;
 import org.gridgain.testframework.*;
 
@@ -74,20 +74,20 @@ public abstract class GridCacheGroupLockPartitionedAbstractSelfTest extends Grid
     private void checkUpdateEntry(IgniteTxConcurrency concurrency, IgniteTxIsolation isolation) throws Exception {
         UUID affinityKey = primaryKeyForCache(grid(0));
 
-        GridCache<GridCacheAffinityKey<Integer>, Integer> cache = cache(0);
+        GridCache<CacheAffinityKey<Integer>, Integer> cache = cache(0);
 
         assert cache.isEmpty();
 
         // Put initial values.
         for (int i = 0; i < 10; i++)
-            cache.put(new GridCacheAffinityKey<>(i, affinityKey), i);
+            cache.put(new CacheAffinityKey<>(i, affinityKey), i);
 
         for (int i = 0; i < 3; i++) {
             try (IgniteTx tx = cache.txStartAffinity(affinityKey, concurrency, isolation, 0, 10)) {
-                Set<GridCacheEntry<GridCacheAffinityKey<Integer>, Integer>> set =
-                    cache.entrySet(cache(0).affinity().partition(affinityKey));
+                Set<GridCacheEntry<CacheAffinityKey<Integer>, Integer>> set =
+                    cache.entrySet(affinity(0).partition(affinityKey));
 
-                for (GridCacheEntry<GridCacheAffinityKey<Integer>, Integer> entry : set) {
+                for (GridCacheEntry<CacheAffinityKey<Integer>, Integer> entry : set) {
                     Integer old = entry.get();
 
                     if (old != null)
@@ -114,7 +114,7 @@ public abstract class GridCacheGroupLockPartitionedAbstractSelfTest extends Grid
 
         final GridCache<UUID, String> cache = grid(0).cache(null);
 
-        try (IgniteTx tx = cache.txStartPartition(cache.affinity().partition(affinityKey), PESSIMISTIC, REPEATABLE_READ,
+        try (IgniteTx tx = cache.txStartPartition(grid(0).affinity(null).partition(affinityKey), PESSIMISTIC, REPEATABLE_READ,
             0, 2)) {
             GridTestUtils.assertThrows(log, new Callable<Object>() {
                 @Override public Object call() throws Exception {
@@ -123,7 +123,7 @@ public abstract class GridCacheGroupLockPartitionedAbstractSelfTest extends Grid
                     do {
                         key1 = UUID.randomUUID();
                     }
-                    while (cache.affinity().partition(key1) == cache.affinity().partition(affinityKey));
+                    while (grid(0).affinity(null).partition(key1) == grid(0).affinity(null).partition(affinityKey));
 
                     // Key with affinity key different from enlisted on tx start should raise exception.
                     cache.put(key1, "val1");

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/GridCacheGroupLockPartitionedMultiNodeAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedMultiNodeAbstractSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedMultiNodeAbstractSelfTest.java
index 6074966..a1b265d 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedMultiNodeAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCacheGroupLockPartitionedMultiNodeAbstractSelfTest.java
@@ -20,7 +20,7 @@ package org.gridgain.grid.kernal.processors.cache.distributed.dht;
 import org.apache.ignite.*;
 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.util.typedef.*;
 
 import java.util.*;
@@ -64,7 +64,7 @@ public abstract class GridCacheGroupLockPartitionedMultiNodeAbstractSelfTest ext
         try {
             tx = cache.txStartAffinity(key, concurrency, READ_COMMITTED, 0, 2);
 
-            cache.put(new GridCacheAffinityKey<>("1", key), "2");
+            cache.put(new CacheAffinityKey<>("1", key), "2");
 
             tx.commit();
 
@@ -115,13 +115,13 @@ public abstract class GridCacheGroupLockPartitionedMultiNodeAbstractSelfTest ext
     private void checkNearReadersUpdate(boolean touchAffKey, IgniteTxConcurrency concurrency) throws Exception {
         UUID affinityKey = primaryKeyForCache(grid(0));
 
-        GridCacheAffinityKey<String> key1 = new GridCacheAffinityKey<>("key1", affinityKey);
-        GridCacheAffinityKey<String> key2 = new GridCacheAffinityKey<>("key2", affinityKey);
-        GridCacheAffinityKey<String> key3 = new GridCacheAffinityKey<>("key3", affinityKey);
+        CacheAffinityKey<String> key1 = new CacheAffinityKey<>("key1", affinityKey);
+        CacheAffinityKey<String> key2 = new CacheAffinityKey<>("key2", affinityKey);
+        CacheAffinityKey<String> key3 = new CacheAffinityKey<>("key3", affinityKey);
 
         grid(0).cache(null).put(affinityKey, "aff");
 
-        GridCache<GridCacheAffinityKey<String>, String> cache = grid(0).cache(null);
+        GridCache<CacheAffinityKey<String>, String> cache = grid(0).cache(null);
 
         cache.putAll(F.asMap(
             key1, "val1",
@@ -132,7 +132,7 @@ public abstract class GridCacheGroupLockPartitionedMultiNodeAbstractSelfTest ext
         Ignite reader = null;
 
         for (int i = 0; i < gridCount(); i++) {
-            if (!grid(i).cache(null).affinity().isPrimaryOrBackup(grid(i).localNode(), affinityKey))
+            if (!grid(i).affinity(null).isPrimaryOrBackup(grid(i).localNode(), affinityKey))
                 reader = grid(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/dht/GridCachePartitionedPreloadEventsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedPreloadEventsSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedPreloadEventsSelfTest.java
index fcf0b66..fd75909 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedPreloadEventsSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedPreloadEventsSelfTest.java
@@ -21,7 +21,7 @@ import org.apache.ignite.*;
 import org.apache.ignite.cluster.*;
 import org.apache.ignite.events.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
+import org.apache.ignite.cache.affinity.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.dht.preloader.*;
 import org.gridgain.grid.util.typedef.*;
@@ -48,7 +48,7 @@ public class GridCachePartitionedPreloadEventsSelfTest extends GridCachePreloadE
 
         if (replicatedAffinity)
             // replicate entries to all nodes
-            cacheCfg.setAffinity(new GridCacheAffinityFunction() {
+            cacheCfg.setAffinity(new CacheAffinityFunction() {
                 /** {@inheritDoc} */
                 @Override public void reset() {
                 }
@@ -64,7 +64,7 @@ public class GridCachePartitionedPreloadEventsSelfTest extends GridCachePreloadE
                 }
 
                 /** {@inheritDoc} */
-                @Override public List<List<ClusterNode>> assignPartitions(GridCacheAffinityFunctionContext affCtx) {
+                @Override public List<List<ClusterNode>> assignPartitions(CacheAffinityFunctionContext affCtx) {
                     List<ClusterNode> nodes = new ArrayList<>(affCtx.currentTopologySnapshot());
 
                     return Collections.singletonList(nodes);
@@ -108,7 +108,7 @@ public class GridCachePartitionedPreloadEventsSelfTest extends GridCachePreloadE
 
         Ignite g2 = startGrid("g2");
 
-        Map<ClusterNode, Collection<Object>> keysMap = g1.cache(null).affinity().mapKeysToNodes(keys);
+        Map<ClusterNode, Collection<Object>> keysMap = g1.affinity(null).mapKeysToNodes(keys);
         Collection<Object> g2Keys = keysMap.get(g2.cluster().localNode());
 
         assertNotNull(g2Keys);

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/GridCachePartitionedTopologyChangeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedTopologyChangeSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedTopologyChangeSelfTest.java
index 92acdd8..298f746 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedTopologyChangeSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedTopologyChangeSelfTest.java
@@ -24,8 +24,7 @@ import org.apache.ignite.events.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.transactions.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.*;
-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.*;
@@ -74,7 +73,7 @@ public class GridCachePartitionedTopologyChangeSelfTest extends GridCommonAbstra
         GridCacheConfiguration cc = defaultCacheConfiguration();
 
         cc.setCacheMode(PARTITIONED);
-        cc.setAffinity(new GridCacheConsistentHashAffinityFunction(false, 18));
+        cc.setAffinity(new CacheConsistentHashAffinityFunction(false, 18));
         cc.setBackups(1);
         cc.setPreloadMode(SYNC);
         cc.setDistributionMode(PARTITIONED_ONLY);
@@ -492,7 +491,7 @@ public class GridCachePartitionedTopologyChangeSelfTest extends GridCommonAbstra
                 txFut.get(1000);
 
             for (int i = 0; i < 3; i++) {
-                GridCacheConsistentHashAffinityFunction affinity = (GridCacheConsistentHashAffinityFunction)((GridKernal)grid(i))
+                CacheConsistentHashAffinityFunction affinity = (CacheConsistentHashAffinityFunction)((GridKernal)grid(i))
                     .internalCache().context().config().getAffinity();
 
                 ConcurrentMap addedNodes = U.field(affinity, "addedNodes");
@@ -559,7 +558,7 @@ public class GridCachePartitionedTopologyChangeSelfTest extends GridCommonAbstra
     private List<Integer> partitions(Ignite node, int partType) {
         List<Integer> res = new LinkedList<>();
 
-        GridCacheAffinity<Object> aff = node.cache(null).affinity();
+        IgniteCacheAffinity<Object> aff = node.affinity(null);
 
         for (int partCnt = aff.partitions(), i = 0; i < partCnt; i++) {
             ClusterNode locNode = node.cluster().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/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java
index 4950b1f..7b2a70c 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedTxOriginatingNodeFailureSelfTest.java
@@ -19,6 +19,7 @@ package org.gridgain.grid.kernal.processors.cache.distributed.dht;
 
 import org.apache.ignite.cluster.*;
 import org.gridgain.grid.cache.*;
+import org.apache.ignite.IgniteCacheAffinity;
 import org.gridgain.grid.kernal.*;
 import org.gridgain.grid.kernal.processors.cache.*;
 import org.gridgain.grid.kernal.processors.cache.distributed.*;
@@ -63,13 +64,14 @@ public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends
      */
     public void testTxFromPrimary() throws Exception {
         GridCacheAdapter<Integer, String> cache = ((GridKernal)grid(originatingNode())).internalCache();
+        IgniteCacheAffinity<Integer> aff = grid(originatingNode()).affinity(cache.name());
 
         ClusterNode txNode = grid(originatingNode()).localNode();
 
         Integer key = null;
 
         for (int i = 0; i < Integer.MAX_VALUE; i++) {
-            if (cache.affinity().isPrimary(txNode, i)) {
+            if (aff.isPrimary(txNode, i)) {
                 key = i;
 
                 break;
@@ -86,13 +88,14 @@ public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends
      */
     public void testTxFromBackup() throws Exception {
         GridCacheAdapter<Integer, String> cache = ((GridKernal)grid(originatingNode())).internalCache();
+        IgniteCacheAffinity<Integer> aff = grid(originatingNode()).affinity(cache.name());
 
         ClusterNode txNode = grid(originatingNode()).localNode();
 
         Integer key = null;
 
         for (int i = 0; i < Integer.MAX_VALUE; i++) {
-            if (cache.affinity().isBackup(txNode, i)) {
+            if (aff.isBackup(txNode, i)) {
                 key = i;
 
                 break;
@@ -109,13 +112,14 @@ public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends
      */
     public void testTxFromNotColocated() throws Exception {
         GridCacheAdapter<Integer, String> cache = ((GridKernal)grid(originatingNode())).internalCache();
+        IgniteCacheAffinity<Integer> aff = grid(originatingNode()).affinity(cache.name());
 
         ClusterNode txNode = grid(originatingNode()).localNode();
 
         Integer key = null;
 
         for (int i = 0; i < Integer.MAX_VALUE; i++) {
-            if (!cache.affinity().isPrimary(txNode, i) && !cache.affinity().isBackup(txNode, i)) {
+            if (!aff.isPrimary(txNode, i) && !aff.isBackup(txNode, i)) {
                 key = i;
 
                 break;
@@ -132,6 +136,7 @@ public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends
      */
     public void testTxAllNodes() throws Exception {
         GridCacheAdapter<Integer, String> cache = ((GridKernal)grid(originatingNode())).internalCache();
+        IgniteCacheAffinity<Integer> aff = grid(originatingNode()).affinity(cache.name());
 
         List<ClusterNode> allNodes = new ArrayList<>(GRID_CNT);
 
@@ -144,7 +149,7 @@ public class GridCachePartitionedTxOriginatingNodeFailureSelfTest extends
             for (Iterator<ClusterNode> iter = allNodes.iterator(); iter.hasNext();) {
                 ClusterNode node = iter.next();
 
-                if (cache.affinity().isPrimary(node, i)) {
+                if (aff.isPrimary(node, i)) {
                     keys.add(i);
 
                     iter.remove();

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/GridCachePartitionedUnloadEventsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java
index 34139d1..a6a553f 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/GridCachePartitionedUnloadEventsSelfTest.java
@@ -23,7 +23,7 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.events.*;
 import org.apache.ignite.lang.*;
 import org.gridgain.grid.cache.*;
-import org.gridgain.grid.cache.affinity.consistenthash.*;
+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.*;
@@ -62,7 +62,7 @@ public class GridCachePartitionedUnloadEventsSelfTest extends GridCommonAbstract
         GridCacheConfiguration cacheCfg = defaultCacheConfiguration();
         cacheCfg.setCacheMode(PARTITIONED);
         cacheCfg.setPreloadMode(SYNC);
-        cacheCfg.setAffinity(new GridCacheConsistentHashAffinityFunction(false, 10));
+        cacheCfg.setAffinity(new CacheConsistentHashAffinityFunction(false, 10));
         cacheCfg.setBackups(0);
         return cacheCfg;
     }
@@ -84,7 +84,7 @@ public class GridCachePartitionedUnloadEventsSelfTest extends GridCommonAbstract
 
         Ignite g2 = startGrid("g2");
 
-        Map<ClusterNode, Collection<Object>> keysMap = g1.cache(null).affinity().mapKeysToNodes(allKeys);
+        Map<ClusterNode, Collection<Object>> keysMap = g1.affinity(null).mapKeysToNodes(allKeys);
         Collection<Object> g2Keys = keysMap.get(g2.cluster().localNode());
 
         assertNotNull(g2Keys);

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/IgniteTxReentryColocatedSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/IgniteTxReentryColocatedSelfTest.java b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/IgniteTxReentryColocatedSelfTest.java
index 89cffb6..ff78529 100644
--- a/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/IgniteTxReentryColocatedSelfTest.java
+++ b/modules/core/src/test/java/org/gridgain/grid/kernal/processors/cache/distributed/dht/IgniteTxReentryColocatedSelfTest.java
@@ -46,7 +46,7 @@ public class IgniteTxReentryColocatedSelfTest extends IgniteTxReentryAbstractSel
         GridCache<Object, Object> cache = grid(0).cache(null);
 
         while (true) {
-            Collection<ClusterNode> nodes = cache.affinity().mapKeyToPrimaryAndBackups(key);
+            Collection<ClusterNode> nodes = grid(0).affinity(null).mapKeyToPrimaryAndBackups(key);
 
             if (nodes.contains(grid(0).localNode()))
                 key++;


Mime
View raw message