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.- address – (
-
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.
- f – (
-
-
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, logger_extras=None)¶ 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.
-