Github user squito commented on a diff in the pull request:
https://github.com/apache/spark/pull/6205#discussion_r32258055
--- Diff:
core/src/test/scala/org/apache/spark/rpc/akka/AkkaRpcEnvSuite.scala ---
@@ -47,4 +56,60 @@ class AkkaRpcEnvSuite extends RpcEnvSuite {
}
}
+ test("timeout on ask Future with RpcTimeout") {
+
+ class EchoActor(sleepDuration: Long) extends Actor {
+ def receive: Receive = {
+ case msg =>
+ Thread.sleep(sleepDuration)
+ sender() ! msg
+ }
+ }
+
+ val system = ActorSystem("EchoSystem")
+ val echoActor = system.actorOf(Props(new EchoActor(0)), name = "echo")
+ val sleepyActor = system.actorOf(Props(new EchoActor(50)), name =
"sleepy")
+
+ val shortProp = "spark.rpc.short.timeout"
+ val timeout = new RpcTimeout(10 millis, shortProp)
+
+ try {
+
+ // Ask with immediate response
+ var fut = echoActor.ask("hello")(timeout.duration).mapTo[String].
+ recover(timeout.addMessageIfTimeout)
+
+ // This should complete successfully
+ val result = timeout.awaitResult(fut)
+
+ assert(result.nonEmpty)
+
+ // Ask with delayed response
+ fut = sleepyActor.ask("goodbye")(timeout.duration).mapTo[String].
+ recover(timeout.addMessageIfTimeout)
+
+ // Allow future to complete with failure using plain Await.result,
this will return
+ // once the future is complete
+ val msg1 =
+ intercept[RpcTimeoutException] {
+ Await.result(fut, 200 millis)
--- End diff --
when creating your `ActorSystem` above, can you also pass in a config with
`log-dead-letters=off`? see
http://doc.akka.io/docs/akka/2.3.11/general/configuration.html
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]