Merge pull request #887 from akka/wip-2732-getDefaultAddress-∂π

add ActorRefProvider.getDefaultAddress, see #2732
This commit is contained in:
Roland Kuhn 2012-11-26 05:16:03 -08:00
commit acc52ffd58
3 changed files with 22 additions and 10 deletions

View file

@ -42,8 +42,7 @@ trait ActorRefProvider {
def deadLetters: ActorRef
/**
* The root path for all actors within this actor system, including remote
* address if enabled.
* The root path for all actors within this actor system, not including any remote address information.
*/
def rootPath: ActorPath
@ -146,6 +145,11 @@ trait ActorRefProvider {
* attempt is made to verify actual reachability).
*/
def getExternalAddressFor(addr: Address): Option[Address]
/**
* Obtain the external address of the default transport.
*/
def getDefaultAddress: Address
}
/**
@ -317,6 +321,10 @@ private[akka] object SystemGuardian {
/**
* Local ActorRef provider.
*
* INTERNAL API!
*
* Depending on this class is not supported, only the [[ActorRefProvider]] interface is supported.
*/
class LocalActorRefProvider(
_systemName: String,
@ -597,4 +605,6 @@ class LocalActorRefProvider(
}
def getExternalAddressFor(addr: Address): Option[Address] = if (addr == rootPath.address) Some(addr) else None
def getDefaultAddress: Address = rootPath.address
}

View file

@ -237,7 +237,7 @@ trait ConsistentHashingLike { this: RouterConfig ⇒
}
val log = Logging(routeeProvider.context.system, routeeProvider.context.self)
val selfAddress = routeeProvider.context.system.asInstanceOf[ExtendedActorSystem].provider.rootPath.address
val selfAddress = routeeProvider.context.system.asInstanceOf[ExtendedActorSystem].provider.getDefaultAddress
val vnodes =
if (virtualNodesFactor == 0) routeeProvider.context.system.settings.DefaultVirtualNodesFactor
else virtualNodesFactor

View file

@ -14,6 +14,10 @@ import scala.util.control.NonFatal
/**
* Remote ActorRefProvider. Starts up actor on remote node and creates a RemoteActorRef representing it.
*
* INTERNAL API!
*
* Depending on this class is not supported, only the [[ActorRefProvider]] interface is supported.
*/
class RemoteActorRefProvider(
val systemName: String,
@ -32,9 +36,7 @@ class RemoteActorRefProvider(
private var _log = local.log
def log: LoggingAdapter = _log
@volatile
private var _rootPath = local.rootPath
override def rootPath: ActorPath = _rootPath
override def rootPath: ActorPath = local.rootPath
override def deadLetters: InternalActorRef = local.deadLetters
// these are only available after init()
@ -63,7 +65,7 @@ class RemoteActorRefProvider(
def init(system: ActorSystemImpl): Unit = {
local.init(system)
_remoteDaemon = new RemoteSystemDaemon(system, local.rootPath / "remote", rootGuardian, log, untrustedMode = remoteSettings.UntrustedMode)
_remoteDaemon = new RemoteSystemDaemon(system, rootPath / "remote", rootGuardian, log, untrustedMode = remoteSettings.UntrustedMode)
local.registerExtraNames(Map(("remote", remoteDaemon)))
_serialization = SerializationExtension(system)
@ -84,8 +86,6 @@ class RemoteActorRefProvider(
// this enables reception of remote requests
_transport.start()
_rootPath = RootActorPath(local.rootPath.address.copy(host = transport.address.host, port = transport.address.port))
val remoteClientLifeCycleHandler = system.systemActorOf(Props(new Actor {
def receive = {
case RemoteClientError(cause, remote, address) remote.shutdownClientConnection(address)
@ -201,8 +201,10 @@ class RemoteActorRefProvider(
}
}
def getDefaultAddress: Address = transport.address
private def isSelfAddress(address: Address): Boolean =
address == local.rootPath.address || address == rootPath.address || address == transport.address
address == rootPath.address || address == transport.address
}