HazelcastClient API Documentation

class HazelcastClient(config: Optional[Config] = None, **kwargs)[source]

Bases: object

Hazelcast client instance to access and manipulate distributed data structures on the Hazelcast clusters.

The client can be configured either by:

  • providing a configuration object as the first parameter of the constructor

from hazelcast import HazelcastClient
from hazelcast.config import Config

config = Config()
config.cluster_name = "a-cluster"
client = HazelcastClient(config)
  • passing configuration options as keyword arguments

from hazelcast import HazelcastClient

client = HazelcastClient(
    cluster_name="a-cluster",
)

See the hazelcast.config.Config documentation for the possible configuration options.

Parameters:
  • config – Optional configuration object.

  • **kwargs – Optional keyword arguments of the client configuration.

get_executor(name: str) Executor[source]

Creates cluster-wide ExecutorService.

Parameters:

name – Name of the Executor proxy.

Returns:

Executor proxy for the given name.

get_flake_id_generator(name: str) FlakeIdGenerator[source]

Creates or returns a cluster-wide FlakeIdGenerator.

Parameters:

name – Name of the FlakeIdGenerator proxy.

Returns:

FlakeIdGenerator proxy for the given name.

get_queue(name: str) Queue[ItemType][source]

Returns the distributed queue instance with the specified name.

Parameters:

name – Name of the distributed queue.

Returns:

Distributed queue instance with the specified name.

get_list(name: str) List[ItemType][source]

Returns the distributed list instance with the specified name.

Parameters:

name – Name of the distributed list.

Returns:

Distributed list instance with the specified name.

get_map(name: str) Map[KeyType, ValueType][source]

Returns the distributed map instance with the specified name.

Parameters:

name – Name of the distributed map.

Returns:

Distributed map instance with the specified name.

get_multi_map(name: str) MultiMap[KeyType, ValueType][source]

Returns the distributed MultiMap instance with the specified name.

Parameters:

name – Name of the distributed MultiMap.

Returns:

Distributed MultiMap instance with the specified name.

get_pn_counter(name: str) PNCounter[source]

Returns the PN Counter instance with the specified name.

Parameters:

name – Name of the PN Counter.

Returns:

Distributed PN Counter instance with the specified name.

get_reliable_topic(name: str) ReliableTopic[MessageType][source]

Returns the ReliableTopic instance with the specified name.

Parameters:

name – Name of the ReliableTopic.

Returns:

Distributed ReliableTopic instance with the specified name.

get_replicated_map(name: str) ReplicatedMap[KeyType, ValueType][source]

Returns the distributed ReplicatedMap instance with the specified name.

Parameters:

name – Name of the distributed ReplicatedMap.

Returns:

Distributed ReplicatedMap instance with the specified name.

get_ringbuffer(name: str) Ringbuffer[ItemType][source]

Returns the distributed Ringbuffer instance with the specified name.

Parameters:

name – Name of the distributed Ringbuffer.

Returns:

Distributed RingBuffer instance with the specified name.

get_set(name: str) Set[ItemType][source]

Returns the distributed Set instance with the specified name.

Parameters:

name – Name of the distributed Set.

Returns:

Distributed Set instance with the specified name.

get_topic(name: str) Topic[MessageType][source]

Returns the Topic instance with the specified name.

Parameters:

name – Name of the Topic.

Returns:

The Topic.

new_transaction(timeout: float = 120, durability: int = 1, type: int = 1) Transaction[source]
Creates a new Transaction associated with the current thread

using default or given options.

Parameters:
  • timeout – The timeout in seconds determines the maximum lifespan of a transaction. So if a transaction is configured with a timeout of 2 minutes, then it will automatically rollback if it hasn’t committed yet.

  • durability – The durability is the number of machines that can take over if a member fails during a transaction commit or rollback.

  • type – The transaction type which can be TWO_PHASE or ONE_PHASE.

Returns:

New Transaction associated with the current thread.

add_distributed_object_listener(listener_func: Callable[[DistributedObjectEvent], None]) Future[str][source]

Adds a listener which will be notified when a new distributed object is created or destroyed.

Parameters:

listener_func – Function to be called when a distributed object is created or destroyed.

Returns:

A registration id which is used as a key to remove the listener.

remove_distributed_object_listener(registration_id: str) Future[bool][source]

Removes the specified distributed object listener.

Returns silently if there is no such listener added before.

Parameters:

registration_id – The id of registered listener.

Returns:

True if registration is removed, False otherwise.

get_distributed_objects() Future[List[Proxy]][source]

Returns all distributed objects such as; queue, map, set, list, topic, lock, multimap.

Also, as a side effect, it clears the local instances of the destroyed proxies.

Returns:

List of instances created by Hazelcast.

shutdown() None[source]

Shuts down this HazelcastClient.

property name: str

Name of the client.

property lifecycle_service: LifecycleService

Lifecycle service allows you to check if the client is running and add and remove lifecycle listeners.

property partition_service: PartitionService

Partition service allows you to get partition count, introspect the partition owners, and partition ids of keys.

property cluster_service: ClusterService

Cluster service allows you to get the list of the cluster members and add and remove membership listeners.

Type:

ClusterService

property cp_subsystem: CPSubsystem

CP Subsystem offers set of in-memory linearizable data structures.

property sql: SqlService

Returns a service to execute distributed SQL queries.