Connection

class ConnectionManager(client, new_connection_func, address_translator)

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.

Parameters:
  • 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.
get_connection(address)

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.

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

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

on_auth(f, connection, address)

Checks for authentication of a connection.

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

Result of authentication.

close_connection(address, cause)

Closes the connection with given address.

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

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

class Heartbeat(client)

Bases: object

HeartBeat Service.

logger = <logging.Logger object>
start()

Starts sending periodic HeartBeat operations.

shutdown()

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.

Parameters:
  • 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>
live()

Determines whether this connection is live or not.

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

Sends a message to this connection.

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

Receives a message from this connection.

write(data)

Writes data to this connection when sending messages.

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

Closes the connection.

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

Bases: object

Provides initial addresses for client to find and connect to a node. Loads addresses from the Hazelcast configuration.

load_addresses()
Returns:(Sequence), The possible member addresses to connect to.
class DefaultAddressTranslator

Bases: object

DefaultAddressTranslator is a no-op. It always returns the given address.

translate(address)
Parameters:address – (Address), address to be translated.
Returns:(Address), translated address.
refresh()

Refreshes the internal lookup table if necessary.