apache/incubator-spark — pull request #336 by liancheng (2014-01-06 01:28:53+00:00)
Title: Get rid of `Either[ActorRef, ActorSelection]'

Although we can send messages via an `ActorSelection`, it would be better to identify the actor and obtain an `ActorRef` first, so that we can:

1. get informed earlier if the remote actor doesn't exist,
1. obtain better message passing performance (every message sent via an `ActorSelection` involves a remote actor path lookup),
1. get rid of the annoying `Either` wrapper.

In this pull request, instead of returning an `Either[ActorRef, ActorSelection]`, `registerOrLookup` identifies the remote actor blockingly to obtain an `ActorRef`, or throws an exception if the remote actor doesn't exist or the lookup times out (configured by `spark.akka.lookupTimeout`). This function is only called when an `SparkEnv` is constructed (instantiating driver or executor), so the blocking call is considered acceptable.