Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A575918241 for ; Wed, 8 Jul 2015 13:31:33 +0000 (UTC) Received: (qmail 19846 invoked by uid 500); 8 Jul 2015 13:31:33 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 19814 invoked by uid 500); 8 Jul 2015 13:31:33 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 19805 invoked by uid 99); 8 Jul 2015 13:31:33 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Jul 2015 13:31:33 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 21BCBD308B for ; Wed, 8 Jul 2015 13:31:33 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.134 X-Spam-Level: X-Spam-Status: No, score=0.134 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.666] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 4RmX9npK80Mw for ; Wed, 8 Jul 2015 13:31:17 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id A801547BE9 for ; Wed, 8 Jul 2015 13:31:12 +0000 (UTC) Received: (qmail 18183 invoked by uid 99); 8 Jul 2015 13:31:12 -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, 08 Jul 2015 13:31:12 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D2EF7E10D0; Wed, 8 Jul 2015 13:31:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Date: Wed, 08 Jul 2015 13:31:22 -0000 Message-Id: <6c5d9e39bef94386bac282e5e93d153e@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [12/50] incubator-ignite git commit: #ignite-1086: ClusterNode.consistentId() should be the same after restart. #ignite-1086: ClusterNode.consistentId() should be the same after restart. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a577d27b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a577d27b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a577d27b Branch: refs/heads/ignite-gg-10052 Commit: a577d27b6a857e80d4ddf48a635dce09123eec8a Parents: 3a4d008 Author: ivasilinets Authored: Mon Jul 6 11:19:00 2015 +0300 Committer: ivasilinets Committed: Mon Jul 6 11:19:00 2015 +0300 ---------------------------------------------------------------------- .../ignite/internal/util/IgniteUtils.java | 6 +- .../TcpDiscoveryNodeConsistentIdSelfTest.java | 80 ++++++++++++++++++++ .../IgniteSpiDiscoverySelfTestSuite.java | 2 + 3 files changed, 87 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a577d27b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java index f457d6c..46a23d6 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java @@ -8048,9 +8048,13 @@ public abstract class IgniteUtils { public static String consistentId(Collection addrs, int port) { assert !F.isEmpty(addrs); + List sortedAddrs = new ArrayList<>(addrs); + + Collections.sort(sortedAddrs); + StringBuilder sb = new StringBuilder(); - for (String addr : addrs) + for (String addr : sortedAddrs) sb.append(addr).append(','); sb.delete(sb.length() - 1, sb.length()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a577d27b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConsistentIdSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConsistentIdSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConsistentIdSelfTest.java new file mode 100644 index 0000000..d159d72 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryNodeConsistentIdSelfTest.java @@ -0,0 +1,80 @@ +/* + * 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.tcp; + +import org.apache.ignite.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.spi.discovery.tcp.internal.*; +import org.apache.ignite.spi.discovery.tcp.ipfinder.*; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; +import org.apache.ignite.testframework.junits.common.*; + +/** + * Test for {@link TcpDiscoveryNode#consistentId()} + */ +public class TcpDiscoveryNodeConsistentIdSelfTest extends GridCommonAbstractTest { + /** IP finder. */ + private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + cfg.setLocalHost("0.0.0.0"); + + cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder)); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + startGrids(1); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + } + + /** + * @throws Exception If failed. + */ + public void testConsistentId() throws Exception { + Object id0 = grid(0).localNode().consistentId(); + + int port0 = getDiscoveryPort(grid(0)); + + for (int i = 0; i < 10; ++i) { + stopAllGrids(); + + startGrids(1); + + if (port0 == getDiscoveryPort(grid(0))) + assertEquals(id0, grid(0).localNode().consistentId()); + } + } + + /** + * @param ignite Ignite. + * @return Discovery port. + */ + private int getDiscoveryPort(Ignite ignite) { + return ((TcpDiscoveryNode) ignite.cluster().localNode()).discoveryPort(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a577d27b/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 ea5a7ac..498f50c 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 @@ -55,6 +55,8 @@ public class IgniteSpiDiscoverySelfTestSuite extends TestSuite { suite.addTest(new TestSuite(TcpClientDiscoveryMarshallerCheckSelfTest.class)); suite.addTest(new TestSuite(TcpClientDiscoverySpiMulticastTest.class)); + suite.addTest(new TestSuite(TcpDiscoveryNodeConsistentIdSelfTest.class)); + return suite; } }