Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 61320200D37 for ; Wed, 25 Oct 2017 16:01:25 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 5F8D81609E5; Wed, 25 Oct 2017 14:01:25 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 825E1160BDA for ; Wed, 25 Oct 2017 16:01:24 +0200 (CEST) Received: (qmail 13198 invoked by uid 500); 25 Oct 2017 14:01:23 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 13180 invoked by uid 99); 25 Oct 2017 14:01:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Oct 2017 14:01:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9ED32DFBC7; Wed, 25 Oct 2017 14:01:22 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Wed, 25 Oct 2017 14:01:24 -0000 Message-Id: <731be733ca3149a1a9994ea784638394@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [03/14] ignite git commit: IGNITE-6667 wip. archived-at: Wed, 25 Oct 2017 14:01:25 -0000 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 Authored: Sat Oct 21 17:34:48 2017 +0300 Committer: ascherbakoff 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 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; } }