You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/07/01 03:36:36 UTC

[13/50] incubator-ignite git commit: # ignite-1006

# ignite-1006


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

Branch: refs/heads/ignite-973-2
Commit: c6f66c64becfda669e381aade63ae59d946962c2
Parents: addc91b
Author: Atri <at...@gmail.com>
Authored: Thu Jun 25 14:14:23 2015 +0530
Committer: ashutak <as...@gridgain.com>
Committed: Thu Jun 25 21:11:55 2015 +0300

----------------------------------------------------------------------
 .../org/apache/ignite/cluster/ClusterGroup.java |  7 +++++++
 .../internal/cluster/ClusterGroupAdapter.java   | 14 +++++++++++++
 .../cluster/IgniteClusterAsyncImpl.java         |  5 +++++
 .../ignite/internal/GridProjectionSelfTest.java | 22 ++++++++++++++++++++
 4 files changed, 48 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6f66c64/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java
index 06854d4..e2831a7 100644
--- a/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java
+++ b/modules/core/src/main/java/org/apache/ignite/cluster/ClusterGroup.java
@@ -261,6 +261,13 @@ public interface ClusterGroup {
     public ClusterNode node();
 
     /**
+     * Gets the read-only collection of hostnames in this cluster group.
+     *
+     * @return All hostnames in this cluster group.
+     */
+    public Collection<String> hostNames();
+
+    /**
      * Gets predicate that defines a subset of nodes for this cluster group.
      *
      * @return Predicate that defines a subset of nodes for this cluster group.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6f66c64/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
index bb82c3b..8c2fece 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/cluster/ClusterGroupAdapter.java
@@ -295,6 +295,20 @@ public class ClusterGroupAdapter implements ClusterGroupEx, Externalizable {
     }
 
     /** {@inheritDoc} */
+    @Override public Collection<String> hostNames() {
+        Collection<String> resultHostNames = new HashSet<String> ();
+        Collection<ClusterNode> allNodes = nodes();
+
+        if (!(allNodes.isEmpty()))
+        {
+            for (ClusterNode currentNode : allNodes)
+                Collections.addAll(resultHostNames, currentNode.hostNames().toArray(new String[0]));
+        }
+
+        return resultHostNames;
+    }
+
+    /** {@inheritDoc} */
     @Override public final ClusterNode node(UUID id) {
         A.notNull(id, "id");
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6f66c64/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterAsyncImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterAsyncImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterAsyncImpl.java
index 7f67b4f..8c6f4e0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterAsyncImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/cluster/IgniteClusterAsyncImpl.java
@@ -262,6 +262,11 @@ public class IgniteClusterAsyncImpl extends AsyncSupportAdapter<IgniteCluster>
     }
 
     /** {@inheritDoc} */
+    @Override public Collection<String> hostNames() {
+        return cluster.hostNames();
+    }
+
+    /** {@inheritDoc} */
     @Nullable @Override public ClusterNode node() {
         return cluster.node();
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/c6f66c64/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionSelfTest.java
index 9fbad80..fc2c64d 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridProjectionSelfTest.java
@@ -248,4 +248,26 @@ public class GridProjectionSelfTest extends GridProjectionAbstractTest {
 
         return even ? cnt - 1 : cnt - 2;
     }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testHostNames() throws Exception {
+        Collection<String> inputHostNames = ignite.cluster().hostNames();
+        Collection<String> localNodeHostNames = ignite.cluster().localNode().hostNames();
+        Collection<String> randomNodeHostNames = ignite.cluster().forRandom().node().hostNames();
+        Collection<ClusterNode> allNodes = ignite.cluster().nodes();
+        Collection<String> checkHostNames = new HashSet<String> ();
+
+        for (ClusterNode currentNode : allNodes)
+            Collections.addAll(checkHostNames, currentNode.hostNames().toArray(new String[0]));
+
+        assert(checkHostNames.equals(inputHostNames));
+
+        if (!(localNodeHostNames.isEmpty()) && !(inputHostNames.isEmpty()))
+            assert((inputHostNames.containsAll(localNodeHostNames)) == true);
+
+        if (!(randomNodeHostNames.isEmpty()) && !(inputHostNames.isEmpty()))
+            assert((inputHostNames.containsAll(randomNodeHostNames)) == true);
+    }
 }