Skip to content

Commit 8acc3c0

Browse files
committed
Remove protocol v1/v2 - additional removals
Remove additional getters and setters that only make sense for V1/V2 protocols. Signed-off-by: Yaniv Kaul <[email protected]>
1 parent 787c18b commit 8acc3c0

File tree

11 files changed

+2
-97
lines changed

11 files changed

+2
-97
lines changed

cassandra/cluster.py

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,31 +1666,6 @@ def get_core_connections_per_host(self, host_distance):
16661666
"""
16671667
return self._core_connections_per_host[host_distance]
16681668

1669-
def set_core_connections_per_host(self, host_distance, core_connections):
1670-
"""
1671-
Sets the minimum number of connections per Session that will be opened
1672-
for each host with :class:`~.HostDistance` equal to `host_distance`.
1673-
The default is 2 for :attr:`~HostDistance.LOCAL` and 1 for
1674-
:attr:`~HostDistance.REMOTE`.
1675-
1676-
Protocol version 1 and 2 are limited in the number of concurrent
1677-
requests they can send per connection. The driver implements connection
1678-
pooling to support higher levels of concurrency.
1679-
1680-
If :attr:`~.Cluster.protocol_version` is set to 3 or higher, this
1681-
is not supported (there is always one connection per host, unless
1682-
the host is remote and :attr:`connect_to_remote_hosts` is :const:`False`)
1683-
and using this will result in an :exc:`~.UnsupportedOperation`.
1684-
"""
1685-
if self.protocol_version >= 3:
1686-
raise UnsupportedOperation(
1687-
"Cluster.set_core_connections_per_host() only has an effect "
1688-
"when using protocol_version 1 or 2.")
1689-
old = self._core_connections_per_host[host_distance]
1690-
self._core_connections_per_host[host_distance] = core_connections
1691-
if old < core_connections:
1692-
self._ensure_core_connections()
1693-
16941669
def get_max_connections_per_host(self, host_distance):
16951670
"""
16961671
Gets the maximum number of connections per Session that will be opened
@@ -1703,24 +1678,6 @@ def get_max_connections_per_host(self, host_distance):
17031678
"""
17041679
return self._max_connections_per_host[host_distance]
17051680

1706-
def set_max_connections_per_host(self, host_distance, max_connections):
1707-
"""
1708-
Sets the maximum number of connections per Session that will be opened
1709-
for each host with :class:`~.HostDistance` equal to `host_distance`.
1710-
The default is 2 for :attr:`~HostDistance.LOCAL` and 1 for
1711-
:attr:`~HostDistance.REMOTE`.
1712-
1713-
If :attr:`~.Cluster.protocol_version` is set to 3 or higher, this
1714-
is not supported (there is always one connection per host, unless
1715-
the host is remote and :attr:`connect_to_remote_hosts` is :const:`False`)
1716-
and using this will result in an :exc:`~.UnsupportedOperation`.
1717-
"""
1718-
if self.protocol_version >= 3:
1719-
raise UnsupportedOperation(
1720-
"Cluster.set_max_connections_per_host() only has an effect "
1721-
"when using protocol_version 1 or 2.")
1722-
self._max_connections_per_host[host_distance] = max_connections
1723-
17241681
def connection_factory(self, endpoint, host_conn = None, *args, **kwargs):
17251682
"""
17261683
Called to create a new connection with proper configuration.
@@ -2238,15 +2195,6 @@ def listeners(self):
22382195
with self._listener_lock:
22392196
return self._listeners.copy()
22402197

2241-
def _ensure_core_connections(self):
2242-
"""
2243-
If any host has fewer than the configured number of core connections
2244-
open, attempt to open connections until that number is met.
2245-
"""
2246-
for session in tuple(self.sessions):
2247-
for pool in tuple(session._pools.values()):
2248-
pool.ensure_core_connections()
2249-
22502198
@staticmethod
22512199
def _validate_refresh_schema(keyspace, table, usertype, function, aggregate):
22522200
if any((table, usertype, function, aggregate)):

cassandra/concurrent.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ def execute_concurrent(session, statements_and_parameters, concurrency=100, rais
3333
``parameters`` item must be a sequence or :const:`None`.
3434
3535
The `concurrency` parameter controls how many statements will be executed
36-
concurrently. When :attr:`.Cluster.protocol_version` is set to 1 or 2,
37-
it is recommended that this be kept below 100 times the number of
38-
core connections per host times the number of connected hosts (see
39-
:meth:`.Cluster.set_core_connections_per_host`). If that amount is exceeded,
40-
the event loop thread may attempt to block on new connection creation,
41-
substantially impacting throughput. If :attr:`~.Cluster.protocol_version`
42-
is 3 or higher, you can safely experiment with higher levels of concurrency.
36+
concurrently.
4337
4438
If `raise_on_first_error` is left as :const:`True`, execution will stop
4539
after the first failed statement and the corresponding exception will be

cassandra/pool.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,17 +1234,6 @@ def shutdown(self):
12341234
for conn in connections_to_close:
12351235
conn.close()
12361236

1237-
def ensure_core_connections(self):
1238-
if self.is_shutdown:
1239-
return
1240-
1241-
core_conns = self._session.cluster.get_core_connections_per_host(self.host_distance)
1242-
with self._lock:
1243-
to_create = core_conns - (len(self._connections) + self._scheduled_for_creation)
1244-
for i in range(to_create):
1245-
self._scheduled_for_creation += 1
1246-
self._session.submit(self._create_new_connection)
1247-
12481237
def _set_keyspace_for_all_conns(self, keyspace, callback):
12491238
"""
12501239
Asynchronously sets the keyspace for all connections. When all

docs/api/cassandra/cluster.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,8 @@
8888

8989
.. automethod:: get_core_connections_per_host
9090

91-
.. automethod:: set_core_connections_per_host
92-
9391
.. automethod:: get_max_connections_per_host
9492

95-
.. automethod:: set_max_connections_per_host
96-
9793
.. automethod:: get_control_connection_host
9894

9995
.. automethod:: refresh_schema_metadata

tests/integration/standard/test_authentication.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,12 @@ class AuthenticationTests(unittest.TestCase):
6262
def get_authentication_provider(self, username, password):
6363
"""
6464
Return correct authentication provider based on protocol version.
65-
There is a difference in the semantics of authentication provider argument with protocol versions 1 and 2
6665
For protocol version 2 and higher it should be a PlainTextAuthProvider object.
67-
For protocol version 1 it should be a function taking hostname as an argument and returning a dictionary
68-
containing username and password.
6966
:param username: authentication username
7067
:param password: authentication password
7168
:return: authentication object suitable for Cluster.connect()
7269
"""
73-
if PROTOCOL_VERSION < 2:
74-
return lambda hostname: dict(username=username, password=password)
75-
else:
76-
return PlainTextAuthProvider(username=username, password=password)
70+
return PlainTextAuthProvider(username=username, password=password)
7771

7872
def cluster_as(self, usr, pwd):
7973
# test we can connect at least once with creds

tests/integration/standard/test_cluster.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,6 @@ def test_idle_heartbeat(self):
728728
interval = 2
729729
cluster = TestCluster(idle_heartbeat_interval=interval,
730730
monitor_reporting_enabled=False)
731-
if PROTOCOL_VERSION < 3:
732-
cluster.set_core_connections_per_host(HostDistance.LOCAL, 1)
733731
session = cluster.connect(wait_for_all_pools=True)
734732

735733
# This test relies on impl details of connection req id management to see if heartbeats

tests/integration/standard/test_concurrent.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ def setUpClass(cls):
4545
EXEC_PROFILE_DICT: ExecutionProfile(row_factory=dict_factory)
4646
}
4747
)
48-
if PROTOCOL_VERSION < 3:
49-
cls.cluster.set_core_connections_per_host(HostDistance.LOCAL, 1)
5048
cls.session = cls.cluster.connect()
5149

5250
@classmethod

tests/integration/standard/test_query.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,6 @@ def setUp(self):
665665
% (PROTOCOL_VERSION,))
666666

667667
self.cluster = TestCluster()
668-
if PROTOCOL_VERSION < 3:
669-
self.cluster.set_core_connections_per_host(HostDistance.LOCAL, 1)
670668
self.session = self.cluster.connect(wait_for_all_pools=True)
671669

672670
def tearDown(self):
@@ -796,8 +794,6 @@ def setUp(self):
796794
% (PROTOCOL_VERSION,))
797795

798796
self.cluster = TestCluster()
799-
if PROTOCOL_VERSION < 3:
800-
self.cluster.set_core_connections_per_host(HostDistance.LOCAL, 1)
801797
self.session = self.cluster.connect()
802798

803799
def tearDown(self):

tests/integration/standard/test_query_paging.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ def setUp(self):
4343
self.cluster = TestCluster(
4444
execution_profiles={EXEC_PROFILE_DEFAULT: ExecutionProfile(consistency_level=ConsistencyLevel.LOCAL_QUORUM)}
4545
)
46-
if PROTOCOL_VERSION < 3:
47-
self.cluster.set_core_connections_per_host(HostDistance.LOCAL, 1)
4846
self.session = self.cluster.connect(wait_for_all_pools=True)
4947
self.session.execute("TRUNCATE test3rf.test")
5048

tests/integration/util.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,3 @@ def assert_quiescent_pool_state(test_case, cluster, wait=None):
5353
test_case.assertEqual(len(req_ids), len(set(req_ids)))
5454
test_case.assertEqual(connection.highest_request_id, len(req_ids) + len(orphan_ids) - 1)
5555
test_case.assertEqual(connection.highest_request_id, max(chain(req_ids, orphan_ids)))
56-
if PROTOCOL_VERSION < 3:
57-
test_case.assertEqual(connection.highest_request_id, connection.max_request_id)

0 commit comments

Comments
 (0)