Skip to content

Commit 7a4221f

Browse files
authored
Merge pull request #376 from sylwiaszunejko/clean_tablets
Cleanup tablet implementation
2 parents f112165 + f2cc29d commit 7a4221f

File tree

4 files changed

+18
-23
lines changed

4 files changed

+18
-23
lines changed

cassandra/query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ class Statement(object):
254254
table = None
255255
"""
256256
The string name of the table this query acts on. This is used when the tablet
257-
experimental feature is enabled and in the same time :class`~.TokenAwarePolicy`
258-
is configured in the profile load balancing policy.
257+
feature is enabled and in the same time :class`~.TokenAwarePolicy` is configured
258+
in the profile load balancing policy.
259259
"""
260260

261261
custom_payload = None

cassandra/tablets.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# Experimental, this interface and use may change
21
from threading import Lock
32

43

54
class Tablet(object):
65
"""
76
Represents a single ScyllaDB tablet.
8-
It stores information about each replica, its host and shard,
7+
It stores information about each replica, its host and shard,
98
and the token interval in the format (first_token, last_token].
109
"""
1110
first_token = 0
@@ -34,20 +33,19 @@ def from_row(first_token, last_token, replicas):
3433
return None
3534

3635

37-
# Experimental, this interface and use may change
3836
class Tablets(object):
3937
_lock = None
4038
_tablets = {}
4139

4240
def __init__(self, tablets):
4341
self._tablets = tablets
4442
self._lock = Lock()
45-
43+
4644
def get_tablet_for_key(self, keyspace, table, t):
4745
tablet = self._tablets.get((keyspace, table), [])
4846
if not tablet:
4947
return None
50-
48+
5149
id = bisect_left(tablet, t.value, key=lambda tablet: tablet.last_token)
5250
if id < len(tablet) and t.value > tablet[id].first_token:
5351
return tablet[id]

tests/integration/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def start_cluster_wait_for_up(cluster):
506506

507507

508508
def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=None, set_keyspace=True, ccm_options=None,
509-
configuration_options=None, dse_options=None, use_single_interface=USE_SINGLE_INTERFACE, use_tablets=False):
509+
configuration_options=None, dse_options=None, use_single_interface=USE_SINGLE_INTERFACE):
510510
configuration_options = configuration_options or {}
511511
dse_options = dse_options or {}
512512
workloads = workloads or []
@@ -616,10 +616,7 @@ def use_cluster(cluster_name, nodes, ipformat=None, start=True, workloads=None,
616616
# CDC is causing an issue (can't start cluster with multiple seeds)
617617
# Selecting only features we need for tests, i.e. anything but CDC.
618618
CCM_CLUSTER = CCMScyllaCluster(path, cluster_name, **ccm_options)
619-
if use_tablets:
620-
CCM_CLUSTER.set_configuration_options({'experimental_features': ['lwt', 'udf', 'consistent-topology-changes', 'tablets'], 'start_native_transport': True})
621-
else:
622-
CCM_CLUSTER.set_configuration_options({'experimental_features': ['lwt', 'udf'], 'start_native_transport': True})
619+
CCM_CLUSTER.set_configuration_options({'experimental_features': ['lwt', 'udf'], 'start_native_transport': True})
623620

624621
CCM_CLUSTER.set_configuration_options({'skip_wait_for_gossip_to_settle': 0})
625622
# Permit IS NOT NULL restriction on non-primary key columns of a materialized view

tests/integration/experiments/test_tablets.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from tests.unit.test_host_connection_pool import LOGGER
1010

1111
def setup_module():
12-
use_cluster('tablets', [3], start=True, use_tablets=True)
12+
use_cluster('tablets', [3], start=True)
1313

1414
class TestTabletsIntegration(unittest.TestCase):
1515
@classmethod
@@ -20,7 +20,7 @@ def setup_class(cls):
2020
cls.session = cls.cluster.connect()
2121
cls.create_ks_and_cf(cls)
2222
cls.create_data(cls.session)
23-
23+
2424
@classmethod
2525
def teardown_class(cls):
2626
cls.cluster.shutdown()
@@ -32,7 +32,7 @@ def verify_same_host_in_tracing(self, results):
3232
for event in events:
3333
LOGGER.info("TRACE EVENT: %s %s %s", event.source, event.thread_name, event.description)
3434
host_set.add(event.source)
35-
35+
3636
self.assertEqual(len(host_set), 1)
3737
self.assertIn('locally', "\n".join([event.description for event in events]))
3838

@@ -43,7 +43,7 @@ def verify_same_host_in_tracing(self, results):
4343
for event in events:
4444
LOGGER.info("TRACE EVENT: %s %s", event.source, event.activity)
4545
host_set.add(event.source)
46-
46+
4747
self.assertEqual(len(host_set), 1)
4848
self.assertIn('locally', "\n".join([event.activity for event in events]))
4949

@@ -54,7 +54,7 @@ def verify_same_shard_in_tracing(self, results):
5454
for event in events:
5555
LOGGER.info("TRACE EVENT: %s %s %s", event.source, event.thread_name, event.description)
5656
shard_set.add(event.thread_name)
57-
57+
5858
self.assertEqual(len(shard_set), 1)
5959
self.assertIn('locally', "\n".join([event.description for event in events]))
6060

@@ -65,10 +65,10 @@ def verify_same_shard_in_tracing(self, results):
6565
for event in events:
6666
LOGGER.info("TRACE EVENT: %s %s", event.thread, event.activity)
6767
shard_set.add(event.thread)
68-
68+
6969
self.assertEqual(len(shard_set), 1)
7070
self.assertIn('locally', "\n".join([event.activity for event in events]))
71-
71+
7272
def create_ks_and_cf(self):
7373
self.session.execute(
7474
"""
@@ -79,8 +79,8 @@ def create_ks_and_cf(self):
7979
"""
8080
CREATE KEYSPACE test1
8181
WITH replication = {
82-
'class': 'NetworkTopologyStrategy',
83-
'replication_factor': 1
82+
'class': 'NetworkTopologyStrategy',
83+
'replication_factor': 1
8484
} AND tablets = {
8585
'initial': 8
8686
}
@@ -90,14 +90,14 @@ def create_ks_and_cf(self):
9090
"""
9191
CREATE TABLE test1.table1 (pk int, ck int, v int, PRIMARY KEY (pk, ck));
9292
""")
93-
93+
9494
@staticmethod
9595
def create_data(session):
9696
prepared = session.prepare(
9797
"""
9898
INSERT INTO test1.table1 (pk, ck, v) VALUES (?, ?, ?)
9999
""")
100-
100+
101101
for i in range(50):
102102
bound = prepared.bind((i, i%5, i%2))
103103
session.execute(bound)

0 commit comments

Comments
 (0)