#19192 Cluster extension helper to get full path of an actor ref

This commit is contained in:
Balazs Kossovics 2015-12-15 22:31:50 +01:00 committed by Roland Kuhn
parent f77fd82b10
commit 9d71142748
2 changed files with 21 additions and 0 deletions

View file

@ -356,6 +356,20 @@ class Cluster(val system: ExtendedActorSystem) extends Extension {
else
clusterDaemons ! InternalClusterAction.AddOnMemberRemovedListener(callback)
}
/**
* Generate the remote actor path by replacing the Address in the RootActor Path for the given
* ActorRef with the cluster's `selfAddress`, unless address' host is already defined
*/
def remotePathOf(actorRef: ActorRef): ActorPath = {
val path = actorRef.path
if (path.address.host.isDefined) {
path
} else {
path.root.copy(selfAddress) / path.elements withUid path.uid
}
}
// ========================================================
// ===================== INTERNAL API =====================
// ========================================================