Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions cassandra/policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@ def address_is_ignored(host):
load_balancing_policy=blacklist_filter_policy,
)

See the note in the :meth:`.make_query_plan` documentation for a caveat on
how wrapping ordering polices (e.g. :class:`.RoundRobinPolicy`) may break
desirable properties of the wrapped policy.

Please note that whitelist and blacklist policies are not recommended for
general, day-to-day use. You probably want something like
:class:`.DCAwareRoundRobinPolicy`, which prefers a local DC but has
Expand Down Expand Up @@ -553,10 +557,15 @@ def populate(self, cluster, hosts):
def make_query_plan(self, working_keyspace=None, query=None):
"""
Defers to the child policy's
:meth:`.LoadBalancingPolicy.make_query_plan`. Since host changes (up,
down, addition, and removal) have not been propagated to the child
policy, the child policy will only ever return policies for which
:meth:`.predicate(host)` was truthy when that change occurred.
:meth:`.LoadBalancingPolicy.make_query_plan` and filters the results.

Note that this filtering may break desirable properties of the wrapped
policy in some cases. For instance, imagine if you configure this
policy to filter out ``host2``, and to wrap a round-robin policy that
rotates through three hosts in the order ``host1, host2, host3``,
``host2, host3, host1``, ``host3, host1, host2``, repeating. This
policy will yield ``host1, host3``, ``host3, host1``, ``host3, host1``,
disproportionately favoring ``host3``.
"""
child_qp = self._child_policy.make_query_plan(
working_keyspace=working_keyspace, query=query
Expand Down
2 changes: 1 addition & 1 deletion docs/api/cassandra/policies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Load Balancing

.. autoclass:: HostFilterPolicy

# we document these methods manually so we can specify a param to predicate
.. we document these methods manually so we can specify a param to predicate

.. automethod:: predicate(host)
.. automethod:: distance
Expand Down