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
4 changes: 2 additions & 2 deletions cassandra/policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,12 @@ class TokenAwarePolicy(LoadBalancingPolicy):

_child_policy = None
_cluster_metadata = None
shuffle_replicas = False
shuffle_replicas = True
"""
Yield local replicas in a random order.
"""

def __init__(self, child_policy, shuffle_replicas=False):
def __init__(self, child_policy, shuffle_replicas=True):
self._child_policy = child_policy
self.shuffle_replicas = shuffle_replicas

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/advanced/test_insights.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_execution_profile(self):
'options': {'local_dc': '',
'used_hosts_per_remote_dc': 0},
'type': 'DCAwareRoundRobinPolicy'},
'shuffle_replicas': False},
'shuffle_replicas': True},
'type': 'TokenAwarePolicy'},
'readTimeout': 10.0,
'retry': {'namespace': 'cassandra.policies', 'options': {}, 'type': 'RetryPolicy'},
Expand All @@ -145,7 +145,7 @@ def test_graph_execution_profile(self):
'options': {'local_dc': '',
'used_hosts_per_remote_dc': 0},
'type': 'DCAwareRoundRobinPolicy'},
'shuffle_replicas': False},
'shuffle_replicas': True},
'type': 'TokenAwarePolicy'},
'readTimeout': 30.0,
'retry': {'namespace': 'cassandra.policies', 'options': {}, 'type': 'NeverRetryPolicy'},
Expand All @@ -167,7 +167,7 @@ def test_graph_analytics_execution_profile(self):
'options': {'local_dc': '',
'used_hosts_per_remote_dc': 0},
'type': 'DCAwareRoundRobinPolicy'},
'shuffle_replicas': False},
'shuffle_replicas': True},
'type': 'TokenAwarePolicy'}},
'type': 'DefaultLoadBalancingPolicy'},
'readTimeout': 604800.0,
Expand Down Expand Up @@ -195,7 +195,7 @@ def test_token_aware_policy(self):
'options': {'child_policy': {'namespace': 'cassandra.policies',
'options': {},
'type': 'LoadBalancingPolicy'},
'shuffle_replicas': False},
'shuffle_replicas': True},
'type': 'TokenAwarePolicy'}

def test_whitelist_round_robin_policy(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,14 +604,14 @@ def get_replicas(keyspace, packed_key):

replicas = get_replicas(None, struct.pack('>i', i))
other = set(h for h in hosts if h not in replicas)
assert replicas == qplan[:2]
assert sorted(replicas) == sorted(qplan[:2])
assert other == set(qplan[2:])

# Should use the secondary policy
for i in range(4):
qplan = list(policy.make_query_plan())

assert set(qplan) == set(hosts)
assert sorted(set(qplan)) == sorted(set(hosts))

def test_wrap_dc_aware(self):
cluster = Mock(spec=Cluster)
Expand Down
Loading