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
18 changes: 18 additions & 0 deletions cassandra/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,13 @@ def get_min_requests_per_connection(self, host_distance):
return self._min_requests_per_connection[host_distance]

def set_min_requests_per_connection(self, host_distance, min_requests):
"""
Sets a threshold for concurrent requests per connection, below which
connections will be considered for disposal (down to core connections;
see :meth:`~Cluster.set_core_connections_per_host`).

Pertains to connection pool management in protocol versions {1,2}.
"""
if self.protocol_version >= 3:
raise UnsupportedOperation(
"Cluster.set_min_requests_per_connection() only has an effect "
Expand All @@ -670,6 +677,13 @@ def get_max_requests_per_connection(self, host_distance):
return self._max_requests_per_connection[host_distance]

def set_max_requests_per_connection(self, host_distance, max_requests):
"""
Sets a threshold for concurrent requests per connection, above which new
connections will be created to a host (up to max connections;
see :meth:`~Cluster.set_max_connections_per_host`).

Pertains to connection pool management in protocol versions {1,2}.
"""
if self.protocol_version >= 3:
raise UnsupportedOperation(
"Cluster.set_max_requests_per_connection() only has an effect "
Expand All @@ -695,6 +709,10 @@ def set_core_connections_per_host(self, host_distance, core_connections):
The default is 2 for :attr:`~HostDistance.LOCAL` and 1 for
:attr:`~HostDistance.REMOTE`.

Protocol version 1 and 2 are limited in the number of concurrent
requests they can send per connection. The driver implements connection
pooling to support higher levels of concurrency.

If :attr:`~.Cluster.protocol_version` is set to 3 or higher, this
is not supported (there is always one connection per host, unless
the host is remote and :attr:`connect_to_remote_hosts` is :const:`False`)
Expand Down
8 changes: 8 additions & 0 deletions docs/api/cassandra/cluster.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@

.. automethod:: unregister_listener

.. automethod:: set_max_requests_per_connection

.. automethod:: get_max_requests_per_connection

.. automethod:: set_min_requests_per_connection

.. automethod:: get_min_requests_per_connection

.. automethod:: get_core_connections_per_host

.. automethod:: set_core_connections_per_host
Expand Down