- class ClusterService(internal_cluster_service)¶
Cluster service for Hazelcast clients.
It provides access to the members in the cluster and one can register for changes in the cluster members.
- add_listener(member_added: Optional[Callable[[MemberInfo], None]] = None, member_removed: Optional[Callable[[MemberInfo], None]] = None, fire_for_existing=False) str ¶
Adds a membership listener to listen for membership updates.
It will be notified when a member is added to the cluster or removed from the cluster. There is no check for duplicate registrations, so if you register the listener twice, it will get events twice.
member_added – Function to be called when a member is added to the cluster.
member_removed – Function to be called when a member is removed from the cluster.
fire_for_existing – Whether or not fire member_added for existing members.
Registration id of the listener which will be used for removing this listener.
- remove_listener(registration_id: str) bool ¶
Removes the specified membership listener.
registration_id – Registration id of the listener to be removed.
Trueif the registration is removed,
- get_members(member_selector: Optional[Callable[[MemberInfo], bool]] = None) List[MemberInfo] ¶
Lists the current members in the cluster.
Every member in the cluster returns the members in the same order. To obtain the oldest member in the cluster, you can retrieve the first item in the list.
member_selector – Function to filter members to return. If not provided, the returned list will contain all the available cluster members.
Current members in the cluster