ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [45/50] [abbrv] incubator-ignite git commit: #Tests: rename IgniteCacheAffinitySelfTest
Date Wed, 28 Jan 2015 15:21:06 GMT
#Tests: rename IgniteCacheAffinitySelfTest


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/099b6b37
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/099b6b37
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/099b6b37

Branch: refs/heads/ignite-72
Commit: 099b6b37a62f11236c88ed7006e3ad842dae16e7
Parents: 95ab4a9
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Wed Jan 28 17:05:24 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Wed Jan 28 17:05:24 2015 +0300

----------------------------------------------------------------------
 .../ignite/IgniteCacheAffinitySelfTest.java     | 283 +++++++++++++++++++
 .../apache/ignite/IgniteCacheAffinityTest.java  | 283 -------------------
 .../ignite/testsuites/IgniteCacheTestSuite.java |   2 +-
 3 files changed, 284 insertions(+), 284 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/099b6b37/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java
new file mode 100644
index 0000000..f760c3f
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinitySelfTest.java
@@ -0,0 +1,283 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite;
+
+import org.apache.ignite.cache.*;
+import org.apache.ignite.cache.affinity.*;
+import org.apache.ignite.cache.affinity.consistenthash.*;
+import org.apache.ignite.cache.affinity.fair.*;
+import org.apache.ignite.cache.affinity.rendezvous.*;
+import org.apache.ignite.cluster.*;
+import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.processors.cache.*;
+
+import java.util.*;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.*;
+import static org.apache.ignite.cache.CacheDistributionMode.*;
+import static org.apache.ignite.cache.CacheMode.*;
+
+/**
+ * Tests for {@link org.apache.ignite.internal.processors.affinity.GridAffinityProcessor.CacheAffinityProxy}.
+ */
+public class IgniteCacheAffinitySelfTest extends IgniteCacheAbstractTest {
+    /** Initial grid count. */
+    private int GRID_COUNT = 3;
+
+    /** Cache name */
+    private final String CACHE1 = "ConsistentHash";
+
+    /** Cache name */
+    private final String CACHE2 = "Fair";
+
+    /** Cache name */
+    private final String CACHE3 = "Rendezvous";
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return GRID_COUNT;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        CacheConfiguration cache0 = cacheConfiguration(null);
+
+        CacheConfiguration cache1 = cacheConfiguration(null);
+        cache1.setName(CACHE1);
+        cache1.setAffinity(new CacheConsistentHashAffinityFunction());
+
+        CacheConfiguration cache2 = cacheConfiguration(null);
+        cache2.setName(CACHE2);
+        cache2.setAffinity(new CachePartitionFairAffinity());
+
+        CacheConfiguration cache3 = cacheConfiguration(null);
+        cache3.setName(CACHE3);
+        cache3.setAffinity(new CacheRendezvousAffinityFunction());
+
+        if (gridName.contains("0"))
+            cfg.setCacheConfiguration(cache0);
+        else
+            cfg.setCacheConfiguration(cache0, cache1, cache2, cache3);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return PARTITIONED;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheAtomicityMode atomicityMode() {
+        return TRANSACTIONAL;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheDistributionMode distributionMode() {
+        return NEAR_PARTITIONED;
+    }
+
+    /**
+     * Throws Exception if failed.
+     */
+    public void testAffinity() throws Exception {
+        checkAffinity();
+
+        stopGrid(gridCount() - 1);
+
+        startGrid(gridCount() - 1);
+        startGrid(gridCount());
+
+        GRID_COUNT += 1;
+
+        checkAffinity();
+    }
+
+    /**
+     * Check CacheAffinityProxy methods.
+     */
+    private void checkAffinity() {
+        checkAffinity(grid(0).affinity(null), grid(1).cache(null).affinity());
+        checkAffinity(grid(0).affinity(CACHE1), grid(1).cache(CACHE1).affinity());
+        checkAffinity(grid(0).affinity(CACHE2), grid(1).cache(CACHE2).affinity());
+        checkAffinity(grid(0).affinity(CACHE3), grid(1).cache(CACHE3).affinity());
+    }
+
+    /**
+     * @param testAff Cache affinity to test.
+     * @param aff Cache affinity.
+     */
+    private void checkAffinity(CacheAffinity testAff, CacheAffinity aff) {
+        checkAffinityKey(testAff, aff);
+        checkPartitions(testAff, aff);
+        checkIsBackupOrPrimary(testAff, aff);
+        checkMapKeyToNode(testAff, aff);
+        checkMapKeysToNodes(testAff, aff);
+        checkMapPartitionToNode(testAff, aff);
+        checkMapPartitionsToNodes(testAff, aff);
+    }
+
+    /**
+     * Check affinityKey method.
+     */
+    private void checkAffinityKey(CacheAffinity testAff,CacheAffinity aff) {
+        for (int i = 0; i < 10000; i++)
+            assertEquals(testAff.affinityKey(i), aff.affinityKey(i));
+    }
+
+    /**
+     * Check allPartitions, backupPartitions and primaryPartitions methods.
+     */
+    private void checkPartitions(CacheAffinity testAff, CacheAffinity aff) {
+        for (ClusterNode n : nodes()) {
+            checkEqualIntArray(testAff.allPartitions(n), aff.allPartitions(n));
+
+            checkEqualIntArray(testAff.backupPartitions(n), aff.backupPartitions(n));
+
+            checkEqualIntArray(testAff.primaryPartitions(n), aff.primaryPartitions(n));
+        }
+    }
+
+    /**
+     * Check isBackup, isPrimary and isPrimaryOrBackup methods.
+     */
+    private void checkIsBackupOrPrimary(CacheAffinity testAff, CacheAffinity aff) {
+        for (int i = 0; i < 10000; i++)
+            for (ClusterNode n : nodes()) {
+                assertEquals(testAff.isBackup(n, i), aff.isBackup(n, i));
+
+                assertEquals(testAff.isPrimary(n, i), aff.isPrimary(n, i));
+
+                assertEquals(testAff.isPrimaryOrBackup(n, i), aff.isPrimaryOrBackup(n, i));
+            }
+    }
+
+    /**
+     * Check mapKeyToNode, mapKeyToPrimaryAndBackups methods.
+     */
+    private void checkMapKeyToNode(CacheAffinity testAff, CacheAffinity aff) {
+        for (int i = 0; i < 10000; i++) {
+            assertEquals(testAff.mapKeyToNode(i).id(), aff.mapKeyToNode(i).id());
+
+            checkEqualCollection(testAff.mapKeyToPrimaryAndBackups(i), aff.mapKeyToPrimaryAndBackups(i));
+        }
+    }
+
+    /**
+     * Check mapPartitionToPrimaryAndBackups and mapPartitionToNode methods.
+     */
+    private void checkMapPartitionToNode(CacheAffinity testAff, CacheAffinity aff) {
+        assertEquals(aff.partitions(), testAff.partitions());
+
+        for (int part = 0; part < aff.partitions(); ++part) {
+            assertEquals(testAff.mapPartitionToNode(part).id(), aff.mapPartitionToNode(part).id());
+
+            checkEqualCollection(testAff.mapPartitionToPrimaryAndBackups(part),
+                aff.mapPartitionToPrimaryAndBackups(part));
+        }
+    }
+
+    /**
+     * Check mapKeysToNodes methods.
+     */
+    private void checkMapKeysToNodes(CacheAffinity testAff, CacheAffinity aff) {
+        List<Integer> keys = new ArrayList<>(10000);
+
+        for (int i = 0; i < 10000; ++i)
+            keys.add(i);
+
+        checkEqualMaps(testAff.mapKeysToNodes(keys), aff.mapKeysToNodes(keys));
+    }
+
+    /**
+     * Check mapPartitionsToNodes methods.
+     */
+    private void checkMapPartitionsToNodes(CacheAffinity testAff, CacheAffinity aff) {
+        List<Integer> parts = new ArrayList<>(aff.partitions());
+
+        for (int i = 0; i < aff.partitions(); ++i)
+            parts.add(i);
+
+        checkEqualPartitionMaps(testAff.mapPartitionsToNodes(parts), aff.mapPartitionsToNodes(parts));
+    }
+
+    /**
+     * Check equal arrays.
+     */
+    private static void checkEqualIntArray(int[] arr1, int[] arr2) {
+        assertEquals(arr1.length, arr2.length);
+
+        Collection<Integer> col1 = new HashSet<>();
+
+        for (int i = 0; i < arr1.length; ++i)
+            col1.add(arr1[i]);
+
+        for (int i = 0; i < arr2.length; ++i) {
+            assertTrue(col1.contains(arr2[i]));
+
+            col1.remove(arr2[i]);
+        }
+
+        assertEquals(0, col1.size());
+    }
+
+    /**
+     * Check equal collections.
+     */
+    private static void checkEqualCollection(Collection<ClusterNode> col1, Collection<ClusterNode>
col2) {
+        assertEquals(col1.size(), col2.size());
+
+        for (ClusterNode node : col1)
+            assertTrue(col2.contains(node));
+    }
+
+    /**
+     * Check equal maps.
+     */
+    private static void checkEqualMaps(Map<ClusterNode, Collection> map1, Map<ClusterNode,
Collection> map2) {
+        assertEquals(map1.size(), map2.size());
+
+        for (ClusterNode node : map1.keySet()) {
+            assertTrue(map2.containsKey(node));
+
+            assertEquals(map1.get(node).size(), map2.get(node).size());
+        }
+    }
+
+    /**
+     * Check equal maps.
+     */
+    private static void checkEqualPartitionMaps(Map<Integer, ClusterNode> map1, Map<Integer,
ClusterNode> map2) {
+        assertEquals(map1.size(), map2.size());
+
+        for (Integer i : map1.keySet()) {
+            assertTrue(map2.containsKey(i));
+
+            assertEquals(map1.get(i), map2.get(i));
+        }
+    }
+
+    /**
+     * @return Cluster nodes.
+     */
+    private Collection<ClusterNode> nodes() {
+        return grid(0).nodes();
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/099b6b37/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinityTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinityTest.java b/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinityTest.java
deleted file mode 100644
index 38a6672..0000000
--- a/modules/core/src/test/java/org/apache/ignite/IgniteCacheAffinityTest.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite;
-
-import org.apache.ignite.cache.*;
-import org.apache.ignite.cache.affinity.*;
-import org.apache.ignite.cache.affinity.consistenthash.*;
-import org.apache.ignite.cache.affinity.fair.*;
-import org.apache.ignite.cache.affinity.rendezvous.*;
-import org.apache.ignite.cluster.*;
-import org.apache.ignite.configuration.*;
-import org.apache.ignite.internal.processors.cache.*;
-
-import java.util.*;
-
-import static org.apache.ignite.cache.CacheAtomicityMode.*;
-import static org.apache.ignite.cache.CacheDistributionMode.*;
-import static org.apache.ignite.cache.CacheMode.*;
-
-/**
- * Tests for {@link org.apache.ignite.internal.processors.affinity.GridAffinityProcessor.CacheAffinityProxy}.
- */
-public class IgniteCacheAffinityTest extends IgniteCacheAbstractTest {
-    /** Initial grid count. */
-    private int GRID_COUNT = 3;
-
-    /** Cache name */
-    private final String CACHE1 = "ConsistentHash";
-
-    /** Cache name */
-    private final String CACHE2 = "Fair";
-
-    /** Cache name */
-    private final String CACHE3 = "Rendezvous";
-
-    /** {@inheritDoc} */
-    @Override protected int gridCount() {
-        return GRID_COUNT;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        CacheConfiguration cache0 = cacheConfiguration(null);
-
-        CacheConfiguration cache1 = cacheConfiguration(null);
-        cache1.setName(CACHE1);
-        cache1.setAffinity(new CacheConsistentHashAffinityFunction());
-
-        CacheConfiguration cache2 = cacheConfiguration(null);
-        cache2.setName(CACHE2);
-        cache2.setAffinity(new CachePartitionFairAffinity());
-
-        CacheConfiguration cache3 = cacheConfiguration(null);
-        cache3.setName(CACHE3);
-        cache3.setAffinity(new CacheRendezvousAffinityFunction());
-
-        if (gridName.contains("0"))
-            cfg.setCacheConfiguration(cache0);
-        else
-            cfg.setCacheConfiguration(cache0, cache1, cache2, cache3);
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheMode cacheMode() {
-        return PARTITIONED;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheAtomicityMode atomicityMode() {
-        return TRANSACTIONAL;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheDistributionMode distributionMode() {
-        return NEAR_PARTITIONED;
-    }
-
-    /**
-     * Throws Exception if failed.
-     */
-    public void testAffinity() throws Exception {
-        checkAffinity();
-
-        stopGrid(gridCount() - 1);
-
-        startGrid(gridCount() - 1);
-        startGrid(gridCount());
-
-        GRID_COUNT += 1;
-
-        checkAffinity();
-    }
-
-    /**
-     * Check CacheAffinityProxy methods.
-     */
-    private void checkAffinity() {
-        checkAffinity(grid(0).affinity(null), grid(1).cache(null).affinity());
-        checkAffinity(grid(0).affinity(CACHE1), grid(1).cache(CACHE1).affinity());
-        checkAffinity(grid(0).affinity(CACHE2), grid(1).cache(CACHE2).affinity());
-        checkAffinity(grid(0).affinity(CACHE3), grid(1).cache(CACHE3).affinity());
-    }
-
-    /**
-     * @param testAff Cache affinity to test.
-     * @param aff Cache affinity.
-     */
-    private void checkAffinity(CacheAffinity testAff, CacheAffinity aff) {
-        checkAffinityKey(testAff, aff);
-        checkPartitions(testAff, aff);
-        checkIsBackupOrPrimary(testAff, aff);
-        checkMapKeyToNode(testAff, aff);
-        checkMapKeysToNodes(testAff, aff);
-        checkMapPartitionToNode(testAff, aff);
-        checkMapPartitionsToNodes(testAff, aff);
-    }
-
-    /**
-     * Check affinityKey method.
-     */
-    private void checkAffinityKey(CacheAffinity testAff,CacheAffinity aff) {
-        for (int i = 0; i < 10000; i++)
-            assertEquals(testAff.affinityKey(i), aff.affinityKey(i));
-    }
-
-    /**
-     * Check allPartitions, backupPartitions and primaryPartitions methods.
-     */
-    private void checkPartitions(CacheAffinity testAff, CacheAffinity aff) {
-        for (ClusterNode n : nodes()) {
-            checkEqualIntArray(testAff.allPartitions(n), aff.allPartitions(n));
-
-            checkEqualIntArray(testAff.backupPartitions(n), aff.backupPartitions(n));
-
-            checkEqualIntArray(testAff.primaryPartitions(n), aff.primaryPartitions(n));
-        }
-    }
-
-    /**
-     * Check isBackup, isPrimary and isPrimaryOrBackup methods.
-     */
-    private void checkIsBackupOrPrimary(CacheAffinity testAff, CacheAffinity aff) {
-        for (int i = 0; i < 10000; i++)
-            for (ClusterNode n : nodes()) {
-                assertEquals(testAff.isBackup(n, i), aff.isBackup(n, i));
-
-                assertEquals(testAff.isPrimary(n, i), aff.isPrimary(n, i));
-
-                assertEquals(testAff.isPrimaryOrBackup(n, i), aff.isPrimaryOrBackup(n, i));
-            }
-    }
-
-    /**
-     * Check mapKeyToNode, mapKeyToPrimaryAndBackups methods.
-     */
-    private void checkMapKeyToNode(CacheAffinity testAff, CacheAffinity aff) {
-        for (int i = 0; i < 10000; i++) {
-            assertEquals(testAff.mapKeyToNode(i).id(), aff.mapKeyToNode(i).id());
-
-            checkEqualCollection(testAff.mapKeyToPrimaryAndBackups(i), aff.mapKeyToPrimaryAndBackups(i));
-        }
-    }
-
-    /**
-     * Check mapPartitionToPrimaryAndBackups and mapPartitionToNode methods.
-     */
-    private void checkMapPartitionToNode(CacheAffinity testAff, CacheAffinity aff) {
-        assertEquals(aff.partitions(), testAff.partitions());
-
-        for (int part = 0; part < aff.partitions(); ++part) {
-            assertEquals(testAff.mapPartitionToNode(part).id(), aff.mapPartitionToNode(part).id());
-
-            checkEqualCollection(testAff.mapPartitionToPrimaryAndBackups(part),
-                aff.mapPartitionToPrimaryAndBackups(part));
-        }
-    }
-
-    /**
-     * Check mapKeysToNodes methods.
-     */
-    private void checkMapKeysToNodes(CacheAffinity testAff, CacheAffinity aff) {
-        List<Integer> keys = new ArrayList<>(10000);
-
-        for (int i = 0; i < 10000; ++i)
-            keys.add(i);
-
-        checkEqualMaps(testAff.mapKeysToNodes(keys), aff.mapKeysToNodes(keys));
-    }
-
-    /**
-     * Check mapPartitionsToNodes methods.
-     */
-    private void checkMapPartitionsToNodes(CacheAffinity testAff, CacheAffinity aff) {
-        List<Integer> parts = new ArrayList<>(aff.partitions());
-
-        for (int i = 0; i < aff.partitions(); ++i)
-            parts.add(i);
-
-        checkEqualPartitionMaps(testAff.mapPartitionsToNodes(parts), aff.mapPartitionsToNodes(parts));
-    }
-
-    /**
-     * Check equal arrays.
-     */
-    private static void checkEqualIntArray(int[] arr1, int[] arr2) {
-        assertEquals(arr1.length, arr2.length);
-
-        Collection<Integer> col1 = new HashSet<>();
-
-        for (int i = 0; i < arr1.length; ++i)
-            col1.add(arr1[i]);
-
-        for (int i = 0; i < arr2.length; ++i) {
-            assertTrue(col1.contains(arr2[i]));
-
-            col1.remove(arr2[i]);
-        }
-
-        assertEquals(0, col1.size());
-    }
-
-    /**
-     * Check equal collections.
-     */
-    private static void checkEqualCollection(Collection<ClusterNode> col1, Collection<ClusterNode>
col2) {
-        assertEquals(col1.size(), col2.size());
-
-        for (ClusterNode node : col1)
-            assertTrue(col2.contains(node));
-    }
-
-    /**
-     * Check equal maps.
-     */
-    private static void checkEqualMaps(Map<ClusterNode, Collection> map1, Map<ClusterNode,
Collection> map2) {
-        assertEquals(map1.size(), map2.size());
-
-        for (ClusterNode node : map1.keySet()) {
-            assertTrue(map2.containsKey(node));
-
-            assertEquals(map1.get(node).size(), map2.get(node).size());
-        }
-    }
-
-    /**
-     * Check equal maps.
-     */
-    private static void checkEqualPartitionMaps(Map<Integer, ClusterNode> map1, Map<Integer,
ClusterNode> map2) {
-        assertEquals(map1.size(), map2.size());
-
-        for (Integer i : map1.keySet()) {
-            assertTrue(map2.containsKey(i));
-
-            assertEquals(map1.get(i), map2.get(i));
-        }
-    }
-
-    /**
-     * @return Cluster nodes.
-     */
-    private Collection<ClusterNode> nodes() {
-        return grid(0).nodes();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/099b6b37/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
index 930e2e7..f3eb42a 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite.java
@@ -68,7 +68,7 @@ public class IgniteCacheTestSuite extends TestSuite {
         // Affinity tests.
         suite.addTestSuite(GridCachePartitionFairAffinityNodesSelfTest.class);
         suite.addTestSuite(GridCacheAffinityBackupsSelfTest.class);
-        suite.addTestSuite(IgniteCacheAffinityTest.class);
+        suite.addTestSuite(IgniteCacheAffinitySelfTest.class);
 
         // Swap tests.
         suite.addTestSuite(GridCacheSwapPreloadSelfTest.class);


Mime
View raw message