dongjoon-hyun commented on a change in pull request #28002: [SPARK-31233][Core] 
Enhance RpcTimeoutException Log Message
URL: https://github.com/apache/spark/pull/28002#discussion_r401947033
 
 

 ##########
 File path: core/src/test/scala/org/apache/spark/rpc/RpcEnvSuite.scala
 ##########
 @@ -190,6 +190,47 @@ abstract class RpcEnvSuite extends SparkFunSuite with 
BeforeAndAfterAll {
     }
   }
 
+  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 answer = remoteRef.ask[String]("msg",
+        RpcTimeout(conf, Seq("spark.rpc.askTimeout", "spark.network.timeout"), 
"1s"))
+      val thrown = intercept[Exception] {
+        ThreadUtils.awaitResult(answer, Duration(1300, MILLISECONDS))
+      }
+      assert(thrown.getClass.equals(classOf[RpcTimeoutException]))
 
 Review comment:
   It seems that you can remove this if you do 
https://github.com/apache/spark/pull/28002/files#r401946844 .

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


With regards,
Apache Git Services

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

Reply via email to