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
= <Logger HazelcastClient.ClusterService (WARNING)>¶
-
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.
-
property
members
¶ Returns the members in the cluster. :return: (list), List of members.
-
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.
-
get_member_by_address
(address)¶ Returns the member with the specified address if it is in the cluster, None otherwise.
-
get_members
(selector)¶ Returns the members that satisfy the given selector.
- Parameters
selector – (
MemberSelector
), Selector to be applied to the members.- Returns
(List), List of members.
-
get_member_list
()¶ Returns all the members as a list.
- Returns
(List), List of members.
-
-
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
()¶
-
-
class
VectorClock
¶ Bases:
object
Vector clock consisting of distinct replica logical clocks.
See https://en.wikipedia.org/wiki/Vector_clock The vector clock may be read from different thread but concurrent updates must be synchronized externally. There is no guarantee for concurrent updates.
-
is_after
(other)¶ Returns true if this vector clock is causally strictly after the provided vector clock. This means that it the provided clock is neither equal to, greater than or concurrent to this vector clock.
- Parameters
other – (
VectorClock
), Vector clock to be compared- Returns
(bool), True if this vector clock is strictly after the other vector clock, False otherwise
-
set_replica_timestamp
(replica_id, timestamp)¶ Sets the logical timestamp for the given replica ID.
- Parameters
replica_id – (str), Replica ID.
timestamp – (int), Timestamp for the given replica ID.
-
entry_set
()¶ Returns the entry set of the replica timestamps in a format of list of tuples. Each tuple contains the replica ID and the timestamp associated with it.
- Returns
(list), List of tuples.
-
size
()¶ Returns the number of timestamps that are in the replica timestamps dictionary.
- Returns
(int), Number of timestamps in the replica timestamps.
-