IGNITE-8944 TcpDiscoverySpi: set connection check frequency to fixed value. - Fixes #4320.
Signed-off-by: Alexey Kuznetsov <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/8d75ebf9 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/8d75ebf9 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/8d75ebf9 Branch: refs/heads/ignite-8446 Commit: 8d75ebf9c7c4933185eb428a5a42dce5f241be5c Parents: 225ebac Author: dkarachentsev <[email protected]> Authored: Wed Jul 25 19:51:15 2018 +0700 Committer: Alexey Kuznetsov <[email protected]> Committed: Wed Jul 25 19:51:15 2018 +0700 ---------------------------------------------------------------------- .../ignite/spi/discovery/tcp/ServerImpl.java | 31 +++++++------------- .../spi/discovery/tcp/TcpDiscoverySpiMBean.java | 2 +- .../TcpDiscoverySpiFailureTimeoutSelfTest.java | 4 +-- 3 files changed, 14 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/8d75ebf9/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 1bfa467..4ba071c 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 @@ -184,6 +184,9 @@ class ServerImpl extends TcpDiscoveryImpl { /** */ private static final int ENSURED_MSG_HIST_SIZE = getInteger(IGNITE_DISCOVERY_CLIENT_RECONNECT_HISTORY_SIZE, 512); + /** When this interval pass connection check will be performed. */ + private static final int CON_CHECK_INTERVAL = 500; + /** */ private IgniteThreadPoolExecutor utilityPool; @@ -317,7 +320,7 @@ class ServerImpl extends TcpDiscoveryImpl { /** {@inheritDoc} */ @Override public long connectionCheckInterval() { - return msgWorker.connCheckFreq; + return CON_CHECK_INTERVAL; } /** {@inheritDoc} */ @@ -2633,9 +2636,6 @@ class ServerImpl extends TcpDiscoveryImpl { /** Flag that keeps info on whether the threshold is reached or not. */ private boolean failureThresholdReached; - /** Connection check frequency. */ - private long connCheckFreq; - /** Connection check threshold. */ private long connCheckThreshold; @@ -2649,7 +2649,7 @@ class ServerImpl extends TcpDiscoveryImpl { super("tcp-disco-msg-worker", log, 10, spi.ignite() instanceof IgniteEx ? ((IgniteEx)spi.ignite()).context().workersRegistry() : null); - initConnectionCheckFrequency(); + initConnectionCheckThreshold(); } /** @@ -2741,23 +2741,14 @@ class ServerImpl extends TcpDiscoveryImpl { /** * Initializes connection check frequency. Used only when failure detection timeout is enabled. */ - private void initConnectionCheckFrequency() { + private void initConnectionCheckThreshold() { if (spi.failureDetectionTimeoutEnabled()) connCheckThreshold = spi.failureDetectionTimeout(); else connCheckThreshold = Math.min(spi.getSocketTimeout(), spi.metricsUpdateFreq); - for (int i = 3; i > 0; i--) { - connCheckFreq = connCheckThreshold / i; - - if (connCheckFreq > 10) - break; - } - - assert connCheckFreq > 0; - if (log.isInfoEnabled()) - log.info("Connection check frequency is calculated: " + connCheckFreq); + log.info("Connection check threshold is calculated: " + connCheckThreshold); } /** @@ -5705,7 +5696,7 @@ class ServerImpl extends TcpDiscoveryImpl { if (log.isInfoEnabled()) log.info("Local node seems to be disconnected from topology (failure detection timeout " + "is reached) [failureDetectionTimeout=" + spi.failureDetectionTimeout() + - ", connCheckFreq=" + connCheckFreq + ']'); + ", connCheckInterval=" + CON_CHECK_INTERVAL + ']'); failureThresholdReached = true; @@ -5713,7 +5704,7 @@ class ServerImpl extends TcpDiscoveryImpl { lastTimeConnCheckMsgSent = 0; } - long elapsed = (lastTimeConnCheckMsgSent + connCheckFreq) - U.currentTimeMillis(); + long elapsed = (lastTimeConnCheckMsgSent + CON_CHECK_INTERVAL) - U.currentTimeMillis(); if (elapsed > 0) return; @@ -6056,7 +6047,7 @@ class ServerImpl extends TcpDiscoveryImpl { long now = U.currentTimeMillis(); // We got message from previous in less than double connection check interval. - boolean ok = rcvdTime + msgWorker.connCheckFreq * 2 >= now; + boolean ok = rcvdTime + CON_CHECK_INTERVAL * 2 >= now; if (ok) { // Check case when previous node suddenly died. This will speed up @@ -6100,7 +6091,7 @@ class ServerImpl extends TcpDiscoveryImpl { if (log.isInfoEnabled()) { log.info("Previous node alive: [alive=" + ok + ", lastMessageReceivedTime=" - + rcvdTime + ", now=" + now + ", connCheckFreq=" + msgWorker.connCheckFreq + ']'); + + rcvdTime + ", now=" + now + ", connCheckInterval=" + CON_CHECK_INTERVAL + ']'); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/8d75ebf9/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java index cf64926..9cd03c2 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiMBean.java @@ -58,7 +58,7 @@ public interface TcpDiscoverySpiMBean extends IgniteSpiManagementMBean, Discover /** * Gets connection check interval in ms. * - * @return Number of connection attempts. + * @return Connection check interval. */ @MXBeanDescription("Connection check interval.") public long getConnectionCheckInterval(); http://git-wip-us.apache.org/repos/asf/ignite/blob/8d75ebf9/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java index cb5e84b..b6759e6 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpiFailureTimeoutSelfTest.java @@ -194,8 +194,8 @@ public class TcpDiscoverySpiFailureTimeoutSelfTest extends AbstractDiscoverySelf int sent = firstSpi().connCheckStatusMsgCntSent; int received = nextSpi.connCheckStatusMsgCntReceived; - assert sent >= 3 && sent < 7 : "messages sent: " + sent; - assert received >= 3 && received < 7 : "messages received: " + received; + assert sent >= 15 && sent < 25 : "messages sent: " + sent; + assert received >= 15 && received < 25 : "messages received: " + received; } finally { firstSpi().resetState();
