ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: # IGNITE-709 Use joinTimeout instead of openConnTimeout.
Date Fri, 08 May 2015 15:29:58 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-709_2 c4eab3c26 -> 28498e99b


# IGNITE-709 Use joinTimeout instead of openConnTimeout.


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

Branch: refs/heads/ignite-709_2
Commit: 28498e99bafbd167257fd1cf836cde7902b8aa51
Parents: c4eab3c
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Fri May 8 18:29:35 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Fri May 8 18:29:35 2015 +0300

----------------------------------------------------------------------
 .../discovery/tcp/TcpClientDiscoverySpi.java    | 28 ++------------
 .../spi/discovery/tcp/TcpDiscoverySpi.java      | 31 ----------------
 .../discovery/tcp/TcpDiscoverySpiAdapter.java   | 39 ++++++++++++++++++++
 .../tcp/TcpClientDiscoverySelfTest.java         | 11 +++++-
 .../TcpClientDiscoverySpiConfigSelfTest.java    |  2 +-
 5 files changed, 53 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/28498e99/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 2513298..6752bf5 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
@@ -60,9 +60,6 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements
Tcp
     /** Default disconnect check interval. */
     public static final long DFLT_DISCONNECT_CHECK_INT = 2000;
 
-    /** Default open connection. */
-    public static final long DFLT_OPEN_CONN_TIMEOUT = 5000;
-
     /** */
     private static final Object JOIN_TIMEOUT = "JOIN_TIMEOUT";
 
@@ -109,9 +106,6 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements
Tcp
     private final Timer timer = new Timer("TcpClientDiscoverySpi.timer");
 
     /** */
-    private long openConnTimeout = DFLT_OPEN_CONN_TIMEOUT;
-
-    /** */
     private MessageWorker msgWorker;
 
     /** {@inheritDoc} */
@@ -144,20 +138,6 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements
Tcp
         return netTimeout;
     }
 
-    /**
-     * @return Timeout for opening socket.
-     */
-    public long getOpenConnectionTimeout() {
-        return openConnTimeout;
-    }
-
-    /**
-     * @param openConnTimeout Timeout for opening socket
-     */
-    public void setOpenConnectionTimeout(long openConnTimeout) {
-        this.openConnTimeout = openConnTimeout;
-    }
-
     /** {@inheritDoc} */
     @Override public int getThreadPriority() {
         return threadPri;
@@ -233,7 +213,7 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements
Tcp
         assertParameter(ackTimeout > 0, "ackTimeout > 0");
         assertParameter(hbFreq > 0, "heartbeatFreq > 0");
         assertParameter(threadPri > 0, "threadPri > 0");
-        assertParameter(openConnTimeout > 0, "openConnectionTimeout > 0");
+        assertParameter(joinTimeout >= 0, "joinTimeout >= 0");
 
         try {
             locHost = U.resolveLocalHost(locAddr);
@@ -430,7 +410,7 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements
Tcp
 
     /**
      * @return Opened socket or {@code null} if timeout.
-     * @see #openConnTimeout
+     * @see #joinTimeout
      */
     @SuppressWarnings("BusyWait")
     @Nullable private Socket joinTopology(boolean recon) throws IgniteSpiException, InterruptedException
{
@@ -452,7 +432,7 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements
Tcp
                 else {
                     U.warn(log, "No addresses registered in the IP finder (will retry in
2000ms): " + ipFinder);
 
-                    if ((U.currentTimeMillis() - startTime) > openConnTimeout)
+                    if ((U.currentTimeMillis() - startTime) > joinTimeout)
                         return null;
 
                     Thread.sleep(2000);
@@ -526,7 +506,7 @@ public class TcpClientDiscoverySpi extends TcpDiscoverySpiAdapter implements
Tcp
                 U.warn(log, "Failed to connect to any address from IP finder (will retry
to join topology " +
                     "in 2000ms): " + addrs0);
 
-                if ((U.currentTimeMillis() - startTime) > openConnTimeout)
+                if ((U.currentTimeMillis() - startTime) > joinTimeout)
                     return null;
 
                 Thread.sleep(2000);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/28498e99/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 c1b60a7..3624791 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
@@ -152,9 +152,6 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements
TcpDiscov
     /** Default local port range (value is <tt>100</tt>). */
     public static final int DFLT_PORT_RANGE = 100;
 
-    /** Default timeout for joining topology (value is <tt>0</tt>). */
-    public static final long DFLT_JOIN_TIMEOUT = 0;
-
     /** Default reconnect attempts count (value is <tt>10</tt>). */
     public static final int DFLT_RECONNECT_CNT = 10;
 
@@ -192,10 +189,6 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements
TcpDiscov
     /** Maximum message acknowledgement timeout. */
     private long maxAckTimeout = DFLT_MAX_ACK_TIMEOUT;
 
-    /** Join timeout. */
-    @SuppressWarnings("RedundantFieldInitialization")
-    private long joinTimeout = DFLT_JOIN_TIMEOUT;
-
     /** Max heartbeats count node can miss without initiating status check. */
     private int maxMissedHbs = DFLT_MAX_MISSED_HEARTBEATS;
 
@@ -367,30 +360,6 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements
TcpDiscov
     }
 
     /** {@inheritDoc} */
-    @Override public long getJoinTimeout() {
-        return joinTimeout;
-    }
-
-    /**
-     * Sets join timeout.
-     * <p>
-     * If non-shared IP finder is used and node fails to connect to
-     * any address from IP finder, node keeps trying to join within this
-     * timeout. If all addresses are still unresponsive, exception is thrown
-     * and node startup fails.
-     * <p>
-     * If not specified, default is {@link #DFLT_JOIN_TIMEOUT}.
-     *
-     * @param joinTimeout Join timeout ({@code 0} means wait forever).
-     *
-     * @see TcpDiscoveryIpFinder#isShared()
-     */
-    @IgniteSpiConfiguration(optional = true)
-    public void setJoinTimeout(long joinTimeout) {
-        this.joinTimeout = joinTimeout;
-    }
-
-    /** {@inheritDoc} */
     @Override public int getLocalPort() {
         TcpDiscoveryNode locNode0 = locNode;
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/28498e99/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
index 3133169..ac925d2 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiAdapter.java
@@ -60,6 +60,9 @@ abstract class TcpDiscoverySpiAdapter extends IgniteSpiAdapter implements
Discov
     /** Default network timeout in milliseconds (value is <tt>5,000ms</tt>).
*/
     public static final long DFLT_NETWORK_TIMEOUT = 5000;
 
+    /** Default timeout for joining topology (value is <tt>0</tt>). */
+    public static final long DFLT_JOIN_TIMEOUT = 0;
+
     /** Default value for thread priority (value is <tt>10</tt>). */
     public static final int DFLT_THREAD_PRI = 10;
 
@@ -93,6 +96,10 @@ abstract class TcpDiscoverySpiAdapter extends IgniteSpiAdapter implements
Discov
     /** Network timeout. */
     protected long netTimeout = DFLT_NETWORK_TIMEOUT;
 
+    /** Join timeout. */
+    @SuppressWarnings("RedundantFieldInitialization")
+    protected long joinTimeout = DFLT_JOIN_TIMEOUT;
+
     /** Thread priority for all threads started by SPI. */
     protected int threadPri = DFLT_THREAD_PRI;
 
@@ -249,6 +256,38 @@ abstract class TcpDiscoverySpiAdapter extends IgniteSpiAdapter implements
Discov
     }
 
     /**
+     * Join timeout.
+     * <p>
+     * If non-shared IP finder is used and node fails to connect to
+     * any address from IP finder, node keeps trying to join within this
+     * timeout. If all addresses are still unresponsive, exception is thrown
+     * and node startup fails.
+     * @return Join timeout in milliseconds, ({@code 0} means wait forever).
+     */
+    public long getJoinTimeout() {
+        return joinTimeout;
+    }
+
+    /**
+     * Sets join timeout.
+     * <p>
+     * If non-shared IP finder is used and node fails to connect to
+     * any address from IP finder, node keeps trying to join within this
+     * timeout. If all addresses are still unresponsive, exception is thrown
+     * and node startup fails.
+     * <p>
+     * If not specified, default is {@link #DFLT_JOIN_TIMEOUT}.
+     *
+     * @param joinTimeout Join timeout ({@code 0} means wait forever).
+     *
+     * @see TcpDiscoveryIpFinder#isShared()
+     */
+    @IgniteSpiConfiguration(optional = true)
+    public void setJoinTimeout(long joinTimeout) {
+        this.joinTimeout = joinTimeout;
+    }
+
+    /**
      * Sets thread priority. All threads within SPI will be started with it.
      * <p>
      * If not provided, default value is {@link #DFLT_THREAD_PRI}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/28498e99/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySelfTest.java
index 15d9c64..2a123ce 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySelfTest.java
@@ -94,6 +94,9 @@ public class TcpClientDiscoverySelfTest extends GridCommonAbstractTest {
     /** */
     private TcpDiscoveryVmIpFinder clientIpFinder;
 
+    /** */
+    private long joinTimeout = TcpClientDiscoverySpi.DFLT_JOIN_TIMEOUT;
+
     /** {@inheritDoc} */
     @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
         IgniteConfiguration cfg = super.getConfiguration(gridName);
@@ -110,6 +113,8 @@ public class TcpClientDiscoverySelfTest extends GridCommonAbstractTest
{
         else if (gridName.startsWith("client")) {
             TcpClientDiscoverySpi disco = new TestTcpClientDiscovery();
 
+            disco.setJoinTimeout(joinTimeout);
+
             TcpDiscoveryVmIpFinder ipFinder;
 
             if (clientIpFinder != null)
@@ -166,6 +171,7 @@ public class TcpClientDiscoverySelfTest extends GridCommonAbstractTest
{
 
         nodeId = null;
         clientIpFinder = null;
+        joinTimeout = TcpClientDiscoverySpi.DFLT_JOIN_TIMEOUT;
 
         assert G.allGrids().isEmpty();
     }
@@ -174,8 +180,9 @@ public class TcpClientDiscoverySelfTest extends GridCommonAbstractTest
{
      *
      * @throws Exception
      */
-    public void testNodeJoinedTimeout() throws Exception {
+    public void testJoinTimeout() throws Exception {
         clientIpFinder = new TcpDiscoveryVmIpFinder();
+        joinTimeout = 1000;
 
         try {
             startClientNodes(1);
@@ -670,7 +677,7 @@ public class TcpClientDiscoverySelfTest extends GridCommonAbstractTest
{
     /**
      * @throws Exception If any error occurs.
      */
-    public void testJoinTimeout() throws Exception {
+    public void testTimeoutWaitingNodeAddedMessage() throws Exception {
         startServerNodes(2);
 
         final CountDownLatch cnt = new CountDownLatch(1);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/28498e99/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiConfigSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiConfigSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiConfigSelfTest.java
index 6dbd34e..3e8b231 100644
--- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiConfigSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpClientDiscoverySpiConfigSelfTest.java
@@ -34,6 +34,6 @@ public class TcpClientDiscoverySpiConfigSelfTest extends GridSpiAbstractConfigTe
         checkNegativeSpiProperty(new TcpClientDiscoverySpi(), "ackTimeout", 0);
         checkNegativeSpiProperty(new TcpClientDiscoverySpi(), "heartbeatFrequency", 0);
         checkNegativeSpiProperty(new TcpClientDiscoverySpi(), "threadPriority", -1);
-        checkNegativeSpiProperty(new TcpClientDiscoverySpi(), "openConnectionTimeout", 0);
+        checkNegativeSpiProperty(new TcpClientDiscoverySpi(), "joinTimeout", -1);
     }
 }


Mime
View raw message