TOP

Akka(10): 分布式运算:集群-Cluster(七)
2017-10-09 13:50:40 】 浏览:10563
Tags:Akka 分布式 运算 集群 -Cluster

g.info(
"Member is Removed: {} after {}", member.address, previousStatus) case UnreachableMember(member) => log.info("Member detected as unreachable: {}", member) cluster.down(member.address) //手工驱除,不用auto-down case _: MemberEvent => // ignore } } object ClusterEventsDemo { def main(args: Array[String]): Unit = { //重设port,seed-node-address val port = if (args.isEmpty) "0" else args(0) val addr = if (args.length < 2) "2551" else args(1) val seednodeSetting = "akka.cluster.seed-nodes = ["+ "\"akka.tcp://clusterSystem@127.0.0.1:"+ s"${addr}"+"\"]" val config = ConfigFactory.parseString(s"akka.remote.netty.tcp.port = ${port}") .withFallback(ConfigFactory.parseString(seednodeSetting)) .withFallback(ConfigFactory.load("cluster.conf")) val clusterSystem = ActorSystem(name="clusterSystem",config=config) val eventListener = clusterSystem.actorOf(Props[EventLisener],"eventListener") val cluster = Cluster(clusterSystem) cluster.registerOnMemberRemoved(println("Leaving cluster. I should cleanup... ")) cluster.registerOnMemberUp(println("Hookup to cluster. Do some setups ...")) println("actor system started!") scala.io.StdIn.readLine() clusterSystem.terminate() } }

 

 

 

 

 

 

 

 

 

 


Akka(10): 分布式运算:集群-Cluster(七) https://www.cppentry.com/bencandy.php?fid=90&id=124492

首页 上一页 4 5 6 7 下一页 尾页 7/7/7
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Akka(9): 分布式运算:Remotin.. 下一篇Akka(12): 分布式运算:Cluste..