我想知道是否有办法获取远程akka actor的ip地址,因为目前我正在使用广播ip地址来设置actor系统(这是唯一一个似乎可行的)。我目前能够看到演员路径,但是想知道它所居住的机器,因为广播IP是针对网络的。
以下是我对主演员的一些代码:
# remote actor config
remotecreation{ #user defined name for the configuration
include "common"
akka {
actor{
deployment{
/remoteActor{ #Specifically has to be the name of the remote actor
router = "round-robin"
nr-of-instances = 10
target {
nodes = ["akka://RemoteCreation@172.17.100.232:2554", "akka://RemoteCreation@172.17.100.224:2554"]
}
}
}
}
remote.netty.port = 2554
}
remote{
log-received-messages = on
log-sent-messages = on
}
}
这是主要定义:
class Master(goodies: AuthNetActorObject) extends Actor {
var start: Long = _ // helps measure the calculation time
def receive = {
case "start" => {
System.out.println("Master Started!")
System.out.println("The master is at: " + self.path.toString())
...
}
}
}
这是我初始化和轰炸演员的地方:
object Payment extends Controller {
var goodies: AuthNetActorObject = null
val system = ActorSystem("RemoteCreation",ConfigFactory.load.getConfig("remotecreation"))
...
val master = system.actorOf(Props(new Master(actorObject)))
master ! "start"
...
}
答案 0 :(得分:4)
使用actorRef.path.address.host