Hazelcast Cluster

class ClusterService(config, client, address_providers)

Bases: object

Hazelcast cluster service. It provides access to the members in the cluster and the client can register for changes in the cluster members.

All the methods on the Cluster are thread-safe.

logger = <logging.Logger object>
start()

Connects to cluster.

shutdown()
size()

Returns the size of the cluster.

Returns:(int), size of the cluster.
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 (optional).
  • member_removed – (Function), function to be called when a member is removed to the cluster (optional).
  • fire_for_existing – (bool), (optional).
Returns:

(str), registration id of the listener which will be used for removing this listener.

remove_listener(registration_id)

Removes the specified membership listener.

Parameters:registration_id – (str), registration id of the listener to be deleted.
Returns:(bool), if the registration is removed, false otherwise.
get_member_by_uuid(member_uuid)

Returns the member with specified member uuid.

Parameters:member_uuid – (int), uuid of the desired member.
Returns:(Member), the corresponding member.
class RandomLoadBalancer(cluster)

Bases: object

RandomLoadBalancer make the Client send operations randomly on members not to increase the load on a specific member.

next_address()