Get the Master Ip Address from Hazelcast grid
Asked Answered
D

1

3

I would like to get the masterIpAddress use on the Hazelcast node in HazelcastInsatnceImpl from an instance HazelcastInsatnce.

Somebody know how to do that?

Thanks for your help

Destefano answered 9/5, 2014 at 16:59 Comment(0)
G
11

There is no real master in Hazelcast clusters. The oldest node plays some kind of a special role so you can imagine this one as the "master".

To get this node get retrieve the first element from the memberlist.

Cluster cluster = hazelcastInstance.getCluster();
Set<Member> members = cluster.getMembers();
Member master = members.iterator().next();
Gyration answered 9/5, 2014 at 19:12 Comment(3)
Means what? What happens or does not happen?Gyration
cluster.getMembers() now returns a Set. The docs still state that the first element is the oldest Member, so the equivalent code is now cluster.getMembers().iterator().next().Driest
Oh right, forgot about the change, thanks for pointing it out. Changed the example above! Really appreciated.Gyration

© 2022 - 2024 — McMap. All rights reserved.