Terminate remote deployed actors when parent node goes down, see #2551
* RemoteSystemDaemon listens to AddressTerminated and stops matching children
This commit is contained in:
parent
d6e5b0a46b
commit
fd757fb680
1 changed files with 7 additions and 2 deletions
|
|
@ -5,7 +5,7 @@
|
|||
package akka.remote
|
||||
|
||||
import scala.annotation.tailrec
|
||||
import akka.actor.{ VirtualPathContainer, Terminated, Deploy, Props, Nobody, LocalActorRef, InternalActorRef, Address, ActorSystemImpl, ActorRef, ActorPathExtractor, ActorPath, Actor }
|
||||
import akka.actor.{ VirtualPathContainer, Terminated, Deploy, Props, Nobody, LocalActorRef, InternalActorRef, Address, ActorSystemImpl, ActorRef, ActorPathExtractor, ActorPath, Actor, AddressTerminated }
|
||||
import akka.event.LoggingAdapter
|
||||
import akka.dispatch.Watch
|
||||
import akka.actor.ActorRefWithCell
|
||||
|
|
@ -26,9 +26,11 @@ private[akka] class RemoteSystemDaemon(system: ActorSystemImpl, _path: ActorPath
|
|||
|
||||
import akka.actor.Guardian._
|
||||
|
||||
@volatile private var terminating = false
|
||||
|
||||
system.provider.systemGuardian.tell(RegisterTerminationHook, this)
|
||||
|
||||
@volatile private var terminating = false
|
||||
system.eventStream.subscribe(this, classOf[AddressTerminated])
|
||||
|
||||
/**
|
||||
* Find the longest matching path which we know about and return that ref
|
||||
|
|
@ -89,6 +91,9 @@ private[akka] class RemoteSystemDaemon(system: ActorSystemImpl, _path: ActorPath
|
|||
terminationHookDoneWhenNoChildren()
|
||||
allChildren foreach system.stop
|
||||
|
||||
case AddressTerminated(address) ⇒
|
||||
allChildren filter { _.asInstanceOf[InternalActorRef].getParent.path.address == address } foreach system.stop
|
||||
|
||||
case unknown ⇒ log.warning("Unknown message {} received by {}", unknown, this)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue