mdedetrich commented on code in PR #539:
URL: https://github.com/apache/incubator-pekko/pull/539#discussion_r1285185177


##########
project/SbtMultiJvm.scala:
##########
@@ -372,11 +374,41 @@ object MultiJvmPlugin extends AutoPlugin {
         val connectInput = input && index == 0
         log.debug("Starting %s for %s".format(jvmName, testClass))
         log.debug("  with JVM options: %s".format(allJvmOptions.mkString(" ")))
-        (testClass, Jvm.startJvm(javaBin, allJvmOptions, runOptions, 
jvmLogger, connectInput))
+        val testClass2Process = (testClass, Jvm.startJvm(javaBin, 
allJvmOptions, runOptions, jvmLogger, connectInput))
+        if (index == 0) {
+          log.debug("%s for %s 's started as `Controller`, waiting before can 
be connected for clients.".format(jvmName,
+            testClass))
+          val controllerHost = hosts.head
+          val serverPort: Int = Integer.getInteger("multinode.server-port", 
4711)
+          waitingBeforeConnectable(controllerHost, serverPort, 
TimeUnit.SECONDS.toMillis(20L))
+        }
+        testClass2Process
     }
     processExitCodes(name, processes, log)
   }
 
+  private def waitingBeforeConnectable(host: String, port: Int, 
timeoutInMillis: Long): Unit = {
+    val inetSocketAddress = new InetSocketAddress(host, port)
+    def telnet(addr: InetSocketAddress, timeout: Int): Boolean = {
+      val socket: Socket = new Socket()
+      try {
+        socket.connect(inetSocketAddress, timeout)
+        socket.isConnected
+      } catch {
+        case _: Exception => false
+      } finally {
+        socket.close()
+      }
+    }
+
+    val startTime = System.currentTimeMillis()
+    var connectivity = false
+    while (!connectivity && (System.currentTimeMillis() - startTime < 
timeoutInMillis)) {

Review Comment:
   I will resolve this for now, I don't want to block the PR because of this 
and if people have issues we can always update this later (its just tests)



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to