Skip to content

Commit

Permalink
[cloudera] Configure the number of connection pools to cache (#18886)
Browse files Browse the repository at this point in the history
* added 'pools_size' to configure the number of connection pools to cache

* added changelog

* validate models

* run code formatter
  • Loading branch information
jose-manuel-almaza authored Oct 22, 2024
1 parent 6cd3ac6 commit 87acd78
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cloudera/assets/configuration/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ files:
value:
example: <KEY_FILE_PATH>
type: string
- name: pools_size
description: |
Number of connection pools to cache before discarding the least recently used pool.
hidden: true
value:
default: 4
type: integer
example: 10
- name: max_parallel_requests
description: |
The maximum number of requests to Cloudera Manager that are allowed in parallel.
Expand Down
1 change: 1 addition & 0 deletions cloudera/changelog.d/18886.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[cloudera] Configure the number of connection pools to cache
1 change: 1 addition & 0 deletions cloudera/datadog_checks/cloudera/api/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def make_api(check) -> Api:
'api_url': check.config.api_url,
'workload_username': check.shared_config.workload_username,
'workload_password': check.shared_config.workload_password,
'pools_size': check.config.pools_size,
'max_parallel_requests': check.config.max_parallel_requests,
'verify_ssl': check.config.verify_ssl,
'ssl_ca_cert': check.config.ssl_ca_cert,
Expand Down
4 changes: 3 additions & 1 deletion cloudera/datadog_checks/cloudera/client/cm_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def __init__(self, log, **kwargs):
cm_client.configuration.ssl_ca_cert = kwargs.get('ssl_ca_cert')
cm_client.configuration.cert_file = kwargs.get('cert_file')
cm_client.configuration.key_file = kwargs.get('key_file')
self._client.rest_client = RESTClientObject(maxsize=kwargs.get('max_parallel_requests'))
self._client.rest_client = RESTClientObject(
pools_size=kwargs.get('pools_size'), maxsize=kwargs.get('max_parallel_requests')
)

def get_version(self) -> Version:
self._log.debug('getting version from cloudera')
Expand Down
4 changes: 4 additions & 0 deletions cloudera/datadog_checks/cloudera/config_models/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@ def instance_min_collection_interval():
return 15


def instance_pools_size():
return 4


def instance_verify_ssl():
return True
1 change: 1 addition & 0 deletions cloudera/datadog_checks/cloudera/config_models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class InstanceConfig(BaseModel):
max_parallel_requests: Optional[int] = None
metric_patterns: Optional[MetricPatterns] = None
min_collection_interval: Optional[float] = None
pools_size: Optional[int] = None
service: Optional[str] = None
ssl_ca_cert: Optional[str] = None
tags: Optional[tuple[str, ...]] = None
Expand Down
1 change: 1 addition & 0 deletions cloudera/tests/test_unit_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def test_client_ssl(dd_run_check, cloudera_check, cloudera_cm_client):
api_url='http://localhost:8080/api/v48/',
workload_username='~',
workload_password='~',
pools_size=4,
max_parallel_requests=4,
verify_ssl=True,
ssl_ca_cert='ssl_ca_cert_path',
Expand Down

0 comments on commit 87acd78

Please sign in to comment.