Skip to content

Commit

Permalink
GG-21206 fix ringLatencyCheck loop (apache#266)
Browse files Browse the repository at this point in the history
* GG-21206 fix ringLatencyCheck if there is only one server node with clients in topology
* GG-21206 Improve test and code style fixes.
  • Loading branch information
iakkuratov authored Jul 31, 2019
1 parent 16d19a9 commit 1f70b22
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 1f70b22

Please sign in to comment.