pygridgain.connection package¶
Submodules¶
pygridgain.connection.handshake module¶
-
class
pygridgain.connection.handshake.
HandshakeRequest
(protocol_version: Tuple[int, int, int], username: Union[str, NoneType] = None, password: Union[str, NoneType] = None)¶ Bases:
object
Handshake request.
-
__init__
(protocol_version: Tuple[int, int, int], username: Union[str, NoneType] = None, password: Union[str, NoneType] = None)¶ Initialize self. See help(type(self)) for accurate signature.
-
handshake_struct
= None¶
-
password
= None¶
-
protocol_version
= None¶
-
username
= None¶
-
pygridgain.connection.ssl module¶
-
pygridgain.connection.ssl.
wrap
(conn: Connection, _socket)¶ Wrap socket in SSL wrapper.
Module contents¶
This module contains Connection class, that wraps TCP socket handling, as well as GridGain protocol handshaking.
-
class
pygridgain.connection.
Connection
(client: Client, prefetch: bytes = b'', timeout: int = None, username: str = None, password: str = None, **ssl_params)¶ Bases:
object
This is a pygridgain class, that represents a connection to GridGain node. It serves multiple purposes:
- socket wrapper. Detects fragmentation and network errors. See also https://docs.python.org/3/howto/sockets.html,
- binary protocol connector. Incapsulates handshake, data read-ahead and failover reconnection.
-
__init__
(client: Client, prefetch: bytes = b'', timeout: int = None, username: str = None, password: str = None, **ssl_params)¶ Initialize connection.
For the use of the SSL-related parameters see https://docs.python.org/3/library/ssl.html#ssl-certificates.
Parameters: - client – GridGain client object,
- prefetch – (optional) initialize the read-ahead data buffer. Empty by default,
- timeout – (optional) sets timeout (in seconds) for each socket operation including connect. 0 means non-blocking mode, which is virtually guaranteed to fail. Can accept integer or float value. Default is None (blocking mode),
- use_ssl – (optional) set to True if GridGain server uses SSL on its binary connector. Defaults to use SSL when username and password has been supplied, not to use SSL otherwise,
- ssl_version – (optional) SSL version constant from standard ssl module. Defaults to TLS v1.1, as in GridGain 8.5,
- ssl_ciphers – (optional) ciphers to use. If not provided, ssl default ciphers are used,
- ssl_cert_reqs –
(optional) determines how the remote side certificate is treated:
- ssl.CERT_NONE − remote certificate is ignored (default),
- ssl.CERT_OPTIONAL − remote certificate will be validated, if provided,
- ssl.CERT_REQUIRED − valid remote certificate is required,
- ssl_keyfile – (optional) a path to SSL key file to identify local (client) party,
- ssl_certfile – (optional) a path to ssl certificate file to identify local (client) party,
- ssl_ca_certfile – (optional) a path to a trusted certificate or a certificate chain. Required to check the validity of the remote (server-side) certificate,
- username – (optional) user name to authenticate to GridGain cluster,
- password – (optional) password to authenticate to GridGain cluster.
-
alive
¶ Tells if connection is up and no failure detected.
-
client
= None¶
-
clone
(prefetch: bytes = b'') → pygridgain.connection.Connection¶ Clones this connection in its current state.
Returns: Connection object.
-
close
(release=True)¶ Try to mark socket closed, then unlink it. This is recommended but not required, since sockets are automatically closed when garbage-collected.
-
closed
¶ Tells if socket is closed.
-
connect
(host: str = None, port: int = None) → Union[dict, collections.OrderedDict]¶ Connect to the given server node with protocol version fallback.
Parameters: - host – GridGain server node’s host name or IP,
- port – GridGain server node’s port number.
-
failed
¶ Tells if connection is failed.
-
get_protocol_version
()¶ Returns the tuple of major, minor, and revision numbers of the used thin protocol version, or None, if no connection to the GridGain cluster was yet established.
-
host
= None¶
-
password
= None¶
-
port
= None¶
-
prefetch
= None¶
-
read_response
(*args, **kwargs) → Callable¶
-
read_response_120
()¶ Processes server’s response to the handshake request (thin protocol version 1.2.0).
Returns: handshake data.
-
read_response_130
()¶ Processes server’s response to the handshake request (thin protocol version 1.2.0).
Returns: handshake data.
-
reconnect
(*args, **kwargs) → Callable¶
-
reconnect_120
()¶ Tries to reconnect synchronously.
-
reconnect_130
()¶ Tries to reconnect synchronously.
-
recv
(buffersize, flags=None) → bytes¶ Receive data from socket or read-ahead buffer.
Parameters: - buffersize – bytes to receive,
- flags – (optional) OS-specific flags,
Returns: data received.
-
send
(data: bytes, flags=None)¶ Send data down the socket.
Parameters: - data – bytes to send,
- flags – (optional) OS-specific flags.
-
socket
¶ Network socket.
-
ssl_params
= {}¶
-
timeout
= None¶
-
username
= None¶
-
uuid
= None¶