Merge branch 'master' into wip-2053d-actorbased-remote-drewhk

This commit is contained in:
Endre Sándor Varga 2012-11-21 11:44:39 +01:00
commit 0f0c5cb17a
160 changed files with 2071 additions and 1089 deletions

View file

@ -32,7 +32,9 @@ class RemoteActorRefProvider(
private var _log = local.log
def log: LoggingAdapter = _log
override def rootPath: ActorPath = local.rootPath
@volatile
private var _rootPath = local.rootPath
override def rootPath: ActorPath = _rootPath
override def deadLetters: InternalActorRef = local.deadLetters
// these are only available after init()
@ -61,14 +63,14 @@ class RemoteActorRefProvider(
def init(system: ActorSystemImpl): Unit = {
local.init(system)
_remoteDaemon = new RemoteSystemDaemon(system, rootPath / "remote", rootGuardian, log, untrustedMode = remoteSettings.UntrustedMode)
_remoteDaemon = new RemoteSystemDaemon(system, local.rootPath / "remote", rootGuardian, log, untrustedMode = remoteSettings.UntrustedMode)
local.registerExtraNames(Map(("remote", remoteDaemon)))
_serialization = SerializationExtension(system)
_transport = {
val fqn = remoteSettings.RemoteTransport
val args = Seq(
val args = List(
classOf[ExtendedActorSystem] -> system,
classOf[RemoteActorRefProvider] -> this)
@ -82,6 +84,11 @@ class RemoteActorRefProvider(
// this enables reception of remote requests
_transport.start()
//FIXME defaultaddress maybe?
_rootPath = RootActorPath(local.rootPath.address.copy(
host = transport.addresses.head.host,
port = transport.addresses.head.port))
val remoteClientLifeCycleHandler = system.systemActorOf(Props(new Actor {
def receive = {
case RemoteClientError(cause, remote, address) remote.shutdownClientConnection(address)
@ -154,7 +161,7 @@ class RemoteActorRefProvider(
Iterator(props.deploy) ++ deployment.iterator reduce ((a, b) b withFallback a) match {
case d @ Deploy(_, _, _, RemoteScope(addr))
if (addr == rootPath.address || transport.addresses(addr)) {
if (isSelfAddress(addr)) {
local.actorOf(system, props, supervisor, path, false, deployment.headOption, false, async)
} else {
val localAddress = transport.localAddressForRemote(addr)
@ -169,13 +176,15 @@ class RemoteActorRefProvider(
}
def actorFor(path: ActorPath): InternalActorRef =
if (path.address == rootPath.address || transport.addresses(path.address)) actorFor(rootGuardian, path.elements)
else new RemoteActorRef(this, transport, transport.localAddressForRemote(path.address), path, Nobody, props = None, deploy = None)
if (isSelfAddress(path.address)) actorFor(rootGuardian, path.elements)
else new RemoteActorRef(this, transport, transport.localAddressForRemote(path.address),
path, Nobody, props = None, deploy = None)
def actorFor(ref: InternalActorRef, path: String): InternalActorRef = path match {
case ActorPathExtractor(address, elems)
if (address == rootPath.address || transport.addresses(address)) actorFor(rootGuardian, elems)
else new RemoteActorRef(this, transport, transport.localAddressForRemote(address), new RootActorPath(address) / elems, Nobody, props = None, deploy = None)
if (isSelfAddress(address)) actorFor(rootGuardian, elems)
else new RemoteActorRef(this, transport, transport.localAddressForRemote(address),
new RootActorPath(address) / elems, Nobody, props = None, deploy = None)
case _ local.actorFor(ref, path)
}
@ -192,13 +201,16 @@ class RemoteActorRefProvider(
}
def getExternalAddressFor(addr: Address): Option[Address] = {
val ra = rootPath.address
addr match {
case a if (a eq ra) || transport.addresses(a) Some(rootPath.address)
case Address(_, _, Some(_), Some(_)) Some(transport.localAddressForRemote(addr))
case _ None
case _ if isSelfAddress(addr) Some(local.rootPath.address)
case Address("akka", _, Some(_), Some(_)) Some(transport.localAddressForRemote(addr))
case _ None
}
}
private def isSelfAddress(address: Address): Boolean =
address == local.rootPath.address || address == rootPath.address || transport.addresses(address)
}
private[akka] trait RemoteRef extends ActorRefScope {
@ -258,4 +270,4 @@ private[akka] class RemoteActorRef private[akka] (
@throws(classOf[java.io.ObjectStreamException])
private def writeReplace(): AnyRef = SerializedActorRef(path)
}
}