Skip to content

Commit 0fa9520

Browse files
mykauldkropachev
authored andcommitted
(cleanup) remove code related to v1,v2 protocols
I'm not sure why I did not remove it as part of #493 Signed-off-by: Yaniv Kaul <[email protected]>
1 parent 8a6d95b commit 0fa9520

File tree

8 files changed

+1
-118
lines changed

8 files changed

+1
-118
lines changed

cassandra/cluster.py

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,6 @@ def _connection_reduce_fn(val,import_fn):
192192
log = logging.getLogger(__name__)
193193

194194

195-
DEFAULT_MIN_REQUESTS = 5
196-
DEFAULT_MAX_REQUESTS = 100
197-
198-
DEFAULT_MIN_CONNECTIONS_PER_LOCAL_HOST = 2
199-
DEFAULT_MAX_CONNECTIONS_PER_LOCAL_HOST = 8
200-
201-
DEFAULT_MIN_CONNECTIONS_PER_REMOTE_HOST = 1
202-
DEFAULT_MAX_CONNECTIONS_PER_REMOTE_HOST = 2
203-
204195
_GRAPH_PAGING_MIN_DSE_VERSION = Version('6.8.0')
205196

206197
_NOT_SET = object()
@@ -1449,18 +1440,6 @@ def __init__(self,
14491440

14501441
self._user_types = defaultdict(dict)
14511442

1452-
self._core_connections_per_host = {
1453-
HostDistance.LOCAL_RACK: DEFAULT_MIN_CONNECTIONS_PER_LOCAL_HOST,
1454-
HostDistance.LOCAL: DEFAULT_MIN_CONNECTIONS_PER_LOCAL_HOST,
1455-
HostDistance.REMOTE: DEFAULT_MIN_CONNECTIONS_PER_REMOTE_HOST
1456-
}
1457-
1458-
self._max_connections_per_host = {
1459-
HostDistance.LOCAL_RACK: DEFAULT_MAX_CONNECTIONS_PER_LOCAL_HOST,
1460-
HostDistance.LOCAL: DEFAULT_MAX_CONNECTIONS_PER_LOCAL_HOST,
1461-
HostDistance.REMOTE: DEFAULT_MAX_CONNECTIONS_PER_REMOTE_HOST
1462-
}
1463-
14641443
self.executor = self._create_thread_pool_executor(max_workers=executor_threads)
14651444
self.scheduler = _Scheduler(self.executor)
14661445

@@ -1651,73 +1630,6 @@ def add_execution_profile(self, name, profile, pool_wait_timeout=5):
16511630
if not_done:
16521631
raise OperationTimedOut("Failed to create all new connection pools in the %ss timeout.")
16531632

1654-
def get_core_connections_per_host(self, host_distance):
1655-
"""
1656-
Gets the minimum number of connections per Session that will be opened
1657-
for each host with :class:`~.HostDistance` equal to `host_distance`.
1658-
The default is 2 for :attr:`~HostDistance.LOCAL` and 1 for
1659-
:attr:`~HostDistance.REMOTE`.
1660-
1661-
This property is ignored if :attr:`~.Cluster.protocol_version` is
1662-
3 or higher.
1663-
"""
1664-
return self._core_connections_per_host[host_distance]
1665-
1666-
def set_core_connections_per_host(self, host_distance, core_connections):
1667-
"""
1668-
Sets the minimum number of connections per Session that will be opened
1669-
for each host with :class:`~.HostDistance` equal to `host_distance`.
1670-
The default is 2 for :attr:`~HostDistance.LOCAL` and 1 for
1671-
:attr:`~HostDistance.REMOTE`.
1672-
1673-
Protocol version 1 and 2 are limited in the number of concurrent
1674-
requests they can send per connection. The driver implements connection
1675-
pooling to support higher levels of concurrency.
1676-
1677-
If :attr:`~.Cluster.protocol_version` is set to 3 or higher, this
1678-
is not supported (there is always one connection per host, unless
1679-
the host is remote and :attr:`connect_to_remote_hosts` is :const:`False`)
1680-
and using this will result in an :exc:`~.UnsupportedOperation`.
1681-
"""
1682-
if self.protocol_version >= 3:
1683-
raise UnsupportedOperation(
1684-
"Cluster.set_core_connections_per_host() only has an effect "
1685-
"when using protocol_version 1 or 2.")
1686-
old = self._core_connections_per_host[host_distance]
1687-
self._core_connections_per_host[host_distance] = core_connections
1688-
if old < core_connections:
1689-
self._ensure_core_connections()
1690-
1691-
def get_max_connections_per_host(self, host_distance):
1692-
"""
1693-
Gets the maximum number of connections per Session that will be opened
1694-
for each host with :class:`~.HostDistance` equal to `host_distance`.
1695-
The default is 8 for :attr:`~HostDistance.LOCAL` and 2 for
1696-
:attr:`~HostDistance.REMOTE`.
1697-
1698-
This property is ignored if :attr:`~.Cluster.protocol_version` is
1699-
3 or higher.
1700-
"""
1701-
return self._max_connections_per_host[host_distance]
1702-
1703-
def set_max_connections_per_host(self, host_distance, max_connections):
1704-
"""
1705-
Sets the maximum number of connections per Session that will be opened
1706-
for each host with :class:`~.HostDistance` equal to `host_distance`.
1707-
The default is 2 for :attr:`~HostDistance.LOCAL` and 1 for
1708-
:attr:`~HostDistance.REMOTE`.
1709-
1710-
If :attr:`~.Cluster.protocol_version` is set to 3 or higher, this
1711-
is not supported (there is always one connection per host, unless
1712-
the host is remote and :attr:`connect_to_remote_hosts` is :const:`False`)
1713-
and using this will result in an :exc:`~.UnsupportedOperation`.
1714-
"""
1715-
if self.protocol_version >= 3:
1716-
raise UnsupportedOperation(
1717-
"Cluster.set_max_connections_per_host() only has an effect "
1718-
"when using protocol_version 1 or 2.")
1719-
self._max_connections_per_host[host_distance] = max_connections
1720-
17211633
def connection_factory(self, endpoint, host_conn = None, *args, **kwargs):
17221634
"""
17231635
Called to create a new connection with proper configuration.

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

docs/api/cassandra/cluster.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,6 @@
8686

8787
.. automethod:: add_execution_profile
8888

89-
.. automethod:: get_core_connections_per_host
90-
91-
.. automethod:: set_core_connections_per_host
92-
93-
.. automethod:: get_max_connections_per_host
94-
95-
.. automethod:: set_max_connections_per_host
96-
9789
.. automethod:: get_control_connection_host
9890

9991
.. automethod:: refresh_schema_metadata

tests/integration/standard/test_cluster.py

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

736734
# 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
@@ -46,8 +46,6 @@ def setUpClass(cls):
4646
EXEC_PROFILE_DICT: ExecutionProfile(row_factory=dict_factory)
4747
}
4848
)
49-
if PROTOCOL_VERSION < 3:
50-
cls.cluster.set_core_connections_per_host(HostDistance.LOCAL, 1)
5149
cls.session = cls.cluster.connect()
5250

5351
@classmethod

tests/integration/standard/test_query.py

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

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

671669
def tearDown(self):
@@ -800,8 +798,6 @@ def setUp(self):
800798
% (PROTOCOL_VERSION,))
801799

802800
self.cluster = TestCluster()
803-
if PROTOCOL_VERSION < 3:
804-
self.cluster.set_core_connections_per_host(HostDistance.LOCAL, 1)
805801
self.session = self.cluster.connect()
806802

807803
def tearDown(self):

tests/integration/standard/test_query_paging.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ def setUp(self):
4646
self.cluster = TestCluster(
4747
execution_profiles={EXEC_PROFILE_DEFAULT: ExecutionProfile(consistency_level=ConsistencyLevel.LOCAL_QUORUM)}
4848
)
49-
if PROTOCOL_VERSION < 3:
50-
self.cluster.set_core_connections_per_host(HostDistance.LOCAL, 1)
5149
self.session = self.cluster.connect(wait_for_all_pools=True)
5250
self.session.execute("TRUNCATE test3rf.test")
5351

tests/unit/test_host_connection_pool.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ class _PoolTests(unittest.TestCase):
3939

4040
def make_session(self):
4141
session = NonCallableMagicMock(spec=Session, keyspace='foobarkeyspace')
42-
session.cluster.get_core_connections_per_host.return_value = 1
43-
session.cluster.get_max_connections_per_host.return_value = 1
4442
return session
4543

4644
def test_borrow_and_return(self):
@@ -113,9 +111,6 @@ def test_spawn_when_at_max(self):
113111
conn.max_request_id = 100
114112
session.cluster.connection_factory.return_value = conn
115113

116-
# core conns = 1, max conns = 2
117-
session.cluster.get_max_connections_per_host.return_value = 2
118-
119114
pool = self.PoolImpl(host, HostDistance.LOCAL, session)
120115
session.cluster.connection_factory.assert_called_once_with(host.endpoint, on_orphaned_stream_released=pool.on_orphaned_stream_released)
121116

0 commit comments

Comments
 (0)