ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [16/50] [abbrv] ignite git commit: IGNITE-3152 Client node's addresses are registered in IP finder
Date Tue, 28 Jun 2016 13:07:03 GMT
IGNITE-3152 Client node's addresses are registered in IP finder


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

Branch: refs/heads/ignite-1232
Commit: 8ce29a92d5e06d5a3d68aae0f6a2865ffd21a28c
Parents: 5177c33
Author: Anton Vinogradov <av@apache.org>
Authored: Wed Jun 22 12:43:05 2016 +0300
Committer: Anton Vinogradov <av@apache.org>
Committed: Wed Jun 22 12:58:10 2016 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  2 +-
 .../vm/TcpDiscoveryVmIpFinderSelfTest.java      | 75 ++++++++++++++++++++
 2 files changed, 76 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/8ce29a92/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 38ed671..b1c56c0 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -4035,7 +4035,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                     notifyDiscovery(EVT_NODE_JOINED, topVer, node);
 
                 try {
-                    if (spi.ipFinder.isShared() && locNodeCoord)
+                    if (spi.ipFinder.isShared() && locNodeCoord && !node.isClient())
                         spi.ipFinder.registerAddresses(node.socketAddresses());
                 }
                 catch (IgniteSpiException e) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/8ce29a92/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/vm/TcpDiscoveryVmIpFinderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/vm/TcpDiscoveryVmIpFinderSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/vm/TcpDiscoveryVmIpFinderSelfTest.java
index 86587ba..aa00007 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/vm/TcpDiscoveryVmIpFinderSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/ipfinder/vm/TcpDiscoveryVmIpFinderSelfTest.java
@@ -19,8 +19,16 @@ package org.apache.ignite.spi.discovery.tcp.ipfinder.vm;
 
 import java.util.Arrays;
 import java.util.Collections;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.lang.GridAbsPredicate;
+import org.apache.ignite.internal.util.typedef.G;
 import org.apache.ignite.spi.IgniteSpiException;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinderAbstractSelfTest;
+import org.apache.ignite.testframework.GridTestUtils;
+
+import static org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryObjectsAbstractSelfTest.IP_FINDER;
 
 /**
  * GridTcpDiscoveryVmIpFinder test.
@@ -190,4 +198,71 @@ public class TcpDiscoveryVmIpFinderSelfTest
         assertEquals("Registered addresses: " + finder.getRegisteredAddresses().toString(),
             10, finder.getRegisteredAddresses().size());
     }
+
+    /**
+     *
+     */
+    public void testUnregistration() throws Exception {
+        Ignition.start(config("server1", false, false));
+
+        int srvSize = IP_FINDER.getRegisteredAddresses().size();
+
+        Ignition.start(config("server2", false, false));
+        Ignition.start(config("client1", true, false));
+
+        assertEquals(2 * srvSize, IP_FINDER.getRegisteredAddresses().size());
+
+        Ignition.start(config("client2", true, false));
+        Ignition.start(config("client3", true, false));
+
+        assertEquals(2 * srvSize, IP_FINDER.getRegisteredAddresses().size());
+
+        Ignition.start(config("client4", true, true));
+
+        assertEquals(3 * srvSize, IP_FINDER.getRegisteredAddresses().size());
+
+        Ignition.stop("client1", true);
+        Ignition.stop("client2", true);
+
+        assertEquals(3 * srvSize, IP_FINDER.getRegisteredAddresses().size());
+
+        Ignition.stop("client4", true);
+
+        GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                return 2 == G.allGrids().size();
+            }
+        }, 10000);
+
+        Ignition.stop("server1", true);
+        Ignition.stop("server2", true);
+
+        GridTestUtils.waitForCondition(new GridAbsPredicate() {
+            @Override public boolean apply() {
+                return 0 == G.allGrids().size();
+            }
+        }, 10000);
+
+        assertTrue(3 * srvSize >= IP_FINDER.getRegisteredAddresses().size());
+    }
+
+    /**
+     * @param name Name.
+     * @param client Client.
+     */
+    private static IgniteConfiguration config(String name, boolean client, boolean forceServerMode)
{
+        IgniteConfiguration cfg = new IgniteConfiguration();
+
+        cfg.setGridName(name);
+        cfg.setClientMode(client);
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setForceServerMode(forceServerMode);
+        disco.setIpFinder(IP_FINDER);
+
+        cfg.setDiscoverySpi(disco);
+
+        return cfg;
+    }
 }
\ No newline at end of file


Mime
View raw message