From 1f70b2206df6d18d49343e5af0024ac6249e9fe4 Mon Sep 17 00:00:00 2001 From: iakkuratov <38322509+iakkuratov@users.noreply.github.com> Date: Wed, 31 Jul 2019 06:44:01 +0300 Subject: [PATCH] GG-21206 fix ringLatencyCheck loop (#266) * GG-21206 fix ringLatencyCheck if there is only one server node with clients in topology * GG-21206 Improve test and code style fixes. --- .../ignite/spi/discovery/tcp/ServerImpl.java | 2 +- .../discovery/tcp/TcpDiscoverySelfTest.java | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) 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 a5c1fbc25c717..c377f192d12a0 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 @@ -5110,7 +5110,7 @@ private void processRingLatencyCheckMessage(TcpDiscoveryRingLatencyCheckMessage if (log.isInfoEnabled()) log.info("Latency check processing: " + msg.id()); - if (sendMessageToRemotes(msg)) + if (ring.hasRemoteServerNodes()) sendMessageAcrossRing(msg); else { if (log.isInfoEnabled()) diff --git a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java index 4109716be4920..c771a6cb1558e 100644 --- a/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySelfTest.java @@ -89,6 +89,8 @@ import org.apache.ignite.spi.discovery.tcp.messages.TcpDiscoveryNodeLeftMessage; import org.apache.ignite.testframework.GridStringLogger; import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.ListeningTestLogger; +import org.apache.ignite.testframework.LogListener; import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -2250,6 +2252,36 @@ public void testFailedNodeRestoreConnection() throws Exception { } } + /** + * @throws Exception If failed. + */ + @Test + public void testCheckRingLatency() throws Exception { + int hops = 1; + + ListeningTestLogger testLog = new ListeningTestLogger(false, log); + + // We should discard ring check latency on server node. + LogListener lsnr = LogListener.matches("Latency check has been discarded").times(hops).build(); + + testLog.registerListener(lsnr); + + try { + IgniteEx node = startGrid(getConfiguration("server").setGridLogger(testLog)); + + startGrid(getConfiguration("client").setClientMode(true)); + + TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi)node.context().discovery().getInjectedDiscoverySpi(); + + discoverySpi.impl.checkRingLatency(hops); + + assertTrue("Check ring latency message wasn't discarded", lsnr.check(1000)); + } + finally { + stopAllGrids(); + } + } + /** * @param nodeName Node name. * @throws Exception If failed.