Hazelcast Cluster¶
-
class
ClusterService
(internal_cluster_service)¶ Bases:
object
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=None, member_removed=None, fire_for_existing=False)¶ Adds a membership listener to listen for membership updates.
It will be notified when a member is added to cluster or removed from cluster. There is no check for duplicate registrations, so if you register the listener twice, it will get events twice.
- Parameters
member_added (function) – Function to be called when a member is added to the cluster.
member_removed (function) – Function to be called when a member is removed from the cluster.
fire_for_existing (bool) – Whether or not fire member_added for existing members.
- Returns
Registration id of the listener which will be used for removing this listener.
- Return type
str
-
remove_listener
(registration_id)¶ Removes the specified membership listener.
- Parameters
registration_id (str) – Registration id of the listener to be removed.
- Returns
True
if the registration is removed,False
otherwise.- Return type
bool
-
get_members
(member_selector=None)¶ 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.
- Parameters
member_selector (function) – Function to filter members to return. If not provided, the returned list will contain all the available cluster members.
- Returns
Current members in the cluster
- Return type
-