ivandasch commented on a change in pull request #45:
URL:
https://github.com/apache/ignite-python-thin-client/pull/45#discussion_r669412587
##########
File path: pyignite/connection/connection.py
##########
@@ -78,21 +81,53 @@ def protocol_context(self):
return self.client.protocol_context
def _process_handshake_error(self, response):
- error_text = f'Handshake error: {response.message}'
# if handshake fails for any reason other than protocol mismatch
# (i.e. authentication error), server version is 0.0.0
+ if response.client_status == CLIENT_STATUS_AUTH_FAILURE:
+ raise AuthenticationError(response.message)
+
protocol_version = self.client.protocol_context.version
server_version = (response.version_major, response.version_minor,
response.version_patch)
-
+ error_text = f'Handshake error: {response.message}'
if any(server_version):
error_text += f' Server expects binary protocol version ' \
f'{server_version[0]}.{server_version[1]}.{server_version[2]}. ' \
f'Client provides ' \
f'{protocol_version[0]}.{protocol_version[1]}.{protocol_version[2]}.'
- elif response.client_status == CLIENT_STATUS_AUTH_FAILURE:
- raise AuthenticationError(error_text)
raise HandshakeError(server_version, error_text)
+ def _on_handshake_start(self):
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug("Connecting to node(address=%s, port=%d) with
protocol context %s",
+ self.host, self.port, self.client.protocol_context)
+
+ def _on_handshake_success(self, result):
+ features = BitmaskFeature.from_array(result.get('features', None))
+ self.client.protocol_context.features = features
+ self.uuid = result.get('node_uuid', None) # version-specific (1.4+)
+ self.failed = False
+
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug("Connected to node(address=%s, port=%d, node_uuid=%s)
with protocol context %s",
+ self.host, self.port, self.uuid,
self.client.protocol_context)
+
+ def _on_handshake_fail(self, err):
+ if isinstance(err, AuthenticationError):
+ logger.error("Authentication failed while connecting to
node(address=%s, port=%d): %s",
+ self.host, self.port, err)
+ if isinstance(err, connection_errors):
+ logger.error("Failed to perform handshake, connection to
node(address=%s, port=%d) "
+ "with protocol context %s failed: %s",
+ self.host, self.port, self.client.protocol_context,
err, exc_info=True)
Review comment:
Good point, let's catch in this branch all others exceptions, other than
`AuthenticationError`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]