0

为了可扩展性,我希望 Map actor 实例(mapActor如下命名)分布在多个远程节点上,比如host1,host2host3. 我不确定如何在 Akka 中做到这一点, application.conf例如

MapReduceSystem {
  include "common"
  akka {
    actor {
      deployment {
        /mapActor {
          router = round-robin
          nr-of-instances = 48
          remote = "akka.tcp://MapReduceSystem@host1:2552,akka.tcp://MapReduceSystem@host2:2552,akka.tcp://MapReduceSystem@host3:2552" 
        }
        /reduceActor {
          remote = "akka.tcp://MapReduceSystem@host1:2552"
          router = round-robin
          nr-of-instances = 1
        }
        /masterActor {
          remote = "akka.tcp://MapReduceSystem@host1:2552"
          nr-of-instances = 1
        }
      }
    }
    remote.enabled-transports = ["akka.remote.netty.tcp"]
    remote.netty.tcp.hostname = "host1"
  }
}

为了完整起见,这是我的common.conf

akka {
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }
  remote.netty.tcp.port = 0
  remote.log-remote-lifecycle-events = off
  loggers = ["akka.event.slf4j.Slf4jLogger"]
  loglevel = "DEBUG"
}  

请注意mapActor我想提供 3 个主机来创建此 Actor 的实例的定义,每个实例 16 个,但remote参数只接受一个主机。我怎样才能做到这一点?

据我了解,此配置将对应于系统启动机器,配置在andhost1上看起来如何?host2host3

4

2 回答 2

2

文档

akka {
  actor {
    deployment {
     /serviceA/aggregation {
       router = "round-robin"
       nr-of-instances = 10
       target {
         nodes = ["akka.tcp://app@10.0.0.2:2552", "akka.tcp://app@10.0.0.3:2552"]
       }
      }
    }
  }
}

所以不是remote = "a,b,c"你需要target.nodes = ["a","b","c"]

于 2013-10-23T14:41:21.170 回答
2

host1除了 pushy 指出的配置语法问题之外,除了在启动系统时和host2之前启动系统之外,您不需要做任何事情,host1以便在/user/mapActor启动时它的路由可以成功部署到它们上。配置从其他主机获取host1并传输到其他主机,不需要进一步的配置,也不actorOf需要在工作主机上进行调用(至少对于正在讨论的路由器而言)。

于 2013-10-23T19:11:21.903 回答