ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-4154
Date Tue, 08 Nov 2016 10:58:08 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-4154-2 9617e80b9 -> e81079d01


ignite-4154


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

Branch: refs/heads/ignite-4154-2
Commit: e81079d013421d3db3732519ec3ac2e5b783186f
Parents: 9617e80
Author: sboikov <sboikov@gridgain.com>
Authored: Tue Nov 8 13:58:00 2016 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Tue Nov 8 13:58:00 2016 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 16 +---
 .../spi/discovery/tcp/TcpDiscoverySelfTest.java | 98 +++++++++++++-------
 2 files changed, 68 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e81079d0/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 a62f18f..e182177 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
@@ -4005,21 +4005,7 @@ class ServerImpl extends TcpDiscoveryImpl {
                         spi.onExchange(node.id(), node.id(), data,
                             U.resolveClassLoader(spi.ignite().configuration()));
 
-                    Map<Integer, byte[]> d0 = spi.collectExchangeData(node.id());
-
-                    if (!F.isEmpty(msg.oldNodesDiscoveryData())) {
-                        try {
-                            Object o1 = spi.marshaller().unmarshal(d0.get(1), null);
-                            Object o2 = spi.marshaller().unmarshal(msg.oldNodesDiscoveryData().values().iterator().next().get(1),
null);
-
-                            System.out.println();
-                        }
-                        catch (Exception e) {
-                            e.printStackTrace();;
-                        }
-                    }
-
-                    msg.addDiscoveryData(locNodeId, d0);
+                    msg.addDiscoveryData(locNodeId, spi.collectExchangeData(node.id()));
 
                     processMessageFailedNodes(msg);
                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/e81079d0/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
index 1cbb5f3..043208c 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java
@@ -118,6 +118,9 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
     /** */
     private CacheConfiguration[] ccfgs;
 
+    /** */
+    private boolean client;
+
     /**
      * @throws Exception If fails.
      */
@@ -211,6 +214,8 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
         else if (gridName.contains("testNodeShutdownOnRingMessageWorkerFailureFailedNode"))
             cfg.setGridLogger(strLog = new GridStringLogger());
 
+        cfg.setClientMode(client);
+
         return cfg;
     }
 
@@ -1972,38 +1977,50 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
     public void testDuplicatedDiscoveryDataRemoved() throws Exception {
         try {
             TestDiscoveryDataDuplicateSpi.checkNodeAdded = false;
+            TestDiscoveryDataDuplicateSpi.checkClientNodeAddFinished = false;
             TestDiscoveryDataDuplicateSpi.fail = false;
 
-//            ccfgs = new CacheConfiguration[5];
-//
-//            for (int i = 0; i < ccfgs.length; i++) {
-//                CacheConfiguration ccfg = new CacheConfiguration();
-//                ccfg.setName("static-cache-" + i);
-//
-//                ccfgs[i] = ccfg;
-//            }
+            ccfgs = new CacheConfiguration[5];
+
+            for (int i = 0; i < ccfgs.length; i++) {
+                CacheConfiguration ccfg = new CacheConfiguration();
+
+                ccfg.setName(i == 0 ? null : ("static-cache-" + i));
+
+                ccfgs[i] = ccfg;
+            }
 
             TestDiscoveryDataDuplicateSpi spi = new TestDiscoveryDataDuplicateSpi();
 
             nodeSpi.set(spi);
 
-            Ignite ignite0 = startGrid(0);
+            startGrid(0);
 
-            CacheConfiguration ccfg1 = new CacheConfiguration();
-            ccfg1.setName("cache1");
+            for (int i = 0; i < 5; i++) {
+                nodeSpi.set(new TestDiscoveryDataDuplicateSpi());
 
-            ignite0.createCache(ccfg1);
+                startGrid(i + 1);
+            }
 
-            nodeSpi.set(new TestDiscoveryDataDuplicateSpi());
-            startGrid(1);
+            client = true;
 
-            nodeSpi.set(new TestDiscoveryDataDuplicateSpi());
-            startGrid(2);
+            Ignite clientNode = startGrid(6);
+
+            assertTrue(clientNode.configuration().isClientMode());
+
+            CacheConfiguration ccfg = new CacheConfiguration();
+            ccfg.setName("c1");
+
+            clientNode.createCache(ccfg);
+
+            client = false;
 
             nodeSpi.set(new TestDiscoveryDataDuplicateSpi());
-            startGrid(3);
+
+            startGrid(7);
 
             assertTrue(TestDiscoveryDataDuplicateSpi.checkNodeAdded);
+            assertTrue(TestDiscoveryDataDuplicateSpi.checkClientNodeAddFinished);
             assertFalse(TestDiscoveryDataDuplicateSpi.fail);
         }
         finally {
@@ -2076,6 +2093,9 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
         /** */
         static volatile boolean checkNodeAdded;
 
+        /** */
+        static volatile boolean checkClientNodeAddFinished;
+
         /** {@inheritDoc} */
         @Override protected void writeToSocket(Socket sock, OutputStream out,
             TcpDiscoveryAbstractMessage msg,
@@ -2083,27 +2103,43 @@ public class TcpDiscoverySelfTest extends GridCommonAbstractTest {
             if (msg instanceof TcpDiscoveryNodeAddedMessage) {
                 Map<UUID, Map<Integer, byte[]>> discoData = ((TcpDiscoveryNodeAddedMessage)msg).oldNodesDiscoveryData();
 
-                int cnt = 0;
+                checkDiscoData(discoData, msg);
+            }
+            else if (msg instanceof TcpDiscoveryNodeAddFinishedMessage) {
+                Map<UUID, Map<Integer, byte[]>> discoData = ((TcpDiscoveryNodeAddFinishedMessage)msg).clientDiscoData();
 
-                if (discoData != null && discoData.size() > 1) {
-                    for (Map.Entry<UUID, Map<Integer, byte[]>> e : discoData.entrySet())
{
-                        Map<Integer, byte[]> map = e.getValue();
+                checkDiscoData(discoData, msg);
+            }
 
-                        if (map.containsKey(GridComponent.DiscoveryDataExchangeType.CACHE_PROC.ordinal()))
-                            cnt++;
-                    }
+            super.writeToSocket(sock, out, msg, timeout);
+        }
 
-                    checkNodeAdded = true;
+        /**
+         * @param discoData Discovery data.
+         * @param msg Message.
+         */
+        private void checkDiscoData(Map<UUID, Map<Integer, byte[]>> discoData,
TcpDiscoveryAbstractMessage msg) {
+            if (discoData != null && discoData.size() > 1) {
+                int cnt = 0;
 
-                    if (cnt > 1) {
-                        fail = true;
+                for (Map.Entry<UUID, Map<Integer, byte[]>> e : discoData.entrySet())
{
+                    Map<Integer, byte[]> map = e.getValue();
 
-                        log.error("Expect cache data only from one node, but actually: "
+ cnt);
-                    }
+                    if (map.containsKey(GridComponent.DiscoveryDataExchangeType.CACHE_PROC.ordinal()))
+                        cnt++;
                 }
-            }
 
-            super.writeToSocket(sock, out, msg, timeout);
+                if (cnt > 1) {
+                    fail = true;
+
+                    log.error("Expect cache data only from one node, but actually: " + cnt);
+                }
+
+                if (msg instanceof TcpDiscoveryNodeAddedMessage)
+                    checkNodeAdded = true;
+                else if (msg instanceof TcpDiscoveryNodeAddFinishedMessage)
+                    checkClientNodeAddFinished = true;
+            }
         }
     }
 


Mime
View raw message