(self, host, refresh_nodes=True)
| 1975 | self._start_reconnector(host, is_host_addition) |
| 1976 | |
| 1977 | def on_add(self, host, refresh_nodes=True): |
| 1978 | if self.is_shutdown: |
| 1979 | return |
| 1980 | |
| 1981 | log.debug("Handling new host %r and notifying listeners", host) |
| 1982 | |
| 1983 | distance = self.profile_manager.distance(host) |
| 1984 | if distance != HostDistance.IGNORED: |
| 1985 | self._prepare_all_queries(host) |
| 1986 | log.debug("Done preparing queries for new host %r", host) |
| 1987 | |
| 1988 | self.profile_manager.on_add(host) |
| 1989 | self.control_connection.on_add(host, refresh_nodes) |
| 1990 | |
| 1991 | if distance == HostDistance.IGNORED: |
| 1992 | log.debug("Not adding connection pool for new host %r because the " |
| 1993 | "load balancing policy has marked it as IGNORED", host) |
| 1994 | self._finalize_add(host, set_up=False) |
| 1995 | return |
| 1996 | |
| 1997 | futures_lock = Lock() |
| 1998 | futures_results = [] |
| 1999 | futures = set() |
| 2000 | |
| 2001 | def future_completed(future): |
| 2002 | with futures_lock: |
| 2003 | futures.discard(future) |
| 2004 | |
| 2005 | try: |
| 2006 | futures_results.append(future.result()) |
| 2007 | except Exception as exc: |
| 2008 | futures_results.append(exc) |
| 2009 | |
| 2010 | if futures: |
| 2011 | return |
| 2012 | |
| 2013 | log.debug('All futures have completed for added host %s', host) |
| 2014 | |
| 2015 | for exc in [f for f in futures_results if isinstance(f, Exception)]: |
| 2016 | log.error("Unexpected failure while adding node %s, will not mark up:", host, exc_info=exc) |
| 2017 | return |
| 2018 | |
| 2019 | if not all(futures_results): |
| 2020 | log.warning("Connection pool could not be created, not marking node %s up", host) |
| 2021 | return |
| 2022 | |
| 2023 | self._finalize_add(host) |
| 2024 | |
| 2025 | have_future = False |
| 2026 | for session in tuple(self.sessions): |
| 2027 | future = session.add_or_renew_pool(host, is_host_addition=True) |
| 2028 | if future is not None: |
| 2029 | have_future = True |
| 2030 | futures.add(future) |
| 2031 | future.add_done_callback(future_completed) |
| 2032 | |
| 2033 | if not have_future: |
| 2034 | self._finalize_add(host) |
no test coverage detected