ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [16/16] incubator-ignite git commit: # ignite-1033: Fix.
Date Thu, 18 Jun 2015 14:48:37 GMT
# ignite-1033: 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/60650b0f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/60650b0f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/60650b0f

Branch: refs/heads/ignite-917-review
Commit: 60650b0ffbc063343a630631570d8dc2801b657b
Parents: c878b3c
Author: ashutak <ashutak@gridgain.com>
Authored: Thu Jun 18 17:48:20 2015 +0300
Committer: ashutak <ashutak@gridgain.com>
Committed: Thu Jun 18 17:48:20 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cluster/ClusterNode.java  |  2 ++
 .../ignite/internal/util/IgniteUtils.java       |  6 +++---
 .../internal/util/IgniteUtilsSelfTest.java      | 22 ++++++++++++++++++++
 3 files changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/60650b0f/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
index 85fd08a..bb792d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
+++ b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterNode.java
@@ -188,6 +188,8 @@ public interface ClusterNode {
      * <p>
      * If {@link IgniteConfiguration#getLocalHost()} value is {@code null} then local wildcard
address will be used,
      * and this method returns host names of all addresses of that node.
+     * <p/
+     * Note: the loopback address will skipped from the results.
      *
      * @return Collection of host names.
      */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/60650b0f/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 6623e85..f457d6c 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
@@ -1658,10 +1658,10 @@ public abstract class IgniteUtils {
 
         String ipAddr = addr.getHostAddress();
 
-        hostName = F.isEmpty(hostName) || hostName.equals(ipAddr) || addr.isLoopbackAddress()
? "" : hostName;
-
         addrs.add(ipAddr);
-        hostNames.add(hostName);
+
+        if (!F.isEmpty(hostName) && !addr.isLoopbackAddress())
+            hostNames.add(hostName);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/60650b0f/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
index 6e3e0e2..4762001 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/IgniteUtilsSelfTest.java
@@ -23,6 +23,7 @@ import org.apache.ignite.compute.*;
 import org.apache.ignite.internal.util.lang.*;
 import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.lang.*;
 import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.http.*;
 import org.apache.ignite.testframework.junits.*;
@@ -698,6 +699,27 @@ public class IgniteUtilsSelfTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testResolveLocalAddresses() throws Exception {
+        InetAddress inetAddress = InetAddress.getByName("0.0.0.0");
+
+        IgniteBiTuple<Collection<String>, Collection<String>> addrs = U.resolveLocalAddresses(inetAddress);
+
+        Collection<String> hostNames = addrs.get2();
+
+        assertFalse(hostNames.contains(null));
+        assertFalse(hostNames.contains(""));
+        assertFalse(hostNames.contains("127.0.0.1"));
+
+        assertFalse(F.exist(hostNames, new IgnitePredicate<String>() {
+            @Override public boolean apply(String hostName) {
+                return hostName.contains("localhost") || hostName.contains("0:0:0:0:0:0:0:1");
+            }
+        }));
+    }
+
+    /**
      * Test enum.
      */
     private enum TestEnum {


Mime
View raw message