Skip to content

Commit fb13815

Browse files
roydahandkropachev
authored andcommitted
Replace SimpleStrategy with NetworkTopologyStrategy across codebase
ScyllaDB has dropped support for SimpleStrategy. Update all CQL statements, test fixtures, examples, benchmarks, and management utilities to use NetworkTopologyStrategy instead. The SimpleStrategy class definition in cassandra/metadata.py is preserved for backward compatibility with Cassandra clusters.
1 parent b9813e7 commit fb13815

15 files changed

Lines changed: 58 additions & 58 deletions

File tree

benchmarks/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def setup(options):
9797
try:
9898
session.execute("""
9999
CREATE KEYSPACE %s
100-
WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '2' }
100+
WITH replication = { 'class': 'NetworkTopologyStrategy', 'replication_factor': '2' }
101101
""" % options.keyspace)
102102

103103
log.debug("Setting keyspace...")

cassandra/cqlengine/management.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _get_context(keyspaces, connections):
5656

5757
def create_keyspace_simple(name, replication_factor, durable_writes=True, connections=None):
5858
"""
59-
Creates a keyspace with SimpleStrategy for replica placement
59+
Creates a keyspace with NetworkTopologyStrategy for replica placement
6060
6161
If the keyspace already exists, it will not be modified.
6262
@@ -66,11 +66,11 @@ def create_keyspace_simple(name, replication_factor, durable_writes=True, connec
6666
*There are plans to guard schema-modifying functions with an environment-driven conditional.*
6767
6868
:param str name: name of keyspace to create
69-
:param int replication_factor: keyspace replication factor, used with :attr:`~.SimpleStrategy`
69+
:param int replication_factor: keyspace replication factor, used with :attr:`~.NetworkTopologyStrategy`
7070
:param bool durable_writes: Write log is bypassed if set to False
7171
:param list connections: List of connection names
7272
"""
73-
_create_keyspace(name, durable_writes, 'SimpleStrategy',
73+
_create_keyspace(name, durable_writes, 'NetworkTopologyStrategy',
7474
{'replication_factor': replication_factor}, connections=connections)
7575

7676

docs/scylla-specific.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ New Error Types
9191
session = cluster.connect()
9292
session.execute("""
9393
CREATE KEYSPACE IF NOT EXISTS keyspace1
94-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}
94+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}
9595
""")
9696
9797
session.execute("USE keyspace1")

examples/concurrent_executions/execute_async_with_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
session = cluster.connect()
3232

3333
session.execute(("CREATE KEYSPACE IF NOT EXISTS examples "
34-
"WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1' }"))
34+
"WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1' }"))
3535
session.execute("USE examples")
3636
session.execute("CREATE TABLE IF NOT EXISTS tbl_sample_kv (id uuid, value text, PRIMARY KEY (id))")
3737
prepared_insert = session.prepare("INSERT INTO tbl_sample_kv (id, value) VALUES (?, ?)")

examples/concurrent_executions/execute_with_threads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
session = cluster.connect()
3535

3636
session.execute(("CREATE KEYSPACE IF NOT EXISTS examples "
37-
"WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1' }"))
37+
"WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1' }"))
3838
session.execute("USE examples")
3939
session.execute("CREATE TABLE IF NOT EXISTS tbl_sample_kv (id uuid, value text, PRIMARY KEY (id))")
4040
prepared_insert = session.prepare("INSERT INTO tbl_sample_kv (id, value) VALUES (?, ?)")

examples/example_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def main():
3636
log.info("creating keyspace...")
3737
session.execute("""
3838
CREATE KEYSPACE IF NOT EXISTS %s
39-
WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '2' }
39+
WITH replication = { 'class': 'NetworkTopologyStrategy', 'replication_factor': '2' }
4040
""" % KEYSPACE)
4141

4242
log.info("setting keyspace...")

tests/integration/cqlengine/connections/test_connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ def setUpClass(cls):
7676
super(SeveralConnectionsTest, cls).setUpClass()
7777
cls.setup_cluster = TestCluster()
7878
cls.setup_session = cls.setup_cluster.connect()
79-
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'SimpleStrategy', 'replication_factor': '{1}'}}".format(cls.keyspace1, 1)
79+
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': '{1}'}}".format(cls.keyspace1, 1)
8080
execute_with_long_wait_retry(cls.setup_session, ddl)
81-
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'SimpleStrategy', 'replication_factor': '{1}'}}".format(cls.keyspace2, 1)
81+
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': '{1}'}}".format(cls.keyspace2, 1)
8282
execute_with_long_wait_retry(cls.setup_session, ddl)
8383

8484
@classmethod

tests/integration/long/test_failure_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def test_write_failures_from_coordinator(self):
187187
self._perform_cql_statement(
188188
"""
189189
CREATE KEYSPACE testksfail
190-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'}
190+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '3'}
191191
""", consistency_level=ConsistencyLevel.ALL, expected_exception=None)
192192

193193
# create table

tests/integration/long/test_policies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def test_should_rethrow_on_unvailable_with_default_policy_if_cas(self):
4848
cluster = TestCluster(execution_profiles={EXEC_PROFILE_DEFAULT: ep})
4949
session = cluster.connect()
5050

51-
session.execute("CREATE KEYSPACE test_retry_policy_cas WITH replication = {'class':'SimpleStrategy','replication_factor': 3};")
51+
session.execute("CREATE KEYSPACE test_retry_policy_cas WITH replication = {'class':'NetworkTopologyStrategy','replication_factor': 3};")
5252
session.execute("CREATE TABLE test_retry_policy_cas.t (id int PRIMARY KEY, data text);")
5353
session.execute('INSERT INTO test_retry_policy_cas.t ("id", "data") VALUES (%(0)s, %(1)s)', {'0': 42, '1': 'testing'})
5454

tests/integration/long/test_schema.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_recreates(self):
5757
log.debug(drop)
5858
execute_until_pass(session, drop)
5959

60-
create = "CREATE KEYSPACE {0} WITH replication = {{'class': 'SimpleStrategy', 'replication_factor': 3}}".format(keyspace)
60+
create = "CREATE KEYSPACE {0} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': 3}}".format(keyspace)
6161
log.debug(create)
6262
execute_until_pass(session, create)
6363

@@ -82,7 +82,7 @@ def test_for_schema_disagreements_different_keyspaces(self):
8282
session = self.session
8383

8484
for i in range(30):
85-
execute_until_pass(session, "CREATE KEYSPACE test_{0} WITH replication = {{'class': 'SimpleStrategy', 'replication_factor': 1}}".format(i))
85+
execute_until_pass(session, "CREATE KEYSPACE test_{0} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': 1}}".format(i))
8686
execute_until_pass(session, "CREATE TABLE test_{0}.cf (key int PRIMARY KEY, value int)".format(i))
8787

8888
for j in range(100):
@@ -100,10 +100,10 @@ def test_for_schema_disagreements_same_keyspace(self):
100100

101101
for i in range(30):
102102
try:
103-
execute_until_pass(session, "CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}")
103+
execute_until_pass(session, "CREATE KEYSPACE test WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}")
104104
except AlreadyExists:
105105
execute_until_pass(session, "DROP KEYSPACE test")
106-
execute_until_pass(session, "CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}")
106+
execute_until_pass(session, "CREATE KEYSPACE test WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}")
107107

108108
execute_until_pass(session, "CREATE TABLE test.cf (key int PRIMARY KEY, value int)")
109109

@@ -132,7 +132,7 @@ def test_for_schema_disagreement_attribute(self):
132132
cluster = TestCluster(max_schema_agreement_wait=0.001)
133133
session = cluster.connect(wait_for_all_pools=True)
134134

135-
rs = session.execute("CREATE KEYSPACE test_schema_disagreement WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}")
135+
rs = session.execute("CREATE KEYSPACE test_schema_disagreement WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 3}")
136136
self.check_and_wait_for_agreement(session, rs, False)
137137
rs = session.execute(SimpleStatement("CREATE TABLE test_schema_disagreement.cf (key int PRIMARY KEY, value int)",
138138
consistency_level=ConsistencyLevel.ALL))
@@ -144,7 +144,7 @@ def test_for_schema_disagreement_attribute(self):
144144
# These should have schema agreement
145145
cluster = TestCluster(max_schema_agreement_wait=100)
146146
session = cluster.connect()
147-
rs = session.execute("CREATE KEYSPACE test_schema_disagreement WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}")
147+
rs = session.execute("CREATE KEYSPACE test_schema_disagreement WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 3}")
148148
self.check_and_wait_for_agreement(session, rs, True)
149149
rs = session.execute(SimpleStatement("CREATE TABLE test_schema_disagreement.cf (key int PRIMARY KEY, value int)",
150150
consistency_level=ConsistencyLevel.ALL))

0 commit comments

Comments
 (0)