ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [09/11] incubator-ignite git commit: # IGNITE-709 Bug fix: client with wrong Ignite version got "Join timeout" instead of correct exception
Date Tue, 19 May 2015 19:40:01 GMT
# IGNITE-709 Bug fix: client with wrong Ignite version got "Join timeout" instead of correct
exception


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

Branch: refs/heads/ignite-23
Commit: ecf34cae4157c28a5979120072cd3c1f6a213be7
Parents: a48dd26
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Tue May 19 20:07:32 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Tue May 19 20:07:32 2015 +0300

----------------------------------------------------------------------
 .../discovery/tcp/TcpClientDiscoverySpi.java    |  6 +-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      | 23 +++--
 .../internal/GridReleaseTypeSelfTest.java       | 92 ++++++++++++++------
 3 files changed, 78 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ecf34cae/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
index 9a0a460..7097e1b 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpi.java
@@ -1499,7 +1499,11 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements
Tcp
          * Router want to ping this client.
          */
         private void processPingRequest() {
-            sockWriter.sendMessage(new TcpDiscoveryPingResponse(getLocalNodeId()));
+            TcpDiscoveryPingResponse res = new TcpDiscoveryPingResponse(getLocalNodeId());
+
+            res.client(true);
+
+            sockWriter.sendMessage(res);
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ecf34cae/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index 1a8e626..f80f00f 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -2654,9 +2654,6 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements
TcpDiscov
             else if (msg instanceof TcpDiscoveryClientPingRequest)
                 processClientPingRequest((TcpDiscoveryClientPingRequest)msg);
 
-            else if (msg instanceof TcpDiscoveryPingResponse)
-                processPingResponse((TcpDiscoveryPingResponse)msg);
-
             else
                 assert false : "Unknown message type: " + msg.getClass().getSimpleName();
 
@@ -4516,16 +4513,6 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements
TcpDiscov
         /**
          * @param msg Message.
          */
-        private void processPingResponse(final TcpDiscoveryPingResponse msg) {
-            ClientMessageWorker clientWorker = clientMsgWorkers.get(msg.creatorNodeId());
-
-            if (clientWorker != null)
-                clientWorker.pingResult(true);
-        }
-
-        /**
-         * @param msg Message.
-         */
         private void processCustomMessage(TcpDiscoveryCustomEventMessage msg) {
             if (isLocalNodeCoordinator()) {
                 boolean sndNext;
@@ -5065,6 +5052,16 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements
TcpDiscov
 
                             continue;
                         }
+                        if (msg instanceof TcpDiscoveryPingResponse) {
+                            assert msg.client() : msg;
+
+                            ClientMessageWorker clientWorker = clientMsgWorkers.get(msg.creatorNodeId());
+
+                            if (clientWorker != null)
+                                clientWorker.pingResult(true);
+
+                            continue;
+                        }
 
                         msgWorker.addMessage(msg);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ecf34cae/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java
index 284aa0c..4733ae5 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/GridReleaseTypeSelfTest.java
@@ -27,7 +27,6 @@ import org.apache.ignite.testframework.junits.common.*;
 
 import java.io.*;
 import java.util.*;
-import java.util.concurrent.atomic.*;
 
 /**
  * Test grids starting with non compatible release types.
@@ -36,32 +35,36 @@ public class GridReleaseTypeSelfTest extends GridCommonAbstractTest {
     /** IP finder. */
     private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true);
 
-    /** Counter. */
-    private static final AtomicInteger cnt = new AtomicInteger();
-
     /** */
-    private String firstNodeVer;
+    private String nodeVer;
 
     /** */
-    private String secondNodeVer;
+    private boolean clientMode;
 
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
 
-        final int idx = cnt.getAndIncrement();
+        TcpDiscoverySpiAdapter discoSpi;
 
-        // Override node attributes in discovery spi.
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi() {
-            @Override public void setNodeAttributes(Map<String, Object> attrs, IgniteProductVersion
ver) {
-                super.setNodeAttributes(attrs, ver);
+        if (clientMode) {
+            discoSpi = new TcpClientDiscoverySpi() {
+                @Override public void setNodeAttributes(Map<String, Object> attrs,
IgniteProductVersion ver) {
+                    super.setNodeAttributes(attrs, ver);
 
-                if (idx % 2 == 0)
-                    attrs.put(IgniteNodeAttributes.ATTR_BUILD_VER, firstNodeVer);
-                else
-                    attrs.put(IgniteNodeAttributes.ATTR_BUILD_VER, secondNodeVer);
-            }
-        };
+                    attrs.put(IgniteNodeAttributes.ATTR_BUILD_VER, nodeVer);
+                }
+            };
+        }
+        else {
+            discoSpi = new TcpDiscoverySpi() {
+                @Override public void setNodeAttributes(Map<String, Object> attrs,
IgniteProductVersion ver) {
+                    super.setNodeAttributes(attrs, ver);
+
+                    attrs.put(IgniteNodeAttributes.ATTR_BUILD_VER, nodeVer);
+                }
+            };
+        }
 
         discoSpi.setIpFinder(IP_FINDER);
 
@@ -70,15 +73,27 @@ public class GridReleaseTypeSelfTest extends GridCommonAbstractTest {
         return cfg;
     }
 
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        clientMode = false;
+
+        stopAllGrids();
+    }
+
     /**
      * @throws Exception If failed.
      */
     public void testOsEditionDoesNotSupportRollingUpdates() throws Exception {
-        firstNodeVer = "1.0.0";
-        secondNodeVer = "1.0.1";
+        nodeVer = "1.0.0";
+
+        startGrid(0);
 
         try {
-            startGrids(2);
+            nodeVer = "1.0.1";
+
+            startGrid(1);
+
+            fail("Exception has not been thrown.");
         }
         catch (IgniteCheckedException e) {
             StringWriter errors = new StringWriter();
@@ -87,17 +102,36 @@ public class GridReleaseTypeSelfTest extends GridCommonAbstractTest {
 
             String stackTrace = errors.toString();
 
-            assertTrue(
-                "Caught exception does not contain specified string.",
-                stackTrace.contains("Local node and remote node have different version numbers")
-            );
-
-            return;
+            if (!stackTrace.contains("Local node and remote node have different version numbers"))
+                throw e;
         }
-        finally {
-            stopAllGrids();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testOsEditionDoesNotSupportRollingUpdatesClientMode() throws Exception {
+        nodeVer = "1.0.0";
+
+        startGrid(0);
+
+        try {
+            nodeVer = "1.0.1";
+            clientMode = true;
+
+            startGrid(1);
+
+            fail("Exception has not been thrown.");
         }
+        catch (IgniteCheckedException e) {
+            StringWriter errors = new StringWriter();
+
+            e.printStackTrace(new PrintWriter(errors));
 
-        fail("Exception has not been thrown.");
+            String stackTrace = errors.toString();
+
+            if (!stackTrace.contains("Local node and remote node have different version numbers"))
+                throw e;
+        }
     }
 }


Mime
View raw message