You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/08/10 09:10:52 UTC

[GitHub] [ignite-3] sashapolo commented on a change in pull request #265: IGNITE-15275 Fix handshake operation

sashapolo commented on a change in pull request #265:
URL: https://github.com/apache/ignite-3/pull/265#discussion_r685803370



##########
File path: modules/core/src/test/java/org/apache/ignite/internal/testframework/IgniteTestUtils.java
##########
@@ -184,4 +185,29 @@ private static boolean hasCause(
 
         return false;
     }
+
+    /**
+     * Waits for the condition.
+     *
+     * @param cond Condition.
+     * @param timeout Timeout.
+     * @return {@code True} if the condition was satisfied within the timeout.
+     */
+    @SuppressWarnings("BusyWait") public static boolean waitForCondition(BooleanSupplier cond, long timeout) {
+        long stop = System.currentTimeMillis() + timeout;
+
+        while (System.currentTimeMillis() < stop) {
+            if (cond.getAsBoolean())
+                return true;
+
+            try {
+                sleep(50);
+            }
+            catch (InterruptedException e) {

Review comment:
       should we re-throw this exception instead?

##########
File path: modules/core/src/test/java/org/apache/ignite/internal/testframework/IgniteTestUtils.java
##########
@@ -184,4 +185,29 @@ private static boolean hasCause(
 
         return false;
     }
+
+    /**
+     * Waits for the condition.
+     *
+     * @param cond Condition.
+     * @param timeout Timeout.

Review comment:
       please specify the unit of the timeout value (I suggest to rename the parameter to `timeoutMillis`)

##########
File path: modules/network/src/integrationTest/java/org/apache/ignite/internal/network/recovery/RecoveryHandshakeTest.java
##########
@@ -138,6 +143,50 @@ public void testHandshakeFailsOnServerWhenClientResponded() throws Exception {
         from2to1.channel().closeFuture().get(3, TimeUnit.SECONDS);
     }
 
+    /**
+     * Tests that one server can handle multiple incoming connections and perform the handshake operation successfully.
+     *
+     * @throws Exception If failed.
+     */
+    @Test
+    public void testHandshakeWithMultipleClients() throws Exception {
+        ConnectionManager server = startManager(4000);
+
+        List<ConnectionManager> clients = new ArrayList<>();
+
+        int clientCount = 10;
+
+        for (int i = 0; i < clientCount; i++)
+            clients.add(startManager(4001 + i));
+
+        // A key is the client's consistent id, a value is the channel between the client and the server
+        Map<String, NettySender> channelsToServer = clients.stream().collect(
+            Collectors.toMap(
+                ConnectionManager::consistentId,
+                manager -> {
+                    try {

Review comment:
       I think this code will look better using a `for` loop




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org