ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject incubator-ignite git commit: IGNITE-995 - Discovery fix
Date Fri, 05 Jun 2015 02:29:56 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-995 [created] 06dcdff6e


IGNITE-995 - Discovery fix


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

Branch: refs/heads/ignite-995
Commit: 06dcdff6eea66573fcd32a3ef54134c5a61081a3
Parents: c9f7291
Author: Valentin Kulichenko <vkulichenko@gridgain.com>
Authored: Thu Jun 4 19:29:47 2015 -0700
Committer: Valentin Kulichenko <vkulichenko@gridgain.com>
Committed: Thu Jun 4 19:29:47 2015 -0700

----------------------------------------------------------------------
 .../spi/discovery/tcp/TcpDiscoverySpi.java      | 13 +++----
 .../ignite/internal/GridStartStopSelfTest.java  | 38 +++++++++++++++++++-
 2 files changed, 44 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/06dcdff6/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 70bc9fb..3121afe 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1402,14 +1402,15 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi,
T
 
         for (InetSocketAddress addr : ipFinder.getRegisteredAddresses()) {
             if (addr.getPort() == 0) {
-                // TcpDiscoveryNode.discoveryPort() returns an correct port for a server
node and 0 for client node.
-                int port = locNode.discoveryPort() != 0 ? locNode.discoveryPort() : DFLT_PORT;
+                for (int port = locPort; port < locPort + locPortRange; port++) {
+                    addr = addr.isUnresolved() ? new InetSocketAddress(addr.getHostName(),
port) :
+                        new InetSocketAddress(addr.getAddress(), port);
 
-                addr = addr.isUnresolved() ? new InetSocketAddress(addr.getHostName(), port)
:
-                    new InetSocketAddress(addr.getAddress(), port);
+                    res.add(addr);
+                }
             }
-
-            res.add(addr);
+            else
+                res.add(addr);
         }
 
         return res;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/06dcdff6/modules/core/src/test/java/org/apache/ignite/internal/GridStartStopSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridStartStopSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/GridStartStopSelfTest.java
index 839e0ac..b4d5473 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridStartStopSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridStartStopSelfTest.java
@@ -20,10 +20,13 @@ package org.apache.ignite.internal;
 import org.apache.ignite.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.spi.discovery.tcp.*;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
 import org.apache.ignite.transactions.*;
 
+import java.util.*;
 import java.util.concurrent.*;
 
 import static java.util.concurrent.TimeUnit.*;
@@ -75,7 +78,7 @@ public class GridStartStopSelfTest extends GridCommonAbstractTest {
     public void testStopWhileInUse() throws Exception {
         // Test works too long.
         fail("https://issues.apache.org/jira/browse/IGNITE-580");
-        
+
         IgniteConfiguration cfg = new IgniteConfiguration();
 
         cfg.setConnectorConfiguration(null);
@@ -182,4 +185,37 @@ public class GridStartStopSelfTest extends GridCommonAbstractTest {
             assert e instanceof IllegalStateException : "Wrong exception type.";
         }
     }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNoPortInIpFinder() throws Exception {
+        try {
+            int nodesCnt = 3;
+
+            for (int i = 0; i < nodesCnt; i++) {
+                IgniteConfiguration cfg = new IgniteConfiguration();
+
+                cfg.setGridName("grid-" + i);
+
+                TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+                TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
+
+                ipFinder.setAddresses(Arrays.asList("127.0.0.1"));
+
+                disco.setIpFinder(ipFinder);
+
+                cfg.setDiscoverySpi(disco);
+
+                Ignition.start(cfg);
+            }
+
+            for (int i = 0; i < nodesCnt; i++)
+                assertEquals(nodesCnt, Ignition.ignite("grid-" + i).cluster().nodes().size());
+        }
+        finally {
+            Ignition.stopAll(true);
+        }
+    }
 }


Mime
View raw message