When the set of live nodes change, the loadbalancer will change its mind on host distances. It might change it on the node that came/left but also on other nodes (for instance, if a node dies, another previously ignored node may be now considered). This meth
(self)
| 3344 | return None |
| 3345 | |
| 3346 | def update_created_pools(self): |
| 3347 | """ |
| 3348 | When the set of live nodes change, the loadbalancer will change its |
| 3349 | mind on host distances. It might change it on the node that came/left |
| 3350 | but also on other nodes (for instance, if a node dies, another |
| 3351 | previously ignored node may be now considered). |
| 3352 | |
| 3353 | This method ensures that all hosts for which a pool should exist |
| 3354 | have one, and hosts that shouldn't don't. |
| 3355 | |
| 3356 | For internal use only. |
| 3357 | """ |
| 3358 | futures = set() |
| 3359 | for host in self.cluster.metadata.all_hosts(): |
| 3360 | distance = self._profile_manager.distance(host) |
| 3361 | pool = self._pools.get(host) |
| 3362 | future = None |
| 3363 | if not pool or pool.is_shutdown: |
| 3364 | # we don't eagerly set is_up on previously ignored hosts. None is included here |
| 3365 | # to allow us to attempt connections to hosts that have gone from ignored to something |
| 3366 | # else. |
| 3367 | if distance != HostDistance.IGNORED and host.is_up in (True, None): |
| 3368 | future = self.add_or_renew_pool(host, False) |
| 3369 | elif distance != pool.host_distance: |
| 3370 | # the distance has changed |
| 3371 | if distance == HostDistance.IGNORED: |
| 3372 | future = self.remove_pool(host) |
| 3373 | else: |
| 3374 | pool.host_distance = distance |
| 3375 | if future: |
| 3376 | futures.add(future) |
| 3377 | return futures |
| 3378 | |
| 3379 | def on_down(self, host): |
| 3380 | """ |