You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/06/22 16:18:20 UTC

[24/35] incubator-ignite git commit: # ignite-sprint-6 minor

# ignite-sprint-6 minor


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

Branch: refs/heads/ignite-gg-10440
Commit: 6f5e676a2599a4e5441dc51f67763bdd10b2db24
Parents: 1cc0000
Author: sboikov <sb...@gridgain.com>
Authored: Mon Jun 22 11:06:38 2015 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Mon Jun 22 11:06:38 2015 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ClientImpl.java    | 45 ++++++++++----------
 1 file changed, 23 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6f5e676a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index e255e08..b524e13 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -36,6 +36,7 @@ import java.io.*;
 import java.net.*;
 import java.util.*;
 import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
 
 import static java.util.concurrent.TimeUnit.*;
 import static org.apache.ignite.events.EventType.*;
@@ -79,7 +80,7 @@ class ClientImpl extends TcpDiscoveryImpl {
     private volatile long topVer;
 
     /** Join error. Contains error what occurs on join process. */
-    private IgniteSpiException joinErr;
+    private final AtomicReference<IgniteSpiException> joinErr = new AtomicReference<>();
 
     /** Joined latch. */
     private final CountDownLatch joinLatch = new CountDownLatch(1);
@@ -171,8 +172,10 @@ class ClientImpl extends TcpDiscoveryImpl {
         try {
             joinLatch.await();
 
-            if (joinErr != null)
-                throw joinErr;
+            IgniteSpiException err = joinErr.get();
+
+            if (err != null)
+                throw err;
         }
         catch (InterruptedException e) {
             throw new IgniteSpiException("Thread has been interrupted.", e);
@@ -645,7 +648,7 @@ class ClientImpl extends TcpDiscoveryImpl {
     private void joinError(IgniteSpiException err) {
         assert err != null;
 
-        joinErr = err;
+        joinErr.compareAndSet(null, err);
 
         joinLatch.countDown();
     }
@@ -1000,8 +1003,16 @@ class ClientImpl extends TcpDiscoveryImpl {
                         if (log.isDebugEnabled())
                             log.error("Reconnect error [join=" + join + ", timeout=" + timeout + ']', e);
 
-                        if (timeout > 0 && (U.currentTimeMillis() - startTime) > timeout)
+                        if (timeout > 0 && (U.currentTimeMillis() - startTime) > timeout) {
+                            String msg = join ? "Failed to connect to cluster (consider increasing 'joinTimeout' " +
+                                "configuration  property) [joinTimeout=" + spi.joinTimeout + ", err=" + e + ']' :
+                                "Failed to reconnect to cluster (consider increasing 'networkTimeout' " +
+                                    "configuration  property) [networkTimeout=" + spi.netTimeout + ", err=" + e + ']';
+
+                            U.warn(log, msg);
+
                             throw e;
+                        }
                         else
                             U.warn(log, "Failed to reconnect to cluster (will retry): " + e);
                     }
@@ -1062,9 +1073,7 @@ class ClientImpl extends TcpDiscoveryImpl {
                 final Socket sock = joinTopology(false, spi.joinTimeout);
 
                 if (sock == null) {
-                    joinErr = new IgniteSpiException("Join process timed out.");
-
-                    joinLatch.countDown();
+                    joinError(new IgniteSpiException("Join process timed out."));
 
                     return;
                 }
@@ -1089,11 +1098,9 @@ class ClientImpl extends TcpDiscoveryImpl {
 
                     if (msg == JOIN_TIMEOUT) {
                         if (joinLatch.getCount() > 0) {
-                            joinErr = new IgniteSpiException("Join process timed out, did not receive response for " +
+                            joinError(new IgniteSpiException("Join process timed out, did not receive response for " +
                                 "join request (consider increasing 'joinTimeout' configuration property) " +
-                                "[joinTimeout=" + spi.joinTimeout + ", sock=" + sock +']');
-
-                            joinLatch.countDown();
+                                "[joinTimeout=" + spi.joinTimeout + ", sock=" + sock +']'));
 
                             break;
                         }
@@ -1159,9 +1166,7 @@ class ClientImpl extends TcpDiscoveryImpl {
                                 err = spi.checkFailedError((TcpDiscoveryCheckFailedMessage)msg);
 
                             if (err != null) {
-                                joinErr = err;
-
-                                joinLatch.countDown();
+                                joinError(err);
 
                                 break;
                             }
@@ -1174,12 +1179,8 @@ class ClientImpl extends TcpDiscoveryImpl {
             finally {
                 U.closeQuiet(currSock);
 
-                if (joinLatch.getCount() > 0) {
-                    // This should not occurs.
-                    joinErr = new IgniteSpiException("Some error in join process.");
-
-                    joinLatch.countDown();
-                }
+                if (joinLatch.getCount() > 0)
+                    joinError(new IgniteSpiException("Some error in join process.")); // This should not occur.
 
                 if (reconnector != null) {
                     reconnector.cancel();
@@ -1297,7 +1298,7 @@ class ClientImpl extends TcpDiscoveryImpl {
 
                     notifyDiscovery(EVT_NODE_JOINED, topVer, locNode, updateTopologyHistory(topVer, msg));
 
-                    joinErr = null;
+                    joinErr.set(null);;
 
                     joinLatch.countDown();