MCPcopy Create free account
hub / github.com/apache/cassandra-python-driver / _HostReconnectionHandler

Class _HostReconnectionHandler

cassandra/pool.py:340–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

338
339
340class _HostReconnectionHandler(_ReconnectionHandler):
341
342 def __init__(self, host, connection_factory, is_host_addition, on_add, on_up, *args, **kwargs):
343 _ReconnectionHandler.__init__(self, *args, **kwargs)
344 self.is_host_addition = is_host_addition
345 self.on_add = on_add
346 self.on_up = on_up
347 self.host = host
348 self.connection_factory = connection_factory
349
350 def try_reconnect(self):
351 return self.connection_factory()
352
353 def on_reconnection(self, connection):
354 log.info("Successful reconnection to %s, marking node up if it isn't already", self.host)
355 if self.is_host_addition:
356 self.on_add(self.host)
357 else:
358 self.on_up(self.host)
359
360 def on_exception(self, exc, next_delay):
361 if isinstance(exc, AuthenticationFailed):
362 return False
363 else:
364 log.warning("Error attempting to reconnect to %s, scheduling retry in %s seconds: %s",
365 self.host, next_delay, exc)
366 log.debug("Reconnection error details", exc_info=True)
367 return True
368
369
370class HostConnection(object):

Callers 1

_start_reconnectorMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected