Huang-yi-3456 commented on a change in pull request #28002:
URL: https://github.com/apache/spark/pull/28002#discussion_r412459777
##########
File path: core/src/test/scala/org/apache/spark/rpc/netty/NettyRpcEnvSuite.scala
##########
@@ -135,4 +136,49 @@ class NettyRpcEnvSuite extends RpcEnvSuite with
MockitoSugar with TimeLimits {
anotherEnv.awaitTermination()
}
}
+
+
+ test("SPARK-31233: ask rpcEndpointRef in client mode timeout") {
+ var remoteRef: RpcEndpointRef = null
+ env.setupEndpoint("ask-remotely-server", new RpcEndpoint {
+ override val rpcEnv = env
+ override def receiveAndReply(context: RpcCallContext):
PartialFunction[Any, Unit] = {
+ case Register(ref) =>
+ remoteRef = ref
+ context.reply("okay")
+ case msg: String =>
+ context.reply(msg)
+ }
+ })
+ val conf = new SparkConf()
+ val anotherEnv = createRpcEnv(conf, "remote", 0, clientMode = true)
+ // Use anotherEnv to find out the RpcEndpointRef
+ val rpcEndpointRef = anotherEnv.setupEndpointRef(env.address,
"ask-remotely-server")
+ // Register a rpcEndpointRef in anotherEnv
+ val anotherRef = anotherEnv.setupEndpoint("receiver", new RpcEndpoint {
+ override val rpcEnv = anotherEnv
+ override def receiveAndReply(context: RpcCallContext):
PartialFunction[Any, Unit] = {
+ case _ =>
+ Thread.sleep(1200)
+ context.reply("okay")
+ }
+ })
+ try {
+ val reply = rpcEndpointRef.askSync[String](Register(anotherRef))
+ assert("okay" === reply)
+ val timeout = "1s"
+ val answer = remoteRef.ask[String]("msg",
+ RpcTimeout(conf, Seq("spark.rpc.askTimeout", "spark.network.timeout"),
timeout))
+ val thrown = intercept[RpcTimeoutException] {
+ ThreadUtils.awaitResult(answer, Duration(1300, MILLISECONDS))
+ }
+ val remoteAddr =
remoteRef.asInstanceOf[NettyRpcEndpointRef].client.getChannel.remoteAddress
+ val exptMsg = s"Cannot receive any reply from $remoteAddr in 1 second. "
+
Review comment:
thanks @srowen It is updated.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]