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

Method get_replicas

cassandra/metadata.py:1767–1785  ·  view source on GitHub ↗

Get a set of :class:`.Host` instances representing all of the replica nodes for a given :class:`.Token`.

(self, keyspace, token)

Source from the content-addressed store, hash-verified

1765 self.tokens_to_hosts_by_ks.pop(keyspace, None)
1766
1767 def get_replicas(self, keyspace, token):
1768 """
1769 Get a set of :class:`.Host` instances representing all of the
1770 replica nodes for a given :class:`.Token`.
1771 """
1772 tokens_to_hosts = self.tokens_to_hosts_by_ks.get(keyspace, None)
1773 if tokens_to_hosts is None:
1774 self.rebuild_keyspace(keyspace, build_if_absent=True)
1775 tokens_to_hosts = self.tokens_to_hosts_by_ks.get(keyspace, None)
1776
1777 if tokens_to_hosts:
1778 # The values in self.ring correspond to the end of the
1779 # token range up to and including the value listed.
1780 point = bisect_left(self.ring, token)
1781 if point == len(self.ring):
1782 return tokens_to_hosts[self.ring[0]]
1783 else:
1784 return tokens_to_hosts[self.ring[point]]
1785 return []
1786
1787
1788@total_ordering

Callers 1

_get_replicasMethod · 0.95

Calls 2

rebuild_keyspaceMethod · 0.95
getMethod · 0.45

Tested by 1

_get_replicasMethod · 0.76