2

我想知道是否有办法获取远程 akka 演员的 ip 地址,因为目前我正在使用广播 ip 地址来设置演员系统(这是唯一一个似乎有效的方法)。我目前能够看到演员路径,但我想确切地知道它所在的机器,因为广播 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"
    ...
}
4

1 回答 1

4

采用actorRef.path.address.host

于 2012-09-07T00:13:35.130 回答