class ConnectionManager(client, new_connection_func)

Bases: object

ConnectionManager is responsible for managing Connection objects.

logger = <logging.Logger object>
add_listener(on_connection_opened=None, on_connection_closed=None)

Registers a ConnectionListener. If the same listener is registered multiple times, it will be notified multiple times.

  • on_connection_opened – (Function), function to be called when a connection is opened.
  • on_connection_closed – (Function), function to be called when a connection is removed.

Gets the existing connection for a given address or connects. This call is silent.

Parameters:address – (Address), the address to connect to.
Returns:(Connection), the found connection, or None if no connection exists.
get_or_connect(address, authenticator=None)

Gets the existing connection for a given address. If it does not exist, the system will try to connect asynchronously. In this case, it returns a Future. When the connection is established at some point in time, it can be retrieved by using the get_connection(Address) or from Future.

  • address – (Address), the address to connect to.
  • authenticator – (Function), function to be used for authentication (optional).

(Connection), the existing connection or it returns a Future which includes asynchronously.

on_auth(f, connection, address)

Checks for authentication of a connection.

  • f – (Future), future that contains the result of authentication.
  • connection – (Connection), newly established connection.
  • address – (Address), the adress of new connection.

Result of authentication.

close_connection(address, cause)

Closes the connection with given address.

  • address – (Address), address of the connection to be closed.
  • cause – (Exception), the cause for closing the connection.

(bool), true if the connection is closed, false otherwise.

class Heartbeat(client)

Bases: object

HeartBeat Service.

logger = <logging.Logger object>

Starts sending periodic HeartBeat operations.


Stops HeartBeat operations.

add_listener(on_heartbeat_restored=None, on_heartbeat_stopped=None)

Registers a HeartBeat listener. Listener is invoked when a HeartBeat related event occurs.

  • on_heartbeat_restored – (Function), function to be called when a HeartBeat is restored (optional).
  • on_heartbeat_stopped – (Function), function to be called when a HeartBeat is stopped (optional).
class Connection(address, connection_closed_callback, message_callback)

Bases: object

Connection object which stores connection related information and operations.

endpoint = None
heartbeating = True
is_owner = False
counter = <hazelcast.util.AtomicInteger object>

Determines whether this connection is live or not.

Returns:(bool), true if the connection is live, false otherwise.

Sends a message to this connection.

Parameters:message – (Message), message to be sent to this connection.

Receives a message from this connection.


Writes data to this connection when sending messages.

Parameters:data – (Data), data to be written to connection.

Closes the connection.

Parameters:cause – (Exception), the cause of closing the connection.