Skip to content

Instantly share code, notes, and snippets.

@Mortimerp9
Created October 31, 2013 23:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mortimerp9/7258848 to your computer and use it in GitHub Desktop.
Save Mortimerp9/7258848 to your computer and use it in GitHub Desktop.
case object IdentifyTimeout
class MyActor extends Actor {
var driver: ActorRef = null
val identifyId = //get a unique identifyId for that driverUrl
override def preStart() {
val driverSel = context.actorSelection(driverUrl)
driverSel ! Identify(identifyId)
context.scheduler.scheduleOnce(10 seconds, self, IdentifyTimeout)
}
private def waitingForDriver: Receive = {
case IdentifyTimeout =>
// do something smart
//tell someone that we couldn't initialize in time
context stop(self)
case ActorIdentity(identifyId, Some(actorRef)) =>
val timeout = 100.millis
driver = context.actorOf(Props(classOf[ReliableProxy], actorRef, timeout))
driver ! RegisterExecutor(executorId, hostPort, cores)
context.system.eventStream.subscribe(self, classOf[RemotingLifecycleEvent])
context watch driver
context become mainReceive
}
private def mainReceive: Receive = {
// the current receive
}
override def receive = waitingForDriver
}
@Mortimerp9
Copy link
Author

some stuff for @squito working on spark internals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment