You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/04/07 09:17:56 UTC

ignite git commit: IGNITE-3477 - Fixing reconnects

Repository: ignite
Updated Branches:
  refs/heads/ignite-3477-debug 7a46e0542 -> a0b6940c7


IGNITE-3477 - Fixing reconnects


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

Branch: refs/heads/ignite-3477-debug
Commit: a0b6940c704090df3a5dd085e23ac3c0730ebbaa
Parents: 7a46e05
Author: Alexey Goncharuk <al...@gmail.com>
Authored: Fri Apr 7 12:18:05 2017 +0300
Committer: Alexey Goncharuk <al...@gmail.com>
Committed: Fri Apr 7 12:18:05 2017 +0300

----------------------------------------------------------------------
 .../spi/IgniteSpiOperationTimeoutHelper.java    |  3 +--
 .../communication/tcp/TcpCommunicationSpi.java  | 22 +++++++++++++++-----
 2 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a0b6940c/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java
index e17b0dd..efee175 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutHelper.java
@@ -96,7 +96,6 @@ public class IgniteSpiOperationTimeoutHelper {
         if (!failureDetectionTimeoutEnabled)
             return false;
 
-        return e instanceof IgniteSpiOperationTimeoutException || e instanceof SocketTimeoutException ||
-            X.hasCause(e, IgniteSpiOperationTimeoutException.class, SocketException.class);
+        return X.hasCause(e, IgniteSpiOperationTimeoutException.class, SocketTimeoutException.class, SocketException.class);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/a0b6940c/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
index 0f407c4..b67cbc6 100755
--- a/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/communication/tcp/TcpCommunicationSpi.java
@@ -23,6 +23,7 @@ import java.io.OutputStream;
 import java.net.ConnectException;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
+import java.net.SocketException;
 import java.net.SocketTimeoutException;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
@@ -3192,8 +3193,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
                     errs.addSuppressed(new IgniteCheckedException("Failed to connect to address: " + addr, e));
 
                     // Reconnect for the second time, if connection is not established.
-                    if (!failureDetThrReached && connectAttempts < 2 &&
-                        (e instanceof ConnectException || X.hasCause(e, ConnectException.class))) {
+                    if (!failureDetThrReached && connectAttempts < 3 && isRetryException(e)) {
                         connectAttempts++;
 
                         continue;
@@ -3213,15 +3213,14 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
         if (client == null) {
             assert errs != null;
 
-            if (X.hasCause(errs, ConnectException.class))
+            if (X.hasCause(errs, SocketException.class, SocketTimeoutException.class))
                 log.warning("Failed to connect to a remote node " +
                     "(make sure that destination node is alive and " +
                     "operating system firewall is disabled on local and remote hosts) " +
                     "[addrs=" + addrs + ']');
 
             if (getSpiContext().node(node.id()) != null && (CU.clientNode(node) || !CU.clientNode(getLocalNode())) &&
-                X.hasCause(errs, ConnectException.class, SocketTimeoutException.class, HandshakeTimeoutException.class,
-                    IgniteSpiOperationTimeoutException.class)) {
+                isRetryException(errs)) {
 
                 log.warning("TcpCommunicationSpi failed to establish connection to node, node will be dropped from " +
                     "cluster [" +
@@ -3250,6 +3249,19 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
     }
 
     /**
+     * @param e Throwable to check.
+     * @return {@code True} if connect should be retried.
+     */
+    private boolean isRetryException(Throwable e) {
+        return X.hasCause(e,
+            ConnectException.class,
+            SocketException.class,
+            SocketTimeoutException.class,
+            HandshakeTimeoutException.class,
+            IgniteSpiOperationTimeoutException.class);
+    }
+
+    /**
      * Performs handshake in timeout-safe way.
      *
      * @param client Client.