Akka: How to find the current nodes in a cluster?

akka, cluster-computing, distributed-computing, java, scala

Solution

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)

Problem

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. Thanks, - Daniel

Original source