ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [28/50] incubator-ignite git commit: # IGNITE-709 Fix IgfsOneClientNodeTest
Date Mon, 01 Jun 2015 17:24:19 GMT
# IGNITE-709 Fix IgfsOneClientNodeTest


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

Branch: refs/heads/ignite-218
Commit: 2bc07956a828ac836641f4fbe6ae0db7b3cc1793
Parents: 2799c3a
Author: sevdokimov <sergey.evdokimov@jetbrains.com>
Authored: Thu May 28 21:47:48 2015 +0300
Committer: sevdokimov <sergey.evdokimov@jetbrains.com>
Committed: Thu May 28 21:47:48 2015 +0300

----------------------------------------------------------------------
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 112 ++++++++-----------
 .../processors/igfs/IgfsOneClientNodeTest.java  |   8 +-
 2 files changed, 47 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2bc07956/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 59e25fc..b5c9519 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
@@ -810,84 +810,61 @@ class ServerImpl extends TcpDiscoveryImpl {
             boolean retry = false;
             Collection<Exception> errs = new ArrayList<>();
 
-            for (int j = 2; --j >= 0;) {
-                for (InetSocketAddress addr : addrs) {
-                    Socket sock = null;
-                    Exception ex = null;
+            for (InetSocketAddress addr : addrs) {
+                try {
+                    Integer res = sendMessageDirectly(joinReq, addr);
 
-                    try {
-                        sock = spi.openSocket(addr);
-                    }
-                    catch (Exception e) {
-                        if (j > 0)
-                            continue;
+                    assert res != null;
 
-                        ex = e;
-                    }
+                    noResAddrs.remove(addr);
 
-                    if (ex == null) {
-                        try {
-                            Integer res = sendMessageDirectly(joinReq, addr, sock);
+                    // Address is responsive, reset period start.
+                    noResStart = 0;
 
-                            assert res != null;
+                    switch (res) {
+                        case RES_WAIT:
+                            // Concurrent startup, try sending join request again or wait
if no success.
+                            retry = true;
 
-                            noResAddrs.remove(addr);
+                            break;
+                        case RES_OK:
+                            if (log.isDebugEnabled())
+                                log.debug("Join request message has been sent to address
[addr=" + addr +
+                                    ", req=" + joinReq + ']');
 
-                            // Address is responsive, reset period start.
-                            noResStart = 0;
+                            // Join request sending succeeded, wait for response from topology.
+                            return true;
 
-                            switch (res) {
-                                case RES_WAIT:
-                                    // Concurrent startup, try sending join request again
or wait if no success.
+                        default:
+                            // Concurrent startup, try next node.
+                            if (res == RES_CONTINUE_JOIN) {
+                                if (!fromAddrs.contains(addr))
                                     retry = true;
+                            }
+                            else {
+                                if (log.isDebugEnabled())
+                                    log.debug("Unexpected response to join request: " + res);
 
-                                    break;
-                                case RES_OK:
-                                    if (log.isDebugEnabled())
-                                        log.debug("Join request message has been sent to
address [addr=" + addr +
-                                            ", req=" + joinReq + ']');
-
-                                    // Join request sending succeeded, wait for response
from topology.
-                                    return true;
-
-                                default:
-                                    // Concurrent startup, try next node.
-                                    if (res == RES_CONTINUE_JOIN) {
-                                        if (!fromAddrs.contains(addr))
-                                            retry = true;
-                                    }
-                                    else {
-                                        if (log.isDebugEnabled())
-                                            log.debug("Unexpected response to join request:
" + res);
-
-                                        retry = true;
-                                    }
-
-                                    break;
+                                retry = true;
                             }
-                        }
-                        catch (IgniteSpiException e) {
-                            e.printStackTrace();
 
-                            ex = e;
-                        }
+                            break;
                     }
+                }
+                catch (IgniteSpiException e) {
+                    errs.add(e);
 
-                    if (ex != null) {
-                        errs.add(ex);
-
-                        if (log.isDebugEnabled()) {
-                            IOException ioe = X.cause(ex, IOException.class);
-
-                            log.debug("Failed to send join request message [addr=" + addr
+
-                                ", msg=" + ioe != null ? ioe.getMessage() : ex.getMessage()
+ ']');
+                    if (log.isDebugEnabled()) {
+                        IOException ioe = X.cause(e, IOException.class);
 
-                            onException("Failed to send join request message [addr=" + addr
+
-                                ", msg=" + ioe != null ? ioe.getMessage() : ex.getMessage()
+ ']', ioe);
-                        }
+                        log.debug("Failed to send join request message [addr=" + addr +
+                            ", msg=" + (ioe != null ? ioe.getMessage() : e.getMessage())
+ ']');
 
-                        noResAddrs.add(addr);
+                        onException("Failed to send join request message [addr=" + addr +
+                            ", msg=" + (ioe != null ? ioe.getMessage() : e.getMessage())
+ ']', ioe);
                     }
+
+                    noResAddrs.add(addr);
                 }
             }
 
@@ -950,7 +927,7 @@ class ServerImpl extends TcpDiscoveryImpl {
      * @return Response read from the recipient or {@code null} if no response is supposed.
      * @throws IgniteSpiException If an error occurs.
      */
-    @Nullable private Integer sendMessageDirectly(TcpDiscoveryAbstractMessage msg, InetSocketAddress
addr, Socket sock)
+    @Nullable private Integer sendMessageDirectly(TcpDiscoveryAbstractMessage msg, InetSocketAddress
addr)
         throws IgniteSpiException {
         assert msg != null;
         assert addr != null;
@@ -972,11 +949,12 @@ class ServerImpl extends TcpDiscoveryImpl {
 
             boolean openSock = false;
 
+            Socket sock = null;
+
             try {
                 long tstamp = U.currentTimeMillis();
 
-                if (sock == null)
-                    sock = spi.openSocket(addr);
+                sock = spi.openSocket(addr);
 
                 openSock = true;
 
@@ -1060,8 +1038,6 @@ class ServerImpl extends TcpDiscoveryImpl {
             }
             finally {
                 U.closeQuiet(sock);
-
-                sock = null;
             }
         }
 
@@ -2718,7 +2694,7 @@ class ServerImpl extends TcpDiscoveryImpl {
 
             for (InetSocketAddress addr : spi.getNodeAddresses(node, U.sameMacs(locNode,
node))) {
                 try {
-                    sendMessageDirectly(msg, addr, null);
+                    sendMessageDirectly(msg, addr);
 
                     ex = null;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/2bc07956/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsOneClientNodeTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsOneClientNodeTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsOneClientNodeTest.java
index 49ddb03..3498cd9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsOneClientNodeTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsOneClientNodeTest.java
@@ -52,11 +52,9 @@ public class IgfsOneClientNodeTest extends GridCommonAbstractTest {
 
         cfg.setClientMode(true);
 
-        TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
-
-        discoSpi.setIpFinder(new TcpDiscoveryVmIpFinder(true));
-
-        cfg.setDiscoverySpi(discoSpi);
+        cfg.setDiscoverySpi(new TcpDiscoverySpi()
+            .setForceServerMode(true)
+            .setIpFinder(new TcpDiscoveryVmIpFinder(true)));
 
         FileSystemConfiguration igfsCfg = new FileSystemConfiguration();
 


Mime
View raw message