|
14 | 14 | import random |
15 | 15 |
|
16 | 16 | from collections import namedtuple |
17 | | -from functools import lru_cache |
18 | 17 | from itertools import islice, cycle, groupby, repeat |
19 | 18 | import logging |
20 | 19 | from random import randint, shuffle |
@@ -254,7 +253,7 @@ def _dc(self, host): |
254 | 253 |
|
255 | 254 | def populate(self, cluster, hosts): |
256 | 255 | for dc, dc_hosts in groupby(hosts, lambda h: self._dc(h)): |
257 | | - self._dc_live_hosts[dc] = tuple(set(dc_hosts)) |
| 256 | + self._dc_live_hosts[dc] = tuple({*dc_hosts, *self._dc_live_hosts.get(dc, [])}) |
258 | 257 |
|
259 | 258 | if not self.local_dc: |
260 | 259 | self._endpoints = [ |
@@ -374,9 +373,9 @@ def _dc(self, host): |
374 | 373 |
|
375 | 374 | def populate(self, cluster, hosts): |
376 | 375 | for (dc, rack), rack_hosts in groupby(hosts, lambda host: (self._dc(host), self._rack(host))): |
377 | | - self._live_hosts[(dc, rack)] = tuple(set(rack_hosts)) |
| 376 | + self._live_hosts[(dc, rack)] = tuple({*rack_hosts, *self._live_hosts.get((dc, rack), [])}) |
378 | 377 | for dc, dc_hosts in groupby(hosts, lambda host: self._dc(host)): |
379 | | - self._dc_live_hosts[dc] = tuple(set(dc_hosts)) |
| 378 | + self._dc_live_hosts[dc] = tuple({*dc_hosts, *self._dc_live_hosts.get(dc, [])}) |
380 | 379 |
|
381 | 380 | self._position = randint(0, len(hosts) - 1) if hosts else 0 |
382 | 381 |
|
|
0 commit comments