IGNITE-5869 Code review

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

Branch: refs/heads/ignite-3478
Commit: db5880ab88fd513ddad7599b78b27bde37e733c5
Parents: ccc334d
Author: Andrey Gura <[email protected]>
Authored: Fri Sep 1 17:25:26 2017 +0300
Committer: Andrey Gura <[email protected]>
Committed: Fri Sep 1 17:25:53 2017 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  8 ++-
 ...pClientDiscoveryMarshallerCheckSelfTest.java | 67 ++++++++++----------
 2 files changed, 39 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/db5880ab/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 7dc94d3..c227bf7 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
@@ -6077,11 +6077,15 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                                     if (worker != null) {
                                         msg.verify(getLocalNodeId());
+
                                         worker.addMessage(msg);
                                     }
-                                    else if (log.isDebugEnabled())
-                                        log.debug("Failed to find client 
message worker " +
+                                    else {
+                                        if (log.isDebugEnabled()) {
+                                            log.debug("Failed to find client 
message worker " +
                                                 "[clientNode=" + 
msg.creatorNodeId() + ']');
+                                        }
+                                    }
 
                                     state = spiState;
                                 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/db5880ab/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
index f88a9ea..f14e0b1 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoveryMarshallerCheckSelfTest.java
@@ -17,11 +17,9 @@
 
 package org.apache.ignite.spi.discovery.tcp;
 
-import org.apache.ignite.IgniteCache;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.configuration.BinaryConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteEx;
 import org.apache.ignite.internal.binary.BinaryMarshaller;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
 import org.apache.ignite.spi.IgniteSpiException;
@@ -53,10 +51,11 @@ public class TcpClientDiscoveryMarshallerCheckSelfTest 
extends GridCommonAbstrac
             cfg.setDiscoverySpi(spi);
 
             if (igniteInstanceName.endsWith("0")) {
-                cfg.setClientMode(true);
                 BinaryConfiguration bc = new BinaryConfiguration();
                 bc.setCompactFooter(false);
+
                 cfg.setBinaryConfiguration(bc);
+                cfg.setClientMode(true);
             }
         }
         else {
@@ -100,48 +99,48 @@ public class TcpClientDiscoveryMarshallerCheckSelfTest 
extends GridCommonAbstrac
     }
 
     /**
-     * Starts client-server grid with different binary configurations.
-     *
      * @throws Exception If failed.
      */
-    private void clientServerInconsistentConfigFail(boolean multiNodes) throws 
Exception {
-        testFooter = true;
-
-        IgniteEx ig0 = startGrid(1);
-        IgniteCache ic = ig0.getOrCreateCache("cahe_name");
-        if (multiNodes)
-            startGrid(2);
-
-        try {
-            IgniteEx ig = startGrid(0);
-
-            for (String c : ig.cacheNames())
-                System.out.println(c);
-
-            fail("Expected SPI exception was not thrown, multiNodes=" + 
multiNodes);
-        } catch (IgniteCheckedException expect) {
-            Throwable ex = expect.getCause().getCause();
-
-            assertTrue(ex instanceof IgniteSpiException);
-            assertTrue("Catched exception: " + ex.getMessage(), 
ex.getMessage().contains("Local node's binary " +
-                    "configuration is not equal to remote node's binary 
configuration"));
-        } finally {
-            stopAllGrids();
-        }
+    public void testInconsistentCompactFooterSingle() throws Exception {
+        clientServerInconsistentConfigFail(false, 1, 1);
     }
 
     /**
      * @throws Exception If failed.
      */
-    public void testInconsistentFooterConfigSingle() throws Exception {
-        clientServerInconsistentConfigFail(false);
+    public void testInconsistentCompactFooterMulti() throws Exception {
+        clientServerInconsistentConfigFail(true, 2, 10);
     }
 
     /**
+     * Starts client-server grid with different binary configurations.
+     *
      * @throws Exception If failed.
      */
-    public void testInconsistentFooterConfigMulti() throws Exception {
-        for (int i = 0; i < 10; ++i)
-            clientServerInconsistentConfigFail(true);
+    private void clientServerInconsistentConfigFail(boolean multiNodes, int 
cnt, int iters) throws Exception {
+        testFooter = true;
+
+        for (int i = 1; i <= cnt; i++)
+            startGrid(i);
+
+        for (int i = 0; i < iters; i++) {
+            try {
+                startGrid(0);
+
+                fail("Expected SPI exception was not thrown, multiNodes=" + 
multiNodes);
+            }
+            catch (IgniteCheckedException expect) {
+                Throwable ex = expect.getCause().getCause();
+
+                String msg = ex.getMessage();
+
+                assertTrue(ex instanceof IgniteSpiException);
+                assertTrue("Caught exception: " + msg, msg.contains("Local 
node's binary " +
+                    "configuration is not equal to remote node's binary 
configuration"));
+            }
+            finally {
+                stopGrid(0);
+            }
+        }
     }
 }

Reply via email to