Reputation: 447
With akka cluster, is it possible to query what members are currently in the cluster? If the seed node goes down, and eventually comes back up, could it find out what other members are using it as the seed node?
Upvotes: 0
Views: 305
Reputation: 7247
You can get a snapshot of the current cluster members like this:
val system = ActorSystem(...) // whatever
val members = Cluster(system).state.members
But this could be out of date. If you need to track cluster membership you should subscribe to cluster events.
val monitor = system.actorOf(Props[MyClusterMonitor])
Cluster(system).subscribe(monitor, classOf[ClusterEvent.ClusterDomainEvent])
That actor will then receive updates on members of the cluster as their state changes.
Seed nodes have no special qualities other than being listed as seeds by other members of the cluster. Once a member has used a seed to join, they no longer have any special relationship, they are just members of the same cluster. A node can only find out which nodes it considers as seeds (though you could write your own code to shuttle that data around the cluster, personally I can't think of a use case for that).
Upvotes: 2