He-Pin commented on code in PR #539:
URL: https://github.com/apache/incubator-pekko/pull/539#discussion_r1285184562


##########
multi-node-testkit/src/main/scala/org/apache/pekko/remote/testconductor/RemoteConnection.scala:
##########
@@ -94,44 +95,88 @@ private[pekko] case object Client extends Role
  */
 private[pekko] case object Server extends Role
 
+/**
+ * INTERNAL API.
+ */
+private[pekko] trait RemoteConnection {
+
+  /**
+   * The channel future associated with this connection.
+   */
+  def channelFuture: ChannelFuture
+
+  /**
+   * Shutdown the connection and release the resources.
+   */
+  def shutdown(): Unit
+}
+
 /**
  * INTERNAL API.
  */
 private[pekko] object RemoteConnection {
-  def apply(role: Role, sockaddr: InetSocketAddress, poolSize: Int, handler: 
ChannelUpstreamHandler): Channel = {
+  def apply(
+      role: Role,
+      sockaddr: InetSocketAddress,
+      poolSize: Int,
+      handler: ChannelInboundHandler): RemoteConnection = {
     role match {
       case Client =>
-        val socketfactory =
-          new NioClientSocketChannelFactory(Executors.newCachedThreadPool, 
Executors.newCachedThreadPool, poolSize)
-        val bootstrap = new ClientBootstrap(socketfactory)
-        bootstrap.setPipelineFactory(new TestConductorPipelineFactory(handler))
-        bootstrap.setOption("tcpNoDelay", true)
-        bootstrap.connect(sockaddr).getChannel
+        val bootstrap = new Bootstrap()
+        val eventLoopGroup = new NioEventLoopGroup(poolSize)
+        val cf = bootstrap
+          .group(eventLoopGroup)
+          .channel(classOf[NioSocketChannel])
+          .handler(new TestConductorPipelineFactory(handler))
+          .option[java.lang.Boolean](ChannelOption.TCP_NODELAY, true)
+          .option[java.lang.Boolean](ChannelOption.SO_KEEPALIVE, true)
+          .connect(sockaddr)
+        new RemoteConnection {
+          override def channelFuture: ChannelFuture = cf
+
+          override def shutdown(): Unit = {
+            try {
+              channelFuture.channel().close().sync()
+              eventLoopGroup.shutdownGracefully(1L, 1L, TimeUnit.SECONDS)

Review Comment:
   Noop, The reason it not working because of the `Player` not wanting the 
`Controller` started in the sbtMultiJvm. the old `shutdown` method is 
deprecated but still can be used. 



-- 
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