ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [03/14] ignite git commit: IGNITE-6667 wip.
Date Wed, 25 Oct 2017 14:01:24 GMT
IGNITE-6667 wip.


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

Branch: refs/heads/ignite-6667
Commit: ee014c43dac159d8832bd55ace3656e8a0442f12
Parents: 6d67754
Author: ascherbakoff <alexey.scherbakoff@gmail.com>
Authored: Sat Oct 21 17:34:48 2017 +0300
Committer: ascherbakoff <alexey.scherbakoff@gmail.com>
Committed: Sat Oct 21 17:34:48 2017 +0300

----------------------------------------------------------------------
 .../IgniteDiscoveryCacheReuseSelfTest.java      | 73 ++++++++++++++++++++
 .../IgniteSpiDiscoverySelfTestSuite.java        |  6 +-
 2 files changed, 78 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ee014c43/modules/core/src/test/java/org/apache/ignite/spi/discovery/IgniteDiscoveryCacheReuseSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/IgniteDiscoveryCacheReuseSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/IgniteDiscoveryCacheReuseSelfTest.java
new file mode 100644
index 0000000..034bfa8
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/IgniteDiscoveryCacheReuseSelfTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.spi.discovery;
+
+import org.apache.ignite.Ignite;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.internal.managers.discovery.DiscoCache;
+import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap;
+import org.apache.ignite.internal.util.typedef.G;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ * Tests discovery cache reuse between topology events.
+ */
+public class IgniteDiscoveryCacheReuseSelfTest extends GridCommonAbstractTest {
+    /**
+     * Tests correct reuse of discovery cache.
+     */
+    public void testDiscoCacheReuseOnNodeJoin() throws Exception {
+        startGridsMultiThreaded(2);
+
+        assertDiscoCacheReuse(new AffinityTopologyVersion(2, 0), new AffinityTopologyVersion(2,
1));
+    }
+
+    /**
+     * Assert disco cache reuse.
+     *
+     * @param v1 First version.
+     * @param v2 Next version.
+     */
+    private void assertDiscoCacheReuse(AffinityTopologyVersion v1,
+                                       AffinityTopologyVersion v2) {
+        for (Ignite ignite : G.allGrids()) {
+            GridBoundedConcurrentLinkedHashMap<AffinityTopologyVersion, DiscoCache>
discoCacheHist =
+                    U.field(((IgniteEx) ignite).context().discovery(), "discoCacheHist");
+
+            DiscoCache discoCache1 = discoCacheHist.get(v1);
+            DiscoCache discoCache2 = discoCacheHist.get(v2);
+
+            assertEquals(v1, discoCache1.version());
+            assertEquals(v2, discoCache2.version());
+
+            String[] props = new String[] {
+                    "state", "loc", "rmtNodes", "allNodes", "srvNodes", "daemonNodes", "rmtNodesWithCaches",
+                    "allCacheNodes", "allCacheNodes", "cacheGrpAffNodes", "nodeMap", "minNodeVer"
+            };
+
+            for (String prop : props)
+                assertSame(U.field(discoCache1, prop), U.field(discoCache2, prop));
+
+            assertNotSame(U.field(discoCache1, "alives"), U.field(discoCache2, "alives"));
+            assertEquals(U.field(discoCache1, "alives"), U.field(discoCache2, "alives"));
+
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/ee014c43/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
index 3335797..ff4c9c1 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteSpiDiscoverySelfTestSuite.java
@@ -20,6 +20,7 @@ package org.apache.ignite.testsuites;
 import junit.framework.TestSuite;
 import org.apache.ignite.spi.GridTcpSpiForwardingSelfTest;
 import org.apache.ignite.spi.discovery.AuthenticationRestartTest;
+import org.apache.ignite.spi.discovery.IgniteDiscoveryCacheReuseSelfTest;
 import org.apache.ignite.spi.discovery.tcp.IgniteClientConnectTest;
 import org.apache.ignite.spi.discovery.tcp.IgniteClientReconnectMassiveShutdownTest;
 import org.apache.ignite.spi.discovery.tcp.TcpClientDiscoveryMarshallerCheckSelfTest;
@@ -94,7 +95,7 @@ public class IgniteSpiDiscoverySelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(TcpDiscoveryNodeAttributesUpdateOnReconnectTest.class));
         suite.addTest(new TestSuite(AuthenticationRestartTest.class));
 
-        //Client connect
+        // Client connect.
         suite.addTest(new TestSuite(IgniteClientConnectTest.class));
         suite.addTest(new TestSuite(IgniteClientReconnectMassiveShutdownTest.class));
 
@@ -104,6 +105,9 @@ public class IgniteSpiDiscoverySelfTestSuite extends TestSuite {
         suite.addTest(new TestSuite(TcpDiscoverySslSecuredUnsecuredTest.class));
         suite.addTest(new TestSuite(TcpDiscoverySslTrustedUntrustedTest.class));
 
+        // Disco cache reuse.
+        suite.addTest(new TestSuite(IgniteDiscoveryCacheReuseSelfTest.class));
+
         return suite;
     }
 }


Mime
View raw message