Akka:如何查找集群中的当前节点? [英] Akka: How to find the current nodes in a cluster?

查看:252
本文介绍了Akka:如何查找集群中的当前节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Akka演员中,你怎么能找到集群的节点?
也就是说,本地节点认为当前可以访问的节点。

From within an Akka actor, how can you find out the nodes of the cluster? That is, the nodes which the local node considers to be currently accessible.

谢谢,
- Daniel

Thanks, - Daniel

推荐答案

您实际上不需要订阅 ClusterDomainEvent MemberEvent 。您只需访问群集扩展的成员,例如

You actually do not need to subscribe to ClusterDomainEvent or MemberEvent. You can just access the state member of the Cluster extension, e.g.,

val cluster = akka.cluster.Cluster(context.system)

val members = cluster.state.members.filter(_.status == MemberStatus.Up)

这篇关于Akka:如何查找集群中的当前节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆